; delete this[strKey]; } this.length = 0; } /** * 判断HashMap是否为空 */ HashMap.prototype.isEmpty = function() { return this.length == 0; } /** * 判断HashMap是否存在某个key */ HashMap.prototype.containsKey = function(key) { for(var strKey in this) { if(strKey == this.prefix + key) return true; } return false; } /** * 判断HashMap是否存在某个value */ HashMap.prototype.containsValue = function(value) { for(var strKey in this) { if(this[strKey] == value) return true; } return false; } /** * 把一个HashMap的值加入到另一个HashMap中,参数必须是HashMap */ HashMap.prototype.putAll = function(map) { if(map == null) return; if(map.constructor != JHashMap) return; var arrKey = map.keySet(); var arrValue = map.values(); for(var i in arrKey) this.put(arrKey[i],arrValue[i]); } //toString HashMap.prototype.toString = function() { var str = ""; for(var strKey in this)
{ if(strKey.substring(0,this.prefix.length) == this.prefix) str += strKey.substring(this.prefix.length) + " : " + this[strKey] + "\r\n"; } return str; }
<!-- main.htm -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> </head>
<body> <p>{HEAD}</p> <p>{WELCOME} </p> <table width="100%" border="1" cellspacing="1" cellpadding="3"> <!-- BEGIN BROWS --> <tr> <!-- BEGIN BCOLS --> <td>{NUMBER}</td> <!-- END BCOLS --> </tr> <!-- END BROWS --> </table> <p>{FOOT}</p> </body> </html>
<!-- head.htm -->
<table width="100%" border="1" cellspacing="1" cellpadding="3"> <tr> <td>网站首页</td> </tr> </table>
<!-- foot.htm -->
<table width="100%" border="1" cellspacing="1" cellpadding="3"> <tr> <td>版权所有:网站梦工厂</td> </tr> </table>
<!-- index.htm -->
<script src="script/Template.class.js"></script> <script> var tmplt=new Template(); var root=location.href; root=unescape(root.substring(8,root.lastIndexOf("/")+1)); tmplt.set_root(root); tmplt.set_file("fh","tpl/main.htm"); tmplt.set_file("head","tpl/head.htm"); tmplt.set_file("foot","tpl/foot.htm"); tmplt.set_block("fh","BROWS","rows"); tmplt.set_block("BROWS","BCOLS","cols"); tmplt.set_var("WELCOME","欢迎光临"); for(var i=0;i<10;i++) { tmplt.set_var("cols",""); for(var j=0;j<10;j++) { tmplt.set_var("NUMBER",i+"."+j); tmplt.parse("cols","BCOLS",true); } tmplt.parse("rows","BROWS",true); } tmplt.parse("HEAD","head",false); tmplt.parse("FOOT","foot",false); tmplt.pparse("out","fh",false); </script>
上一页 [1] [2] |