JavaScriptのみで記述されたブログツール・ソフトウェアです。表示にExt JSを使用します
Revision | 53f2066a4f122d5d55bf7eb63547ba2485062714 (tree) |
---|---|
Time | 2009-06-06 16:48:26 |
Author | elixirel <elixirel@user...> |
Commiter | elixirel |
modified regexp for triming
@@ -120,7 +120,8 @@ function requiredElementError(parent, name){ | ||
120 | 120 | } |
121 | 121 | |
122 | 122 | function xmlAttrContentEscape(str){ |
123 | - return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); | |
123 | + // return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); | |
124 | + return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/^[ ]+/mg, " ").replace(/^[\t]+/mg, ""); | |
124 | 125 | } |
125 | 126 | |
126 | 127 | /** |
@@ -302,8 +303,10 @@ function searchMode(urlhash){ | ||
302 | 303 | '<div id="drawPanel"><div id="drawItem" class="code"><\/div><\/div>' + |
303 | 304 | '<div style="line-height: ' + |
304 | 305 | entrySpan + |
305 | - 'px;"><br/></div>' + | |
306 | - '<div><table class="pager" width="' + extPanelWidth + '" cellspacing="1"><tbody>' + | |
306 | + 'px;"><br/></div>' + | |
307 | + '<div><table class="pager" width="' + | |
308 | + extPanelWidth + | |
309 | + '" cellspacing="1"><tbody>' + | |
307 | 310 | '<tr><td align="left"><<< 前の3件を表示</td><td align="center">[ 0 ]</td><td align="right">次の3件を表示 >>></td></tr>' + |
308 | 311 | '<tr><td class="pager" colspan="3">1件~1件(全1件)目の記事を表示中<br/></td></tr></tbody></table></div>'; |
309 | 312 | document.getElementById("drawItem").innerHTML = contentsWithid(entry.content, entry.id); |
@@ -56,8 +56,8 @@ var loadedEntries; | ||
56 | 56 | * Extへのイベント登録です。すべてのDOMが利用可能になった時点で実行されます。 |
57 | 57 | */ |
58 | 58 | $(document).ready(function(){ |
59 | - generateForm(); | |
60 | - | |
59 | + generateForm(); | |
60 | + | |
61 | 61 | // テキストボックスをExt js化し、空欄入力を拒否します |
62 | 62 | var searchTextBox = new Ext.form.TextField({ |
63 | 63 | applyTo: "searchWord", |
@@ -102,7 +102,9 @@ function generateForm(){ | ||
102 | 102 | "<input type='checkbox' id='isAsyncOn'/><label for='isAsyncOn'>非同期通信モードで検索を行う</label><br/>" + |
103 | 103 | "<span style='font-weight: bold;'>[ 注意 ]</span>非同期通信モードをオンにすると速度は上昇しますが、検索の順序が保障されません。<br/><br/>" + |
104 | 104 | "▼ 検索対象ログ選択<br/><div id='logSelecter'/></div><input type='checkbox' id='allSearchCheck' checked='checked'/><label for='allSearchCheck'>すべてのログに対して検索を行う</label>" + |
105 | - "<br/><a href='" + blogUrl + "'>トップページへ戻る</a><br/></form></td></tr></tbody></table>" | |
105 | + "<br/><a href='" + | |
106 | + blogUrl + | |
107 | + "'>トップページへ戻る</a><br/></form></td></tr></tbody></table>" | |
106 | 108 | document.getElementById("genForm").innerHTML = formBuffer; |
107 | 109 | |
108 | 110 | var resultAreaBuffer = "<table align='center'><tbody><tr><td class='resultarea' style='width: " + resultAreaWidth + "px;'>" + |
@@ -229,7 +231,8 @@ function validateText(contents){ | ||
229 | 231 | * @param {String} str エスケープを行いたい文字列 |
230 | 232 | */ |
231 | 233 | function xmlAttrContentEscape(str){ |
232 | - return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); | |
234 | + // return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); | |
235 | + return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/^[ ]+/mg, " ").replace(/^[\t]+/mg, ""); | |
233 | 236 | } |
234 | 237 | |
235 | 238 | /** |
@@ -288,7 +288,8 @@ function Entry(obj){ | ||
288 | 288 | |
289 | 289 | if (inputValidateMode == 1) { |
290 | 290 | this.content = this.content.replace(/[\r\n]|\r\n/g, ""); |
291 | - this.content = this.content.replace(/<br>/ig, "\n"); | |
291 | + this.content = this.content.replace(/<br[ \/]*>/ig, "\n"); | |
292 | + this.content = this.content.replace(/^[ \t]*/mg, ""); | |
292 | 293 | } |
293 | 294 | } |
294 | 295 |
@@ -363,7 +364,7 @@ function convertContent(content){ | ||
363 | 364 | * @param {String} str エスケープを行う文字列 |
364 | 365 | */ |
365 | 366 | function xmlAttrContentEscape(str){ |
366 | - return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); | |
367 | + return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/^[ ]+/mg, " ").replace(/^[\t]+/mg, ""); | |
367 | 368 | } |
368 | 369 | |
369 | 370 | /** |
@@ -371,7 +372,7 @@ function xmlAttrContentEscape(str){ | ||
371 | 372 | * @param {String} str 逆エスケープを行う文字列 |
372 | 373 | */ |
373 | 374 | function xmlAttrContentUnescape(str){ |
374 | - return str.replace.replace(/"/g, '"').replace(/>/g, ">").replace(/</g, "<").replace(/&/g, "&"); | |
375 | + return str.replace(/^[\t]+/mg, "").replace(/^[ ]+/mg, " ").replace(/"/g, '"').replace(/>/g, ">").replace(/</g, "<").replace(/&/g, "&"); | |
375 | 376 | } |
376 | 377 | |
377 | 378 | /** |
@@ -35,7 +35,7 @@ function logXMLLoader(){ | ||
35 | 35 | jQuery.ajax({ |
36 | 36 | url: logXmlUrl, |
37 | 37 | method: "GET", |
38 | - error: showError, | |
38 | + // error: showError, | |
39 | 39 | success: function(xmlData){ |
40 | 40 | var separateTag = xmlData.getElementsByTagName("file"); |
41 | 41 | var fileList = new Array(separateTag.length); |
@@ -127,7 +127,7 @@ function entryLoader(index){ | ||
127 | 127 | */ |
128 | 128 | function refleshEntrylistBox(){ |
129 | 129 | var stringBuffer = []; |
130 | - stringBuffer.push("<form name='logform'><select name='logbox' style='width: " + comboWidth + "px' onchange='entryLoader(this.options[this.selectedIndex].value)'>"); | |
130 | + stringBuffer.push("<form name='logform'><select id='logBox' style='width: " + comboWidth + "px' onchange='entryLoader(this.options[this.selectedIndex].value)'>"); | |
131 | 131 | for (var i = 0; i < entryList.length; i++) { |
132 | 132 | stringBuffer.push("<option value='" + i + "'/>" + entryList[i].title + "</option>"); |
133 | 133 | } |
@@ -213,8 +213,13 @@ function validateText(contents){ | ||
213 | 213 | } |
214 | 214 | |
215 | 215 | // ブロック要素のタグが存在した場合、改行をその後に挿入します。 |
216 | - contents = contents.replace(/<(div|h\d|p)[^>]*>/ig, "-----------------------------------------------------------------------------\n"); | |
217 | - contents = contents.replace(/(\n|)<\/(div|h\d|p)>/ig, "\n-----------------------------------------------------------------------------\n"); | |
216 | + if (document.getElementById("isCoverBlockTag").checked) { | |
217 | + contents = contents.replace(/<(div|h\d|p)[^>]*>/ig, "-----------------------------------------------------------------------------\n"); | |
218 | + contents = contents.replace(/(\n|)<\/(div|h\d|p)>/ig, "\n-----------------------------------------------------------------------------\n"); | |
219 | + } | |
220 | + else { | |
221 | + contents = contents.replace(/<\/(div|h\d|p)>/ig, "\n"); | |
222 | + } | |
218 | 223 | |
219 | 224 | // 通常のタグすべてを削除する |
220 | 225 | contents = contents.replace(/<[^>]*>|<\/[^>]*>/ig, ""); |
@@ -237,32 +242,17 @@ function showError(){ | ||
237 | 242 | } |
238 | 243 | |
239 | 244 | /** |
240 | - * <content>要素の変換を行います | |
241 | - * @param {String} content | |
242 | - */ | |
243 | -function convertContent(content){ | |
244 | - if (document.getElementById("addContentBr").checked) { | |
245 | - content = content.replace(/[\n\r]|\r\n/g, "<br>\n"); | |
246 | - } | |
247 | - else { | |
248 | - content = content.replace(/<br>/ig, "\n"); | |
249 | - } | |
250 | - | |
251 | - return content; | |
252 | -} | |
253 | - | |
254 | -/** | |
255 | 245 | * XMLのエスケープを行う関数 |
256 | 246 | * @param {String} str エスケープを行う文字列 |
257 | 247 | */ |
258 | 248 | function xmlAttrContentEscape(str){ |
259 | - return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); | |
249 | + return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/^[ ]+/mg, " ").replace(/^[\t]+/mg, ""); | |
260 | 250 | } |
261 | 251 | |
262 | 252 | /** |
263 | - * XMLのエスケープを行う関数 | |
264 | - * @param {String} str エスケープを行う文字列 | |
253 | + * XMLの逆エスケープを行う関数 | |
254 | + * @param {String} str 逆エスケープを行う文字列 | |
265 | 255 | */ |
266 | 256 | function xmlAttrContentUnescape(str){ |
267 | - return str.replace(/"/g, '"').replace(/>/g, ">").replace(/</g, "<").replace(/&/g, "&"); | |
257 | + return str.replace(/^[\t]+/mg, "").replace(/^[ ]+/mg, " ").replace(/"/g, '"').replace(/>/g, ">").replace(/</g, "<").replace(/&/g, "&"); | |
268 | 258 | } |
@@ -60,7 +60,7 @@ | ||
60 | 60 | <tbody> |
61 | 61 | <tr> |
62 | 62 | <td class="default" colspan="2" style="padding: 5px; text-align: center; vertical-align: bottom;"> |
63 | - <table> | |
63 | + <table style="width: 100%"> | |
64 | 64 | <tbody> |
65 | 65 | <tr> |
66 | 66 | <td class="formnavi" style="padding: 0px 20px 0px 20px;"> |
@@ -70,6 +70,11 @@ | ||
70 | 70 | <div id="logSelecter"> |
71 | 71 | </div> |
72 | 72 | </td> |
73 | + <td style="width: 10px;"> | |
74 | + </td> | |
75 | + <td class="formnavi"> | |
76 | + オプション | |
77 | + </td> | |
73 | 78 | </tr> |
74 | 79 | <tr> |
75 | 80 | <td class="formnavi" style="padding: 0px 20px 0px 20px;"> |
@@ -79,6 +84,11 @@ | ||
79 | 84 | <div id="entrySelect"> |
80 | 85 | </div> |
81 | 86 | </td> |
87 | + <td> | |
88 | + </td> | |
89 | + <td class="forminput"> | |
90 | + <input type="checkbox" id="isCoverBlockTag" checked="checked" onclick="entryLoader(document.getElementById('logBox').selectedIndex);">ブロック要素のタグを---で囲む | |
91 | + </td> | |
82 | 92 | </tr> |
83 | 93 | </tbody> |
84 | 94 | </table> |