~ubuntu-branches/ubuntu/natty/ntop/natty

« back to all changes in this revision

Viewing changes to html/autosuggest.js

  • Committer: Bazaar Package Importer
  • Author(s): Ludovico Cavedon, Jordan Metzmeier, Ludovico Cavedon
  • Date: 2010-12-15 20:06:19 UTC
  • mfrom: (5.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20101215200619-0ojz3iak95ihibun
Tags: 3:4.0.3+dfsg1-1
[ Jordan Metzmeier ]
* New upstream release (Closes: #522042)
* Move data files to /usr/share/ntop (Closes: #595450).
* Package architecture independent data in a separate ntop-data package.
* Use debhelper 7.
* Update Standards-Version to 3.9.1.
* Depend on python-mako.
* Do not include ntop.txt in binary packages as it is a copy of the man
  page.
* Do not include NEWS, as it is outdated.
* Switch to package source version 3.0 (quilt).
* Add password creation to debconf
* Changed init script to fix localization problems (thanks to Alejandro
  Varas <alej0varas@gmail.com>, LP: #257466)
* Remove manual update-rc.d calls from postrm and postinst. debhelper adds
  this for us.
* Add pre-depends on adduser for postinst script.
* Fix errors in the manpages: fix-manpage-errors.patch.
* Added fixes for matching active interfaces.
* Added a watch file.

[ Ludovico Cavedon ]
* Remove direct changes to upstream tree, and move them into specific patch
  files:
  - fix-manpage-errors.patch: fix typos in ntop.8.
  - dot-path.patch: fix path of /usr/bin/dot executable
* Add patches:
  - reduce-autogen-purged-files.patch: prevent agutogen.sh from reamoving
  too many files during cleanup.
  - Add build-without-ntop-darwin.patch, to fix compilation without
  ntop_darwin.c.
* No longer add faq.html, as it is not distributed in the upstream tarball.
* Use ${source:Version} in control file. Have ntop-data recommend
  ntop.
* Rename dirs to ntop.dirs and keep only empty directories that need
  to be created.
* Remove var/lib from ntop.install file, as it is empty (keeping it in
  ntop.dirs).
* Update po files.
* Breaks and Replaces instead of Conflitcs for ntop-data.
* Use a longer package description.
* Remove useless configure options from debian/rules.
* Move private shared libraries libraries in /usr/lib/ntop.
* Add change-plugin-dir.patch for adjusting plugin directory.
* Remove development files.
* Use system library for MochiKit.js.
* Rewrite DEP5 copyright file.
* Repackage upstream tarball in order to remove non-DFSG-compliant code. Add
  get-orig-source.sh script and get-orig-source target in debian/rules.
* Add explanation to README.Debian why geolocation is no longer working.
* Add avoid-copy-maxmind-db.patch to prevent copying of Geo*.dat
  files.
* Remove old unused patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *      version:        1.2 - 2006-11-17
4
4
 *              1.3 - 2006-12-04
5
5
 *              2.0 - 2007-02-07
 
6
 *              2.1.1 - 2007-04-13
 
7
 *              2.1.2 - 2007-07-07
 
8
 *              2.1.3 - 2007-07-19
6
9
 *
7
10
 */
8
11
 
9
 
var useBSNns;
10
 
 
11
 
if (useBSNns)
12
 
{
13
 
        if (typeof(bsn) == "undefined")
14
 
                bsn = {}
15
 
        _bsn = bsn;
16
 
}
 
12
 
 
13
if (typeof(bsn) == "undefined")
 
14
        _b = bsn = {};
 
15
 
 
16
 
 
17
if (typeof(_b.Autosuggest) == "undefined")
 
18
        _b.Autosuggest = {};
17
19
else
18
 
{
19
 
        _bsn = this;
20
 
}
21
 
 
22
 
 
23
 
 
24
 
if (typeof(_bsn.Autosuggest) == "undefined")
25
 
        _bsn.Autosuggest = {}
26
 
 
27
 
 
28
 
 
29
 
 
30
 
 
31
 
 
32
 
 
33
 
 
34
 
 
35
 
 
36
 
 
37
 
 
38
 
 
39
 
_bsn.AutoSuggest = function (fldID, param)
 
20
        alert("Autosuggest is already set!");
 
21
 
 
22
 
 
23
 
 
24
 
 
25
 
 
26
 
 
27
 
 
28
 
 
29
 
 
30
 
 
31
 
 
32
 
 
33
_b.AutoSuggest = function (id, param)
40
34
{
41
35
        // no DOM - give up!
42
36
        //
43
37
        if (!document.getElementById)
44
 
                return false;
 
38
                return 0;
45
39
        
46
40
        
47
41
        
48
42
        
49
43
        // get field via DOM
50
44
        //
51
 
        this.fld = _bsn.DOM.getElement(fldID);
 
45
        this.fld = _b.DOM.gE(id);
52
46
 
53
47
        if (!this.fld)
54
 
                return false;
 
48
                return 0;
55
49
        
56
50
        
57
51
        
58
52
        
59
53
        // init variables
60
54
        //
61
 
        this.sInput             = "";
62
 
        this.nInputChars        = 0;
63
 
        this.aSuggestions       = [];
64
 
        this.iHighlighted       = 0;
 
55
        this.sInp       = "";
 
56
        this.nInpC      = 0;
 
57
        this.aSug       = [];
 
58
        this.iHigh      = 0;
65
59
        
66
60
        
67
61
        
68
62
        
69
63
        // parameters object
70
64
        //
71
 
        this.oP = (param) ? param : {};
 
65
        this.oP = param ? param : {};
72
66
        
73
67
        // defaults     
74
68
        //
75
 
        if (!this.oP.minchars)                                                                  this.oP.minchars = 1;
76
 
        if (!this.oP.method)                                                                    this.oP.meth = "get";
77
 
        if (!this.oP.varname)                                                                   this.oP.varname = "input";
78
 
        if (!this.oP.className)                                                                 this.oP.className = "autosuggest";
79
 
        if (!this.oP.timeout)                                                                   this.oP.timeout = 2500;
80
 
        if (!this.oP.delay)                                                                             this.oP.delay = 750;
81
 
        if (!this.oP.offsety)                                                                   this.oP.offsety = -5;
82
 
        if (!this.oP.shownoresults)                                                             this.oP.shownoresults = true;
83
 
        if (!this.oP.noresults)                                                                 this.oP.noresults = "No results!";
84
 
        if (!this.oP.maxheight && this.oP.maxheight !== 0)              this.oP.maxheight = 250;
85
 
        if (!this.oP.cache && this.oP.cache != false)                   this.oP.cache = true;
86
 
        
87
 
        
88
 
        
 
69
        var k, def = {minchars:1, meth:"get", varname:"input", className:"autosuggest", timeout:2500, delay:500, offsety:-5, shownoresults: true, noresults: "No results!", maxheight: 250, cache: true, maxentries: 25};
 
70
        for (k in def)
 
71
        {
 
72
                if (typeof(this.oP[k]) != typeof(def[k]))
 
73
                        this.oP[k] = def[k];
 
74
        }
89
75
        
90
76
        
91
77
        // set keyup handler for field
92
78
        // and prevent autocomplete from client
93
79
        //
94
 
        var pointer = this;
 
80
        var p = this;
95
81
        
96
82
        // NOTE: not using addEventListener because UpArrow fired twice in Safari
97
 
        //_bsn.DOM.addEvent( this.fld, 'keyup', function(ev){ return pointer.onKeyPress(ev); } );
 
83
        //_b.DOM.addEvent( this.fld, 'keyup', function(ev){ return pointer.onKeyPress(ev); } );
98
84
        
99
 
        this.fld.onkeypress     = function(ev){ return pointer.onKeyPress(ev); }
100
 
        this.fld.onkeyup                = function(ev){ return pointer.onKeyUp(ev); }
 
85
        this.fld.onkeypress     = function(ev){ return p.onKeyPress(ev); };
 
86
        this.fld.onkeyup                = function(ev){ return p.onKeyUp(ev); };
101
87
        
102
88
        this.fld.setAttribute("autocomplete","off");
103
 
}
104
 
 
105
 
 
106
 
 
107
 
 
108
 
 
109
 
 
110
 
 
111
 
 
112
 
 
113
 
 
114
 
 
115
 
 
116
 
 
117
 
 
118
 
 
119
 
 
120
 
_bsn.AutoSuggest.prototype.onKeyPress = function(ev)
 
89
};
 
90
 
 
91
 
 
92
 
 
93
 
 
94
 
 
95
 
 
96
 
 
97
 
 
98
 
 
99
 
 
100
 
 
101
 
 
102
 
 
103
 
 
104
 
 
105
 
 
106
_b.AutoSuggest.prototype.onKeyPress = function(ev)
121
107
{
122
108
        
123
109
        var key = (window.event) ? window.event.keyCode : ev.keyCode;
133
119
        var TAB = 9;
134
120
        var ESC = 27;
135
121
        
136
 
        var bubble = true;
 
122
        var bubble = 1;
137
123
 
138
124
        switch(key)
139
125
        {
140
 
 
141
126
                case RETURN:
142
127
                        this.setHighlightedValue();
143
 
                        bubble = false;
 
128
                        bubble = 0;
144
129
                        break;
145
130
 
146
 
 
147
131
                case ESC:
148
132
                        this.clearSuggestions();
149
133
                        break;
150
134
        }
151
135
 
152
136
        return bubble;
153
 
}
154
 
 
155
 
 
156
 
 
157
 
_bsn.AutoSuggest.prototype.onKeyUp = function(ev)
 
137
};
 
138
 
 
139
 
 
140
 
 
141
_b.AutoSuggest.prototype.onKeyUp = function(ev)
158
142
{
159
143
        var key = (window.event) ? window.event.keyCode : ev.keyCode;
160
144
        
169
153
        var ARRUP = 38;
170
154
        var ARRDN = 40;
171
155
        
172
 
        var bubble = true;
 
156
        var bubble = 1;
173
157
 
174
158
        switch(key)
175
159
        {
177
161
 
178
162
                case ARRUP:
179
163
                        this.changeHighlight(key);
180
 
                        bubble = false;
 
164
                        bubble = 0;
181
165
                        break;
182
166
 
183
167
 
184
168
                case ARRDN:
185
169
                        this.changeHighlight(key);
186
 
                        bubble = false;
 
170
                        bubble = 0;
187
171
                        break;
188
172
                
189
173
                
194
178
        return bubble;
195
179
        
196
180
 
197
 
}
198
 
 
199
 
 
200
 
 
201
 
 
202
 
 
203
 
 
204
 
 
205
 
 
206
 
_bsn.AutoSuggest.prototype.getSuggestions = function (val)
 
181
};
 
182
 
 
183
 
 
184
 
 
185
 
 
186
 
 
187
 
 
188
 
 
189
 
 
190
_b.AutoSuggest.prototype.getSuggestions = function (val)
207
191
{
208
192
        
209
193
        // if input stays the same, do nothing
210
194
        //
211
 
        if (val == this.sInput)
212
 
                return false;
213
 
 
 
195
        if (val == this.sInp)
 
196
                return 0;
 
197
        
 
198
        
 
199
        // kill list
 
200
        //
 
201
        _b.DOM.remE(this.idAs);
 
202
        
 
203
        
 
204
        this.sInp = val;
 
205
        
214
206
        
215
207
        // input length is less than the min required to trigger a request
216
 
        // reset input string
217
208
        // do nothing
218
209
        //
219
210
        if (val.length < this.oP.minchars)
220
211
        {
221
 
                this.sInput = "";
222
 
                return false;
 
212
                this.aSug = [];
 
213
                this.nInpC = val.length;
 
214
                return 0;
223
215
        }
224
216
        
225
217
        
 
218
        
 
219
        
 
220
        var ol = this.nInpC; // old length
 
221
        this.nInpC = val.length ? val.length : 0;
 
222
        
 
223
        
 
224
        
226
225
        // if caching enabled, and user is typing (ie. length of input is increasing)
227
226
        // filter results out of aSuggestions from last request
228
227
        //
229
 
        if (val.length>this.nInputChars && this.aSuggestions.length && this.oP.cache)
 
228
        var l = this.aSug.length;
 
229
        if (this.nInpC > ol && l && l<this.oP.maxentries && this.oP.cache)
230
230
        {
231
231
                var arr = [];
232
 
                for (var i=0;i<this.aSuggestions.length;i++)
 
232
                for (var i=0;i<l;i++)
233
233
                {
234
 
                        //      if (this.aSuggestions[i].value.substr(0,val.length).toLowerCase() == val.toLowerCase())
235
 
                                if (this.aSuggestions[i].value.indexOf(val) != -1)      
236
 
                                arr.push( this.aSuggestions[i] );
 
234
                        if (this.aSug[i].value.substr(0,val.length).toLowerCase() == val.toLowerCase())
 
235
                                arr.push( this.aSug[i] );
237
236
                }
238
 
                
239
 
                this.sInput = val;
240
 
                this.nInputChars = val.length;
241
 
                this.aSuggestions = arr;
242
 
                
243
 
                this.createList(this.aSuggestions);
 
237
                this.aSug = arr;
 
238
                
 
239
                this.createList(this.aSug);
244
240
                
245
241
                
246
242
                
250
246
        // do new request
251
247
        //
252
248
        {
253
 
                this.sInput = val;
254
 
                this.nInputChars = val.length;
255
 
 
256
 
 
257
249
                var pointer = this;
 
250
                var input = this.sInp;
258
251
                clearTimeout(this.ajID);
259
 
                this.ajID = setTimeout( function() { pointer.doAjaxRequest() }, this.oP.delay );
 
252
                this.ajID = setTimeout( function() { pointer.doAjaxRequest(input) }, this.oP.delay );
260
253
        }
261
254
 
262
255
        return false;
263
 
}
264
 
 
265
 
 
266
 
 
267
 
 
268
 
 
269
 
_bsn.AutoSuggest.prototype.doAjaxRequest = function ()
 
256
};
 
257
 
 
258
 
 
259
 
 
260
 
 
261
 
 
262
_b.AutoSuggest.prototype.doAjaxRequest = function (input)
270
263
{
 
264
        // check that saved input is still the value of the field
 
265
        //
 
266
        if (input != this.fld.value)
 
267
                return false;
 
268
        
271
269
        
272
270
        var pointer = this;
273
271
        
 
272
        
274
273
        // create ajax request
275
 
        var url = this.oP.script+this.oP.varname+"="+escape(this.fld.value);
 
274
        //
 
275
        if (typeof(this.oP.script) == "function")
 
276
                var url = this.oP.script(encodeURIComponent(this.sInp));
 
277
        else
 
278
                var url = this.oP.script+this.oP.varname+"="+encodeURIComponent(this.sInp);
 
279
        
 
280
        if (!url)
 
281
                return false;
 
282
        
276
283
        var meth = this.oP.meth;
 
284
        var input = this.sInp;
277
285
        
278
 
        var onSuccessFunc = function (req) { pointer.setSuggestions(req) };
 
286
        var onSuccessFunc = function (req) { pointer.setSuggestions(req, input) };
279
287
        var onErrorFunc = function (status) { alert("AJAX error: "+status); };
280
288
 
281
 
        var myAjax = new _bsn.Ajax();
 
289
        var myAjax = new _b.Ajax();
282
290
        myAjax.makeRequest( url, meth, onSuccessFunc, onErrorFunc );
283
 
}
284
 
 
285
 
 
286
 
 
287
 
 
288
 
 
289
 
_bsn.AutoSuggest.prototype.setSuggestions = function (req)
 
291
};
 
292
 
 
293
 
 
294
 
 
295
 
 
296
 
 
297
_b.AutoSuggest.prototype.setSuggestions = function (req, input)
290
298
{
291
 
        this.aSuggestions = [];
 
299
        // if field input no longer matches what was passed to the request
 
300
        // don't show the suggestions
 
301
        //
 
302
        if (input != this.fld.value)
 
303
                return false;
 
304
        
 
305
        
 
306
        this.aSug = [];
 
307
        
292
308
        
293
309
        if (this.oP.json)
294
310
        {
296
312
                
297
313
                for (var i=0;i<jsondata.results.length;i++)
298
314
                {
299
 
                        this.aSuggestions.push(  { 'id':jsondata.results[i].id, 'value':jsondata.results[i].value, 'info':jsondata.results[i].info }  );
 
315
                        this.aSug.push(  { 'id':jsondata.results[i].id, 'value':jsondata.results[i].value, 'info':jsondata.results[i].info }  );
300
316
                }
301
317
        }
302
318
        else
311
327
                for (var i=0;i<results.length;i++)
312
328
                {
313
329
                        if (results[i].hasChildNodes())
314
 
                                this.aSuggestions.push(  { 'id':results[i].getAttribute('id'), 'value':results[i].childNodes[0].nodeValue, 'info':results[i].getAttribute('info') }  );
 
330
                                this.aSug.push(  { 'id':results[i].getAttribute('id'), 'value':results[i].childNodes[0].nodeValue, 'info':results[i].getAttribute('info') }  );
315
331
                }
316
332
        
317
333
        }
319
335
        this.idAs = "as_"+this.fld.id;
320
336
        
321
337
 
322
 
        this.createList(this.aSuggestions);
323
 
 
324
 
}
325
 
 
326
 
 
327
 
 
328
 
 
329
 
 
330
 
 
331
 
 
332
 
 
333
 
 
334
 
 
335
 
 
336
 
 
337
 
 
338
 
 
339
 
_bsn.AutoSuggest.prototype.createList = function(arr)
 
338
        this.createList(this.aSug);
 
339
 
 
340
};
 
341
 
 
342
 
 
343
 
 
344
 
 
345
 
 
346
 
 
347
 
 
348
 
 
349
 
 
350
 
 
351
 
 
352
 
 
353
 
 
354
 
 
355
_b.AutoSuggest.prototype.createList = function(arr)
340
356
{
341
357
        var pointer = this;
342
358
        
343
359
        
 
360
        
 
361
        
344
362
        // get rid of old list
345
363
        // and clear the list removal timeout
346
364
        //
347
 
        _bsn.DOM.removeElement(this.idAs);
 
365
        _b.DOM.remE(this.idAs);
348
366
        this.killTimeout();
349
367
        
350
368
        
 
369
        // if no results, and shownoresults is false, do nothing
 
370
        //
 
371
        if (arr.length == 0 && !this.oP.shownoresults)
 
372
                return false;
 
373
        
 
374
        
351
375
        // create holding div
352
376
        //
353
 
        var div = _bsn.DOM.createElement("div", {id:this.idAs, className:this.oP.className});   
 
377
        var div = _b.DOM.cE("div", {id:this.idAs, className:this.oP.className});        
354
378
        
355
 
        var hcorner = _bsn.DOM.createElement("div", {className:"as_corner"});
356
 
        var hbar = _bsn.DOM.createElement("div", {className:"as_bar"});
357
 
        var header = _bsn.DOM.createElement("div", {className:"as_header"});
 
379
        var hcorner = _b.DOM.cE("div", {className:"as_corner"});
 
380
        var hbar = _b.DOM.cE("div", {className:"as_bar"});
 
381
        var header = _b.DOM.cE("div", {className:"as_header"});
358
382
        header.appendChild(hcorner);
359
383
        header.appendChild(hbar);
360
384
        div.appendChild(header);
364
388
        
365
389
        // create and populate ul
366
390
        //
367
 
        var ul = _bsn.DOM.createElement("ul", {id:"as_ul"});
 
391
        var ul = _b.DOM.cE("ul", {id:"as_ul"});
368
392
        
369
393
        
370
394
        
378
402
                // (as HTML, not DOM)
379
403
                //
380
404
                var val = arr[i].value;
381
 
                var st = val.toLowerCase().indexOf( this.sInput.toLowerCase() );
382
 
                var output = val.substring(0,st) + "<em>" + val.substring(st, st+this.sInput.length) + "</em>" + val.substring(st+this.sInput.length);
383
 
                
384
 
                
385
 
                var span                = _bsn.DOM.createElement("span", {}, output, true);
 
405
                var st = val.toLowerCase().indexOf( this.sInp.toLowerCase() );
 
406
                var output = val.substring(0,st) + "<em>" + val.substring(st, st+this.sInp.length) + "</em>" + val.substring(st+this.sInp.length);
 
407
                
 
408
                
 
409
                var span                = _b.DOM.cE("span", {}, output, true);
386
410
                if (arr[i].info != "")
387
411
                {
388
 
                        var br                  = _bsn.DOM.createElement("br", {});
 
412
                        var br                  = _b.DOM.cE("br", {});
389
413
                        span.appendChild(br);
390
 
                        var small               = _bsn.DOM.createElement("small", {}, arr[i].info);
 
414
                        var small               = _b.DOM.cE("small", {}, arr[i].info);
391
415
                        span.appendChild(small);
392
416
                }
393
417
                
394
 
                var a                   = _bsn.DOM.createElement("a", { href:"#" });
 
418
                var a                   = _b.DOM.cE("a", { href:"#" });
395
419
                
396
 
                var tl          = _bsn.DOM.createElement("span", {className:"tl"}, " ");
397
 
                var tr          = _bsn.DOM.createElement("span", {className:"tr"}, " ");
 
420
                var tl          = _b.DOM.cE("span", {className:"tl"}, " ");
 
421
                var tr          = _b.DOM.cE("span", {className:"tr"}, " ");
398
422
                a.appendChild(tl);
399
423
                a.appendChild(tr);
400
424
                
401
425
                a.appendChild(span);
402
426
                
403
427
                a.name = i+1;
404
 
                a.onclick = function () { pointer.setHighlightedValue(); return false; }
405
 
                a.onmouseover = function () { pointer.setHighlight(this.name); }
 
428
                a.onclick = function () { pointer.setHighlightedValue(); return false; };
 
429
                a.onmouseover = function () { pointer.setHighlight(this.name); };
406
430
                
407
 
                var li                  = _bsn.DOM.createElement(  "li", {}, a  );
 
431
                var li = _b.DOM.cE(  "li", {}, a  );
408
432
                
409
433
                ul.appendChild( li );
410
434
        }
412
436
        
413
437
        // no results
414
438
        //
415
 
        if (arr.length == 0)
 
439
        if (arr.length == 0 && this.oP.shownoresults)
416
440
        {
417
 
                var li                  = _bsn.DOM.createElement(  "li", {className:"as_warning"}, this.oP.noresults  );
418
 
                
 
441
                var li = _b.DOM.cE(  "li", {className:"as_warning"}, this.oP.noresults  );
419
442
                ul.appendChild( li );
420
443
        }
421
444
        
423
446
        div.appendChild( ul );
424
447
        
425
448
        
426
 
        var fcorner = _bsn.DOM.createElement("div", {className:"as_corner"});
427
 
        var fbar = _bsn.DOM.createElement("div", {className:"as_bar"});
428
 
        var footer = _bsn.DOM.createElement("div", {className:"as_footer"});
 
449
        var fcorner = _b.DOM.cE("div", {className:"as_corner"});
 
450
        var fbar = _b.DOM.cE("div", {className:"as_bar"});
 
451
        var footer = _b.DOM.cE("div", {className:"as_footer"});
429
452
        footer.appendChild(fcorner);
430
453
        footer.appendChild(fbar);
431
454
        div.appendChild(footer);
436
459
        // position holding div below it
437
460
        // set width of holding div to width of field
438
461
        //
439
 
        var pos = _bsn.DOM.getPos(this.fld);
 
462
        var pos = _b.DOM.getPos(this.fld);
440
463
        
441
464
        div.style.left          = pos.x + "px";
442
465
        div.style.top           = ( pos.y + this.fld.offsetHeight + this.oP.offsety ) + "px";
448
471
        // when mouse pointer leaves div, set a timeout to remove the list after an interval
449
472
        // when mouse enters div, kill the timeout so the list won't be removed
450
473
        //
451
 
        div.onmouseover         = function(){ pointer.killTimeout() }
452
 
        div.onmouseout          = function(){ pointer.resetTimeout() }
 
474
        div.onmouseover         = function(){ pointer.killTimeout() };
 
475
        div.onmouseout          = function(){ pointer.resetTimeout() };
453
476
 
454
477
 
455
478
        // add DIV to document
460
483
        
461
484
        // currently no item is highlighted
462
485
        //
463
 
        this.iHighlighted = 0;
 
486
        this.iHigh = 0;
464
487
        
465
488
        
466
489
        
471
494
        //
472
495
        var pointer = this;
473
496
        this.toID = setTimeout(function () { pointer.clearSuggestions() }, this.oP.timeout);
474
 
}
475
 
 
476
 
 
477
 
 
478
 
 
479
 
 
480
 
 
481
 
 
482
 
 
483
 
 
484
 
 
485
 
 
486
 
 
487
 
 
488
 
 
489
 
 
490
 
_bsn.AutoSuggest.prototype.changeHighlight = function(key)
 
497
};
 
498
 
 
499
 
 
500
 
 
501
 
 
502
 
 
503
 
 
504
 
 
505
 
 
506
 
 
507
 
 
508
 
 
509
 
 
510
 
 
511
 
 
512
 
 
513
_b.AutoSuggest.prototype.changeHighlight = function(key)
491
514
{       
492
 
        var list = _bsn.DOM.getElement("as_ul");
 
515
        var list = _b.DOM.gE("as_ul");
493
516
        if (!list)
494
517
                return false;
495
518
        
496
519
        var n;
497
520
 
498
521
        if (key == 40)
499
 
                n = this.iHighlighted + 1;
 
522
                n = this.iHigh + 1;
500
523
        else if (key == 38)
501
 
                n = this.iHighlighted - 1;
 
524
                n = this.iHigh - 1;
502
525
        
503
526
        
504
527
        if (n > list.childNodes.length)
508
531
        
509
532
        
510
533
        this.setHighlight(n);
511
 
}
512
 
 
513
 
 
514
 
 
515
 
_bsn.AutoSuggest.prototype.setHighlight = function(n)
 
534
};
 
535
 
 
536
 
 
537
 
 
538
_b.AutoSuggest.prototype.setHighlight = function(n)
516
539
{
517
 
        var list = _bsn.DOM.getElement("as_ul");
 
540
        var list = _b.DOM.gE("as_ul");
518
541
        if (!list)
519
542
                return false;
520
543
        
521
 
        if (this.iHighlighted > 0)
 
544
        if (this.iHigh > 0)
522
545
                this.clearHighlight();
523
546
        
524
 
        this.iHighlighted = Number(n);
 
547
        this.iHigh = Number(n);
525
548
        
526
 
        list.childNodes[this.iHighlighted-1].className = "as_highlight";
 
549
        list.childNodes[this.iHigh-1].className = "as_highlight";
527
550
 
528
551
 
529
552
        this.killTimeout();
530
 
}
531
 
 
532
 
 
533
 
_bsn.AutoSuggest.prototype.clearHighlight = function()
 
553
};
 
554
 
 
555
 
 
556
_b.AutoSuggest.prototype.clearHighlight = function()
534
557
{
535
 
        var list = _bsn.DOM.getElement("as_ul");
 
558
        var list = _b.DOM.gE("as_ul");
536
559
        if (!list)
537
560
                return false;
538
561
        
539
 
        if (this.iHighlighted > 0)
 
562
        if (this.iHigh > 0)
540
563
        {
541
 
                list.childNodes[this.iHighlighted-1].className = "";
542
 
                this.iHighlighted = 0;
 
564
                list.childNodes[this.iHigh-1].className = "";
 
565
                this.iHigh = 0;
543
566
        }
544
 
}
545
 
 
546
 
 
547
 
_bsn.AutoSuggest.prototype.setHighlightedValue = function ()
 
567
};
 
568
 
 
569
 
 
570
_b.AutoSuggest.prototype.setHighlightedValue = function ()
548
571
{
549
 
        if (this.iHighlighted)
 
572
        if (this.iHigh)
550
573
        {
551
 
                this.sInput = this.fld.value = this.aSuggestions[ this.iHighlighted-1 ].value;
 
574
                this.sInp = this.fld.value = this.aSug[ this.iHigh-1 ].value;
552
575
                
553
576
                // move cursor to end of input (safari)
554
577
                //
555
578
                this.fld.focus();
556
579
                if (this.fld.selectionStart)
557
 
                        this.fld.setSelectionRange(this.sInput.length, this.sInput.length);
 
580
                        this.fld.setSelectionRange(this.sInp.length, this.sInp.length);
558
581
                
559
582
 
560
583
                this.clearSuggestions();
562
585
                // pass selected object to callback function, if exists
563
586
                //
564
587
                if (typeof(this.oP.callback) == "function")
565
 
                        this.oP.callback( this.aSuggestions[this.iHighlighted-1] );
 
588
                        this.oP.callback( this.aSug[this.iHigh-1] );
566
589
        }
567
 
}
568
 
 
569
 
 
570
 
 
571
 
 
572
 
 
573
 
 
574
 
 
575
 
 
576
 
 
577
 
 
578
 
 
579
 
 
580
 
 
581
 
_bsn.AutoSuggest.prototype.killTimeout = function()
 
590
};
 
591
 
 
592
 
 
593
 
 
594
 
 
595
 
 
596
 
 
597
 
 
598
 
 
599
 
 
600
 
 
601
 
 
602
 
 
603
 
 
604
_b.AutoSuggest.prototype.killTimeout = function()
582
605
{
583
606
        clearTimeout(this.toID);
584
 
}
 
607
};
585
608
 
586
 
_bsn.AutoSuggest.prototype.resetTimeout = function()
 
609
_b.AutoSuggest.prototype.resetTimeout = function()
587
610
{
588
611
        clearTimeout(this.toID);
589
612
        var pointer = this;
590
613
        this.toID = setTimeout(function () { pointer.clearSuggestions() }, 1000);
591
 
}
592
 
 
593
 
 
594
 
 
595
 
 
596
 
 
597
 
 
598
 
 
599
 
_bsn.AutoSuggest.prototype.clearSuggestions = function ()
 
614
};
 
615
 
 
616
 
 
617
 
 
618
 
 
619
 
 
620
 
 
621
 
 
622
_b.AutoSuggest.prototype.clearSuggestions = function ()
600
623
{
601
624
        
602
625
        this.killTimeout();
603
626
        
604
 
        var ele = _bsn.DOM.getElement(this.idAs);
 
627
        var ele = _b.DOM.gE(this.idAs);
605
628
        var pointer = this;
606
629
        if (ele)
607
630
        {
608
 
                var fade = new _bsn.Fader(ele,1,0,250,function () { _bsn.DOM.removeElement(pointer.idAs) });
 
631
                var fade = new _b.Fader(ele,1,0,250,function () { _b.DOM.remE(pointer.idAs) });
609
632
        }
610
 
}
 
633
};
611
634
 
612
635
 
613
636
 
621
644
// AJAX PROTOTYPE _____________________________________________
622
645
 
623
646
 
624
 
if (typeof(_bsn.Ajax) == "undefined")
625
 
        _bsn.Ajax = {}
626
 
 
627
 
 
628
 
 
629
 
_bsn.Ajax = function ()
 
647
if (typeof(_b.Ajax) == "undefined")
 
648
        _b.Ajax = {};
 
649
 
 
650
 
 
651
 
 
652
_b.Ajax = function ()
630
653
{
631
654
        this.req = {};
632
655
        this.isIE = false;
633
 
}
634
 
 
635
 
 
636
 
 
637
 
_bsn.Ajax.prototype.makeRequest = function (url, meth, onComp, onErr)
 
656
};
 
657
 
 
658
 
 
659
 
 
660
_b.Ajax.prototype.makeRequest = function (url, meth, onComp, onErr)
638
661
{
639
662
        
640
663
        if (meth != "POST")
664
687
                        this.req.send();
665
688
                }
666
689
        }
667
 
}
668
 
 
669
 
 
670
 
_bsn.Ajax.prototype.processReqChange = function()
 
690
};
 
691
 
 
692
 
 
693
_b.Ajax.prototype.processReqChange = function()
671
694
{
672
695
        
673
696
        // only if req shows "loaded"
680
703
                        this.onError( this.req.status );
681
704
                }
682
705
        }
683
 
}
 
706
};
684
707
 
685
708
 
686
709
 
694
717
// DOM PROTOTYPE _____________________________________________
695
718
 
696
719
 
697
 
if (typeof(_bsn.DOM) == "undefined")
698
 
        _bsn.DOM = {}
699
 
 
700
 
 
701
 
 
702
 
 
703
 
_bsn.DOM.createElement = function ( type, attr, cont, html )
 
720
if (typeof(_b.DOM) == "undefined")
 
721
        _b.DOM = {};
 
722
 
 
723
 
 
724
 
 
725
/* create element */
 
726
_b.DOM.cE = function ( type, attr, cont, html )
704
727
{
705
728
        var ne = document.createElement( type );
706
729
        if (!ne)
707
 
                return false;
 
730
                return 0;
708
731
                
709
732
        for (var a in attr)
710
733
                ne[a] = attr[a];
711
 
                
712
 
        if (typeof(cont) == "string" && !html)
 
734
        
 
735
        var t = typeof(cont);
 
736
        
 
737
        if (t == "string" && !html)
713
738
                ne.appendChild( document.createTextNode(cont) );
714
 
        else if (typeof(cont) == "string" && html)
 
739
        else if (t == "string" && html)
715
740
                ne.innerHTML = cont;
716
 
        else if (typeof(cont) == "object")
 
741
        else if (t == "object")
717
742
                ne.appendChild( cont );
718
743
 
719
744
        return ne;
720
 
}
721
 
 
722
 
 
723
 
 
724
 
 
725
 
 
726
 
_bsn.DOM.clearElement = function ( id )
727
 
{
728
 
        var ele = this.getElement( id );
729
 
        
730
 
        if (!ele)
731
 
                return false;
732
 
        
733
 
        while (ele.childNodes.length)
734
 
                ele.removeChild( ele.childNodes[0] );
735
 
        
736
 
        return true;
737
 
}
738
 
 
739
 
 
740
 
 
741
 
 
742
 
 
743
 
 
744
 
 
745
 
 
746
 
 
747
 
_bsn.DOM.removeElement = function ( ele )
748
 
{
749
 
        var e = this.getElement(ele);
 
745
};
 
746
 
 
747
 
 
748
 
 
749
/* get element */
 
750
_b.DOM.gE = function ( e )
 
751
{
 
752
        var t=typeof(e);
 
753
        if (t == "undefined")
 
754
                return 0;
 
755
        else if (t == "string")
 
756
        {
 
757
                var re = document.getElementById( e );
 
758
                if (!re)
 
759
                        return 0;
 
760
                else if (typeof(re.appendChild) != "undefined" )
 
761
                        return re;
 
762
                else
 
763
                        return 0;
 
764
        }
 
765
        else if (typeof(e.appendChild) != "undefined")
 
766
                return e;
 
767
        else
 
768
                return 0;
 
769
};
 
770
 
 
771
 
 
772
 
 
773
/* remove element */
 
774
_b.DOM.remE = function ( ele )
 
775
{
 
776
        var e = this.gE(ele);
750
777
        
751
778
        if (!e)
752
 
                return false;
 
779
                return 0;
753
780
        else if (e.parentNode.removeChild(e))
754
781
                return true;
755
782
        else
756
 
                return false;
757
 
}
758
 
 
759
 
 
760
 
 
761
 
 
762
 
 
763
 
_bsn.DOM.replaceContent = function ( id, cont, html )
764
 
{
765
 
        var ele = this.getElement( id );
766
 
        
767
 
        if (!ele)
768
 
                return false;
769
 
        
770
 
        this.clearElement( ele );
771
 
        
772
 
        if (typeof(cont) == "string" && !html)
773
 
                ele.appendChild( document.createTextNode(cont) );
774
 
        else if (typeof(cont) == "string" && html)
775
 
                ele.innerHTML = cont;
776
 
        else if (typeof(cont) == "object")
777
 
                ele.appendChild( cont );
778
 
}
779
 
 
780
 
 
781
 
 
782
 
 
783
 
 
784
 
 
785
 
 
786
 
 
787
 
 
788
 
_bsn.DOM.getElement = function ( ele )
789
 
{
790
 
        if (typeof(ele) == "undefined")
791
 
        {
792
 
                return false;
793
 
        }
794
 
        else if (typeof(ele) == "string")
795
 
        {
796
 
                var re = document.getElementById( ele );
797
 
                if (!re)
798
 
                        return false;
799
 
                else if (typeof(re.appendChild) != "undefined" ) {
800
 
                        return re;
801
 
                } else {
802
 
                        return false;
803
 
                }
804
 
        }
805
 
        else if (typeof(ele.appendChild) != "undefined")
806
 
                return ele;
807
 
        else
808
 
                return false;
809
 
}
810
 
 
811
 
 
812
 
 
813
 
 
814
 
 
815
 
 
816
 
 
817
 
_bsn.DOM.appendChildren = function ( id, arr )
818
 
{
819
 
        var ele = this.getElement( id );
820
 
        
821
 
        if (!ele)
822
 
                return false;
823
 
        
824
 
        
825
 
        if (typeof(arr) != "object")
826
 
                return false;
827
 
                
828
 
        for (var i=0;i<arr.length;i++)
829
 
        {
830
 
                var cont = arr[i];
831
 
                if (typeof(cont) == "string")
832
 
                        ele.appendChild( document.createTextNode(cont) );
833
 
                else if (typeof(cont) == "object")
834
 
                        ele.appendChild( cont );
835
 
        }
836
 
}
837
 
 
838
 
 
839
 
 
840
 
 
841
 
 
842
 
 
843
 
 
844
 
 
845
 
 
846
 
_bsn.DOM.getPos = function ( ele )
847
 
{
848
 
        var ele = this.getElement(ele);
849
 
 
850
 
        var obj = ele;
 
783
                return 0;
 
784
};
 
785
 
 
786
 
 
787
 
 
788
/* get position */
 
789
_b.DOM.getPos = function ( e )
 
790
{
 
791
        var e = this.gE(e);
 
792
 
 
793
        var obj = e;
851
794
 
852
795
        var curleft = 0;
853
796
        if (obj.offsetParent)
854
797
        {
855
798
                while (obj.offsetParent)
856
799
                {
857
 
                        curleft += obj.offsetLeft
 
800
                        curleft += obj.offsetLeft;
858
801
                        obj = obj.offsetParent;
859
802
                }
860
803
        }
861
804
        else if (obj.x)
862
805
                curleft += obj.x;
863
 
 
864
 
 
865
 
        var obj = ele;
 
806
        
 
807
        var obj = e;
866
808
        
867
809
        var curtop = 0;
868
810
        if (obj.offsetParent)
869
811
        {
870
812
                while (obj.offsetParent)
871
813
                {
872
 
                        curtop += obj.offsetTop
 
814
                        curtop += obj.offsetTop;
873
815
                        obj = obj.offsetParent;
874
816
                }
875
817
        }
876
818
        else if (obj.y)
877
819
                curtop += obj.y;
878
820
 
879
 
        return {x:curleft, y:curtop}
880
 
}
 
821
        return {x:curleft, y:curtop};
 
822
};
881
823
 
882
824
 
883
825
 
892
834
 
893
835
 
894
836
 
895
 
if (typeof(_bsn.Fader) == "undefined")
896
 
        _bsn.Fader = {}
897
 
 
898
 
 
899
 
 
900
 
 
901
 
 
902
 
_bsn.Fader = function (ele, from, to, fadetime, callback)
 
837
if (typeof(_b.Fader) == "undefined")
 
838
        _b.Fader = {};
 
839
 
 
840
 
 
841
 
 
842
 
 
843
 
 
844
_b.Fader = function (ele, from, to, fadetime, callback)
903
845
{       
904
846
        if (!ele)
905
 
                return false;
 
847
                return 0;
906
848
        
907
 
        this.ele = ele;
 
849
        this.e = ele;
908
850
        
909
851
        this.from = from;
910
852
        this.to = to;
911
853
        
912
 
        this.callback = callback;
 
854
        this.cb = callback;
913
855
        
914
856
        this.nDur = fadetime;
915
857
                
918
860
        
919
861
        var p = this;
920
862
        this.nID = setInterval(function() { p._fade() }, this.nInt);
921
 
}
922
 
 
923
 
 
924
 
 
925
 
 
926
 
_bsn.Fader.prototype._fade = function()
 
863
};
 
864
 
 
865
 
 
866
 
 
867
 
 
868
_b.Fader.prototype._fade = function()
927
869
{
928
870
        this.nTime += this.nInt;
929
871
        
930
872
        var ieop = Math.round( this._tween(this.nTime, this.from, this.to, this.nDur) * 100 );
931
873
        var op = ieop / 100;
932
874
        
933
 
        if (this.ele.filters) // internet explorer
 
875
        if (this.e.filters) // internet explorer
934
876
        {
935
877
                try
936
878
                {
937
 
                        this.ele.filters.item("DXImageTransform.Microsoft.Alpha").opacity = ieop;
 
879
                        this.e.filters.item("DXImageTransform.Microsoft.Alpha").opacity = ieop;
938
880
                } catch (e) { 
939
881
                        // If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
940
 
                        this.ele.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+ieop+')';
 
882
                        this.e.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+ieop+')';
941
883
                }
942
884
        }
943
885
        else // other browsers
944
886
        {
945
 
                this.ele.style.opacity = op;
 
887
                this.e.style.opacity = op;
946
888
        }
947
889
        
948
890
        
949
891
        if (this.nTime == this.nDur)
950
892
        {
951
893
                clearInterval( this.nID );
952
 
                if (this.callback != undefined)
953
 
                        this.callback();
 
894
                if (this.cb != undefined)
 
895
                        this.cb();
954
896
        }
955
 
}
956
 
 
957
 
 
958
 
 
959
 
_bsn.Fader.prototype._tween = function(t,b,c,d)
 
897
};
 
898
 
 
899
 
 
900
 
 
901
_b.Fader.prototype._tween = function(t,b,c,d)
960
902
{
961
903
        return b + ( (c-b) * (t/d) );
962
 
}
 
 
b'\\ No newline at end of file'
 
904
};
 
 
b'\\ No newline at end of file'