-
Notifications
You must be signed in to change notification settings - Fork 13
/
base62x_test.js.html
50 lines (48 loc) · 2.04 KB
/
base62x_test.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Base62x in JavaScript Test</title>
<script src="./Base62x.class.js?v=1903111031"></script>
</head>
<body>
<div id="contentid">
Base62x in JavaScript Test/中文: <br/><br/>
</div>
</body>
<script>
var divid = 'contentid';
var randi = Math.ceil(Math.random()*10000);
var s = randi+'abcd'+(randi*randi)+'1234@'+(randi%2==0?'中國-文化-源遠流長'+randi+':::':randi)+(new Date())+'@'+Math.ceil(Math.random()*100000);
//s = '/编号OfferId↿⇂网盟↿⇂标题↿⇂PKG名称↿⇂国家↿⇂收入↿⇂状态↿⇂来源Id↿⇂更新时间↿⇂~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 / 10063015 ▾10063015yeahmobi_marianaJAJU[자주] - 내가 주인인 삶com.jaju.mobile|KR:0.850.00000上线29892292017-02-13 17:23:47 2 / 10063014 ▾10063014yeahmobi_marianahayu – reality TV on demandcom.upst.hayu|AU:1.620.00000上线29892432017-02-13 17:23:45/';
//- static invoke
var encs = Base62x.encode(s);
//encs = 'CZXXOcDaDpWqCJ8pD43akAtbd8ijvfQ7vOoMBUQwaEc1eEQrWUcLjp8uEkx2zcZfDRsuWHcLY834p838mCJSWCJWwC3OwCpCWHqrKAp0uC30WA4DeQMvX85DqOMvaON9a85HfRMKfG3GuCJOv';
var decs = Base62x.decode(encs);
var inum = randi+'a'+1+randi+'fea'; var ibase = 16; var obase = 16;
var num_enc = Base62x.encode(inum, ibase);
var num_dec = Base62x.decode(num_enc, obase);
var wobj = document.getElementById(divid);
var ostr = '';
if(wobj){
ostr = wobj.innerHTML;
ostr += "Time: "+(new Date())+"<br/>";
ostr += "<br/>orgs:["+s+"]<br/>encs:["+encs+"]<br/>decs:["+decs+"] equals:["+(s==decs)+"]";
ostr += "<br/><br/>orgs:["+inum+"]<br/>encs:["+num_enc+"]<br/>decs:["+num_dec+"] equals:["+(inum==num_dec)+"]";
wobj.innerHTML = ostr;
}
else{
console.log("target object:["+divid+"] failed.");
}
//- instance invoke
var mybase62x = new Base62x();
ostr += "<br/><br/>instanceOf: <br/>i:["+mybase62x.i+"] isdebug:["+mybase62x.isdebug+"]";
encs = mybase62x.encode(s);
decs = mybase62x.decode(encs);
ostr += "<br/>encs:["+encs+"]";
ostr += "<br/>decs:["+decs+"] equals:["+(s==decs)+"]";
wobj.innerHTML = ostr;
wobj = null;
ostr = null;
</script>
</html>