lib/template/js/main.js in browser_app_base-0.0.8 vs lib/template/js/main.js in browser_app_base-0.0.9
- old
+ new
@@ -56,17 +56,19 @@
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 if (evt.data.match(/^popup:/)) {
+ open_dialog(evt.data.replace(/^popup:/, ""));
} else {
var log = "<li>" + evt.data + "</li>";
$('#log').append(log);
if ($auto_scroll) {
$('.outarea').scrollTop($('.outarea').get(0).scrollHeight);
@@ -99,11 +101,11 @@
//jQuery(this).autocomplete("search", "");
$(this).keydown();
},
source: function (req, resp) {
$.ajax({
- url: "http://localhost:53492/search?path=" + $("#" + id).val() + "&kind=" + file_kind,
+ url: "http://localhost:61047/search?path=" + $("#" + id).val() + "&kind=" + file_kind,
type: "GET",
cache: false,
dataType: "json",
data: {
param1: req.term
@@ -121,10 +123,42 @@
//jQuery(this).autocomplete("search", "");
$(this).keydown();
});
}
+function autocomp_history(id, file_name) {
+ $("#" + id).autocomplete({
+ autoFocus: true,
+ minLength: 0,
+ delay: 0,
+ select: function (event, ui) {
+ jQuery("#" + id).val(ui.item.value);
+ $(this).keydown();
+ },
+ source: function (req, resp) {
+ $.ajax({
+ url: "http://localhost:61047/history/" + file_name,
+ type: "POST",
+ cache: false,
+ dataType: "json",
+ data: {
+ param1: req.term
+ },
+ success: function (o) {
+ resp(o);
+ },
+ error: function (xhr, ts, err) {
+ resp(['']);
+ }
+ });
+
+ }
+ }).focus(function () {
+ $(this).keydown();
+ });
+}
+
function select_file_dialog(search_id, file_kind, dialog_id, select_file, file_name) {
$("#" + select_file).click(function () {
autocomp(search_id, file_kind);
$(".ui-autocomplete").css("z-index", 1000);
console.log("name=" + $("#" + file_name).val());
@@ -274,24 +308,29 @@
$ws.send("openfile:" + file);
}
// 起動時の処理
$(document).ready(function () {
- // サーバに接続
- server_connect("ws://localhost:53492/wsserver")
+
+ window.onload = function (e) {
+ console.log("onload");
+ // サーバに接続
+ server_connect("ws://localhost:61047/wsserver")
+ }
+
// ウインドウサイズ
var width = 800;
var height = 600;
$(window).resize(function () {
- $(".outarea").height($(window).height() - 300);
+ $(".outarea").height($(window).height() - 220);
});
// ウインドウの位置
$(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() - 300);
+ $(".outarea").height($(window).height() - 220);
});
$('.outarea').scroll(function () {
var h = $('.outarea').get(0).scrollHeight - $('.outarea').innerHeight();
//console.log("scrollEnd=" + Math.abs($('.outarea').scrollTop() - h));
@@ -319,8 +358,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");
+
+ autocomp_history("upFile", "history.json")
});