OSDN Git Service

modified regexp for triming
[feedblog/feedblog_ext.git] / js / lunardial / feedblog_mixi.js
index f9706b9..dea178b 100644 (file)
@@ -35,7 +35,7 @@ function logXMLLoader(){
     jQuery.ajax({
         url: logXmlUrl,
         method: "GET",
-        error: showError,
+        // error: showError,
         success: function(xmlData){
             var separateTag = xmlData.getElementsByTagName("file");
             var fileList = new Array(separateTag.length);
@@ -127,7 +127,7 @@ function entryLoader(index){
  */
 function refleshEntrylistBox(){
     var stringBuffer = [];
-    stringBuffer.push("<form name='logform'><select name='logbox' style='width: " + comboWidth + "px' onchange='entryLoader(this.options[this.selectedIndex].value)'>");
+    stringBuffer.push("<form name='logform'><select id='logBox' style='width: " + comboWidth + "px' onchange='entryLoader(this.options[this.selectedIndex].value)'>");
     for (var i = 0; i < entryList.length; i++) {
         stringBuffer.push("<option value='" + i + "'/>" + entryList[i].title + "</option>");
     }
@@ -213,8 +213,13 @@ function validateText(contents){
     }
     
     // ブロック要素のタグが存在した場合、改行をその後に挿入します。
-    contents = contents.replace(/<(div|h\d|p)[^>]*>/ig, "-----------------------------------------------------------------------------\n");
-    contents = contents.replace(/(\n|)<\/(div|h\d|p)>/ig, "\n-----------------------------------------------------------------------------\n");
+    if (document.getElementById("isCoverBlockTag").checked) {
+        contents = contents.replace(/<(div|h\d|p)[^>]*>/ig, "-----------------------------------------------------------------------------\n");
+        contents = contents.replace(/(\n|)<\/(div|h\d|p)>/ig, "\n-----------------------------------------------------------------------------\n");
+    }
+    else {
+        contents = contents.replace(/<\/(div|h\d|p)>/ig, "\n");
+    }
     
     // 通常のタグすべてを削除する
     contents = contents.replace(/<[^>]*>|<\/[^>]*>/ig, "");
@@ -237,32 +242,17 @@ function showError(){
 }
 
 /**
- * <content>要素の変換を行います
- * @param {String} content
- */
-function convertContent(content){
-    if (document.getElementById("addContentBr").checked) {
-        content = content.replace(/[\n\r]|\r\n/g, "<br>\n");
-    }
-    else {
-        content = content.replace(/<br>/ig, "\n");
-    }
-    
-    return content;
-}
-
-/**
  * XMLのエスケープを行う関数
  * @param {String} str エスケープを行う文字列
  */
 function xmlAttrContentEscape(str){
-    return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
+    return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/^[ ]+/mg, "&nbsp;").replace(/^[\t]+/mg, "");
 }
 
 /**
- * XMLのエスケープを行う関数
- * @param {String} str エスケープを行う文字列
+ * XMLのエスケープを行う関数
+ * @param {String} str エスケープを行う文字列
  */
 function xmlAttrContentUnescape(str){
-    return str.replace(/&quot;/g, '"').replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&amp;/g, "&");
+    return str.replace(/^[\t]+/mg, "").replace(/^[ ]+/mg, "&nbsp;").replace(/&quot;/g, '"').replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&amp;/g, "&");
 }