PageSourceSearch

https://ganbox.com/inc/common.js

js ganbox.com collected 2026-09-24 20:36:22 UTC 3,473 bytes, 139 lines download raw bytes

1/* trim() */
2function trim(stringToTrim) {
3	return stringToTrim.replace(/^\s+|\s+$/g,"");
4}
5
6function isdefined(id)
7{
8	obj = returnObjById(id);
9	if(null == obj) return false;
10    return (typeof(obj) == 'undefined') ? false : true;
11}
12
13function returnObjById( id ) {
14    if (document.getElementById)
15        var returnVar = document.getElementById(id);
16    else if (document.all)
17        var returnVar = document.all[id];
18    else if (document.layers)
19        var returnVar = document.layers[id];
20    return returnVar;
21}
22
23
24
25/* {{{ ############################# */
26var MSGTIMER = 20;
27var MSGSPEED = 5;
28var MSGOFFSET = 3;
29var MSGHIDE = 3;
30
31// build out the divs, set attributes and call the fade function //
32function inlineMsg(target,string,autohide) {
33  var msg;
34  var msgcontent;
35  if(!document.getElementById('msg')) {
36    msg = document.createElement('div');
37    msg.id = 'msg';
38    msgcontent = document.createElement('div');
39    msgcontent.id = 'msgcontent';
40    document.body.appendChild(msg);
41    msg.appendChild(msgcontent);
42    msg.style.filter = 'alpha(opacity=0)';
43    msg.style.opacity = 0;
44    msg.alpha = 0;
45  } else {
46    msg = document.getElementById('msg');
47    msgcontent = document.getElementById('msgcontent');
48  }
49  msgcontent.innerHTML = string;
50  msg.style.display = 'block';
51  var msgheight = msg.offsetHeight;
52  var targetdiv = document.getElementById(target);
53  targetdiv.focus();
54  var targetheight = targetdiv.offsetHeight;
55  var targetwidth = targetdiv.offsetWidth;
56  var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2);
57  var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET;
58  msg.style.top = topposition + 'px';
59  msg.style.left = leftposition + 'px';
60  clearInterval(msg.timer);
61  msg.timer = setInterval("fadeMsg(1)", MSGTIMER);
62  if(!autohide) {
63    autohide = MSGHIDE;  
64  }
65  window.setTimeout("hideMsg()", (autohide * 1000));
66}
67
68// hide the form alert //
69function hideMsg(msg) {
70  var msg = document.getElementById('msg');
71  if(!msg.timer) {
72    msg.timer = setInterval("fadeMsg(0)", MSGTIMER);
73  }
74}
75
76// face the message box //
77function fadeMsg(flag) {
78  if(flag == null) {
79    flag = 1;
80  }
81  var msg = document.getElementById('msg');
82  var value;
83  if(flag == 1) {
84    value = msg.alpha + MSGSPEED;
85  } else {
86    value = msg.alpha - MSGSPEED;
87  }
88  msg.alpha = value;
89  msg.style.opacity = (value / 100);
90  msg.style.filter = 'alpha(opacity=' + value + ')';
91  if(value >= 99) {
92    clearInterval(msg.timer);
93    msg.timer = null;
94  } else if(value <= 1) {
95    msg.style.display = "none";
96    clearInterval(msg.timer);
97  }
98}
99
100// calculate the position of the element in relation to the left of the browser //
101function leftPosition(target) {
102  var left = 0;
103  if(target.offsetParent) {
104    while(1) {
105      left += target.offsetLeft;
106      if(!target.offsetParent) {
107        break;
108      }
109      target = target.offsetParent;
110    }
111  } else if(target.x) {
112    left += target.x;
113  }
114  return left;
115}
116
117// calculate the position of the element in relation to the top of the browser window //
118function topPosition(target) {
119  var top = 0;
120  if(target.offsetParent) {
121    while(1) {
122      top += target.offsetTop;
123      if(!target.offsetParent) {
124        break;
125      }
126      target = target.offsetParent;
127    }
128  } else if(target.y) {
129    top += target.y;
130  }
131  return top;
132}
133
134// preload the arrow //
135if(document.images) {
136  arrow = new Image(7,80); 
137  arrow.src = "/img/msg_arrow.gif"; 
138}
139/* }}} */

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.