Browse Source

增加Unix时间戳和当地时间之间的互相转换

Alien 11 years ago
parent
commit
00bea06130

+ 1 - 1
chrome/manifest.json

@@ -1,6 +1,6 @@
 { 
 	"name": "WEB前端助手(FeHelper)", 
-	"version": "3.9",
+	"version": "4.0",
     "manifest_version": 2,
 	 
 	"default_locale": "zh_CN", 

+ 1 - 1
chrome/online.manifest.json

@@ -1,6 +1,6 @@
 {
     "name": "WEB前端助手(FeHelper)",
-    "version": "3.9",
+    "version": "4.0",
     "manifest_version": 2,
 
     "default_locale": "zh_CN",

+ 3 - 0
chrome/static/css/fe-popup.css

@@ -73,6 +73,9 @@ ul.fe-function-list li.-x-codebeautify b {
 ul.fe-function-list li.-x-tracker b {
     background-position:-193px -193px;
 }
+ul.fe-function-list li.-x-timestamp b {
+    background-position:0px -161px;
+}
 .fe-feedback {
 	font-size:12px;
 	border-top:1px dotted #ddd;

+ 72 - 0
chrome/static/css/fe-timestamp.css

@@ -0,0 +1,72 @@
+html {
+	background:url(../img/baidufe_bj.gif);
+	font-size: 14px;
+}
+body{
+	font-family:Arial,"simsun";
+	color:#666;
+}
+
+.mod-timestamp {
+	width:950px;
+	margin:20px auto 0;
+    padding:5px 15px;
+    background: #fff;
+    border: 1px solid #bbb;
+}
+.mod-timestamp fieldset {
+	border : 1px solid #bbb;
+	margin: 20px 0 50px;
+}
+.mod-timestamp fieldset legend {
+	padding:0 5px;
+	color:#000000;
+}
+.mod-timestamp .x-input div {
+    margin: 5px 0;
+}
+
+#txtNowDate,#txtNow,#txtDesStamp,#txtSrcStamp,#txtDesDate {
+    width: 300px;
+    height: 26px;
+    line-height: 26px;
+    padding:0 5px ;
+    font-size: 16px;
+}
+
+#txtNowDate,#txtNow,#txtDesStamp,#txtDesDate {
+    color: #f00;
+    font-weight: bold;
+}
+
+#txtSrcYear,#txtSrcMonth,#txtSrcDay,#txtSrcHour,#txtSrcMinute,#txtSrcSecond {
+    width: 40px;
+    height: 26px;
+    line-height: 26px;
+    padding:0 5px ;
+    font-size: 16px;
+}
+
+.-e-btn {
+	height:30px;
+	width:70px;
+	font-size:13px;
+	padding:5px;
+	cursor:pointer;
+    background: #f1f1f1;
+    border: 1px solid #aaa;
+    color: #b00;
+    margin: 0 10px;
+}
+.-e-btn:hover {
+    background: #fff;
+}
+
+.-e-x-footer {
+	text-align:center;
+	font-size:12px;
+	margin-top:30px;
+	color:#00c;
+	padding:5px;
+	display:none;
+}

+ 2 - 0
chrome/static/js/core/fe-const.js

@@ -68,6 +68,8 @@ const MSG_TYPE = {
     QR_CODE : 'qrcode',
     //代码美化
     CODE_BEAUTIFY : 'codebeautify',
+    // 时间转换
+    TIME_STAMP : 'timestamp',
 
     //页面json代码自动格式化
     AUTO_FORMART_PAGE_JSON : "opt_item_autojson"

+ 66 - 0
chrome/static/js/timestamp/timestamp.js

@@ -0,0 +1,66 @@
+/**
+ * 时间戳转换工具
+ * @author zhaoxianlie
+ */
+var Timestamp = (function(){
+
+	"use strict";
+
+	var _bindEvents = function(){
+        $('#btnStampToLocale').click(function(e) {
+            var stamp = $.trim($('#txtSrcStamp').val());
+            if(stamp.length == 0) {
+                alert('请先填写你需要转换的Unix时间戳');
+                return;
+            }
+            if(!parseInt(stamp,10)) {
+                alert('请输入合法的Unix时间戳');
+                return;
+            }
+            $('#txtDesDate').val((new Date(stamp * 1000)).toLocaleString());
+        });
+
+        $('#btnLocaleToStamp').click(function(e) {
+            var year = $.trim($('#txtSrcYear').val());
+            var month = $.trim($('#txtSrcMonth').val());
+            var day = $.trim($('#txtSrcDay').val());
+            var hour = $.trim($('#txtSrcHour').val());
+            var minute = $.trim($('#txtSrcMinute').val());
+            var second = $.trim($('#txtSrcSecond').val());
+            if(year.length == 0 || month.length == 0 || day.length == 0 ||
+                hour.length == 0 || minute.length == 0 || second.length == 0 ) {
+                alert('年月日时分秒均不能为空!');
+                return;
+            }
+            if(!parseInt(year,10) || !parseInt(month,10) || !parseInt(day,10) ||
+                !parseInt(hour,10) || !parseInt(minute,10) || !parseInt(second,10)) {
+                alert('请输入合法的时间!');
+                return;
+            }
+            $('#txtDesStamp').val((new Date(Date.UTC(year,month,day,hour,minute,second))).getTime() / 1000);
+        });
+	};
+
+    var _initNowStamp = function(){
+        var txtNowDate = $('#txtNowDate');
+        var txtNowStamp = $('#txtNow');
+        window.setInterval(function(){
+            txtNowDate.val((new Date()).toLocaleString());
+            txtNowStamp.val(Math.round((new Date()).getTime() / 1000));
+        },1000);
+    };
+
+	var _init = function(){
+		$(function(){
+            _initNowStamp();
+			_bindEvents();
+            $('#tab0_url').focus();
+		});
+	};
+
+	return {
+		init : _init
+	};
+})();
+
+Timestamp.init();

+ 1 - 1
chrome/template/fehelper_popup.html

@@ -1 +1 @@
-<!DOCTYPE HTML>
<html lang="zh-CN">
    <head>
        <title>FeHelper弹出页面</title>
        <meta charset="utf-8">
		<link rel="stylesheet" href="../static/css/fe-popup.css" />
		<script type="text/javascript" src="../static/js/core/jquery-1.5.min.js"></script>
		<script type="text/javascript" src="../static/js/mod/mod_popup.js"></script>
    </head>
    <body>
    	<div class="fe-function-title">FE助手</div>
    	<ul class="fe-function-list">
            <li class="-x-endecode" data-msgtype="EN_DECODE" data-usefile="1">
                <b></b><span>字符串编解码</span></li>
            <li class="-x-codebeautify" data-msgtype="CODE_BEAUTIFY" data-usefile="1">
                <b></b><span>代码美化工具</span></li>
            <li class="-x-jsonformat" data-msgtype="JSON_FORMAT" data-usefile="1">
                <b></b><span>JSON格式化</span></li>
            <li class="-x-qrcode" data-msgtype="QR_CODE" data-usefile="1">
                <b></b><span>二维码生成器</span></li>
    		<li class="-x-fcp" data-msgtype="FCP_HELPER_DETECT">
                <b></b><span>编码规范检测</span></li>
            <li class="-x-loadtime" data-msgtype="SHOW_PAGE_LOAD_TIME">
                <b></b><span>页面性能检测</span></li>
    		<li class="-x-grid" data-msgtype="GRID_DETECT">
                <b></b><span>栅格规范检测</span></li>
            <li class="-x-tracker" data-msgtype="JS_TRACKER">
                <b></b><span>Tracker(JS嗅探)</span></li>
    		<li class="-x-fdp fe-hide" data-msgtype="FDP_HELPER" data-usefile="1">
                <b></b><span>FE文档检索</span></li>
    	</ul>
        <div class="fe-feedback">
            <a href="http://www.baidufe.com/item/889639af23968ee688b9.html#comment" target="_blank" tabindex="-1">意见反馈</a>
        </div>
    </body>
</html>
+<!DOCTYPE HTML>
<html lang="zh-CN">
    <head>
        <title>FeHelper弹出页面</title>
        <meta charset="utf-8">
		<link rel="stylesheet" href="../static/css/fe-popup.css" />
		<script type="text/javascript" src="../static/js/core/jquery-1.5.min.js"></script>
		<script type="text/javascript" src="../static/js/mod/mod_popup.js"></script>
    </head>
    <body>
    	<div class="fe-function-title">FE助手</div>
    	<ul class="fe-function-list">
            <li class="-x-endecode" data-msgtype="EN_DECODE" data-usefile="1">
                <b></b><span>字符串编解码</span></li>
            <li class="-x-timestamp" data-msgtype="TIME_STAMP" data-usefile="1">
                <b></b><span>时间(戳)转换</span></li>
            <li class="-x-codebeautify" data-msgtype="CODE_BEAUTIFY" data-usefile="1">
                <b></b><span>代码美化工具</span></li>
            <li class="-x-jsonformat" data-msgtype="JSON_FORMAT" data-usefile="1">
                <b></b><span>JSON格式化</span></li>
            <li class="-x-qrcode" data-msgtype="QR_CODE" data-usefile="1">
                <b></b><span>二维码生成器</span></li>
    		<li class="-x-fcp" data-msgtype="FCP_HELPER_DETECT">
                <b></b><span>编码规范检测</span></li>
            <li class="-x-loadtime" data-msgtype="SHOW_PAGE_LOAD_TIME">
                <b></b><span>页面性能检测</span></li>
    		<li class="-x-grid" data-msgtype="GRID_DETECT">
                <b></b><span>栅格规范检测</span></li>
            <li class="-x-tracker" data-msgtype="JS_TRACKER">
                <b></b><span>Tracker(JS嗅探)</span></li>
    		<li class="-x-fdp fe-hide" data-msgtype="FDP_HELPER" data-usefile="1">
                <b></b><span>FE文档检索</span></li>
    	</ul>
        <div class="fe-feedback">
            <a href="http://www.baidufe.com/item/889639af23968ee688b9.html#comment" target="_blank" tabindex="-1">意见反馈</a>
        </div>
    </body>
</html>

File diff suppressed because it is too large
+ 0 - 0
chrome/template/fehelper_timestamp.html


Some files were not shown because too many files changed in this diff