asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0

/*
 * 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\">&nbsp;</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 汪杰 阅读(226) 评论(0)  编辑 收藏 引用 所属分类: javascript
只有注册用户登录后才能发表评论。

<2006年7月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 457617
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜