2019-10-15 23:45:49 +08:00
function toolUnixTimeToUnix ( GetTime , isMillisecond ) { var Time = new Date ( ) ; Time . setFullYear ( GetTime . substring ( 0 , 4 ) ) ; Time . setMonth ( GetTime . substring ( 5 , 7 ) - 1 ) ; Time . setDate ( GetTime . substring ( 8 , 10 ) ) ; Time . setHours ( GetTime . substring ( 11 , 13 ) ) ; Time . setMinutes ( GetTime . substring ( 14 , 16 ) ) ; Time . setSeconds ( GetTime . substring ( 17 , 19 ) ) ; if ( isMillisecond == false ) { var TextLength = Time . getTime ( ) . toString ( ) . length ; return Time . getTime ( ) . toString ( ) . substring ( 0 , TextLength - 3 ) ; } else if ( isMillisecond == true ) { var TextLength = Time . getTime ( ) . toString ( ) . length ; return Time . getTime ( ) . toString ( ) . substring ( 0 , TextLength - 3 ) + "000" ; } else { return "模式有误!" ; } }
function toolUnixTimeToTime ( GetUnix , isMillisecond ) { var Time = new Date ( ) ; if ( isMillisecond == false ) { GetUnix = GetUnix + "000" ; Time . setTime ( GetUnix ) ; } else if ( isMillisecond == true ) { Time . setTime ( GetUnix ) ; } else { Time . setTime ( "0" ) ; }
2019-09-28 23:48:17 +08:00
var TimeYear = Time . getFullYear ( ) ; var TimeMonth = Time . getMonth ( ) + 1 ; if ( TimeMonth . toString ( ) . length == 1 ) { TimeMonth = "0" + TimeMonth ; }
var TimeDate = Time . getDate ( ) ; if ( TimeDate . toString ( ) . length == 1 ) { TimeDate = "0" + TimeDate ; }
var TimeHour = Time . getHours ( ) ; if ( TimeHour . toString ( ) . length == 1 ) { TimeHour = "0" + TimeHour ; }
var TimeMinute = Time . getMinutes ( ) ; if ( TimeMinute . toString ( ) . length == 1 ) { TimeMinute = "0" + TimeMinute ; }
var TimeSecond = Time . getSeconds ( ) ; if ( TimeSecond . toString ( ) . length == 1 ) { TimeSecond = "0" + TimeSecond ; }
return TimeYear + "-" + TimeMonth + "-" + TimeDate + " " + TimeHour + ":" + TimeMinute + ":" + TimeSecond ; }
2019-10-15 23:45:49 +08:00
function toolUnixTimeNow ( ) { var GetInputA = document . getElementById ( "tool-unixtime-input-a" ) . getElementsByTagName ( "input" ) [ 0 ] ; var GetInputB = document . getElementById ( "tool-unixtime-input-b" ) . getElementsByTagName ( "input" ) [ 0 ] ; var GetSettingAA = document . getElementById ( "unixtime-setting-aa" ) . checked ; var GetSettingAB = document . getElementById ( "unixtime-setting-ab" ) . checked ; var GetSettingBA = document . getElementById ( "unixtime-setting-ba" ) . checked ; var GetSettingBB = document . getElementById ( "unixtime-setting-bb" ) . checked ; if ( GetSettingAA == true ) { var Time = new Date ( ) ; var TextLength = Time . getTime ( ) . toString ( ) . length ; GetInputA . value = Time . getTime ( ) . toString ( ) . substring ( 0 , TextLength - 3 ) ; } else if ( GetSettingAB == true ) { GetInputA . value = new Date ( ) . getTime ( ) ; }
GetInputB . value = toolUnixTimeToTime ( new Date ( ) . getTime ( ) , true ) ; }
function toolUnixTimeSubmit ( ) { var GetInputA = document . getElementById ( "tool-unixtime-input-a" ) . getElementsByTagName ( "input" ) [ 0 ] ; var GetInputB = document . getElementById ( "tool-unixtime-input-b" ) . getElementsByTagName ( "input" ) [ 0 ] ; var GetOutputA = document . getElementById ( "tool-unixtime-output-a" ) . getElementsByTagName ( "input" ) [ 0 ] ; var GetOutputB = document . getElementById ( "tool-unixtime-output-b" ) . getElementsByTagName ( "input" ) [ 0 ] ; var GetSettingAA = document . getElementById ( "unixtime-setting-aa" ) . checked ; var GetSettingAB = document . getElementById ( "unixtime-setting-ab" ) . checked ; var GetSettingBA = document . getElementById ( "unixtime-setting-ba" ) . checked ; var GetSettingBB = document . getElementById ( "unixtime-setting-bb" ) . checked ; if ( GetSettingAA == true ) { GetOutputA . value = toolUnixTimeToTime ( GetInputA . value , false ) ; } else if ( GetSettingAB == true ) { GetOutputA . value = toolUnixTimeToTime ( GetInputA . value , GetSettingAB ) ; }
GetOutputB . value = toolUnixTimeToUnix ( GetInputB . value , GetSettingBB ) ; }
2019-12-04 00:52:19 +08:00
function toolUnixTimeClear ( ) { document . querySelector ( "#tool-unixtime-input-a input" ) . value = '' ; document . querySelector ( "#tool-unixtime-input-b input" ) . value = '' ; document . querySelector ( "#tool-unixtime-output-a input" ) . value = '' ; document . querySelector ( "#tool-unixtime-output-b input" ) . value = '' ; }
2019-09-28 23:48:17 +08:00
function toolCalculateSubmit ( ) { GetInput = document . getElementById ( "tool-calculate-input" ) ; GetToFixed = document . getElementById ( "tool-calculate-tofixed" ) ; GetResult = document . getElementById ( "tool-calculate-result" ) . getElementsByTagName ( "span" ) [ 0 ] ; GetCal = GetInput . value ; GetCal = GetCal . replace ( /π/g , "Math.PI" ) ; GetCal = GetCal . replace ( /幂/g , "Math.pow" ) ; GetCal = GetCal . replace ( /平方根/g , "Math.sqrt" ) ; if ( GetToFixed . value >= 0 && GetToFixed . value <= 16 ) { GetResult . innerText = eval ( GetCal ) . toFixed ( GetToFixed . value ) ; } else { GetResult . innerText = "保留位数有误( 0 ~ 16 之间)" ; } }
2019-09-25 23:03:39 +08:00
function toolCalculateClear ( ) { GetInput = document . getElementById ( "tool-calculate-input" ) ; GetInput . value = '' ; GetResult . innerText = '' ; }
2019-09-28 23:48:17 +08:00
function toolGenLinkSubmit ( ) { var VarText = "(*)" ; var BaseLink = document . getElementById ( "tool-genlink-link" ) . getElementsByTagName ( "input" ) [ 0 ] . value ; var GetSettingType = document . getElementsByName ( "genlink-settings" ) ; var GetSettingA = document . getElementById ( "tool-genlink-settings-a" ) . getElementsByTagName ( "input" ) ; var GetSettingB = document . getElementById ( "tool-genlink-settings-b" ) . getElementsByTagName ( "input" ) ; var GetSettingC = document . getElementById ( "tool-genlink-settings-c" ) . getElementsByTagName ( "input" ) ; var GetResult = document . getElementById ( "tool-genlink-result" ) ; var LinkReplace = '' ; var LinkResult = '' ; function AddZero ( ) { if ( NumLength < NumLastLength ) { var ZeroMax = NumLastLength - NumLength ; for ( let i = 1 ; i <= ZeroMax ; i ++ ) { Num = "0" + Num ; } } }
2019-09-25 23:03:39 +08:00
function CheckReverse ( ) { LinkReplace = BaseLink . replace ( VarText , Num ) ; if ( GetReverse == false ) { LinkResult = LinkResult + LinkReplace + "\n" ; } else if ( GetReverse == true ) { LinkResult = LinkReplace + "\n" + LinkResult ; } }
if ( GetSettingType [ 0 ] . checked == true ) { var GetFirst = parseInt ( GetSettingA [ 1 ] . value ) ; var GetLength = parseInt ( GetSettingA [ 2 ] . value ) ; var GetDiff = parseInt ( GetSettingA [ 3 ] . value ) ; var GetZero = GetSettingA [ 4 ] . checked ; var GetReverse = GetSettingA [ 5 ] . checked ; if ( GetZero == true ) { var Num ; var NumLength ; var NumLast = GetFirst + ( GetLength - 1 ) * GetDiff ; var NumLastLength = NumLast . toString ( ) . length ; for ( var i = 1 ; i <= GetLength ; i ++ ) { Num = GetFirst + ( i - 1 ) * GetDiff ; NumLength = Num . toString ( ) . length ; AddZero ( ) ; CheckReverse ( ) ; } } else if ( GetZero == false ) { var Num ; for ( var i = 1 ; i <= GetLength ; i ++ ) { Num = GetFirst + ( i - 1 ) * GetDiff ; CheckReverse ( ) ; } } } else if ( GetSettingType [ 1 ] . checked == true ) { var GetFirst = parseInt ( GetSettingB [ 1 ] . value ) ; var GetLength = parseInt ( GetSettingB [ 2 ] . value ) ; var GetDiff = parseInt ( GetSettingB [ 3 ] . value ) ; var GetZero = GetSettingB [ 4 ] . checked ; var GetReverse = GetSettingB [ 5 ] . checked ; if ( GetZero == true ) { var Num ; var NumLength ; var NumLast = GetFirst * Math . pow ( GetDiff , ( GetLength - 1 ) ) ; var NumLastLength = NumLast . toString ( ) . length ; for ( var i = 1 ; i <= GetLength ; i ++ ) { Num = GetFirst * Math . pow ( GetDiff , ( i - 1 ) ) ; NumLength = Num . toString ( ) . length ; AddZero ( ) ; CheckReverse ( ) ; } } else if ( GetZero == false ) { var Num ; for ( var i = 1 ; i <= GetLength ; i ++ ) { Num = GetFirst * Math . pow ( GetDiff , ( i - 1 ) ) ; CheckReverse ( ) ; } } } else if ( GetSettingType [ 2 ] . checked == true ) { var GetFirst = GetSettingC [ 1 ] . value . charCodeAt ( 0 ) ; var GetLast = GetSettingC [ 2 ] . value . charCodeAt ( 0 ) ; var GetReverse = GetSettingC [ 3 ] . checked ; if ( GetFirst >= 65 && GetFirst <= 122 && GetLast >= 65 && GetLast <= 122 ) { if ( GetFirst < GetLast ) { for ( var i = GetFirst ; i <= GetLast ; i ++ ) { if ( i >= 91 && i <= 96 ) { continue ; }
Num = String . fromCharCode ( i ) ; CheckReverse ( ) ; } } else if ( GetFirst > GetLast ) { GetResult . placeholder = "字母先后顺序有误。\n请按此顺序填写: \nA - Z a - z\n例如: \n从 a 到 d\n从 A 到 D\n从 X 到 g" ; } else if ( GetFirst == GetLast ) { GetResult . placeholder = "仅有 1 条链接,无需生成。" ; } else { GetResult . placeholder = "异常。" ; } } else { GetResult . placeholder = "超出范围。" ; } } else { GetResult . placeholder = "类型选择有误" ; }
GetResult . value = LinkResult ; }
function toolGenLinkClear ( ) { var GetResult = document . getElementById ( "tool-genlink-result" ) ; GetResult . value = '' ; GetResult . placeholder = "结果" ; }
2019-12-04 00:52:19 +08:00
function toolNewWindowSubmit ( ) { var link = document . querySelector ( "#tool-newwindow-link input" ) . value ; var width = document . querySelectorAll ( "#tool-newwindow-meta input" ) [ 0 ] . value ; var height = document . querySelectorAll ( "#tool-newwindow-meta input" ) [ 1 ] . value ; if ( width == "" ) { width = 400 ; }
if ( height == "" ) { height = 300 ; }
window . open ( link , "_blank" , "height=" + height + ", width=" + width + ", toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=yes, status=yes" ) ; }
function toolNewWindowClear ( ) { document . querySelector ( "#tool-newwindow-link input" ) . value = "" ; document . querySelectorAll ( "#tool-newwindow-meta input" ) [ 0 ] . value = "" ; document . querySelectorAll ( "#tool-newwindow-meta input" ) [ 1 ] . value = "" ; }
function toolRunJSSubmit ( ) { var GetCode = document . querySelector ( "#tool-runjs-input" ) ; eval ( GetCode . value ) ; }
function toolRunJSClear ( ) { var GetCode = document . querySelector ( "#tool-runjs-input" ) ; GetCode . value = '' ; }