Permalink
Browse files

win app & mac app: changed inputs & patterns URL api a bit so it woul…

…d work with MiniHttpd .net library
  • Loading branch information...
todbot committed Jan 6, 2013
1 parent a905581 commit a98460c863c67787be064e6aab21b88ffa14c997
@@ -258,7 +258,7 @@ First let's add a view inputs, same as before:
Now look at the list:
- $ curl 'http://localhost:8934/blink1/input/'
+ $ curl 'http://localhost:8934/blink1/inputs'
{
"enabled": true,
"inputs": [
View
@@ -194,7 +194,7 @@ Base URL: `http://localhost:8934/blink1`
### Input Selection ###
-* `/blink1/input/`
+* `/blink1/inputs`
-- List configured inputs, enable or disable input watching
* `/blink1/input/del`
@@ -227,7 +227,7 @@ Base URL: `http://localhost:8934/blink1`
### Color Patterns ###
-* `/blink1/pattern/`
+* `/blink1/patterns`
-- List saved color patterns
* `/blink1/pattern/add`
@@ -364,15 +364,15 @@ __Response:__
}
-`/blink1/input`
+`/blink1/inputs`
--------------
__Description:__ List configured inputs
__Query args:__ 'enable' : "on" == enable all configured inputs, "off" == off
__Example:__
-`http://localhost:8934/blink1/input`
+`http://localhost:8934/blink1/inputs`
__Response:__
(example with several inputs configured)
@@ -582,7 +582,7 @@ __Response:__ Standard JSON 'status' response
-`/blink1/pattern`
+`/blink1/patterns`
----------------
__Description:__
List saved color patterns
@@ -660,15 +660,15 @@ console.log("save click!");
//
function backendStopInputs() {
- var b1url = '../blink1/input';
+ var b1url = '../blink1/inputs';
var parms = { 'enabled' : false };
$.getJSON( b1url, parms, function(result) {
});
backendSetColor("rgb(0, 0, 0)");
}
//
function backendStartInputs() {
- var b1url = '../blink1/input';
+ var b1url = '../blink1/inputs';
var parms = { 'enabled' : true };
$.getJSON( b1url, parms, function(result) {
});
@@ -1002,7 +1002,7 @@ function backendLoadTriggers() {
$.ajaxSetup({ cache: false, async: false });
// first, load up the info from the input side of things
- $.getJSON( '../blink1/input', function(result) { // FIXME: don't use '..'
+ $.getJSON( '../blink1/inputs', function(result) { // FIXME: don't use '..'
//console.log("input data status '"+ result.status+"'");
//console.log(result);
var inputs = result.inputs;
@@ -1021,7 +1021,7 @@ function backendLoadTriggers() {
});
// then add in the color patterns for each input
- $.getJSON( '../blink1/pattern', function(result) { // FIXME: don't use '..'
+ $.getJSON( '../blink1/patterns', function(result) { // FIXME: don't use '..'
//console.log("pattern data status '"+ result.status+"'");
//console.log(result);
var patterns = result.patterns;
@@ -680,7 +680,7 @@ - (void)setupHttpRoutes
//
// list patterns
- [http get:@"/blink1/pattern" withBlock:^(RouteRequest *request, RouteResponse *response) {
+ [http get:@"/blink1/patterns" withBlock:^(RouteRequest *request, RouteResponse *response) {
NSMutableDictionary *respdict = [[NSMutableDictionary alloc] init];//[NSMutableDictionary dictionaryWithDictionary:patterns];
[respdict setObject:@"pattern results" forKey:@"status"];
[respdict setObject:[patterns allValues] forKey:@"patterns"];
@@ -785,7 +785,7 @@ - (void)setupHttpRoutes
//
// list all inputs
- [http get:@"/blink1/input" withBlock:^(RouteRequest *request, RouteResponse *response) {
+ [http get:@"/blink1/inputs" withBlock:^(RouteRequest *request, RouteResponse *response) {
NSString* enable = [self trimString: [request param:@"enabled"]];
if( enable != nil ) { // i.e. param was specified
inputsEnable = ([enable isEqualToString:@"on"] || [enable isEqualToString:@"true"] );
@@ -36,7 +36,7 @@ public class Blink1Input
// each input can have an independent update interval that's greater than master interval
public DateTime lastTime;
- private int updateInterval;
+ //private int updateInterval;
// holder of last valid response/content
private string lastContent;
@@ -55,19 +55,14 @@ public string pattern
public Blink1Server blink1Server { get; set; } //
-
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="aName"></param>
- /// <param name="patternstr"></param>
- public Blink1Pattern(string aName, string patternstr)
+ public Blink1Pattern(string aName)
{
name = aName;
playpos = 0;
playcount = 0;
playing = false;
- parsePatternStr(patternstr); // FIXME: check for bad patternstr vals
+ colors = new List<Color>();
+ times = new List<float>();
}
/// <summary>
@@ -77,8 +72,6 @@ public Blink1Pattern(string aName, string patternstr)
/// <returns>true if parsing worked, false otherwise</returns>
public Boolean parsePatternStr(string patternstr)
{
- colors = new List<Color>();
- times = new List<float>();
string[] values = patternstr.Split(',');
repeats = 0;
try { repeats = int.Parse(values[0]); }
@@ -163,7 +156,7 @@ public void stop()
playing = false;
}
-
+ // FIXME: maybe use real JSON serializer
public override string ToString()
{
return "{name:"+name+",pattern:"+pattern+",repeats:"+repeats+",playing:"+playing+"}";
Oops, something went wrong.

0 comments on commit a98460c

Please sign in to comment.