-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.html
More file actions
175 lines (172 loc) · 12.8 KB
/
config.html
File metadata and controls
175 lines (172 loc) · 12.8 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?xml version="1.0" encoding="utf-8"?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="user-scalable=yes,width=device-width">
<title>Slanted Lock Setup</title>
<script type="text/javascript">
var systemDB;
function init() {
var myDB = openDatabase("SlantedLockCache", '1.0', "Slanted Lock Cache", 64 * 1024);
systemDB = myDB;
initDB();
getConfig()
}
function nullDataHandler(transaction, results) {}
function initDB() {
var db = systemDB;
/*
The first time the application is run, it will CREATE the table and
INSERT a single row in it. On subsequent runs, the CREATE statement
fails because the table exists already, so the following INSERT
statement is never attempted.
*/
db.transaction(function (transaction) {
transaction.executeSql('CREATE TABLE slcache (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, location TEXT NOT NULL, temp TEXT NOT NULL, desc TEXT NOT NULL, icon TEXT NOT NULL, updatetime INTEGER NOT NULL, source TEXT NOT NULL, woeid TEXT NOT NULL, zipcode TEXT NOT NULL, useRealFeel INTEGER NOT NULL, useCelcius INTEGER NOT NULL, use24hours INTEGER NOT NULL, stylesheet TEXT NOT NULL, iconset TEXT NOT NULL, updateInterval INTEGER NOT NULL DEFAULT 30, bkgset TEXT NOT NULL);', [], nullDataHandler);
transaction.executeSql('INSERT INTO slcache (name, location, temp, desc, icon, updatetime, source, woeid, zipcode, useRealFeel, useCelcius, use24hours, stylesheet, iconset, updateInterval, bkgset) VALUES ("slcache", "noCache", "?°F", "noCache", "images/tick/dunno.png", 0, "yahooWeather", "2408784", "92843", 1, 0, 0, "SlantedLock", "tick", 30, "slbkg24hr");', [], nullDataHandler)
})
}
function configHandler(transaction, results) {
for (var i = 0; i < results.rows.length; i++) {
var cached = results.rows.item(i);
var fcontent = "";
if (cached.source == "none") {
fcontent += '<p>Weather Source:<br/><input type="radio" name="source" value="none" checked /> None <input type="radio" name="source" value="yahooWeather" /> YahooWeather <input type="radio" name="source" value="accuWeather"/> AccuWeather</p>'
} else if (cached.source == "yahooWeather") {
fcontent += '<p>Weather Source:<br/><input type="radio" name="source" value="none" /> None <input type="radio" name="source" value="yahooWeather" checked /> YahooWeather <input type="radio" name="source" value="accuWeather"/> AccuWeather</p>'
} else {
fcontent += '<p>Weather Source:<br/><input type="radio" name="source" value="none" /> None <input type="radio" name="source" value="yahooWeather" /> YahooWeather <input type="radio" name="source" value="accuWeather" checked /> AccuWeather</p>'
}
fcontent += '<p>YahooWeather WOEID: <input id="woeid" type="text" name="woeid" value="' + cached.woeid + '"/></p>';
fcontent += '<p>AccuWeather Zip Code: <input id="zip" type="text" name="zipcode" value="' + cached.zipcode + '"/></p>';
fcontent += (cached.useRealFeel == 1) ? '<p>AccuWeather use Real Feel:<br/><input type="radio" name="realfeel" value="1" checked /> Yes <input type="radio" name="realfeel" value="0"/> No</p>' : '<p>AccuWeather use Real Feel:<br/><input type="radio" name="realfeel" value="1"/> Yes <input type="radio" name="realfeel" value="0" checked /> No</p>';
fcontent += (cached.useCelcius == 0) ? '<p>Temperature Scale:<br/><input type="radio" name="tempscale" value="0" checked /> °F <input type="radio" name="tempscale" value="1"/> °C</p>' : '<p>Temperature Scale:<br/><input type="radio" name="tempscale" value="0"/> °F <input type="radio" name="tempscale" value="1" checked /> °C</p>';
fcontent += (cached.use24hours == 0) ? '<p>Time Display:<br/><input type="radio" name="timedisplay" value="0" checked /> 12 hr <input type="radio" name="timedisplay" value="1"/> 24 hr</p>' : '<p>Time Display:<br/><input type="radio" name="timedisplay" value="0"/> 12 hr <input type="radio" name="timedisplay" value="1" checked /> 24 hr</p>';
if (cached.iconset == "HTC") {
fcontent += '<p>Icon Set:<br/><input type="radio" name="icon" value="HTC" checked /> HTC <input type="radio" name="icon" value="tick"/> Tick <input type="radio" name="icon" value="klear"/> Klear <input type="radio" name="icon" value="custom"/> <input type="text" name="iconset_custom_name" style="width:90px;" value="" /></p>'
} else if (cached.iconset == "tick") {
fcontent += '<p>Icon Set:<br/><input type="radio" name="icon" value="HTC"/> HTC <input type="radio" name="icon" value="tick" checked /> Tick <input type="radio" name="icon" value="klear"/> Klear <input type="radio" name="icon" value="custom"/> <input type="text" name="iconset_custom_name" style="width:90px;" value="" /></p>'
} else if (cached.iconset == "klear") {
fcontent += '<p>Icon Set:<br/><input type="radio" name="icon" value="HTC"/> HTC <input type="radio" name="icon" value="tick"/> Tick <input type="radio" name="icon" value="klear" checked /> Klear <input type="radio" name="icon" value="custom"/> <input type="text" name="iconset_custom_name" style="width:90px;" value="" /></p>'
} else {
fcontent += '<p>Icon Set:<br/><input type="radio" name="icon" value="HTC"/> HTC <input type="radio" name="icon" value="tick"/> Tick <input type="radio" name="icon" value="klear"/> Klear <input type="radio" name="icon" value="custom" checked /> <input type="text" name="iconset_custom_name" style="width:90px;" value="' + cached.iconset + '" /></p>'
}
if (cached.updateInterval == 15) {
fcontent += '<p>Update Interval (minutes):<br/><input type="radio" name="updateint" value="15" checked /> 15 <input type="radio" name="updateint" value="20"/> 20 <input type="radio" name="updateint" value="25"/> 25 <input type="radio" name="updateint" value="30"/> 30 <input type="radio" name="updateint" value="custom"/> <input type="text" name="update_custom_val" value="" style="width:50px;"/></p>'
} else if (cached.updateInterval == 20) {
fcontent += '<p>Update Interval (minutes):<br/><input type="radio" name="updateint" value="15"/> 15 <input type="radio" name="updateint" value="20" checked /> 20 <input type="radio" name="updateint" value="25"/> 25 <input type="radio" name="updateint" value="30"/> 30 <input type="radio" name="updateint" value="custom"/> <input type="text" name="update_custom_val" value="" style="width:50px;"/></p>'
} else if (cached.updateInterval == 25) {
fcontent += '<p>Update Interval (minutes):<br/><input type="radio" name="updateint" value="15"/> 15 <input type="radio" name="updateint" value="20"/> 20 <input type="radio" name="updateint" value="25" checked /> 25 <input type="radio" name="updateint" value="30"/> 30 <input type="radio" name="updateint" value="custom"/> <input type="text" name="update_custom_val" value="" style="width:50px;"/></p>'
} else if (cached.updateInterval == 30) {
fcontent += '<p>Update Interval (minutes):<br/><input type="radio" name="updateint" value="15"/> 15 <input type="radio" name="updateint" value="20"/> 20 <input type="radio" name="updateint" value="25"/> 25 <input type="radio" name="updateint" value="30" checked /> 30 <input type="radio" name="updateint" value="custom"/> <input type="text" name="update_custom_val" value="" style="width:50px;"/></p>'
} else {
fcontent += '<p>Update Interval (minutes):<br/><input type="radio" name="updateint" value="15"/> 15 <input type="radio" name="updateint" value="20"/> 20 <input type="radio" name="updateint" value="25"/> 25 <input type="radio" name="updateint" value="30"/> 30 <input type="radio" name="updateint" value="custom" checked /> <input type="text" name="update_custom_val" value="' + cached.updateInterval + '" style="width:50px;"/></p>'
}
if (cached.bkgset == "default") {
fcontent += '<p>Wallpaper Set:<br/><input type="radio" name="bkgset" value="default" checked /> Default <input type="radio" name="bkgset" value="slbkg24hr" /> 24hr <input type="radio" name="bkgset" value="custom"/> <input type="text" name="custom_bkg" value="" style="width:100px;"/></p>'
} else if (cached.bkgset == "slbkg24hr") {
fcontent += '<p>Wallpaper Set:<br/><input type="radio" name="bkgset" value="default" /> Default <input type="radio" name="bkgset" value="slbkg24hr" checked /> 24hr <input type="radio" name="bkgset" value="custom"/> <input type="text" name="custom_bkg" value="" style="width:100px;"/></p>'
} else {
fcontent += '<p>Wallpaper Set:<br/><input type="radio" name="bkgset" value="default" /> Default <input type="radio" name="bkgset" value="slbkg24hr" /> 24hr <input type="radio" name="bkgset" value="custom" checked /> <input type="text" name="custom_bkg" value="' + cached.bkgset + '" style="width:100px;"/></p>'
}
fcontent += '<p>Style Sheet: <input id="stylesheet" type="text" name="stylesheet" value="' + cached.stylesheet + '"/></p>';
document.getElementById("formcontent").innerHTML = fcontent
}
}
function getConfig() {
var db = systemDB;
db.transaction(function (transaction) {
transaction.executeSql("SELECT source, woeid, zipcode, useRealFeel, useCelcius, use24hours, stylesheet, iconset, updateInterval, bkgset FROM slcache WHERE name='slcache';", [], configHandler)
})
}
function setConfig(formObj) {
var db = systemDB;
var error = false;
source = getRadioValue(formObj, "source");
woeid = formObj.elements["woeid"].value;
zip = formObj.elements["zipcode"].value;
realfeel = parseInt(getRadioValue(formObj, "realfeel"), 10);
usecelcius = parseInt(getRadioValue(formObj, "tempscale"), 10);
use24hr = parseInt(getRadioValue(formObj, "timedisplay"), 10);
iconset = getRadioValue(formObj, "icon");
if (iconset == "custom") {
iconset = formObj.elements["iconset_custom_name"].value;
if (iconset == "") {
error = true;
errmsg = "You didn't specify custom icon set name."
}
}
updateint = getRadioValue(formObj, "updateint");
if (updateint == "custom") {
updateint = parseInt(formObj.elements["update_custom_val"].value, 10);
if (!isNumeric(formObj.elements["update_custom_val"].value) || updateint <= 0 || updateint >= 10080) {
error = true;
errmsg = "You didn't specify a valid time interval in minutes"
}
} else {
updateint = parseInt(updateint, 10)
}
bkgset = getRadioValue(formObj, "bkgset");
if (bkgset == "custom") {
bkgset = formObj.elements["custom_bkg"].value;
if (bkgset == "") {
error = true;
errmsg = "You didn't specify custom wallpaper set name."
}
}
style = formObj.elements["stylesheet"].value;
if (source == "yahooWeather" && woeid == "") {
error = true;
errmsg = "You didn't set WOEID for yahooWeather."
} else if (source == "accuWeather" && zip == "") {
error = true;
errmsg = "You didn't set Zipcode for accuWeather."
}
if (style == "") {
style = "SlantedLock";
alert("You didn't specify a stylesheet. Using default.")
}
if (error == true) {
alert(errmsg)
} else {
db.transaction(function (transaction) {
transaction.executeSql("UPDATE slcache set updatetime=?, source=?, woeid=?, zipcode=?, useRealFeel=?, useCelcius=?, use24hours=?, iconset=?, updateInterval=?, stylesheet=?, bkgset=? WHERE name=?;", [0, source, woeid, zip, realfeel, usecelcius, use24hr, iconset, updateint, style, bkgset, "slcache"])
});
alert("Settings saved!")
}
return false
}
function isNumeric(strString) {
var strValidChars = "0123456789";
var strChar;
var blnResult = true;
if (strString.length == 0) return false;
for (i = 0; i < strString.length; i++) {
strChar = strString.charAt(i);
if (strValidChars.indexOf(strChar) == -1) {
blnResult = false;
break
}
}
return blnResult
}
function getRadioValue(formObj, radio_name) {
var oRadio = formObj.elements[radio_name];
for (var i = 0; i < oRadio.length; i++) {
if (oRadio[i].checked) {
return oRadio[i].value
}
}
return ''
}
</script>
</head>
<body onload="init()">
<h1>Slanted Lock Configurations</h1>
<p>v1.5.4</p>
<form id="configform" name="configform" action="config.html" method="post" onsubmit="return setConfig(document.configform);">
<div id="formcontent"></div>
<p><input type="submit" value="Set Config" style="width:100px; height:50px;"/></p>
</form>
</body>
</html>