| ] | ] | ||||
| }); | }); | ||||
| // from http://css-tricks.com/snippets/javascript/get-url-variables/ | |||||
| function getQueryVariable(variable) { | |||||
| var query = window.location.search.substring(1); | |||||
| var vars = query.split("&"); | |||||
| for (var i=0;i<vars.length;i++) { | |||||
| var pair = vars[i].split("="); | |||||
| if(pair[0] == variable){return pair[1];} | |||||
| } | |||||
| return(false); | |||||
| } | |||||
| function loadNodes() { | function loadNodes() { | ||||
| console.log("loadNodes"); | |||||
| $.get('list.html', function(data) { | $.get('list.html', function(data) { | ||||
| console.log("loadNodes complete"); | |||||
| $("body").append(data); | $("body").append(data); | ||||
| $(".palette-spinner").hide(); | $(".palette-spinner").hide(); | ||||
| $(".palette-scroll").show(); | $(".palette-scroll").show(); | ||||
| $("#btn-deploy").removeClass("disabled").addClass("btn-danger"); | $("#btn-deploy").removeClass("disabled").addClass("btn-danger"); | ||||
| }, 1500); | }, 1500); | ||||
| $('#btn-deploy').click(function() { save(); }); | $('#btn-deploy').click(function() { save(); }); | ||||
| // if the query string has ?info=className, populate info tab | |||||
| var info = getQueryVariable("info"); | |||||
| if (info) { | |||||
| $("#tab-info").html('<div class="node-help">' | |||||
| +($("script[data-help-name|='"+info+"']").html()||"")+"</div>"); | |||||
| } | |||||
| }, "html"); | }, "html"); | ||||
| } | } | ||||
| function getType(type) { | function getType(type) { | ||||
| return node_defs[type]; | return node_defs[type]; | ||||
| } | } | ||||
| function selectNode(name) { | |||||
| window.history.pushState(null, null, window.location.protocol + "//" | |||||
| + window.location.host + window.location.pathname + '?info=' + name); | |||||
| } | |||||
| function addNode(n) { | function addNode(n) { | ||||
| if (n._def.category == "config") { | if (n._def.category == "config") { | ||||
| configNodes[n.id] = n; | configNodes[n.id] = n; | ||||
| registerType: registerType, | registerType: registerType, | ||||
| getType: getType, | getType: getType, | ||||
| convertNode: convertNode, | convertNode: convertNode, | ||||
| selectNode: selectNode, | |||||
| add: addNode, | add: addNode, | ||||
| addLink: addLink, | addLink: addLink, | ||||
| remove: removeNode, | remove: removeNode, |
| content: $(($("script[data-help-name|='"+nt+"']").html()||"<h2>empty</h2><p>no information available</p>").trim())[2] // TODO: how to use jQuery to always select the first <p> within the html? | content: $(($("script[data-help-name|='"+nt+"']").html()||"<h2>empty</h2><p>no information available</p>").trim())[2] // TODO: how to use jQuery to always select the first <p> within the html? | ||||
| }); | }); | ||||
| $(d).click(function() { | $(d).click(function() { | ||||
| var help = '<div class="node-help">'+($("script[data-help-name|='"+d.type+"']").html()||"")+"</div>"; | |||||
| $("#tab-info").html(help); | |||||
| RED.nodes.selectNode(d.type); | |||||
| var help = '<div class="node-help">'+($("script[data-help-name|='"+d.type+"']").html()||"")+"</div>"; | |||||
| $("#tab-info").html(help); | |||||
| }); | }); | ||||
| $(d).draggable({ | $(d).draggable({ | ||||
| helper: 'clone', | helper: 'clone', |
| } | } | ||||
| if (moving_set.length == 1) { | if (moving_set.length == 1) { | ||||
| RED.sidebar.info.refresh(moving_set[0].n); | RED.sidebar.info.refresh(moving_set[0].n); | ||||
| RED.nodes.selectNode(moving_set[0].n.type); | |||||
| } else { | } else { | ||||
| RED.sidebar.info.clear(); | RED.sidebar.info.clear(); | ||||
| } | } |