2019-09-28 23:48:17 +08:00
function toolUnixTimeGetNowA ( TimeSet , SettingBA , SettingBB ) { var Time = new Date ( ) ; if ( TimeSet != '' ) { Time . setFullYear ( TimeSet . substring ( 0 , 4 ) ) ; Time . setMonth ( TimeSet . substring ( 5 , 7 ) - 1 ) ; Time . setDate ( TimeSet . substring ( 8 , 10 ) ) ; Time . setHours ( TimeSet . substring ( 11 , 13 ) ) ; Time . setMinutes ( TimeSet . substring ( 14 , 16 ) ) ; Time . setSeconds ( TimeSet . substring ( 17 , 19 ) ) ; }
if ( TimeSet != '' && SettingBA == true && SettingBB == false ) { var TextLength = Time . getTime ( ) . toString ( ) . length ; return Time . getTime ( ) . toString ( ) . substring ( 0 , TextLength - 3 ) ; } else if ( TimeSet != '' && SettingBA == false && SettingBB == true ) { var TextLength = Time . getTime ( ) . toString ( ) . length ; return Time . getTime ( ) . toString ( ) . substring ( 0 , TextLength - 3 ) + "000" ; } else { return Time . getTime ( ) ; } }
function toolUnixTimeGetNowB ( TimeSet ) { var Time = new Date ( ) ; if ( TimeSet != '' ) { Time . setTime ( TimeSet ) ; }
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 ; }
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 ; GetInputA . value = toolUnixTimeGetNowA ( '' , GetSettingAA , GetSettingAB ) ; GetInputB . value = toolUnixTimeGetNowB ( '' , GetSettingBA , GetSettingBB ) ; }
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 ; GetOutputA . value = toolUnixTimeGetNowB ( GetInputA . value , GetSettingAA , GetSettingAB ) ; GetOutputB . value = toolUnixTimeGetNowA ( GetInputB . value , GetSettingBA , GetSettingBB ) ; }
function toolUnixTimeClear ( ) { document . getElementById ( "tool-unixtime-input-a" ) . getElementsByTagName ( "input" ) [ 0 ] . value = '' ; document . getElementById ( "tool-unixtime-input-b" ) . getElementsByTagName ( "input" ) [ 0 ] . value = '' ; document . getElementById ( "tool-unixtime-output-a" ) . getElementsByTagName ( "input" ) [ 0 ] . value = '' ; document . getElementById ( "tool-unixtime-output-b" ) . getElementsByTagName ( "input" ) [ 0 ] . value = '' ; }
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 = "结果" ; }
function toolRunJSSubmit ( ) { GetCode = document . getElementById ( "tool-runjs-input" ) ; eval ( GetCode . value ) ; }
function toolRunJSClear ( ) { GetCode = document . getElementById ( "tool-runjs-input" ) ; GetCode . value = '' ; }