-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusersChoice.js
82 lines (72 loc) · 2.02 KB
/
usersChoice.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
var ca = new Array();
var coka;
var bgcolor="blue", fontColor="green", fontSize=15;
function setCookie(cname,bgcolor, fontColor, fontSize, exdays)
{
var d = new Date();
d.setTime(d.getTime()+(exdays*24*60*60*1000));
var expires = "expires="+d.toGMTString();
document.cookie = cname+"="+bgcolor+"-"+fontColor+"-"+fontSize+"-"+expires;
}
function getCookie(cname)
{
var name = cname + "=";
ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++)
{
var c = ca[i].trim();
if (c.indexOf(name)==0)
return c.substring(name.length,c.length);
}
return "";
}
function checkCookie()
{
var user=getCookie("username");
if (user != "")
{
coka = user.split('-');
bgcolor = coka[0];
fontColor = coka[1];
fontSize = coka[2];
$("#main").css({'background-color': "#"+bgcolor,
'color': "#" + fontColor,
'font-size': fontSize + "px"
});
}
else
{
setCookie("username",bgcolor, fontColor, fontSize,30);
}
}
//---------------------------------------------------
$(document).ready(function() {
checkCookie();
$("#picker").colpick({
layout:'rgbhex',
onSubmit:function(hsb,hex,rgb,el) {
$("#main").css('background-color', '#'+hex);
$(el).colpickHide();
bgcolor = hex;
setCookie("username",bgcolor, fontColor, fontSize,30);
}
});
$("#fontPicker").colpick({
layout:'rgbhex',
onSubmit:function(hsb,hex,rgb,el) {
$("#main").css('color', '#'+hex);
$(el).colpickHide();
fontColor = hex;
setCookie("username",bgcolor, fontColor, fontSize,30);
}
});
$("#userOptionID").submit(function(){
var letters = /^[0-9]+$/;
var x = $("input:text").val();
if (x.match(letters)) {
fontSize = x;
setCookie("username",bgcolor, fontColor, fontSize,30);
}
else alert("Enter number only!");
})
})