2 Powered by C.S Wowd script
3 for correct work need write to cs_patch full patch to cs wowd site
4 var cs_patch = 'http://localhost/cswowd/';
5 WARNING this script include cs_powered.css style from C.S Wowd
7 var cs_patch
= 'http://localhost/cswowd/cswowd/';
8 var config
= new Object();
10 config
. width
= 0 // Tooltip width, 0 for auto
11 config
. OffsetX
= 40 // Horizontal offset of left-top corner from mousepointer
12 config
. OffsetY
= -30 // Vertical offset
13 config
. Sticky
= false // Move or not while shown
14 config
. Border
= true // Show border
15 config
. step
= 100 // Opacity step time
16 config
. timeUp
= 0 // Show opacity time
17 config
. timeDown
= 1500 // Hide opacity time
18 tt_aV
= new Array(); // Caches and enumerates config data for currently active tooltip
21 var tt_musX
= 0, tt_musY
= 0, tt_scrlX
= 0, tt_scrlY
= 0;
23 var tt_db
= document
.body
||
24 document
.documentElement
||
25 (document
.getElementsByTagName
? document
.getElementsByTagName("body")[0] : null);
27 var tt_u
= "undefined";
29 var tt_opaTimer
= new Number(0),
30 tt_mainDiv
= 0, // Main div
31 tt_subDiv
= 0, // Main sub div - for opacity
32 tt_status
= 0, // Status & 1 - tip shown/hide
33 tt_element
= 0, // onmouseover element for hide tooltip
34 tt_opacity
= 0, // Current sub div opacity
35 tt_Cache
= new Array(),
36 tt_ajaxObjects
= new Array(),
38 tt_loading_text
= '<div class=loading> </div>';
43 this.resetData = function() {
48 this.elementObj
= null;
49 this.requestFile
= file
;
50 this.responseStatus
= new Array(2);
53 this.resetFunctions = function() {
54 this.onLoading = function() { };
55 this.onLoaded = function() { };
56 this.onInteractive = function() { };
57 this.onCompletion = function() { };
58 this.onError = function() { };
59 this.onFail = function() { };
62 this.reset = function() {
63 this.resetFunctions();
67 this.createAJAX = function() {
69 this.xmlhttp
= new ActiveXObject("Msxml2.XMLHTTP");
72 this.xmlhttp
= new ActiveXObject("Microsoft.XMLHTTP");
79 if (typeof XMLHttpRequest
!= "undefined") {
80 this.xmlhttp
= new XMLHttpRequest();
87 this.runResponse = function() {
91 this.runAJAX = function(urlstring
) {
96 this.elementObj
= document
.getElementById(this.element
);
100 if (this.method
== "GET") {
101 this.xmlhttp
.open(this.method
, this.requestFile
, this.mode
);
103 this.xmlhttp
.open(this.method
, this.requestFile
, this.mode
);
105 this.xmlhttp
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
109 this.xmlhttp
.onreadystatechange = function() {
110 switch (self
.xmlhttp
.readyState
) {
118 self
.onInteractive();
121 self
.response
= self
.xmlhttp
.responseText
;
122 self
.responseXML
= self
.xmlhttp
.responseXML
;
123 self
.responseStatus
[0] = self
.xmlhttp
.status
;
124 self
.responseStatus
[1] = self
.xmlhttp
.statusText
;
130 if (self
.elementObj
) {
131 elemNodeName
= self
.elementObj
.nodeName
;
132 elemNodeName
.toLowerCase();
133 if (elemNodeName
== "input"
134 || elemNodeName
== "select"
135 || elemNodeName
== "option"
136 || elemNodeName
== "textarea") {
137 self
.elementObj
.value
= self
.response
;
139 self
.elementObj
.innerHTML
= self
.response
;
142 if (self
.responseStatus
[0] == "200") {
153 this.xmlhttp
.send(this.URLString
);
161 function ajax_AddContent(ajaxIndex
, url
)
163 var result
= tt_ajaxObjects
[ajaxIndex
].response
;
164 tt_Cache
[url
] = result
.replace('src=', 'src=' + cs_patch
);
165 tt_ajaxObjects
[ajaxIndex
] = false;
166 if (tt_currentTip
!= url
)
168 if ((tt_status
& 1) == 0)
170 tt_UpdateTip(tt_Cache
[url
]);
171 tt_SetOpa(tt_subDiv
.style
, tt_opacity
);
176 tt_currentTip
= arguments
[0];
177 if(tt_Cache
[tt_currentTip
])
179 arguments
[0] = tt_Cache
[tt_currentTip
];
184 arguments
[0] = tt_loading_text
;
186 var ajaxIndex
= tt_ajaxObjects
.length
;
187 var i
= tt_currentTip
;
188 tt_ajaxObjects
[ajaxIndex
] = new sack(cs_patch
+ 'ajax.php?tip=' + i
);
189 tt_ajaxObjects
[ajaxIndex
].mode
= true;
190 tt_ajaxObjects
[ajaxIndex
].onCompletion = function(){ ajax_AddContent(ajaxIndex
, i
); };
191 tt_ajaxObjects
[ajaxIndex
].onError = function(){ tt_UpdateTip('Unable to connect'); };
192 tt_ajaxObjects
[ajaxIndex
].runAJAX();
195 function tt_hrefTip(e
)
197 e
= window
.event
|| e
;
198 var ref
= e
.target
|| e
.srcElement
;
199 while (ref
.tagName
!='A')
201 if (ref
.parentNode
== null)
203 ref
= ref
.parentNode
;
207 function tt_enableHrefTip(element
)
209 var r
={'item':'i', 'spell':'s', 'enchant':'e'};
210 var c
= element
.getElementsByTagName("a");
211 for (var i
= 0; i
< c
.length
; i
++)
214 var reg
= a
.href
.match('(.+\\?)(.+?)=(\\d+)');
215 if (reg
&& a
.id
=="" && r
[reg
[2]])
217 a
.id
= r
[reg
[2]] + reg
[3];
218 tt_AddEvtFnc(a
, "mouseover", tt_hrefTip
, true);
230 tt_UpdateTip(arg
[0]);
234 function tt_opaStepUp(step
)
236 tt_opacity
+=(100*step
/tt_aV
[TIMEUP
]);
237 var time
= Math
.floor(tt_aV
[TIMEUP
]/step
);
238 if (tt_opacity
< 100)
239 tt_opaTimer
.Timer("tt_opaStepUp(" + step
+ ")", time
, true);
241 {tt_opaTimer
.EndTimer();tt_opacity
= 100;}
242 tt_SetOpa(tt_subDiv
.style
, tt_opacity
);
244 function tt_opaStepDown(step
)
246 tt_opacity
-=(100*step
/tt_aV
[TIMEDOWN
]);
247 var time
= Math
.floor(tt_aV
[TIMEDOWN
]/step
);
249 tt_opaTimer
.Timer("tt_opaStepDown(" + step
+ ")", time
, true);
251 {tt_opaTimer
.EndTimer();tt_finishHideTip();}
252 tt_SetOpa(tt_subDiv
.style
, tt_opacity
);
254 function tt_startShowTip()
256 tt_opaTimer
.EndTimer();
259 tt_RemEvtFnc(tt_element
, "mouseout", tt_Hide
);
264 tt_mainDiv
.style
.visibility
= "visible";
268 tt_opaStepUp(tt_aV
[STEP
]);
273 function tt_startHideTip()
275 tt_opaTimer
.EndTimer();
278 tt_opaStepDown(tt_aV
[STEP
]);
282 function tt_finishHideTip()
284 tt_mainDiv
.style
.visibility
= "hidden";
287 function tt_updatePosition()
289 var win_width
= tt_GetClientW();
290 var win_height
= tt_GetClientH();
291 var div_width
= tt_mainDiv
.offsetWidth
|| tt_mainDiv
.style
.pixelWidth
|| 0;
292 var div_height
= tt_mainDiv
.offsetHeight
|| tt_mainDiv
.style
.pixelHeight
|| 0;
293 var x
= tt_musX
- tt_scrlX
+ tt_aV
[OFFSETX
];
294 var y
= tt_musY
- tt_scrlY
+ tt_aV
[OFFSETY
];
295 if (x
+ div_width
>= win_width
) x
= win_width
- div_width
;
296 if (y
+ div_height
>= win_height
) y
= win_height
- div_height
;
298 var inX_ByX
= (tt_musX
- tt_scrlX
> x
&& tt_musX
- tt_scrlX
< x
+ div_width
);
299 var inY_ByY
= (tt_musY
- tt_scrlY
> y
&& tt_musY
- tt_scrlY
< y
+ div_height
);
300 if (inX_ByX
&& inY_ByY
)
303 x
= tt_musX
- tt_scrlX
- div_width
- 10;
305 y
= tt_musY
- tt_scrlY
- div_height
- 10;
310 var css
= tt_mainDiv
.style
;
311 css
.left
= (x
+ tt_scrlX
)+'px';
312 css
.top
= (y
+ tt_scrlY
)+'px';
314 function tt_UpdateTip(text
)
316 var width
= tt_aV
[WIDTH
]==0 ? '' : (' style="width:' + tt_aV
[WIDTH
] + 'px;"');
318 tt_mainDiv
.innerHTML
= ''
319 + '<div id=tt_tooltip>'
320 + '<table class=tooltip cellSpacing=0 cellPadding=0><tbody>'
321 + '<tr><td class=tiptopl></td><td class=tiptop></td><td class=tiptopr></td></tr>'
322 + '<tr><td class=tipl> </td><td class=tipbody' + width
+ '>'
324 + '</td><td class=tipr> </td></tr>'
325 + '<tr><td class=tipbottoml></td><td class=tipbottom></td><td class=tipbottomr></td></tr>'
326 + '</tbody></table></div>';
328 tt_mainDiv
.innerHTML
= ''
329 + '<div id=tt_tooltip ' + width
+ '>'
332 tt_subDiv
= document
.getElementById('tt_tooltip');
334 function tt_GetClientW()
336 return(document
.body
&& (typeof(document
.body
.clientWidth
) != tt_u
) ? document
.body
.clientWidth
337 : (typeof(window
.innerWidth
) != tt_u
) ? window
.innerWidth
338 : tt_db
? (tt_db
.clientWidth
|| 0)
341 function tt_GetClientH()
343 return(document
.body
&& (typeof(document
.body
.clientHeight
) != tt_u
) ? document
.body
.clientHeight
344 : (typeof(window
.innerHeight
) != tt_u
) ? window
.innerHeight
345 : tt_db
? (tt_db
.clientHeight
|| 0)
350 e
= window
.event
|| e
;
353 var target
= e
.target
|| e
.srcElement
;
354 if (tt_element
== target
)
356 tt_RemEvtFnc(tt_element
, "mouseout", tt_Hide
);
362 function tt_Scroll(e
)
364 e
= window
.event
|| e
;
367 tt_scrlX
= window
.pageXOffset
|| (tt_db
? (tt_db
.scrollLeft
|| 0) : 0);
368 tt_scrlY
= window
.pageYOffset
|| (tt_db
? (tt_db
.scrollTop
|| 0) : 0);
375 e
= window
.event
|| e
;
378 tt_musX
= (typeof(e
.pageX
) != tt_u
) ? e
.pageX
: (e
.clientX
+ tt_scrlX
);
379 tt_musY
= (typeof(e
.pageY
) != tt_u
) ? e
.pageY
: (e
.clientY
+ tt_scrlY
);
380 if (tt_element
== 0 && tt_status
& 1)
382 tt_element
= e
.target
|| e
.srcElement
;
383 tt_AddEvtFnc(tt_element
, "mouseout", tt_Hide
);
385 if (!tt_aV
[STICKY
] && tt_status
&1)
391 // Create the tooltip DIV
392 if(tt_db
.insertAdjacentHTML
)
393 tt_db
.insertAdjacentHTML("afterBegin", tt_MkMainDivHtm());
394 else if(typeof tt_db
.innerHTML
!= tt_u
&& document
.createElement
&& tt_db
.appendChild
)
395 tt_db
.appendChild(tt_MkMainDivDom());
396 tt_mainDiv
= document
.getElementById('tt_mytooltip');
397 tt_mainDiv
.style
.position
= "absolute";
398 tt_mainDiv
.style
.zIndex
= 1000;
400 tt_AddEvtFnc(window
, "scroll", tt_Scroll
);
401 tt_AddEvtFnc(document
, "mousemove", tt_Move
);
402 tt_AddEvtFnc(window
, "unload", tt_finishHideTip
);
404 tt_addLoadEvent(function() {tt_enableHrefTip(document
);});
405 document
.write('<LINK rel="stylesheet" href="' + cs_patch
+ 'cs_powered.css" type="text/css" />');
407 function tt_MkMainDivHtm()
409 return('<div id=tt_mytooltip></div>');
411 function tt_MkMainDivDom()
413 var el
= document
.createElement("div");
415 el
.id
= "tt_mytooltip";
418 function tt_addLoadEvent(func
)
420 var oldonload
= window
.onload
;
421 if (typeof window
.onload
!= 'function')
422 window
.onload
= func
;
424 window
.onload = function(){oldonload();func();}
426 function tt_AddEvtFnc(el
, sEvt
, PFnc
)
430 if(el
.addEventListener
)
431 el
.addEventListener(sEvt
, PFnc
, false);
433 el
.attachEvent("on" + sEvt
, PFnc
);
436 function tt_RemEvtFnc(el
, sEvt
, PFnc
)
440 if(el
.removeEventListener
)
441 el
.removeEventListener(sEvt
, PFnc
, false);
443 el
.detachEvent("on" + sEvt
, PFnc
);
447 function tt_getOpaSettings()
450 var s
= document
.body
.style
;
451 if (typeof s
.opacity
== 'string') p
= 'opacity';
452 else if (typeof s
.MozOpacity
== 'string') p
= 'MozOpacity';
453 else if (typeof s
.KhtmlOpacity
== 'string') p
= 'KhtmlOpacity';
454 else if (document
.body
.filters
&& navigator
.appVersion
.match(/MSIE ([\d.]+);/)[1]>=5.5) p
='filter';
457 function tt_SetOpa(oElem
, nOpacity
)
459 var p
= tt_getOpaSettings();
461 tt_SetOpa
= new Function('oElem', 'nOpacity', 'if (nOpacity >= 100) {oElem.style.filter = ""; return;} var oAlpha = oElem.filters["DXImageTransform.Microsoft.alpha"] || oElem.filters.alpha; if (oAlpha) oAlpha.opacity = nOpacity;else {oElem.style.zoom = 1;oElem.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";}');
463 tt_SetOpa
= new Function('oElem', 'nOpacity', 'oElem.style.'+p
+' = nOpacity/100;');
465 tt_SetOpa
= new Function(oElem
, nOpacity
);
466 return tt_SetOpa(oElem
, nOpacity
);
468 Number
.prototype.Timer = function(s
, iT
, bUrge
)
470 if(!this.value
|| bUrge
)
471 this.value
= window
.setTimeout(s
, iT
);
473 Number
.prototype.EndTimer = function()
477 window
.clearTimeout(this.value
);
481 // Creates command names by translating config variable names to upper case
482 function tt_MkCmdEnum()
486 eval("window." + i
.toString().toUpperCase() + " = " + n
++);
488 function tt_ReadCmds(a
)
491 // First load the global config values, to initialize also values
492 // for which no command has been passed
495 tt_aV
[i
++] = config
[j
];
496 // Then replace each cached config value for which a command has been
497 // passed (ensure the # of command args plus value args be even)
500 for(i
= a
.length
- 1; i
> 0; i
-= 2)
501 tt_aV
[a
[i
- 1]] = a
[i
];