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 51 52 53 54 55 56 57 58 59 60 61 62 63
|
define(function() { var syshift = {}; var temp = -100000; var chars = '0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ';
syshift.sys10to62 = function(num) { var charsSrr = chars.split(''); var radix = chars.length; var qutient = +num; var arr = []; do { mod = qutient % radix; qutient = (qutient - mod) / radix; arr.unshift(chars[mod]); } while (qutient); return arr.join(''); };
syshift.sys62to10 = function(numberCode) { var radix = chars.length; var numberCode = String(numberCode); var len = numberCode.length; var i = 0; var originNumber = 0; while (i < len) { originNumber += Math.pow(radix, i++) * chars.indexOf(numberCode.charAt(len - i) || 0); } return originNumber; };
syshift.getIdFromDate = function() { var theDate = parseInt(new Date().getTime(), 10); if (theDate === temp) { theDate++; } else { temp = theDate; } return this.sys10to62(theDate); };
return syshift; });
|