--- takahashi.xul 2006/06/09 21:51:42 3 +++ takahashi.xul 2006/06/10 15:31:05 12 @@ -737,6 +737,8 @@ var linksRegExp = this.makePhraseRegExp('^([^%O]+)?%O%O(([^|]+)?\\||)([^%C]+)%C%C', ''); + var wikiRegExp = this.makePhraseRegExp('^([^%O]+)?%O([0-9]*)([#!])?([:\/\*_-])([^%C]+)[:\/\*_-]%C', ''); + var montaRegExp = this.makePhraseRegExp('^([^%O]+)?%O([^%C]+)%C', ''); var inBlock = false, @@ -881,6 +883,25 @@ this.clickableNodes.push(fragment.lastChild.lastChild); } + // modify font size and wiki-style + else if (wikiRegExp.test(line)) { + fragment.lastChild.appendChild(document.createElement('description')); + fragment.lastChild.lastChild.setAttribute('value', RegExp.$5); + var style = 'font-size:'+ ( RegExp.$2 || 100 ) +'%'; + if (RegExp.$4 == '*') { + style += '; font-weight: bold;'; + } else if (RegExp.$4 == '/') { + style += '; font-style: italic;'; + } else if (RegExp.$4 == '_') { + style += '; text-decoration: underline;'; + } else if (RegExp.$4 == '-') { + style += '; text-decoration: line-through;'; + } + fragment.lastChild.lastChild.setAttribute('style', style); + if (RegExp.$3 == '!') fragment.lastChild.lastChild.setAttribute('class', 'em-text'); + else if (RegExp.$3 == '#') fragment.lastChild.lastChild.setAttribute('class', 'preformatted-text'); + } + // Monta else if (montaRegExp.test(line)) { fragment.lastChild.appendChild(document.createElement('stack')); @@ -987,7 +1008,7 @@ if (this.dataPath != file) { var path = this.dataPath; var request = new XMLHttpRequest(); - request.open('GET', path); + request.open('GET', path + '?rand=' + Math.random() ); request.onload = function() { Presentation.textbox.value = request.responseText; Presentation.data = Presentation.textbox.value; @@ -1078,9 +1099,18 @@ insertTextFor : function(aString, aNode, aPosOffset) { var pos = aNode.selectionStart; + var sel_len = aNode.selectionEnd - aNode.selectionStart; var value = aNode.value; - aNode.value = [value.substring(0, pos), aString, value.substring(pos, value.length)].join(''); - aNode.selectionEnd = aNode.selectionStart = pos + (aPosOffset || 0); + if (! aPosOffset) aPosOffset = 0; + aNode.value = [ + value.substring(0, pos), + aString.substring(0,aPosOffset), + value.substring(pos, pos + sel_len), + aString.substring(aPosOffset, aString.length), + value.substring(pos + sel_len, value.length) + ].join(''); + aNode.selectionStart = pos + (aPosOffset || 0); + aNode.selectionEnd = aNode.selectionStart + sel_len; },