-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript1.js
More file actions
199 lines (195 loc) · 6.27 KB
/
script1.js
File metadata and controls
199 lines (195 loc) · 6.27 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
var cookies;
var changeFace = function (e){
console.log('success');
}
window.onload = function() {
setTextListener();
setCopyYear();
checkCookie();
setMedia();
this.transition = getCorrectProperty({
'transition':'transition',
'MozTransition':'MozTransition ',
'WebkitTransition':'WebkitTransition'
});
this.transitionend = getCorrectProperty({
'transition':'transitionend',
'OTransition':'otransitionend',
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd'
});
initSearch();
this.face = document.getElementById('face');
if(face == null) return;
if(window.innerWidth <= 400)
resizeFace();
document.getElementsByClassName('hdrsurround')[0].addEventListener('load', changeFace, false);
face.addEventListener('load', changeFace, false);
};
function setTextListener() {
this.txtChilds = [].slice.call(document.getElementById('textAdjustor').getElementsByTagName('A'));
for(i = 0; i < txtChilds.length; i++){
if(txtChilds[i].tagName == 'A'){
txtChilds[i].addEventListener('click', process, false);
}
}
}
function setCopyYear(){
document.getElementById('year').innerHTML=(new Date()).getFullYear();
}
function checkCookie(){
var theSize = getCookie("textSize");
if(theSize != "")
changeText(parseInt(theSize));
}
function setMedia(){
var scNode = document.getElementById('social').childNodes;
this.socialimgCache=[];
for(i = 0; i < scNode.length; i++){
if(scNode[i].tagName=='A'){
scNode[i].addEventListener('mouseenter', toggleColor, false);
scNode[i].addEventListener('touchend', toggleColor, false);
scNode[i].addEventListener('mouseleave', toggleColor, false);
var colorImg = scNode[i].childNodes[0];
var bwImg = new Image();
bwImg.src=colorImg.src.substring(0,colorImg.src.indexOf('.png'))+'_bw.png';
socialimgCache.push(bwImg.src);
socialimgCache.push(colorImg.src);
}
}
}
function initSearch() {
var myCallback = function() {
if (document.readyState == 'complete') {
// Document is ready when CSE element is initialized.
// Render an element with both search box and search results in div with id 'search-box'.
var a = google.search.cse.element.render(
{
div: "search-box",
tag: 'search'
});
var searchField = document.getElementById('gsc-i-id1');
searchField.placeholder = "Search";
searchField.style.cssText = searchField.style.cssText+"margin:7px;";
initMobile();
} else {
// Document is not ready yet, when CSE element is initialized.
google.setOnLoadCallback(function() {
// Render an element with both search box and search results in div with id 'search-box'.
google.search.cse.element.render(
{
div: "search-box",
tag: 'search'
});
}, true);
}
};
// Insert it before the CSE code snippet so that cse.js can take the script
// parameters, like parsetags, callbacks.
window.__gcse = {
parsetags: 'explicit',
callback: myCallback
};
(function() {
var cx = '013941808584080770434:lxqyuqj2rxi'; // Insert your own Custom Search engine ID here
var gcse = document.createElement('script'); gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
})();
}
var toggleColor = function (e) {
e = e || window.event;
var target = e.target || e.srcElement;
if(target.tagName == 'A')
target = target.childNodes[0];
var subLoc = target.src.indexOf('_bw');
if(subLoc > -1){
target.src = socialimgCache[socialimgCache.indexOf(target.src)+1];
}
else{
target.src = socialimgCache[socialimgCache.indexOf(target.src)-1];
}
};
var process = function (e){
e = e || window.event;
var target = e.target || e.srcElement;
if(target.tagName == 'A'){
var toSize = txtChilds.indexOf(target);
}
else{
return;
}
changeText(toSize);
};
function changeText(size){
if(size == 1)
document.body.style.fontSize='';
else
document.body.style.cssText = "font-size:" + (100 + (size - 1) * 10) + "%";
setCookie("textSize", size, 1);
}
function setCookie(cname,cvalue,exdays){
var d = new Date();
d.setTime(d.getTime()+(exdays*24*60*60*1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname){
var name = cname + "=";
var 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 "";
}
window.onresize = function(){
if(face == null) return;
source = face.src;
var faceWidth = parseInt(source.substring(source.indexOf('width') + 6, source.indexOf('width') + 9));
if(window.innerWidth <= 400)
resizeFace();
else if(faceWidth != 377){
console.log(source);
newsource = source.substring(0, source.indexOf('width')) + "width=" + 377 + source.substring(source.indexOf('width') + 9, source.length);
face.src = newsource;
}
}
function resizeFace(){
source = face.src;
console.log(source);
newsource = source.substring(0, source.indexOf('width')) + "width=" + (window.innerWidth - 30) + source.substring(source.indexOf('width') + 9, source.length);
face.src = newsource;
}
/*Utility Functions*/
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
function getCorrectProperty (properties) {
var i,
undefined,
el = document.createElement('div');
for (i in properties) {
if (properties.hasOwnProperty(i) && el.style[i] !== undefined) {
return properties[i];
}
}
}
function swap(arr,i,j){
var temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}