Косметика интерфейса.)
[cswowd.git] / skin / wrath / js / wrath.js
blob29780e88d94dc52d81eda67dbe927038f51c1565
1 /*
2 * Left menu create and options
3 */
4 dd_options['leftmenu'] = {
5 min:'1',
6 arrow:'skin_pop_arrow',
7 arrowtext:'',
8 row:'skin_pop_row',
9 selrow:'skin_pop_mrow',
10 defpos:{m:'tr', x:-15, y:0}
13 dd_options['langmenu'] = {
14 min:'0',
15 arrow:'skin_pop_arrow',
16 arrowtext:'',
17 row:'skin_pop_row',
18 selrow:'skin_pop_mrow',
19 defpos:{m:'tr', x:0, y:0},
20 mpos1:{m:'bl', x:0, y:0}
23 var langmenu = [{
24 sub:[
25 {link:'?lang=ru',text:'Русский'},
26 {link:'?lang=en',text:'English'}
28 }];
30 dd_options['skinmenu'] = {min:'0',arrow:'skin_pop_arrow',arrowtext:'',row:'skin_pop_row',selrow:'skin_pop_mrow',defpos:{m:'tr', x:0, y:0},mpos1:{m:'bl', x:0, y:0}};
31 var skinmenu = [{
32 sub:[
33 {link:'?skin=default',text:'Default'},
34 {link:'?skin=modern',text:'Modern'},
35 {link:'?skin=lofk_skin',text:'Lofk'},
36 {link:'?skin=dark',text:'Dark'}
38 }];
39 //=========================
40 function generateLeftMenu()
42 prepareCookies();
43 var menu = leftmenu;
44 var l = menu.length;
45 for (var i = 0; i < l; i++)
46 document.write(generateLeftSub(menu[i], i));
48 function generateLeftSub(menu, id)
50 var show = menuCookie[id] == 0 ? false : true;
51 var text = ''
52 + '<div class=' + (show ? 'skin_lm_sub_on':'skin_lm_sub_off') + ' onClick = "toggleMenu(this, ' + id + ')">'
53 + '<div class="skin_lm_ico" style="background: url(skin/wrath/img/menu/' + menu.ico + '-on.gif) no-repeat;"></div>'
54 + '<div class="skin_lm_name">'
55 + '<div style="position: absolute; left:-1px; top: -1px; color: black;">' + menu.name + '</div>'
56 + '<div style="position: absolute; left:-1px; top: 1px; color: black;">' + menu.name + '</div>'
57 + '<div style="position: absolute; left: 1px; top: -1px; color: black;">' + menu.name + '</div>'
58 + '<div style="position: absolute; left: 1px; top: 1px; color: black;">' + menu.name + '</div>'
59 + '<div style="position: absolute; left: 0px; top: 0px;">' + menu.name + '</div>'
60 + '</div>'
61 + '<div class="skin_lm_add"></div>'
62 + '</div>\n'
63 + '<div class=skin_lm_sub_top id=left_sub_'+ id + (show ? '' : ' style="display: none;"') + '>'
64 + '<div class=skin_lm_sub_body>'
65 + '<div class=skin_lm_sub_left>'
66 + '<div class=skin_lm_sub_right>'
67 + getSubMenuText(menu.sub, 'leftmenu_' + id)
68 + '</div>'
69 + '</div>'
70 + '</div>'
71 + '<div class=skin_lm_sub_bottom></div>'
72 + '</div>\n';
73 return text;
76 function changeSearch(element)
78 var a = {'site':'all', 'item':'i', 'itemset':'set', 'quest':'q', 'spell':'s', 'npc':'n', 'object':'g', 'faction':'f', 'player':'p', 'area':'a'}
79 var s = document.getElementById('topsearch');
80 var s1 = document.getElementById('_topsearch');
81 var v = a[element.value];
82 s.alt = v;
83 s1.value = v;
85 function searchClick(link)
87 var s = document.getElementById('topsearch');
88 var s1 = document.getElementById('_topsearch');
89 link.href = "?s=" + s1.value + "&name=" + s.value;
92 function toggleMenu(menu, id)
94 v = document.getElementById('left_sub_' + id);
95 if (v.style.display == "none")
97 menu.className = 'skin_lm_sub_on';
98 v.style.display = "block";
99 menuCookie[id] = 1;
101 else
103 menu.className = 'skin_lm_sub_off';
104 v.style.display = "none";
105 menuCookie[id] = 0;
107 setcookie('menuCookie', menuCookie.join(' '));
108 // disable select
109 if (typeof menu.onselectstart!="undefined") //IE route
110 menu.onselectstart=function(){return false}
111 else if (typeof menu.style.MozUserSelect!="undefined") //Firefox route
112 menu.style.MozUserSelect="none"
113 else //All other route (ie: Opera)
114 menu.onmousedown=function(){return false}
117 // Cookies
118 var menuCookie;
119 function getexpirydate(nodays){
120 var UTCstring;
121 Today = new Date();
122 nomilli=Date.parse(Today);
123 Today.setTime(nomilli+nodays*24*60*60*1000);
124 UTCstring = Today.toUTCString();
125 return UTCstring;
127 function getcookie(cookiename) {
128 var cookiestring=""+document.cookie;
129 var index1=cookiestring.indexOf(cookiename);
130 if (index1==-1 || cookiename=="") return "";
131 var index2=cookiestring.indexOf(';',index1);
132 if (index2==-1) index2=cookiestring.length;
133 return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
135 function setcookie(name,value){
136 cookiestring=name+"="+escape(value)+";EXPIRES="+ getexpirydate(365)+";PATH=/";
137 document.cookie=cookiestring;
139 function prepareCookies()
141 var tempString = getcookie("menuCookie");
142 if(!tempString)
144 tempString = '';
145 var l = leftmenu.length;
146 for (var i = 0; i < l; i++)
147 tempString+=(leftmenu[i].show ? 1 : 0) + ' ';
148 setcookie('menuCookie', tempString);
150 menuCookie = tempString.split(" ");