Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi into observer3.0
[plstackapi.git] / planetstack / core / xoslib / static / js / helloworld.js
diff --git a/planetstack/core/xoslib/static/js/helloworld.js b/planetstack/core/xoslib/static/js/helloworld.js
new file mode 100644 (file)
index 0000000..1563094
--- /dev/null
@@ -0,0 +1,27 @@
+// helloworld.js
+function updateHelloWorldData() {
+    var html = "<table class='table table-bordered table-striped'>";
+    for (var slicekey in xos.slices.models) {
+        slice = xos.slices.models[slicekey]
+        html = html + "<tr><td>" + slice.get("name") + "</td><td>" + slice.get("description") + "</td></tr>";
+    }
+    html = html + "</table>";
+    $('#dynamicTableOfInterestingThings').html(html);
+}
+
+$(document).ready(function(){
+    xos.slices.on("change", function() { updateHelloWorldData(); });
+    xos.slices.on("remove", function() { updateHelloWorldData(); });
+    xos.slices.on("sort", function() { updateHelloWorldData();  });
+
+    xos.slices.startPolling();
+});
+
+// helloworld.js
+$(document).ready(function() {
+    $('#submitNewDescription').bind('click', function() {
+        newDescription = $("#newDescription").val();
+        xos.slices.models[0].set("description", newDescription);
+        xos.slices.models[0].save();
+    });
+});