tring to test real app
This commit is contained in:
Родитель
2b38771fda
Коммит
391fb71fe3
|
@ -28,8 +28,8 @@ function setup() {
|
|||
|
||||
readTag('led1', function(data, err) {
|
||||
if (err)
|
||||
console.log("****************** I fail miserably to read url of my cam :(******************", err);
|
||||
console.log("**** |o/ ****************************data is ", data);
|
||||
console.log("****************** I fail miserably to read url of my led :(******************", err);
|
||||
console.log("**** |o/ **************************** data is ", data);
|
||||
var url = "http://" + data;
|
||||
})
|
||||
var pushMe = $('<button/>',
|
||||
|
@ -57,20 +57,4 @@ function forEach(obj, cb) {
|
|||
}
|
||||
}
|
||||
|
||||
function readTags(tags, cb) {
|
||||
console.log("APP I am in readTags ");
|
||||
var readValues = {};
|
||||
console.log("APP TAGS ARE ", tags);
|
||||
forEach(tags, function(tag) {
|
||||
console.log("APP tag: ", tag);
|
||||
readTag(tag, function(data, err) {
|
||||
readValues[tag] = data;
|
||||
if (err)
|
||||
console.log("APP Error from readTag: ", err);
|
||||
if (Object.keys(readValues).length === Object.keys(tags).length)
|
||||
cb(readValues);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
init(app);
|
||||
|
|
|
@ -9,12 +9,14 @@ function app(){
|
|||
};
|
||||
|
||||
function listExistingTags(links, cb){
|
||||
console.log("links is : ", links);
|
||||
for (var key in links) {
|
||||
$('<a>',{
|
||||
text: " " +"http://" + links[key]["url"],
|
||||
title: key,
|
||||
href: "http://" + links[key]["url"]
|
||||
}).appendTo('#'+ key);
|
||||
if (links[key] !== undefined)
|
||||
$('<a>',{
|
||||
text: " " +"http://" + JSON.parse(links[key]).url,
|
||||
title: key,
|
||||
href: "http://" + JSON.parse(links[key]).url
|
||||
}).appendTo('#'+ key);
|
||||
}
|
||||
cb(links);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
|
||||
<div id="myDiv" class="btn-group btn-group-justified">
|
||||
<button id = "led1" type="button" class="btn btn-default">Led1</button>
|
||||
<!---<button id = "led2" type="button" class="btn btn-default">Led2</button>--->
|
||||
<button id = "led2" type="button" class="btn btn-default">Led2</button>
|
||||
</div>
|
||||
|
||||
<script src="./superagent.js"></script>
|
||||
|
@ -15,7 +15,7 @@
|
|||
<script src="anotherApp.js">
|
||||
</script>
|
||||
<div style="display: inline-flex;">
|
||||
<!--<div>
|
||||
<div>
|
||||
<img id = "myPic" style="float:left;margin: 10px 10px;" src="http://localhost:8989/?action=stream" width="520" height="480" />
|
||||
</div>
|
||||
<form id="speech" class="navbar-form navbar-left" action="http://localhost:3333" method="post">
|
||||
|
@ -23,7 +23,7 @@
|
|||
<input type="text" class="form-control" placeholder="write something">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-danger">ToSpeech</button>
|
||||
</form>-->
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -13,7 +13,7 @@ var allFeatures = {}
|
|||
|
||||
function init(cb) {
|
||||
superagent.get(baseurl + "/ls", function(err, res) {
|
||||
console.log("i am in init ----");
|
||||
console.log("--------------------- ROT init ------------------");
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
|
@ -58,8 +58,6 @@ function queryTags(tags, cb) {
|
|||
|
||||
function readTag(tag, cb) {
|
||||
var tagData = JSON.parse(allTags[tag]);
|
||||
console.log("tagData is ----------------------------", tagData);
|
||||
|
||||
if (tagData === undefined) {
|
||||
cb(undefined, "ROT No such tag: " + tag + " :(");
|
||||
} else if (tagData['url'] === undefined) {
|
||||
|
@ -72,7 +70,6 @@ function readTag(tag, cb) {
|
|||
|
||||
function writeTag(tag, data, cb) {
|
||||
var tagData = JSON.parse(allTags[tag]);
|
||||
console.log("WRITE TAG***************************************************************************************", tagData);
|
||||
if (tagData === undefined) {
|
||||
cb(undefined, "No such tag: " + tag + " :(");
|
||||
} else if (tagData['url'] === undefined) {
|
||||
|
@ -88,7 +85,7 @@ function writeTag(tag, data, cb) {
|
|||
}
|
||||
|
||||
function getAllThings(uuids, cb) {
|
||||
console.log("GET ALL THINGS");
|
||||
console.log("------------------ROT GET ALL THINGS-------------------");
|
||||
var things = {};
|
||||
var errors = undefined;
|
||||
var done = 0;
|
||||
|
@ -194,14 +191,10 @@ function setTag(uuid, feature, tag, cb) {
|
|||
} else if (tag in allTags) {
|
||||
cb("Tag alread used: " + tag + " :(");
|
||||
} else {
|
||||
console.log("allThings: ", allThings, "allThings[uuid]", allThings[uuid]);
|
||||
var url = allThings[uuid].localURL + "/tags/" + tag;
|
||||
console.log("in setTag, setting to url: ", url);
|
||||
superagent.put(url)
|
||||
.send(feature)
|
||||
.end(function(res){
|
||||
console.log("setTag: callback is ", cb);
|
||||
console.log("XXXXXXXXXX allFeatures[uuid][feature]", allFeatures[uuid][feature]);
|
||||
allTags[tag] = allFeatures[uuid][feature];
|
||||
|
||||
if (res.ok) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче