Alien 10 rokov pred
rodič
commit
7d678efbba

+ 78 - 65
chrome/manifest.json

@@ -1,38 +1,41 @@
-{ 
-	"name": "WEB前端助手(FeHelper)", 
-	"version": "5.9",
+{
+    "name": "WEB前端助手(FeHelper)",
+    "version": "6.0",
     "manifest_version": 2,
-	 
-	"default_locale": "zh_CN", 
+
+    "default_locale": "zh_CN",
 
     "description": "FE助手:包括字符串编解码、代码压缩、美化、JSON格式化、正则表达式、时间转换工具、二维码生成器、编码规范检测、页面性能检测、栅格检测等",
-	"icons": { 
-		"16": "static/img/fe-16.png",
-		"48": "static/img/fe-48.png",
-		"128": "static/img/fe-128.png"
-	 }, 
-	 
-	"browser_action": {
-		"default_icon" : "static/img/fe-16.png",
-		"default_title" : "WEB前端助手",
-		"default_popup" : "template/fehelper_popup.html"
-	},
+    "icons": {
+        "16": "static/img/fe-16.png",
+        "48": "static/img/fe-48.png",
+        "128": "static/img/fe-128.png"
+    },
+
+    "browser_action": {
+        "default_icon": "static/img/fe-16.png",
+        "default_title": "WEB前端助手",
+        "default_popup": "template/fehelper_popup.html"
+    },
 
     "background": {
         "persistent": true,
-        "page": "template/fehelper_background.html"
+        "scripts": [
+            "static/js/core/jquery-1.5.min.js",
+            "static/js/mod/mod_background.js"
+        ]
     },
-	"options_page": "template/fehelper_options.html", 
-	
-	"permissions": [
-		"tabs",
-		"contextMenus",
-		"cookies",
-		"notifications",
+    "options_page": "template/fehelper_options.html",
+
+    "permissions": [
+        "tabs",
+        "contextMenus",
+        "cookies",
+        "notifications",
         "alarms",
         "webNavigation",
-		"\u003Call_urls\u003E" 
-	],
+        "\u003Call_urls\u003E"
+    ],
 
     "web_accessible_resources": [
         "static/img/43.png",
@@ -49,46 +52,56 @@
         "static/vendor/jquery-ui-1.8/css/jquery-ui-1.8.16.custom.hot_datauri.css"
     ],
 
-	"content_scripts": [{	
-		"matches":["http://*/*","https://*/*","file://*/*"],
-		"js":[
-			"static/js/core/jquery-1.5.min.js",
-			"static/vendor/jquery-ui-1.8/js/jquery-ui-1.8.11.custom.min.js",
-			
-			"static/js/core/core.js",
-			"static/js/core/fe-const.js",
-            "static/js/fe-option.js",
-			
-			"static/js/fcp/fcp-fl.js",
-			"static/js/fcp/css/fcp-css-analytic.js",
-			"static/js/fcp/css/fcp-css.js",
-			"static/js/fcp/html/fcp-html-analytic.js",
-			"static/js/fcp/html/fcp-html-doctype.js",
-			"static/js/fcp/html/fcp-html.js",
-			"static/js/fcp/js/fcp-js.js",
-			"static/js/fcp/fcp-tabs.js",
-			"static/js/fcp/fcp-main.js",
-			
-			"static/js/grid/grid-main.js",
-			"static/js/fe-helper.js",
-			"static/js/notification/fe-notification.js",
-			"static/js/wpo/fe-calc-wpo.js",
+    "content_scripts": [
+        {
+            "matches": [
+                "http://*/*",
+                "https://*/*",
+                "file://*/*"
+            ],
+            "js": [
+                "static/js/core/jquery-1.5.min.js",
+                "static/vendor/jquery-ui-1.8/js/jquery-ui-1.8.11.custom.min.js",
+
+                "static/js/core/core.js",
+                "static/js/core/fe-const.js",
+                "static/js/fe-option.js",
+
+                "static/js/fcp/fcp-fl.js",
+                "static/js/fcp/css/fcp-css-analytic.js",
+                "static/js/fcp/css/fcp-css.js",
+                "static/js/fcp/html/fcp-html-analytic.js",
+                "static/js/fcp/html/fcp-html-doctype.js",
+                "static/js/fcp/html/fcp-html.js",
+                "static/js/fcp/js/fcp-js.js",
+                "static/js/fcp/fcp-tabs.js",
+                "static/js/fcp/fcp-main.js",
 
-            "static/js/jsonformat/json-format-dealer.js",
-            "static/js/jsonformat/json-format-ent.js",
-            "static/js/jsonformat/contentscript-jsonformat.js"
-		],
-		"run_at":"document_start",
-		"all_frames":false
-	},{
-        "matches":["http://*.baidufe.com/fehelper/*","http://*.baidufe.com/fehelper"],
-        "js":[
-            "static/js/fe-contentscript-fehelper.js"
-        ],
-        "run_at":"document_start",
-        "all_frames":false
-    }],
+                "static/js/grid/grid-main.js",
+                "static/js/fe-helper.js",
+                "static/js/notification/fe-notification.js",
+                "static/js/wpo/fe-calc-wpo.js",
+
+                "static/js/jsonformat/json-format-dealer.js",
+                "static/js/jsonformat/json-format-ent.js",
+                "static/js/jsonformat/contentscript-jsonformat.js"
+            ],
+            "run_at": "document_start",
+            "all_frames": false
+        },
+        {
+            "matches": [
+                "http://*.baidufe.com/fehelper/*",
+                "http://*.baidufe.com/fehelper"
+            ],
+            "js": [
+                "static/js/fe-contentscript-fehelper.js"
+            ],
+            "run_at": "document_start",
+            "all_frames": false
+        }
+    ],
     "content_security_policy": "script-src 'self' https://ssl.google-analytics.com 'unsafe-eval'; object-src 'self'",
-	"homepage_url": "http://www.baidufe.com/fehelper"
+    "homepage_url": "http://www.baidufe.com/fehelper"
 
 }

+ 45 - 32
chrome/online.manifest.json

@@ -1,28 +1,31 @@
 {
     "name": "WEB前端助手(FeHelper)",
-    "version": "5.9",
+    "version": "6.0",
     "manifest_version": 2,
 
     "default_locale": "zh_CN",
 
     "description": "FE助手:包括字符串编解码、图片base64编码、代码压缩、美化、JSON格式化、正则表达式、时间转换工具、二维码生成器、编码规范检测、页面性能检测、栅格检测、JS运行效率分析等",
-	"icons": { 
-		"16": "static/img/fe-16.png",
-		"48": "static/img/fe-48.png",
-		"128": "static/img/fe-128.png"
-	 }, 
-	 
-	"browser_action": {
-		"default_icon" : "static/img/fe-16.png",
-		"default_title" : "WEB前端助手",
-		"default_popup" : "template/fehelper_popup.html"
-	},
+    "icons": {
+        "16": "static/img/fe-16.png",
+        "48": "static/img/fe-48.png",
+        "128": "static/img/fe-128.png"
+    },
+
+    "browser_action": {
+        "default_icon": "static/img/fe-16.png",
+        "default_title": "WEB前端助手",
+        "default_popup": "template/fehelper_popup.html"
+    },
 
     "background": {
         "persistent": true,
-        "page": "template/fehelper_background.html"
+        "scripts": [
+            "static/js/core/jquery-1.5.min.js",
+            "static/js/mod/mod_background.js"
+        ]
     },
-	"options_page": "template/fehelper_options.html",
+    "options_page": "template/fehelper_options.html",
 
     "permissions": [
         "tabs",
@@ -49,24 +52,34 @@
         "static/vendor/jquery-ui-1.8/css/jquery-ui-1.8.16.custom.hot_datauri.css"
     ],
 
-	"content_scripts": [{	
-		"matches":["http://*/*","https://*/*","file://*/*"],
-		"js":[
-			"static/js/core/jquery-1.5.min.js",
-			"static/vendor/jquery-ui-1.8/js/jquery-ui-1.8.11.custom.min.js",
-			
-			"static/js/mod/mod_manifest.js"
-		],
-		"run_at":"document_start",
-		"all_frames":false
-	},{
-        "matches":["http://*.baidufe.com/fehelper/*","http://*.baidufe.com/fehelper"],
-        "js":[
-            "static/js/fe-contentscript-fehelper.js"
-        ],
-        "run_at":"document_start",
-        "all_frames":false
-    }],
+    "content_scripts": [
+        {
+            "matches": [
+                "http://*/*",
+                "https://*/*",
+                "file://*/*"
+            ],
+            "js": [
+                "static/js/core/jquery-1.5.min.js",
+                "static/vendor/jquery-ui-1.8/js/jquery-ui-1.8.11.custom.min.js",
+
+                "static/js/mod/mod_manifest.js"
+            ],
+            "run_at": "document_start",
+            "all_frames": false
+        },
+        {
+            "matches": [
+                "http://*.baidufe.com/fehelper/*",
+                "http://*.baidufe.com/fehelper"
+            ],
+            "js": [
+                "static/js/fe-contentscript-fehelper.js"
+            ],
+            "run_at": "document_start",
+            "all_frames": false
+        }
+    ],
     "content_security_policy": "script-src 'self' https://ssl.google-analytics.com 'unsafe-eval'; object-src 'self'",
     "homepage_url": "http://www.baidufe.com/fehelper"
 }

+ 1 - 1
chrome/static/css/fe-timestamp.css

@@ -26,7 +26,7 @@ body{
     margin: 5px 0;
 }
 
-#txtNowDate,#txtNow,#txtDesStamp,#txtSrcStamp,#txtDesDate {
+#txtNowDate,#txtNow,#txtDesStamp,#txtSrcStamp,#txtDesDate,#txtLocale {
     width: 300px;
     height: 26px;
     line-height: 26px;

+ 15 - 11
chrome/static/js/fe-background.js

@@ -223,30 +223,34 @@ var BgPageInstance = (function () {
     var _createContextMenu = function () {
         _removeContextMenu();
         baidu.contextMenuId = chrome.contextMenus.create({
-            title:"FeHelper-FE助手"
+            title:"FeHelper"
         });
         chrome.contextMenus.create({
-            title:"编码检测",
+            title:"JSON格式化",
             parentId:baidu.contextMenuId,
             onclick:function (info, tab) {
-                //编码检测
-                _doFcpDetect(tab);
+                _openFileAndRun(tab,'jsonformat');
             }
         });
         chrome.contextMenus.create({
-            title:"栅格检测",
+            title:"字符串编解码",
             parentId:baidu.contextMenuId,
             onclick:function (info, tab) {
-                //执行栅格检测
-                _doGridDetect(tab);
+                _openFileAndRun(tab,'endecode');
             }
         });
         chrome.contextMenus.create({
-            title:"网页加载耗时",
+            title:"二维码生成",
             parentId:baidu.contextMenuId,
             onclick:function (info, tab) {
-                //网页加载耗时
-                _getPageWpoInfo();
+                _openFileAndRun(tab,'qrcode');
+            }
+        });
+        chrome.contextMenus.create({
+            title:"代码美化工具",
+            parentId:baidu.contextMenuId,
+            onclick:function (info, tab) {
+                _openFileAndRun(tab,'codebeautify');
             }
         });
     };
@@ -266,7 +270,7 @@ var BgPageInstance = (function () {
     var _createOrRemoveContextMenu = function () {
 
         //管理右键菜单
-        if (baidu.feOption.getOptionItem('opt_item_contextMenus') === 'true') {
+        if (baidu.feOption.getOptionItem('opt_item_contextMenus') !== 'false') {
             _createContextMenu();
         } else {
             _removeContextMenu();

+ 27 - 25
chrome/static/js/jsonformat/contentscript-jsonformat.js

@@ -33,7 +33,7 @@ baidu.csJsonFormat = (function () {
      * @private
      */
     var _getJsonText = function () {
-        var pre = $('body>pre:eq(0)')[0] || {textContent:""};
+        var pre = $('body>pre:eq(0)')[0] || {textContent: ""};
         var source = $.trim(pre.textContent);
         if (!source) {
             source = $.trim(document.body.textContent || '')
@@ -91,32 +91,34 @@ baidu.csJsonFormat = (function () {
 
         // 下面校验给定字符串是否为一个合法的json
         try {
-            jsonObj = new Function("return " + source)();
-
-            // 还要防止下面这种情况:  "{\"ret\":\"0\", \"msg\":\"ok\"}"
-            if (typeof jsonObj == "string") {
-                // 再来一次
-                jsonObj = new Function("return " + jsonObj)();
-            }
-        } catch (ex) {
             // 再看看是不是jsonp的格式
             var reg = /^([\w\.]+)\(\s*([\s\S]*)\s*\)$/igm;
             var matches = reg.exec(source);
-            if (matches == null) {
-                return;
+            if (matches != null) {
+                funcName = matches[1];
+                var newSource = matches[2];
+                jsonObj = new Function("return " + newSource)();
             }
+        } catch (ex) {
+            return;
+        }
 
-            funcName = matches[1];
-            source = matches[2];
-            try {
+        try {
+            if(jsonObj == null || typeof jsonObj != 'object') {
                 jsonObj = new Function("return " + source)();
-            } catch (e) {
-                return;
+
+                // 还要防止下面这种情况:  "{\"ret\":\"0\", \"msg\":\"ok\"}"
+                if (typeof jsonObj == "string") {
+                    // 再来一次
+                    jsonObj = new Function("return " + jsonObj)();
+                }
             }
+        } catch (e) {
+            return;
         }
 
         // 是json格式,可以进行JSON自动格式化
-        if (typeof jsonObj == "object") {
+        if (jsonObj != null && typeof jsonObj == "object") {
             try {
                 // 要尽量保证格式化的东西一定是一个json,所以需要把内容进行JSON.stringify处理
                 source = JSON.stringify(jsonObj);
@@ -129,7 +131,7 @@ baidu.csJsonFormat = (function () {
             _loadCss();
 
             // 点击区块高亮
-            $('#jfContent').delegate('.kvov', 'click',function (e) {
+            $('#jfContent').delegate('.kvov', 'click', function (e) {
                 $('#jfContent .kvov').removeClass('x-outline');
                 $(this).removeClass('x-hover').addClass('x-outline');
                 if (!$(e.target).is('.kvov .e')) {
@@ -137,12 +139,12 @@ baidu.csJsonFormat = (function () {
                 } else {
                     $(e.target).parent().trigger('click');
                 }
-            }).delegate('.kvov', 'mouseover',function (e) {
-                    $(this).addClass('x-hover');
-                    return false;
-                }).delegate('.kvov', 'mouseout', function (e) {
-                    $(this).removeClass('x-hover');
-                });
+            }).delegate('.kvov', 'mouseover', function (e) {
+                $(this).addClass('x-hover');
+                return false;
+            }).delegate('.kvov', 'mouseout', function (e) {
+                $(this).removeClass('x-hover');
+            });
 
             JsonFormatEntrance.clear();
             JsonFormatEntrance.format(source);
@@ -164,7 +166,7 @@ baidu.csJsonFormat = (function () {
     };
 
     return {
-        init:_init
+        init: _init
     };
 })();
 

+ 7 - 19
chrome/static/js/timestamp/timestamp.js

@@ -17,28 +17,16 @@ var Timestamp = (function(){
                 alert('请输入合法的Unix时间戳');
                 return;
             }
-            $('#txtDesDate').val((new Date(parseInt(stamp,10))).format('yyyy-MM-dd HH:mm:ss'));
+            $('#txtDesDate').val((new Date(parseInt(stamp,10) * 1000)).format('yyyy-MM-dd HH:mm:ss'));
         });
 
         $('#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(isNaN(parseInt(year,10)) || isNaN(parseInt(month,10)) || isNaN(parseInt(day,10)) ||
-                isNaN(parseInt(hour,10)) || isNaN(parseInt(minute,10)) || isNaN(parseInt(second,10))) {
-                alert('请输入合法的时间!');
-                return;
+            var locale = $.trim($('#txtLocale').val());
+            locale = Date.parse(locale);
+            if(isNaN(locale)) {
+                alert('请输入合法的时间格式,如:2014-04-01 10:01:01,或:2014-01-01');
             }
-            var dateString = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
-            $('#txtDesStamp').val(Date.parse(dateString));
+            $('#txtDesStamp').val(locale / 1000);
         });
 	};
 
@@ -47,7 +35,7 @@ var Timestamp = (function(){
         var txtNowStamp = $('#txtNow');
         window.setInterval(function(){
             txtNowDate.val((new Date()).toLocaleString());
-            txtNowStamp.val(Math.round((new Date()).getTime()));
+            txtNowStamp.val(Math.round((new Date()).getTime() / 1000));
         },1000);
     };
 

+ 0 - 1
chrome/template/fehelper_background.html

@@ -1 +0,0 @@
-<!DOCTYPE HTML>
<html lang="zh-CN">
	<head>
		<title></title>
		<meta charset="utf-8">
		<script type="text/javascript" src="../static/js/core/jquery-1.5.min.js"></script>
		<script type="text/javascript" src="../static/js/mod/mod_background.js"></script>
	</head>
	<body>
		
	</body>
</html>

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
chrome/template/fehelper_popup.html


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
chrome/template/fehelper_timestamp.html


Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov