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

- old
+ new

@@ -11,22 +11,19 @@ ws.onmessage = function (evt) { //alert(evt.data); if (evt.data.match(/^startup:/)) { file_name = evt.data.replace(/^startup:/, ""); //alert(file_name); - var fs = new ActiveXObject("Scripting.FileSystemObject"); - var file = fs.CreateTextFile(file_name); - file.Close(); } else { var log = $('#log').val() + evt.data + "\n"; $('#log').val(log); var psconsole = $('#log'); psconsole.scrollTop( psconsole[0].scrollHeight - psconsole.height() ); } - + }; ws.onclose = function () { alert("アプリケーションが終了しました!!"); $(window).unbind("beforeunload"); //window.open('about:blank','_self').close(); @@ -39,15 +36,24 @@ if ($ws != null) { $ws.send(msg); } } -function autocomp(id, url) { +function autocomp(id, file_kind) { $("#" + id).autocomplete({ + autoFocus: true, + minLength: 0, + delay: 0, + select: function (event, ui) { + console.log(ui.item.value); + jQuery("#" + id).val(ui.item.value); + //jQuery(this).autocomplete("search", ""); + $(this).keydown(); + }, source: function (req, resp) { $.ajax({ - url: url(), + url: "http://localhost:62857/search?path=" + $("#" + id).val() + "&kind=" + file_kind, type: "GET", cache: false, dataType: "json", data: { param1: req.term @@ -59,71 +65,86 @@ resp(['']); } }); } + }).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 //リサイズ不可 + , closeOnEscape: false //[ESC]キーで閉じられなくする + , draggable: false //ダイアログの移動を不可に + , buttons: { + "OK": function () { //OKボタン + $("#" + file_name).val($("#" + search_id).val()); + $(this).dialog("close"); + $("#" + search_id).autocomplete("destroy"); + }, + "Cancel": function () { //Cancelボタン + $(this).dialog("close"); + $("#" + search_id).autocomplete("destroy"); + } + } + }); + }); +} + function get_dirname(path) { var result = path.replace(/\\/g, '/').replace(/\/[^\/]*$/, ''); if (result.match(/^[^\/]*\.[^\/\.]*$/)) { result = ''; } return result.replace(/\//g, "\\"); } -function select_file(id) { - var file = $("#" + id).val(); - var dir = get_dirname(file); - if (dir != "") { - dir = dir + "\\*.*"; - } else { - dir = "c:\\*.*"; - } - var path = ""; - //alert(dir); - //path = HtmlDlgHelper.openfiledlg(dir,"*.db","database(*.db)|*.db|all(*.*)|*.*|Text file(*.txt)|*.txt|"); - path = HtmlDlgHelper.openfiledlg(dir, "", "all(*.*)|*.*|Text file(*.txt)|*.txt|"); - $("#" + id).val(path); - return (path); -} - function dispFile() { var fName = $("#upFile").val(); alert('選択したファイルの値は' + fName + 'です'); } // 起動時の処理 $(document).ready(function () { // サーバに接続 - server_connect("ws://localhost:61820/wsserver") + server_connect("ws://localhost:62857/wsserver") // ウインドウサイズ - var width = 600; - var height = 700; + var width = 800; + var height = 600; // ウインドウの位置 $(function () { window.resizeTo(width, height); window.moveTo((window.screen.width / 2) - (width / 2), (screen.height / 2) - (height / 2)); //window.moveTo(0,0); }); - // オートコンプリート設定 - var getUrl = function () { - var url = "http://localhost:61820/search?path=" + $("#search_str").val(); - return url; - }; - autocomp("search_str", getUrl); - // ハンドラ登録 - $("#file").click(function () { - select_file("search_str"); + $("#stop").click(function () { + send_message("stop"); }); + $("#exec").click(function () { send_message("exec:" + $("#upFile").val()); }); - $("#stop").click(function () { - send_message("stop"); - }); + + select_file_dialog("search_str", "file", "dialog1", "select_file", "upFile"); + + select_file_dialog("search_str2", "dir", "dialog2", "select_dir", "upDir"); });