-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
60 lines (49 loc) · 1.35 KB
/
app.js
File metadata and controls
60 lines (49 loc) · 1.35 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
//Core js file for style rules to apply
(function(app){
"use strict";
if(!app){
return false;
}
var sheet,
url = app.location.href,
cssRule = {};
cssRule = {
'selector' : '.navbar-inverse',
'rules' : 'background-color:#eee'
};
//Check if location.href has query sting
//console.log(url.split("?"));
if(url.split("?").length > 1){
var oData = ExtractQueryString();
cssRule.rules = 'background-color:#' + oData.color;
}
sheet = (function(){
var style = app.document.createElement("style");
//webkit hack
style.appendChild(app.document.createTextNode(""));
document.head.appendChild(style);
//style - only style tag
//style.sheet - returns a object of style tag
return style.sheet;
})();
function ExtractQueryString() {
var oResult = {};
var aQueryString = (location.search.substr(1)).split("&");
for (var i = 0; i < aQueryString.length; i++) {
var aTemp = aQueryString[i].split("=");
if (aTemp[1].length > 0) {
oResult[aTemp[0]] = unescape(aTemp[1]);
}
}
return oResult;
}
function addCSSRule(sheet, selector, rules, index) {
if("insertRule" in sheet) {
sheet.insertRule(selector + "{" + rules + "}", index);
}
else if("addRule" in sheet) {
sheet.addRule(selector, rules, index);
}
}
addCSSRule(sheet, cssRule.selector, cssRule.rules);
})(window);