lib/template/js/main.js in browser_app_base-0.0.3 vs lib/template/js/main.js in browser_app_base-0.0.4

- old
+ new

@@ -49,11 +49,11 @@ //jQuery(this).autocomplete("search", ""); $(this).keydown(); }, source: function (req, resp) { $.ajax({ - url: "http://localhost:62857/search?path=" + $("#" + id).val() + "&kind=" + file_kind, + url: "http://localhost:64141/search?path=" + $("#" + id).val() + "&kind=" + file_kind, type: "GET", cache: false, dataType: "json", data: { param1: req.term @@ -66,33 +66,30 @@ } }); } }).focus(function () { - console.log("forcus"); //jQuery(this).autocomplete("search", ""); $(this).keydown(); }); } function select_file_dialog(search_id, file_kind, dialog_id, select_file, file_name) { - console.log("select_file_dialog select_file=" + select_file); $("#" + select_file).click(function () { autocomp(search_id, file_kind); - console.log("open dialog dialog_id=", dialog_id); $(".ui-autocomplete").css("z-index", 1000); $("#" + search_id).val("/"); $("#" + dialog_id).dialog({ modal: true , show: "slide" //表示時のアニメーション , hide: "explode" //閉じた時のアニメーション , title: "Select File" //ダイアログのタイトル , width: 580 //ダイアログの横幅 , height: 400 //ダイアログの高さ - , resizable: false //リサイズ不可 + , resizable: true //リサイズ可 , closeOnEscape: false //[ESC]キーで閉じられなくする - , draggable: false //ダイアログの移動を不可に + , draggable: true //ダイアログの移動を可に , buttons: { "OK": function () { //OKボタン $("#" + file_name).val($("#" + search_id).val()); $(this).dialog("close"); $("#" + search_id).autocomplete("destroy"); @@ -104,10 +101,113 @@ } }); }); } +function setting_dialog(open_id, dialog_id, json_file) { + $("#" + 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") { + 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></tr></table>" + $("dl#wrap").append(h); + } else if (s[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>"; + } else { + h += "<td><input class='setting_checkbox' type='checkbox' " + "id=" + s[i].name + "_value ></td>"; + } + h += "</tr></table>"; + $("dl#wrap").append(h); + } else if (s[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 += "<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); + } + } + }); + }); + $("#" + dialog_id).dialog({ + modal: true + , show: "slide" //表示時のアニメーション + , hide: "explode" //閉じた時のアニメーション + , title: "Setting" //ダイアログのタイトル + , width: 580 //ダイアログの横幅 + , height: 400 //ダイアログの高さ + , resizable: true //リサイズ可 + , closeOnEscape: false //[ESC]キーで閉じられなくする + , draggable: true //ダイアログの移動を可に + , buttons: { + "OK": function () { //OKボタン + var json_data = [] + $.getJSON(json_file, function (s) { + for (var i in s) { + console.log(s[i].name); + if (s[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; + json_data.push(data); + } + else if (s[i].type == "checkbox") { + var data = {}; + data["name"] = s[i].name; + if ($("#" + s[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; + json_data.push(data); + } else if (s[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; + json_data.push(data); + } else { + console.log("type=" + s[i].type); + } + } + $ws.send("setting:" + JSON.stringify(json_data)); + }); + $(this).dialog("close"); + }, + "Cancel": function () { //Cancelボタン + $(this).dialog("close"); + } + } + }); + }); +} + function get_dirname(path) { var result = path.replace(/\\/g, '/').replace(/\/[^\/]*$/, ''); if (result.match(/^[^\/]*\.[^\/\.]*$/)) { result = ''; } @@ -120,11 +220,11 @@ } // 起動時の処理 $(document).ready(function () { // サーバに接続 - server_connect("ws://localhost:62857/wsserver") + server_connect("ws://localhost:64141/wsserver") // ウインドウサイズ var width = 800; var height = 600; // ウインドウの位置 $(function () { @@ -143,8 +243,10 @@ }); select_file_dialog("search_str", "file", "dialog1", "select_file", "upFile"); select_file_dialog("search_str2", "dir", "dialog2", "select_dir", "upDir"); + + setting_dialog("setting", "setting_dialog", "config/setting.json"); });