lib/template/js/main.js in browser_app_base-0.1.3 vs lib/template/js/main.js in browser_app_base-0.1.4

- old
+ new

@@ -199,47 +199,49 @@ }); }); } function setting_dialog(open_id, dialog_id, json_file) { + var version; $("#" + open_id).click(function () { $("#" + dialog_id).val = $(function () { $("dl#wrap").empty(); $.getJSON(json_file, function (s) { - for (var i in s) { - if (s[i].type == "input") { + version = s["version"]; + for (var i in s["setting_list"]) { + if (s["setting_list"][i].type == "input") { var h = "<table><tr>" - + "<td class='setting_name'>" + s[i].description + "</td>" - + "<td><input class='setting_value' type='text' " + "id=" + s[i].name + "_value " + "value=" + "'" + s[i].value + "'" + ">" + + "<td class='setting_name'>" + s["setting_list"][i].description + "</td>" + + "<td><input class='setting_value' type='text' " + "id=" + s["setting_list"][i].name + "_value " + "value=" + "'" + s["setting_list"][i].value + "'" + ">" + "</td></tr></table>" $("dl#wrap").append(h); - } else if (s[i].type == "checkbox") { + } else if (s["setting_list"][i].type == "checkbox") { var h = "<table><tr>"; - h += "<td class='setting_name'>" + s[i].description + "</td>"; - if (s[i].value == true) { - h += "<td><input class='setting_checkbox' type='checkbox' " + "id=" + s[i].name + "_value checked ></td>"; + h += "<td class='setting_name'>" + s["setting_list"][i].description + "</td>"; + if (s["setting_list"][i].value == true) { + h += "<td><input class='setting_checkbox' type='checkbox' " + "id=" + s["setting_list"][i].name + "_value checked ></td>"; } else { - h += "<td><input class='setting_checkbox' type='checkbox' " + "id=" + s[i].name + "_value ></td>"; + h += "<td><input class='setting_checkbox' type='checkbox' " + "id=" + s["setting_list"][i].name + "_value ></td>"; } h += "</tr></table>"; $("dl#wrap").append(h); - } else if (s[i].type == "select") { + } else if (s["setting_list"][i].type == "select") { var h = "<table><tr>"; - h += "<td class='setting_name'>" + s[i].description + "</td>"; - h += "<td> <select class='setting_value' id=" + s[i].name + "_value " + ">"; - s[i].select.forEach(e => { - if (e == s[i].value) { + h += "<td class='setting_name'>" + s["setting_list"][i].description + "</td>"; + h += "<td> <select class='setting_value' id=" + s["setting_list"][i].name + "_value " + ">"; + s["setting_list"][i].select.forEach(e => { + if (e == s["setting_list"][i].value) { h += "<option value=" + e + " selected >" + e + "</option>"; } else { h += "<option value=" + e + ">" + e + "</option>"; } }); h += "</select></td>"; h += "</tr></table>"; $("dl#wrap").append(h); } else { - //console.log("type=" + s[i].type); + //console.log("type=" + s["setting_list"][i].type); } } }); }); $("#" + dialog_id).dialog({ @@ -252,49 +254,52 @@ , resizable: true //リサイズ可 , closeOnEscape: false //[ESC]キーで閉じられなくする , draggable: true //ダイアログの移動を可に , buttons: { "OK": function () { //OKボタン - var json_data = [] + var json_obj = {}; + var json_data = []; $.getJSON(json_file, function (s) { - for (var i in s) { - //console.log(s[i].name); - if (s[i].type == "input") { + json_obj["version"] = s["version"]; + for (var i in s["setting_list"]) { + //console.log(s["setting_list"][i].name); + if (s["setting_list"][i].type == "input") { var data = {}; - data["name"] = s[i].name; - data["value"] = $("#" + s[i].name + "_value").val(); - data["type"] = s[i].type; - data["select"] = s[i].select; - data["description"] = s[i].description; + data["name"] = s["setting_list"][i].name; + data["value"] = $("#" + s["setting_list"][i].name + "_value").val(); + data["type"] = s["setting_list"][i].type; + data["select"] = s["setting_list"][i].select; + data["description"] = s["setting_list"][i].description; json_data.push(data); } - else if (s[i].type == "checkbox") { + else if (s["setting_list"][i].type == "checkbox") { var data = {}; - data["name"] = s[i].name; - if ($("#" + s[i].name + "_value:checked").val() == "on") { + data["name"] = s["setting_list"][i].name; + if ($("#" + s["setting_list"][i].name + "_value:checked").val() == "on") { data["value"] = true; } else { data["value"] = false; } - data["type"] = s[i].type; - data["select"] = s[i].select; - data["description"] = s[i].description; + data["type"] = s["setting_list"][i].type; + data["select"] = s["setting_list"][i].select; + data["description"] = s["setting_list"][i].description; json_data.push(data); - } else if (s[i].type == "select") { + } else if (s["setting_list"][i].type == "select") { var data = {}; - data["name"] = s[i].name; - data["value"] = $("#" + s[i].name + "_value" + " option:selected").val(); - data["type"] = s[i].type; - data["select"] = s[i].select; - data["description"] = s[i].description; + data["name"] = s["setting_list"][i].name; + data["value"] = $("#" + s["setting_list"][i].name + "_value" + " option:selected").val(); + data["type"] = s["setting_list"][i].type; + data["select"] = s["setting_list"][i].select; + data["description"] = s["setting_list"][i].description; json_data.push(data); } else { - //console.log("type=" + s[i].type); + //console.log("type=" + s["setting_list"][i].type); } } // Jsonデータをサーバに送信 - $ws.send("setting:" + JSON.stringify(json_data)); + json_obj["setting_list"] = json_data; + $ws.send("setting:" + JSON.stringify(json_obj)); }); $(this).dialog("close"); }, "Cancel": function () { //Cancelボタン $(this).dialog("close"); @@ -374,13 +379,13 @@ // 起動時の処理 $(document).ready(function () { // サーバに接続 - server_connect("ws://localhost:40173/wsserver") + server_connect("ws://localhost:41617/wsserver") window.onload = function (e) { // サーバに接続 - //server_connect("ws://localhost:40173/wsserver") + //server_connect("ws://localhost:41617/wsserver") } // menu $(function () { $(".menu li").hover(