-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
105 lines (84 loc) · 2.39 KB
/
script.js
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
var version = "1.1.2"
document.getElementById("versionnum").innerHTML = version;
//WIP block stuff
/* var WIPshade = document.getElementById("WIPshade");
var WIPbox = document.getElementById("WIPbox");
function WIPBlock(){
if(!localStorage.getItem("isDev")){
WIPshade.style.display = "block";
WIPbox.style.display = "block";
var WIPCSSTransitionTimeout = setTimeout(function(){
WIPshade.className = "WIPactive";
WIPbox.className = "WIPactive";
},40);
}
}
WIPBlock(); */
function ButImDevPlzLetMeIn(){
localStorage.setItem("isDev",true);
location.reload();
}
//Converter
var galacticMilliseconds = 0;
var GMSBox = document.getElementById("gms");
var ACBox = document.getElementById("ac");
var TDBox = document.getElementById("td");
var NTEBox = document.getElementById("nte");
function updateConverter(changedBox){
if(changedBox == "gms"){
galacticMilliseconds = Number(GMSBox.value);
}else if(changedBox == "ac"){
galacticMilliseconds = ACtoGMS();
}else if(changedBox == "td"){
galacticMilliseconds = TDtoGMS();
}else if(changedBox == "nte"){
galacticMilliseconds = NTEtoGMS();
}
GMSBox.value = galacticMilliseconds;
ACBox.value = GMStoAC();
TDBox.value = GMStoTD();
NTEBox.value = GMStoNTE();
}
ACMULT = 32429057361;
ACOFFSET = -311868729306411;
function ACtoGMS(){
var ACnum = Number(ACBox.value);
return (ACnum*ACMULT)-ACOFFSET;
}
function GMStoAC(){
return Math.floor((galacticMilliseconds+ACOFFSET)/ACMULT);
}
TDMULT = 37936153824;
TDOFFSET = -239649299691738;
function TDtoGMS(){
var TDnum = Number(TDBox.value);
return (TDnum*TDMULT)-TDOFFSET;
}
function GMStoTD(){
return Math.floor((galacticMilliseconds+TDOFFSET)/TDMULT);
}
NTEOFFSET = TDOFFSET - (TDMULT*3842);
function NTEtoGMS(){
var NTEnum = Number(NTEBox.value);
return (NTEnum*TDMULT)-NTEOFFSET;
}
function GMStoNTE(){
return Math.floor((galacticMilliseconds+NTEOFFSET)/TDMULT);
}
updateConverter();
//linking to conversions
function getQueryVariable(variable){ //this function is someone elses code (why reinvent the wheel)
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){
return pair[1];
}
}
return(false);
}
if(getQueryVariable("datetype")){
document.getElementById(getQueryVariable("datetype")).value = getQueryVariable("datevalue");
updateConverter(getQueryVariable("datetype"));
}