Skip to content

Commit 3b1fd08

Browse files
committed
Formさらに改良を加えたよ
1 parent 09408a0 commit 3b1fd08

File tree

5 files changed

+33
-24
lines changed

5 files changed

+33
-24
lines changed

Latest/bin/Latest.js

+17-10
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ class CommentManager {
292292
if (id == undefined)
293293
return;
294294
let node = new Comments(id, x, y, z, comment, url);
295-
console.log("id = " + id + ",x = " + x + ",y = " + y + ",z = " + z + ",comment = " + comment + ",url = " + url);
295+
console.log("DEBUG: CreateComment = {id = " + id + ",x = " + x + ",y = " + y + ",z = " + z + ",comment = " + comment + ",url = " + url + "}");
296296
node.createComments();
297297
node.appendComments();
298298
}
@@ -342,7 +342,7 @@ class DB {
342342
data: parameter,
343343
dataType: 'text'
344344
}).done(function (data) {
345-
console.log(data);
345+
console.log("DEBUG: LoadData = " + data);
346346
JSON.parse(data).forEach((e) => {
347347
info.push({ id: e.node_id, x: e.x, y: e.y, comment: e.comment, url: e.url });
348348
});
@@ -372,7 +372,7 @@ class DB {
372372
}
373373
}
374374
}).done(function (data) {
375-
console.log(data);
375+
console.log("DEBUG: SaveData = " + data);
376376
});
377377
}
378378
}
@@ -441,8 +441,7 @@ class Form {
441441
* @param e クリックした場所の座標をjqueryより取得
442442
*/
443443
make_form(comment_manager, e) {
444-
// 書き込みモードを解除
445-
mode.Change_mode("read");
444+
// 書き込みモードを解除
446445
this.init_form();
447446
//ポップアップとして表示するもの全体のdivを用意
448447
let latest_div = document.createElement("div");
@@ -477,9 +476,10 @@ class Form {
477476
comment_manager.creteNewComments(String(e.pageX), String(e.pageY), "1000", tmp_comment);
478477
$(this).dialog('close');
479478
$("#latest_div").remove();
480-
// 書き込みモードを再開
481-
mode.Change_mode("write");
482479
}
480+
},
481+
close: function () {
482+
mode.Change_mode("write");
483483
}
484484
});
485485
}
@@ -571,20 +571,27 @@ let mode = new Mode();
571571
let comment_manager = new CommentManager();
572572
let debug = new Debug();
573573
let form = new Form();
574-
/*
575-
サイトを読み込んだときに実行
576-
*/
574+
// サイトを読み込んだときに実行
577575
window.onload = function () {
576+
// コメントの読み込み
578577
comment_manager.loadComment();
579578
};
580579
//background.jsから送られたメッセージで機能を変更する
581580
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
581+
/*
582+
コマンドをmodeに書き込み
583+
コマンド=>"read", "write"
584+
*/
582585
mode.Change_mode(request.command);
583586
});
584587
$("body").on("click", function (e) {
588+
console.log("DEBUG: mode = " + mode.flag);
585589
// 書き込みモードならPIN・コメントを作成
586590
if (mode.Judge_mode("write")) {
591+
// フォームを閉じる際にもう一度開かないようにするための対策
587592
if (mode.form_unmake) {
593+
// 書き込み中にフォームを再度作らないように制御
594+
mode.Change_mode("read");
588595
form.make_form(comment_manager, e);
589596
}
590597
mode.Change_unmake();

Latest/src/DB.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DB{
2323
data: parameter,
2424
dataType: 'text'
2525
}).done(function (data: string){
26-
console.log(data);
26+
console.log("DEBUG: LoadData = " + data);
2727
JSON.parse(data).forEach((e: { node_id: string; x: string; y: string; comment: string; url: string; }) => {
2828
info.push({id: e.node_id, x: e.x, y: e.y, comment: e.comment, url: e.url})
2929
});
@@ -54,7 +54,7 @@ class DB{
5454
}
5555
}
5656
}).done(function(data){
57-
console.log(data)
57+
console.log("DEBUG: SaveData = {id: " + data.comment.node_id + ", x: " + data.comment.x + ", y: " + data.comment.y + ", comment: " + data.comment.comment + ", url: " + data.comment.url + "}");
5858
});
5959
}
6060
}

Latest/src/Elements.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ class CommentManager{
356356
createComments(id: string, x: string, y: string, z: string = "1000", comment: string, url: string){
357357
if (id == undefined) return;
358358
let node = new Comments(id, x, y, z, comment, url)
359-
console.log("id = " + id + ",x = " + x + ",y = " + y + ",z = " + z + ",comment = " + comment + ",url = " + url);
359+
console.log("DEBUG: CreateComment = {id = " + id + ",x = " + x + ",y = " + y + ",z = " + z + ",comment = " + comment + ",url = " + url + "}");
360360
node.createComments()
361361
node.appendComments()
362362
}

Latest/src/Form.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,19 @@ class Form{
4343
modal: true,
4444
buttons: {
4545
"登録": function(){
46-
let tmp_user: string = "";
47-
let tmp_comment: string = "";
48-
tmp_user = inputs[0].value;
49-
tmp_comment = inputs[1].value;
50-
console.log("ユーザーネーム: "+tmp_user+" コメント: "+tmp_comment);
51-
// コメントを作成
52-
comment_manager.creteNewComments(String(e.pageX), String(e.pageY), "1000", tmp_comment)
53-
$(this).dialog('close');
54-
$("#latest_div").remove();
55-
// 書き込みモードを再開
56-
mode.Change_mode("write")
46+
let tmp_user: string = "";
47+
let tmp_comment: string = "";
48+
tmp_user = inputs[0].value;
49+
tmp_comment = inputs[1].value;
50+
console.log("ユーザーネーム: "+tmp_user+" コメント: "+tmp_comment);
51+
// コメントを作成
52+
comment_manager.creteNewComments(String(e.pageX), String(e.pageY), "1000", tmp_comment)
53+
$(this).dialog('close');
54+
$("#latest_div").remove();
5755
}
56+
},
57+
close: function(){
58+
mode.Change_mode("write");
5859
}
5960
});
6061
}

Latest/src/main.ts

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
2929
});
3030

3131
$("body").on("click", function(e){
32+
console.log("DEBUG: mode = " + mode.flag)
3233
// 書き込みモードならPIN・コメントを作成
3334
if(mode.Judge_mode("write")){
3435
// フォームを閉じる際にもう一度開かないようにするための対策

0 commit comments

Comments
 (0)