lib/template/js/main.js in browser_app_base-0.0.5 vs lib/template/js/main.js in browser_app_base-0.0.6

- old
+ new

@@ -1,21 +1,51 @@ // main.js var $ws = null; var $auto_scroll = true; +var dialog = null; +function open_dialog(msg) { + var top = window.screenTop + 10; + var left = window.screenLeft + 10; + if (dialog != null) { + dialog.close(); + } + var dialog = window.open( + "/open_dialog?msg=" + msg, + "pop", + "width=300, height=100, left=" + left + ", top=" + top + ); + console.log("open dialog dialog=" + dialog); + if (dialog == null) { + console.log("open dialog retry"); + setTimeout(function () { + open_dialog(msg); + }, 1000); + } else { + dialog.focus(); + } +} + function server_connect(url) { var ws = new WebSocket(url); ws.onopen = function () { // Web Socket is connected. You can send data by send() method. ws.send("message to send"); }; ws.onmessage = function (evt) { //alert(evt.data); + if (evt.data.match(/^startup:/)) { file_name = evt.data.replace(/^startup:/, ""); //alert(file_name); + } + else if (evt.data.match(/^app_end:normal/)) { + open_dialog("終了しました"); + } + else if (evt.data.match(/^app_end:error/)) { + open_dialog("<font color='red'>エラーが発生しました</font>"); } else { var log = "<li>" + evt.data + "</li>"; $('#log').append(log); if ($auto_scroll) { $('.outarea').scrollTop($('.outarea').get(0).scrollHeight); @@ -41,18 +71,18 @@ $("#" + id).autocomplete({ autoFocus: true, minLength: 0, delay: 0, select: function (event, ui) { - console.log(ui.item.value); + //console.log(ui.item.value); jQuery("#" + id).val(ui.item.value); //jQuery(this).autocomplete("search", ""); $(this).keydown(); }, source: function (req, resp) { $.ajax({ - url: "http://localhost:52538/search?path=" + $("#" + id).val() + "&kind=" + file_kind, + url: "http://localhost:54068/search?path=" + $("#" + id).val() + "&kind=" + file_kind, type: "GET", cache: false, dataType: "json", data: { param1: req.term @@ -137,11 +167,11 @@ }); h += "</select></td>"; h += "</tr></table>"; $("dl#wrap").append(h); } else { - console.log("type=" + s[i].type); + //console.log("type=" + s[i].type); } } }); }); $("#" + dialog_id).dialog({ @@ -157,11 +187,11 @@ , buttons: { "OK": function () { //OKボタン var json_data = [] $.getJSON(json_file, function (s) { for (var i in s) { - console.log(s[i].name); + //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; @@ -188,11 +218,11 @@ 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); + //console.log("type=" + s[i].type); } } $ws.send("setting:" + JSON.stringify(json_data)); }); $(this).dialog("close"); @@ -216,27 +246,35 @@ function dispFile() { var fName = $("#upFile").val(); alert('選択したファイルの値は' + fName + 'です'); } +function openFile(file) { + $ws.send("openfile:" + file); +} + // 起動時の処理 $(document).ready(function () { // サーバに接続 - server_connect("ws://localhost:52538/wsserver") + server_connect("ws://localhost:54068/wsserver") // ウインドウサイズ var width = 800; var height = 600; + $(window).resize(function() { + $(".outarea").height( $(window).height() - 250 ); + }); // ウインドウの位置 $(function () { window.resizeTo(width, height); window.moveTo((window.screen.width / 2) - (width / 2), (screen.height / 2) - (height / 2)); //window.moveTo(0,0); + $(".outarea").height( $(window).height() - 250 ); }); $('.outarea').scroll(function () { var h = $('.outarea').get(0).scrollHeight - $('.outarea').innerHeight(); - console.log("scrollEnd=" + Math.abs($('.outarea').scrollTop() - h)); - if (Math.abs($('.outarea').scrollTop() - h) < 5) { + //console.log("scrollEnd=" + Math.abs($('.outarea').scrollTop() - h)); + if (Math.abs($('.outarea').scrollTop() - h) < 30) { // 最後までスクロールしている // 自動スクロールON $auto_scroll = true; } else { // 自動スクロールOFF