-
Notifications
You must be signed in to change notification settings - Fork 0
/
love-2.js
66 lines (65 loc) · 2.18 KB
/
love-2.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
function gObj(B){
var A;if(document.all){
if(typeof B=="string"){return document.all(B)}
else{ return B.style}
}
if(document.getElementById){
if(typeof B=="string"){return document.getElementById(B)}
else{return B.style}
}
return null
}
function showquickmsg(B,A){
if(A){B="<div class='error'>"+B+"</div>"}
gObj("coutput").innerHTML=B
}
function trimAll(A){
while(A.substring(0,1)==" "){A=A.substring(1,A.length)}
while(A.substring(A.length-1,A.length)==" "){A=A.substring(0,A.length-1)}
return A
}
function getNum(A){
outputNum=0;
for(i=0;i<A.length;i++){outputNum+=A.charCodeAt(i)}
return outputNum
}
function calc(){
cnameone=trimAll(gObj("cnameone").value);
cnametwo=trimAll(gObj("cnametwo").value);
if(cnameone.length<1){showquickmsg("<p>Please complete all required fields</p>",true);return }
else{
if(cnametwo.length<1){showquickmsg("<p>Please complete all required fields</p>",true);return }
}
cnameone=cnameone.toLowerCase();
cnametwo=cnametwo.toLowerCase();
totalNum=getNum(cnameone)*getNum(cnametwo);
finalScore=totalNum%100;
var newVal = finalScore * 1.8 - 45;
$('.circle-inner, .gauge-copy').css({
'transform' : 'rotate(' + newVal + 'deg)'
});
$('.gauge-copy').css({
'transform' : 'translate(-50%, -50%) rotate(' + finalScore * 1.8 + 'deg)'
});
$('.percentage').text(finalScore + ' %');
document.getElementById("resulta").value = finalScore;
};
window.smoothScroll = function(target) {
var scrollContainer = target;
do {
scrollContainer = scrollContainer.parentNode;
if (!scrollContainer) return;
scrollContainer.scrollTop += 1;
} while (scrollContainer.scrollTop == 0);
var targetY = 0;
do {
if (target == scrollContainer) break;
targetY += target.offsetTop;
} while (target = target.offsetParent);
scroll = function(c, a, b, i) {
i++; if (i > 30) return;
c.scrollTop = a + (b - a) / 30 * i;
setTimeout(function(){ scroll(c, a, b, i); }, 20);
}
scroll(scrollContainer, scrollContainer.scrollTop, targetY, 0);
}