]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/tangle/resources/weave.js
2b369824517b44aba0a6cef4e2a67caf3b6fbc75
[factor.git] / unmaintained / tangle / resources / weave.js
1 $(function() { $.getJSON("/all", false, function(json) {
2     var nodes = $('#nodes');
3     for (node in json) {
4         nodes.append("<option value='" + json[node] + "'>" + json[node] + "</option>");
5     }
6     nodes.change(function(){
7         if (this.value == 'new') {
8             $('#node-content').hide();
9             $('#edit-wrapper').show();
10         } else {
11             $('#node-content').show();
12             $('#edit-wrapper').hide();
13             $.get('/node', { node_id: this.value }, function(data){
14                 $('#node-content').text(data);
15             });
16         }
17     });
18     $('#node-submit').click(function(){
19         $.post('/node', { node_content: $('#node-content-edit').val() }, function(data){
20             nodes.append("<option value='" + data + "'>" + data + "</option>");
21             var option = nodes.get(0).options[data];
22             option.selected = true;
23             nodes.change();
24         });
25         return false;
26     });
27 });})