cockpit/js/instance.js in cpee-1.3.125 vs cockpit/js/instance.js in cpee-1.3.126

- old
+ new

@@ -1,8 +1,7 @@ var ws; var running = false; -var load; var graphrealization; var subscription; var subscription_state = 'less'; var save = {}; save['state']= undefined; @@ -42,43 +41,48 @@ 'topic' + '=' + 'properties/handlers' + '&' + 'events' + '=' + 'change';// }}} $(document).ready(function() {// {{{ $("input[name=base-url]").val(location.protocol + "//" + location.host + ":9298/"); - $("button[name=base]").click(create_instance); - $("button[name=instance]").click(monitor_instance); + $("button[name=base]").click(function(){ create_instance(null); }); + $("button[name=instance]").click(function(){ ui_tab_click("#tabinstance"); monitor_instance(false); }); $("button[name=loadtestset]").click(load_testset); $("button[name=loadtestsetfile]").click(load_testsetfile); $("button[name=loadmodelfile]").click(load_modelfile); $("button[name=savetestset]").click(function(){ save_testset(); }); $("button[name=savesvg]").click(function(){ save_svg(); }); $("input[name=votecontinue]").click(check_subscription); + $.ajax({ url: "testsets/index.xml", dataType: 'xml', success: function(res){ $('testset',res).each(function(){ var ts = $(this).text(); $('select[name=testset-names]').append( $("<option></option>").attr("value",ts).text(ts) ); }); + var q = $.parseQuery(); + if (q.monitor && q.load) { + $("input[name=instance-url]").val(q.monitor); + $("select[name=testset-names]").val(q.load) + ui_tab_click("#tabexecution"); + monitor_instance(true); + } else if (q.load) { + $("select[name=testset-names]").val(q.load) + ui_tab_click("#tabexecution"); + create_instance(q.load); + } else if (q.monitor) { + $("input[name=instance-url]").val(q.monitor); + ui_tab_click("#tabexecution"); + // ui_toggle_vis_tab($("#instance td.switch")); + monitor_instance(false); + } } }); - - var q = $.parseQuery(); - if (q.monitor) { - $("input[name=instance-url]").val(q.monitor); - ui_toggle_vis_tab($("#instance td.switch")); - monitor_instance(); - } - if (q.load) { - load = q.load; - ui_toggle_vis_tab($("#instance td.switch")); - create_instance(); - } });// }}} function check_subscription() { // {{{ var url = $("input[name=current-instance]").val(); var num = 0; @@ -108,23 +112,23 @@ subscription_state = 'less'; format_visual_vote_clear(); } }// }}} -function create_instance() {// {{{ - var info = load ? load : prompt("Instance info?", "Enter info here"); +function create_instance(ask) {// {{{ + var info = ask ? ask: prompt("Instance info?", "Enter info here"); if (info != null) { if (info.match(/\S/)) { var base = $("input[name=base-url]").val(); $.ajax({ type: "POST", url: base, dataType: "text", data: "info=" + info, success: function(res){ $("input[name=instance-url]").val((base + "//" + res + "/").replace(/\/+/g,"/").replace(/:\//,"://")); - if (load) monitor_instance(); + if (ask) monitor_instance(true); }, error: function(a,b,c) { alert("No CPEE running."); } }); @@ -132,11 +136,11 @@ alert("An instance info is necessary!"); } } }// }}} -function monitor_instance() {// {{{ +function monitor_instance(load) {// {{{ var url = $("input[name=instance-url]").val(); $('.tabbehind button').hide(); $('#dat_details').empty(); @@ -151,12 +155,10 @@ $("input[name=current-instance]").val(url); $("#current-instance").text(url); $("#current-instance").attr('href',url); history.replaceState({}, '', '?monitor='+url); - ui_tab_click($("#tabinstance")[0]); - // Change url to return to current instance when reloading (because new subscription is made) $("input[name=votecontinue]").removeAttr('checked'); subscription_state = 'less'; $.ajax({ @@ -220,10 +222,11 @@ monitor_instance_dsl(); monitor_instance_state(); }, error: function(a,b,c) { alert("This ain't no CPEE instance"); + ui_tab_click("#tabnew"); } }); }// }}} function monitor_instance_dataelements() {// {{{ @@ -367,11 +370,10 @@ var ctv = $("#state"); ctv.empty(); if (notification == "stopped") { - format_visual_clear(); monitor_instance_pos(); } if (notification == "running") { format_visual_clear(); } @@ -649,10 +651,10 @@ save['dsl'] = null; // reload dsl and position under all circumstances $('#main .tabbehind button').hide(); $('#dat_details').empty(); - var name = load ? load : $("select[name=testset-names]").val(); + var name = $("select[name=testset-names]").val(); $.ajax({ cache: false, dataType: 'xml', url: "testsets/" + name + ".xml",