Added Apps: clock, moods.
This commit is contained in:
@@ -8,7 +8,7 @@ Current version 0.1.0 is still in development but usable.
|
|||||||
|
|
||||||
OpenKarotz can be found [here](http://openkarotz.filippi.org/).
|
OpenKarotz can be found [here](http://openkarotz.filippi.org/).
|
||||||
|
|
||||||
The following APIs are currently available:
|
The following APIs are available:
|
||||||
- clear_cache
|
- clear_cache
|
||||||
- clear_snapshots
|
- clear_snapshots
|
||||||
- ears
|
- ears
|
||||||
@@ -34,6 +34,10 @@ The following APIs are currently available:
|
|||||||
- voice_list
|
- voice_list
|
||||||
- wakeup
|
- wakeup
|
||||||
|
|
||||||
|
The following Apps are available:
|
||||||
|
- clock
|
||||||
|
- moods
|
||||||
|
|
||||||
|
|
||||||
### Usage ###
|
### Usage ###
|
||||||
|
|
||||||
|
48
handlers.js
48
handlers.js
@@ -91,6 +91,11 @@ function homepage(res, req) {
|
|||||||
+ '<li><a target="results" href="/cgi-bin/snapshot_get">snapshot_get</a>, <a target="results" href="/cgi-bin/snapshot_get?filename=snapshot.thumb.gif">snapshot_get(thumbnail)</a></li>'
|
+ '<li><a target="results" href="/cgi-bin/snapshot_get">snapshot_get</a>, <a target="results" href="/cgi-bin/snapshot_get?filename=snapshot.thumb.gif">snapshot_get(thumbnail)</a></li>'
|
||||||
+ '<li><a target="results" href="/cgi-bin/clear_snapshots">clear_snapshots</a></li>'
|
+ '<li><a target="results" href="/cgi-bin/clear_snapshots">clear_snapshots</a></li>'
|
||||||
+ '</ul>'
|
+ '</ul>'
|
||||||
|
+ '<h2>Apps</h2>'
|
||||||
|
+ '<ul>'
|
||||||
|
+ '<li><a target="results" href="/cgi-bin/apps/clock">clock</a>, <a target="results" href="/cgi-bin/apps/clock?hour=12">clock(12)</a></li>'
|
||||||
|
+ '<li><a target="results" href="/cgi-bin/apps/moods">moods</a>, <a target="results" href="/cgi-bin/apps/moods?id=50">moods(50)</a></li>'
|
||||||
|
+ '</ul>'
|
||||||
+ '<hr/>'
|
+ '<hr/>'
|
||||||
+ '<p><small>'
|
+ '<p><small>'
|
||||||
+ '<a href="https://github.com/hobbe">Copyright © 2013</a> - '
|
+ '<a href="https://github.com/hobbe">Copyright © 2013</a> - '
|
||||||
@@ -570,3 +575,46 @@ function clear_snapshots(res, req) {
|
|||||||
}
|
}
|
||||||
exports.clear_snapshots = clear_snapshots;
|
exports.clear_snapshots = clear_snapshots;
|
||||||
|
|
||||||
|
function clock(res, req) {
|
||||||
|
log.trace('clock: begin');
|
||||||
|
|
||||||
|
var data = '';
|
||||||
|
if (karotz.isSleeping()) {
|
||||||
|
data = '{"return":"1","msg":"Unable to perform action, rabbit is sleeping."}';
|
||||||
|
} else {
|
||||||
|
var hour = getParameter(req, "hour");
|
||||||
|
if (hour === undefined) {
|
||||||
|
hour = new Date().getHours();
|
||||||
|
}
|
||||||
|
if (hour >= 0 && hour <= 23) {
|
||||||
|
data = '{"return":"0","hour":"' + hour + '"}';
|
||||||
|
} else {
|
||||||
|
data = '{"return":"1","hour":"' + hour + '"}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sendResponse(res, data);
|
||||||
|
log.trace('clock: end');
|
||||||
|
}
|
||||||
|
exports.clock = clock;
|
||||||
|
|
||||||
|
function moods(res, req) {
|
||||||
|
log.trace('moods: begin');
|
||||||
|
|
||||||
|
var data = '';
|
||||||
|
if (karotz.isSleeping()) {
|
||||||
|
data = '{"return":"1","msg":"Unable to perform action, rabbit is sleeping."}';
|
||||||
|
} else {
|
||||||
|
var mood = getParameter(req, "id");
|
||||||
|
//var lang = getParameter(req, "lang"); // Unused
|
||||||
|
if (mood === undefined) {
|
||||||
|
mood = Math.floor((Math.random() * 300) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
data = '{"moods":"' + mood + '","return":"0"}';
|
||||||
|
}
|
||||||
|
|
||||||
|
sendResponse(res, data);
|
||||||
|
log.trace('moods: end');
|
||||||
|
}
|
||||||
|
exports.moods = moods;
|
||||||
|
5
index.js
5
index.js
@@ -36,6 +36,7 @@ var handle = {};
|
|||||||
handle['/'] = handlers.homepage;
|
handle['/'] = handlers.homepage;
|
||||||
handle['/cgi-bin'] = handlers.homepage;
|
handle['/cgi-bin'] = handlers.homepage;
|
||||||
|
|
||||||
|
// API
|
||||||
handle['/cgi-bin/clear_cache'] = handlers.clear_cache;
|
handle['/cgi-bin/clear_cache'] = handlers.clear_cache;
|
||||||
handle['/cgi-bin/clear_snapshots'] = handlers.clear_snapshots;
|
handle['/cgi-bin/clear_snapshots'] = handlers.clear_snapshots;
|
||||||
handle['/cgi-bin/ears'] = handlers.ears;
|
handle['/cgi-bin/ears'] = handlers.ears;
|
||||||
@@ -61,5 +62,9 @@ handle['/cgi-bin/tts'] = handlers.tts;
|
|||||||
handle['/cgi-bin/voice_list'] = handlers.voice_list;
|
handle['/cgi-bin/voice_list'] = handlers.voice_list;
|
||||||
handle['/cgi-bin/wakeup'] = handlers.wakeup;
|
handle['/cgi-bin/wakeup'] = handlers.wakeup;
|
||||||
|
|
||||||
|
// APPS
|
||||||
|
handle['/cgi-bin/apps/clock'] = handlers.clock;
|
||||||
|
handle['/cgi-bin/apps/moods'] = handlers.moods;
|
||||||
|
|
||||||
log.info('OpenKarotz Emulator');
|
log.info('OpenKarotz Emulator');
|
||||||
server.start(router.route, handle);
|
server.start(router.route, handle);
|
||||||
|
Reference in New Issue
Block a user