手机版
你好,游客 登录 注册
背景:
阅读新闻

HTML5本地存储之Database Storage篇

[日期:2013-01-06] 来源:Linux社区  作者:hbcui1984 [字体:大 中 小]

其中,涉及到格式化时间的format函数,可参考如下JS实现:

        Date.prototype.format = function(format)
        {
            var o = {
            "M+" : this.getMonth()+1, //month
            "d+" : this.getDate(),    //day
            "h+" : this.getHours(),  //hour
            "m+" : this.getMinutes(), //minute
            "s+" : this.getSeconds(), //second
            "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
            "S" : this.getMilliseconds() //millisecond
            }
            if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
            (this.getFullYear()+"").substr(4 - RegExp.$1.length));
            for(var k in o)if(new RegExp("("+ k +")").test(format))
            format = format.replace(RegExp.$1,
            RegExp.$1.length==1 ? o[k] :
            ("00"+ o[k]).substr((""+ o[k]).length));
            return format;
        }

最后,界面实现效果如下:

 


要实现具体某个联系人,需执行如下JS代码:

        //删除联系人信息
        function del(phone){
            db.transaction(function(tx){
                //注意这里需要显示的将传入的参数phone转变为字符串类型
                tx.executeSql('delete from contact where phone=?',[String(phone)],onSuccess,onError);
            });
        }

如上截图中的表格样式,可参考如下CSS代码:

        th {
            font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
            color: #4f6b72;
            border-right: 1px solid #C1DAD7;
            border-bottom: 1px solid #C1DAD7;
            border-top: 1px solid #C1DAD7;
            letter-spacing: 2px;
            text-transform: uppercase;
            text-align: left;
            padding: 6px 6px 6px 12px;
        }
        td {
            border-right: 1px solid #C9DAD7;
            border-bottom: 1px solid #C9DAD7;
            background: #fff;
            padding: 6px 6px 6px 12px;
            color: #4f6b72;
        }

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款