HTML實現線上程式碼格式化、美化、加密、解密、壓縮、一鍵轉JavaScript功能工具-toolfk程式設計師工具網
阿新 • • 發佈:2018-11-11
本文要推薦的[ToolFk]是一款程式設計師經常使用的線上免費測試工具箱,ToolFk 特色是專注於程式設計師日常的開發工具,不用安裝任何軟體,只要把內容貼上按一個執行按鈕,就能獲取到想要的內容結果。ToolFk還支援 BarCode條形碼線上生成、 QueryList採集器、 PHP程式碼線上執行、 PHP混淆、加密、解密、 Python程式碼線上執行、JavaScript線上執行、YAML格式化工具、HTTP模擬查詢工具、HTML線上工具箱、JavaScript線上工具箱、CSS線上工具箱、JSON線上工具箱、Unixtime時間戳轉換
網站名稱:ToolFk
網站鏈結:https://www.toolfk.com/
工具連結:https://www.toolfk.com/tool-format-html
程式碼教學
本工具[線上HTML美化/加密/解密/轉JS]依賴於Codemirror,它的Github地址為:https://github.com/codemirror/CodeMirror,加密、解密使用到http://dean.edwards.name/packer/ 庫。使用程式碼如下
STEP 1
STEP 2
核心程式碼如下
$(function(){ var sourceArea = toolfk.create_codeMirror('code'); var targetArea = toolfk.create_codeMirror('result'); $(".beauty").click(function(){ toolfk.beautify_start({ language:'html', source:sourceArea, target:targetArea }); }); $(".compress").click(function(){ toolfk.pack_js({ source:sourceArea, target:targetArea }); }); $(".encrypt-compress").click(function(){ toolfk.pack_js({ source:sourceArea, target:targetArea, is_base64:true }); }); $(".deciphering-compress").click(function(){ toolfk.dec_pack({ source:sourceArea, target:targetArea, }); }); $(".html2js").click(function(){ toolfk.html2js({ source:sourceArea, target:targetArea, }); }); $(".copy-code").click(function(){ toolfk.code_code({ source:sourceArea, target:targetArea, }); }); }); #具體實現 beautify_start:function(options){ if (toolfk.beautify_default.beautify_in_progress) { return; } var opts = $.extend({},toolfk.beautify_default, options); var source = opts.source.getValue(); if(source==''){ return layer.msg(NOT_EMPTY); } toolfk.beautify_default.beautify_in_progress = true; if (opts.language === 'html') { output = beautifier.html(source, opts); } else if (opts.language === 'css') { output = beautifier.css(source, opts); } else { if (opts.detect_packers) { source = toolfk.beautify_unpacker_filter(source); } output = beautifier.js(source, opts); } opts.target.setValue(output); toolfk.report('beautify',output); toolfk.beautify_default.beautify_in_progress = false; }, pack_js:function(options) { if (toolfk.beautify_default.beautify_in_progress) { return; } var opts = $.extend({},toolfk.beautify_default, options); var source = opts.source.getValue(); if(source==''){ return layer.msg(NOT_EMPTY); } toolfk.beautify_default.beautify_in_progress = true; var packer = new Packer; if (opts.is_base64) { var output = packer.pack(source, 1, opts.is_shrink); } else { var output = packer.pack(source, 0, opts.is_shrink); } opts.target.setValue(output); toolfk.report('compress',output); toolfk.beautify_default.beautify_in_progress = false; }, dec_pack:function(options){ if (toolfk.beautify_default.beautify_in_progress) { return; } var opts = $.extend({},toolfk.beautify_default, options); var source = opts.source.getValue(); if(source==''){ return layer.msg(NOT_EMPTY); } toolfk.beautify_default.beautify_in_progress = true; try { eval('var value=String' + source.slice(4)); opts.target.setValue(value); toolfk.report('deciphering-compress',value); } catch (e) { layer.msg(TEXT_ERROR); } toolfk.beautify_default.beautify_in_progress = false; }, dec_pack_shrink:function(options){ if (toolfk.beautify_default.beautify_in_progress) { return; } var opts = $.extend({},toolfk.beautify_default, options); var source = opts.source.getValue(); if(source==''){ return layer.msg(NOT_EMPTY); } toolfk.beautify_default.beautify_in_progress = true; try { eval('var value=String' + source.slice(4)); var source = toolfk.beautify_unpacker_filter(value); output = beautifier.js(source, opts); opts.target.setValue(output); toolfk.report('decode-code',output); } catch (e) { layer.msg(TEXT_ERROR); } toolfk.beautify_default.beautify_in_progress = false; }, html2js:function(options){ if (toolfk.beautify_default.beautify_in_progress) { return; } var opts = $.extend({},toolfk.beautify_default, options); var source = opts.source.getValue(); if(source==''){ return layer.msg(NOT_EMPTY); } toolfk.beautify_default.beautify_in_progress = true; var value="document.writeln(\""+source.replace(/\\/g,"\\\\").replace(/\\/g,"\\/").replace(/\'/g,"\\\'").replace(/\"/g,"\\\"").split('\n').join("\");\ndocument.writeln(\"")+"\");"; opts.target.setValue(value); toolfk.report('html2js',value); toolfk.beautify_default.beautify_in_progress = false; },
值得一試的三個理由:
-
整合各種程式設計師開發中經常使用的開發測試工具。
-
簡潔美觀大氣的網站頁面
-
支援 線上格式化執行程式碼、APK線上反編譯、線上高強度密碼生成、線上網頁截圖 等二十多種工具服務
-
同時還推薦一下它的姐妹網 www.videofk.com 視訊下載工具箱