/*
* Letter Paper Constructor
* Author:Dron
* Date: 2007-5-10
* Contact: ucren.com
*/
var LetterPaperConstructor = {
config : (function ()
{
var obj = document.getElementById("paper");
return {
title : obj.getAttribute("title") || "",
date : obj.getAttribute("date") || "1900-1-1",
heart : obj.getAttribute("heart") || "",
weather : obj.getAttribute("weather") || "",
author : obj.getAttribute("author") || "",
content : obj.innerHTML
};
})(),
corePath : (
function ()
{
var s = document.getElementsByTagName("script");
s = s[s.length - 1];
var c = s.src;
c = c.match(/(.*)core\.js$/)[1];
return c;
}
)(),
template : [
"<html>",
" <head>",
" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />",
" <title>{title}</title>",
" <style type=\"text/css\">",
" body, td { font: 14px ËÎÌå; }",
" body { background-color: #ddd; margin: 0; padding: 0; }",
" #content { width: auto; margin: 0 45px; background: #fff url(\"{corePath}common/images/line.gif\") repeat 0 0; line-height: 20px; }",
" #content td { color: #808080; }",
" #content .title { width: auto; text-align: center; font-weight: bold; }",
" #padding-bottom { width: auto; height: 37px; }",
" </style>",
" </head>",
" <body>",
" <table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"608\" align=\"center\" style=\"margin: 5px auto;\">",
" <tr><td background=\"{corePath}common/images/table-top.gif\" width=\"608\" height=\"45\"></td></tr>",
" <tr><td background=\"{corePath}common/images/table-middle.gif\">",
" <div id=\"content\">",
" <div class=\"title\">{title}</div>",
" <table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" height=\"20\">",
" <tr>",
" <td width=\"120\">Date:<i> {date}</i></td>",
" <td width=\"120\">Heart:<i> {heart}</i></td>",
" <td width=\"120\">Weather:<i> {weather}</i></td>",
" <td width=\"120\">Author:<i> {author}</i></td>",
" </tr>",
" </table>",
" {content}",
" </div>",
" <div id=\"padding-bottom\"> </div>",
" </td></tr>",
" <tr><td background=\"{corePath}common/images/table-bottom.gif\" height=\"8\"></td></tr>",
" </table>",
" </body>",
"</html>"
],
disposeTemplate : function ()
{
this.template = this.template.join("\r\n")
.replace(/\{corePath\}/g, this.corePath)
.replace(/\{title\}/g, this.config.title)
.replace(/\{content\}/, this.config.content)
.replace(/\{date\}/, this.config.date)
.replace(/\{heart\}/, this.config.heart)
.replace(/\{weather\}/, this.config.weather)
.replace(/\{author\}/, this.config.author);
},
initialize : function ()
{
var me = this;
this.disposeTemplate();
window.setTimeout(function ()
{
document.write(me.template);
}, 1);
}
}
LetterPaperConstructor.initialize();
posted on 2007-11-23 23:35
汪杰 阅读(242)
评论(0) 编辑 收藏 引用 所属分类:
javascript