即时同步模式(体验死机的感觉)
延迟同步模式
异步模式
装饰器引擎自动装饰模式
JavaEye 讨论
邮件列表讨论
类库代码:
//导入相关css $import(this.packageName.replace(/\./g,'/')+"/code.css"); //记录当前目录 //模板数据,可以放文件里面,简单起见,直接写脚本中 var xmlTemplateData = '<table xmlns:c="http://www.xidea.org/taglib/core" \ width="100%" cellpadding="0" border="0" cellspacing="0" class="xidea--syntax-source">\ <tr> <td colspan="3" style="background: #eee;height:4px;"></td> </tr>\ <c:forEach var="line" items="${lines}" varStatus="i">\ <tr class="${i.index%2?\'xidea-syntax-row1\':\'xidea-syntax-row0\'}">\ <td class="xidea-syntax-vrule0"> <button>${i.index+1}</button></td>\ <td class="xidea-syntax-vrule1"> </td>\ <td nowrap="true">\ <pre><c:script>context.print(line);</c:script></pre>\ </td>\ </tr>\ </c:forEach>\ <tr> <td colspan="3" style="background: #eee;height:6px;"></td> </tr>\ </table>'; /** * @public */ function Code(){ } Code.prototype = new Decorator(); Code.prototype.before = function(){ } Code.prototype.decorate = function(){ var container = this.getContainer(); var content = container.getElementsByTagName('TEXTAREA')[0]; var p = new ECMAParser(content); p.parse(); it = p.buildLineIterator(); var tp = new Template(xmlTemplateData); var out = new Writer(); tp.render({ lines:it },out); container.innerHTML = out.toString(); }