entryList[editIndex].updated = getDate();
entryList[editIndex].content = document.getElementById("entry_stdin").value.replace(/\r\n/g, "\n");
- document.getElementById("logBox").options[editIndex + 1].text = entryList[editIndex].title;
+ document.getElementById("logBox").options[parseInt(editIndex) + 1].text = entryList[editIndex].title;
}
document.getElementById("stdout").value = toXml(feedInfo, entryList);
document.getElementById("previewArea").innerHTML = entryList[editIndex].content.replace(/\n/g, "<br>");
}
+
+/**
+ * mixi用に通常のHTMLを変換します
+ * @param {String} contents 日記の本文が格納されている文字列
+ */
+function mixiWrapper(contents){
+ // 置換に使用する変数
+ var target_tag;
+ var target_element;
+
+ // ニコニコ動画のタグを置換
+ while (target_tag = contents.match(/<iframe[^>]*src=["']http:\/\/ext.nicovideo.jp\/thumb\/[A-Za-z]*\d*["'][^>]*>[^<]*<\/iframe>/i)) {
+ // src="..."の部分だけ抜き出す
+ target_element = target_tag[0].match(/src=["'][^"']*["']/i);
+ target_element = '<externalvideo src="NC:' + target_element[0].replace(/src=["']http:\/\/ext.nicovideo.jp\/thumb\/|["']/ig, "") + ':D">';
+ // iframeタグ全体を置換する
+ contents = contents.replace(target_tag, target_element);
+ }
+
+ // Aタグを変換する
+ while (contents.match(/<a[^>]*>/)) {
+ // 置換対象のAタグを抽出する
+ target_tag = contents.match(/<a[^>]*>/i);
+ // href="..."の部分のみを抜き出す
+ target_element = target_tag[0].match(/href=["'][^"']*["']/i);
+ // 相対URIが検出された場合、フルに置換する
+ var baseUri = document.location.href.replace(/[^\/]+$/, '');
+ target_element = target_element[0].replace(/\.\//, baseUri).replace(/\.\.\//g, "");
+ // Aタグ全体を消去し、再度Aクローズタグの置換を行う
+ contents = contents.replace(target_tag, "");
+ contents = contents.replace(/<\/a>/i, " ( " + target_element.replace(/href=|["']/g, "") + " ) ");
+ }
+
+ // ブロック要素のタグが存在した場合、改行をその後に挿入します。
+ // if (document.getElementById("isCoverBlockTag").checked) {
+ if (true) {
+ 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, "");
+
+ // 通常のタグ置換後、ニコニコ動画のタグを元に戻す
+ contents = contents.replace(/<externalvideo src="NC:/g, "<externalvideo src='NC:");
+ contents = contents.replace(/:D">/, ":D'>");
+
+ // 半角を置換する
+ contents = contents.replace(/ /g, " ");
+
+ return contents;
+}
+
/**
* 選択中の記事を削除します
* @param {int} index entryListから削除される記事のインデックス