JavaScriptのみで記述されたブログツール・ソフトウェアです。表示にExt JSを使用します
Revision | 626812038a7de3bc0f9f409b7998ef9c40fb5003 (tree) |
---|---|
Time | 2009-06-06 14:15:51 |
Author | elixirel <elixirel@user...> |
Commiter | elixirel |
add allRemoveFunction and modified after delete index.
@@ -187,7 +187,7 @@ | ||
187 | 187 | </tbody> |
188 | 188 | </table> |
189 | 189 | <br> |
190 | - <input type="button" value="追加/編集" onclick="javascript:applyChange();"> <input type="button" value="選択中の記事を削除" onclick="javascript:removeEntry()"> <input type="button" value="リセット" onclick="javascript:initLoad()" | |
190 | + <input type="button" value="追加/編集" onclick="javascript:applyChange();"> <input type="button" value="選択中の記事を削除" onclick="javascript:removeEntry()"> <input type="button" value="リセット" onclick="javascript:initLoad()"> <input type="button" value="全記事を削除" onclick="javascript:allRemoveEntry()"> | |
191 | 191 | <br> |
192 | 192 | <br> |
193 | 193 | </td> |
@@ -31,6 +31,12 @@ function applyChange(){ | ||
31 | 31 | feedInfo = applyFeedinfo(); |
32 | 32 | pageAddr = feedInfo.alternate; |
33 | 33 | |
34 | + if (document.getElementById("entry_title").value == "" || document.getElementById("entry_stdin").value == "") { | |
35 | + if (confirm("タイトルか記事が空白です!FeedBlogでの表示時にエラーが出ますがよろしいですか?") == false) { | |
36 | + return; | |
37 | + } | |
38 | + } | |
39 | + | |
34 | 40 | if (editIndex < 0) { |
35 | 41 | var entry = new Object(); |
36 | 42 | var dateRfc3339 = getDate(); |
@@ -43,7 +49,12 @@ function applyChange(){ | ||
43 | 49 | entry.content = document.getElementById("entry_stdin").value.replace(/\r\n/g, "\n"); |
44 | 50 | entryList.unshift(entry); |
45 | 51 | |
52 | + // ログ一覧を更新する | |
46 | 53 | refleshEntrylistBox(); |
54 | + | |
55 | + // 更新後、選択されている項目を、先刻追加した日記に移動する | |
56 | + document.getElementById("logBox").selectedIndex = 1; | |
57 | + editIndex = 0; | |
47 | 58 | } |
48 | 59 | else { |
49 | 60 | entryList[editIndex].title = document.getElementById("entry_title").value; |
@@ -59,8 +70,8 @@ function applyChange(){ | ||
59 | 70 | * @param {int} index entryListから削除される記事のインデックス |
60 | 71 | */ |
61 | 72 | function removeEntry(index){ |
62 | - if (editIndex >= 0) { | |
63 | - entryList.splice(index, 1); | |
73 | + if (editIndex == 0) { | |
74 | + entryList.splice(editIndex, 1); | |
64 | 75 | refleshEntrylistBox(); |
65 | 76 | editIndex = -1; |
66 | 77 |
@@ -68,6 +79,29 @@ function removeEntry(index){ | ||
68 | 79 | document.getElementById("entry_title").value = ""; |
69 | 80 | document.getElementById("entry_stdin").value = ""; |
70 | 81 | } |
82 | + if (editIndex > 0) { | |
83 | + var prevIndex = document.getElementById("logBox").selectedIndex - 1; | |
84 | + entryList.splice(editIndex, 1); | |
85 | + refleshEntrylistBox(); | |
86 | + document.getElementById("logBox").selectedIndex = prevIndex; | |
87 | + editIndex = editIndex - 1; | |
88 | + | |
89 | + entryLoader(editIndex); | |
90 | + } | |
91 | +} | |
92 | + | |
93 | +/** | |
94 | + * すべての記事を削除します | |
95 | + */ | |
96 | +function allRemoveEntry(){ | |
97 | + entryList = []; | |
98 | + | |
99 | + editIndex = -1; | |
100 | + refleshEntrylistBox(); | |
101 | + | |
102 | + document.getElementById("stdout").value = "" | |
103 | + document.getElementById("entry_title").value = ""; | |
104 | + document.getElementById("entry_stdin").value = ""; | |
71 | 105 | } |
72 | 106 | |
73 | 107 | /** |
@@ -213,7 +247,7 @@ function entryLoader(index){ | ||
213 | 247 | */ |
214 | 248 | function refleshEntrylistBox(){ |
215 | 249 | var stringBuffer = []; |
216 | - stringBuffer.push("<form name='logform'><select name='logbox' style='width: " + comboWidth + "px' onchange='entryLoader(this.options[this.selectedIndex].value)'>"); | |
250 | + stringBuffer.push("<form name='logform'><select id='logBox' style='width: " + comboWidth + "px' onchange='entryLoader(this.options[this.selectedIndex].value)'>"); | |
217 | 251 | stringBuffer.push("<option value='-1'>新規作成</option>"); |
218 | 252 | for (var i = 0; i < entryList.length; i++) { |
219 | 253 | stringBuffer.push("<option value='" + i + "'/>" + entryList[i].title + "</option>"); |