web-connect 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,636 @@
1
+ if(typeof nf == 'undefined') {
2
+ nf = function() {
3
+ var m, ret, i;
4
+ if(arguments.length == 1) {
5
+ if(arguments[0].nodeType) {
6
+ return arguments[0];
7
+ }
8
+ if(m = arguments[0].match(/^#([\w$]+)$/)) {
9
+ return document.getElementById(m[1]);
10
+ }
11
+ }
12
+ if(arguments.length >= 1) {
13
+ if(m = arguments[0].match(/^<(\w*)\s*\/?(>?)$/)) {
14
+ ret = m[2]
15
+ ? document.createElement(m[1])
16
+ : document.createTextNode(arguments[2]);
17
+ if(arguments.length > 1 && arguments[1] !== null) {
18
+ nf(arguments[1]).appendChild(ret);
19
+ }
20
+ if(arguments.length > 2 && m[2]) {
21
+ for(i in arguments[2]) {
22
+ try {
23
+ ret[i] = arguments[2][i];
24
+ } catch(e) {
25
+ }
26
+ }
27
+ }
28
+ return ret;
29
+ }
30
+ }
31
+ };
32
+ }
33
+
34
+ nf.json_encode = function(value, whitelist) {
35
+ var charsub = {
36
+ '\b': '\\b',
37
+ '\t': '\\t',
38
+ '\n': '\\n',
39
+ '\f': '\\f',
40
+ '\r': '\\r',
41
+ '"': '\\"',
42
+ '\\': '\\\\'
43
+ };
44
+ var a, i, k, l, v;
45
+ var r = /["\\\x00-\x1F\x7F-\uFFEF]/g;
46
+ switch(typeof value) {
47
+ case 'string':
48
+ return r.test(value) ?
49
+ '"' + value.replace(r, function(a) {
50
+ if(a in charsub) {
51
+ return charsub[a];
52
+ }
53
+ var c = a.charCodeAt().toString(16);
54
+ while(c.length < 4) {
55
+ c = '0' + c;
56
+ }
57
+ return '\\u' + c;
58
+ }) + '"' :
59
+ '"' + value + '"';
60
+ case 'number':
61
+ return isFinite(value) ? String(value) : 'null';
62
+ case 'boolean':
63
+ case 'null':
64
+ return String(value);
65
+ case 'object':
66
+ if(!value) {
67
+ return 'null';
68
+ }
69
+ if(typeof value.toJSON === 'function') {
70
+ return value.toJSON();
71
+ }
72
+ a = [];
73
+ if(typeof value.length === 'number' && !(value.propertyIsEnumerable('length'))) {
74
+ l = value.length;
75
+ for(i = 0; i < l; i++) {
76
+ a.push(nf.json_encode(value[i], whitelist) || 'null');
77
+ }
78
+ return '[' + a.join(',') + ']';
79
+ }
80
+ if(whitelist) {
81
+ l = whitelist.length;
82
+ for(i = 0; i < l; i++) {
83
+ k = whitelist[i];
84
+ if(typeof k === 'string') {
85
+ v = nf.json_encode(value[k], whitelist);
86
+ if(v) {
87
+ a.push(nf.json_encode(k) + ':' + v);
88
+ }
89
+ }
90
+ }
91
+ } else {
92
+ for(k in value) {
93
+ if(typeof k === 'string') {
94
+ v = nf.json_encode(value[k], whitelist);
95
+ if(v) {
96
+ a.push(nf.json_encode(k) + ':' + v);
97
+ }
98
+ }
99
+ }
100
+ }
101
+ return '{' + a.join(',') + '}';
102
+ }
103
+ };
104
+
105
+ nf.className = function(node, classname) {
106
+ if(!node) {
107
+ return false;
108
+ }
109
+ if(node.nodeType != 1) {
110
+ return false;
111
+ }
112
+ var classes = node.className ? node.className.replace(/(^\s+|\s+$)/, '').split(/\s+/) : new Array();
113
+ var found = -1;
114
+ for(var i = 0; i < classes.length; i++) {
115
+ if(classes[i] == classname) {
116
+ found = i;
117
+ }
118
+ }
119
+ var action;
120
+ if(action = arguments[2]) {
121
+ if(found >= 0 && action < 0) {
122
+ classes[found] = null;
123
+ }
124
+ if(found == -1 && action > 0) {
125
+ classes[classes.length] = classname;
126
+ }
127
+ } else {
128
+ return found >= 0;
129
+ }
130
+ for(i = 0; i < classes.length; i++) {
131
+ if(!classes[i]) {
132
+ classes.splice(i, 1);
133
+ }
134
+ }
135
+ node.className = classes.join(' ');
136
+ };
137
+
138
+ nf.api = {
139
+ endpoint: null,
140
+ password: null,
141
+ version: 8,
142
+ headers: [],
143
+ get: function(path, callback) {
144
+ return new this.Call("GET", path, null, callback);
145
+ },
146
+ post: function(path, data, callback) {
147
+ return new this.Call("POST", path, data, callback);
148
+ },
149
+ put: function(path, data, callback) {
150
+ return new this.Call("PUT", path, data, callback);
151
+ },
152
+ del: function(path, callback) {
153
+ return new this.Call("DELETE", path, null, callback);
154
+ },
155
+ Call: function(method, path, data, callback) {
156
+ if(nf.api.endpoint === null) {
157
+ return false;
158
+ }
159
+ var e;
160
+ try {
161
+ this.xh = new XMLHttpRequest()
162
+ }
163
+ catch(e) {
164
+ try {
165
+ this.xh = new ActiveXObject('Msxml2.XMLHTTP')
166
+ }
167
+ catch(e) {
168
+ try {
169
+ this.xh = new ActiveXObject('Microsoft.XMLHTTP')
170
+ }
171
+ catch(e) {
172
+ this.xh = false;
173
+ }
174
+ }
175
+ }
176
+ if(!this.xh) {
177
+ return false;
178
+ }
179
+ this.xh.owner = this;
180
+ this.method = method;
181
+ this.path = path;
182
+ this.data = data;
183
+ this.callback = callback;
184
+ this.xh.onreadystatechange = this.stateChange;
185
+ this.xh.open(
186
+ "POST",
187
+ nf.api.endpoint +
188
+ ( nf.api.password
189
+ ? "?pw=" + encodeURIComponent(nf.api.password)
190
+ : ''
191
+ ),
192
+ true
193
+ );
194
+ this.xh.setRequestHeader('Content-Type', 'application/x-netfira-webconnect-packed');
195
+ this.body = method + " /" + nf.api.version + "/" + path + " HTTP/1.1\r\n";
196
+ if(!nf.api.headers['Content-Type']) {
197
+ nf.api.headers['Content-Type'] = 'application/json'
198
+ }
199
+ for(e in nf.api.headers) {
200
+ if(nf.api.headers.hasOwnProperty(e)) // <----------- This stops methods being added to post data
201
+ {
202
+ this.body += e + ': ' + nf.api.headers[e] + "\r\n";
203
+ }
204
+ }
205
+ if(data !== null) {
206
+ if(typeof data == 'string') {
207
+ if('sendAsBinary' in this.xh) {
208
+ this.body += "\r\n" + data;
209
+ }
210
+ else {
211
+ this.body += "Content-Encoding: base64\r\n\r\n" + nf.base64.encode(data);
212
+ }
213
+ }
214
+ else if(typeof data == 'object') {
215
+ this.body += "\r\n" + nf.json_encode(data);
216
+ }
217
+ }
218
+ this.xh.sendAsBinary
219
+ ? this.xh.sendAsBinary(this.body)
220
+ : this.xh.send(this.body);
221
+ },
222
+ findEndpoint: function() {
223
+ var scripts = document.getElementsByTagName('script');
224
+ var a = scripts[scripts.length - 1].src.split('?', 2);
225
+ this.endpoint = a[0].replace(/\/\d+\/web\/nf\.js/, '');
226
+ // this.endpoint=a[0];
227
+ // if(a.length<2) return;
228
+ // var p=a[1].split('&');
229
+ // var d={};
230
+ // for(var i=0;i<p.length;i++){
231
+ // a=p[i].split('=',2);
232
+ // d[decodeURIComponent(a[0])]=decodeURIComponent(a[1]);
233
+ // }
234
+ // if('pw' in d) this.password=d.pw;
235
+ // if('v' in d) this.version=parseFloat(d.v);
236
+ }
237
+ }
238
+
239
+ nf.api.Call.prototype = {
240
+
241
+ stateChange: function() {
242
+ if(this.readyState != 4) {
243
+ return;
244
+ }
245
+ this.owner.success = this.status == 200 || this.status == 201;
246
+ var r, t = this.responseText || '';
247
+ if(this.owner.success && t.match(/^[{[][\s\S]*[}\]]/)) {
248
+ eval('r=' + t + ';');
249
+ this.owner.success &= !r.errorCode;
250
+ } else {
251
+ r = t;
252
+ }
253
+ if(!this.owner.success && ('onerror' in this.owner)) {
254
+ this.owner.onerror(r);
255
+ }
256
+ else {
257
+ this.owner.callback(r);
258
+ }
259
+ },
260
+
261
+ cancel: function() {
262
+ this.callback = function() {
263
+ };
264
+ return null;
265
+ },
266
+
267
+ set: function(name, value) {
268
+ this[name] = value;
269
+ return this;
270
+ }
271
+ };
272
+ nf.currency = function(n, dec, symbol) {
273
+ symbol = symbol || '$';
274
+ if(typeof n == 'string') {
275
+ n = parseFloat(n.replace(/[^-\d.]/g, '').replace(/^$/, '0'));
276
+ }
277
+ var neg = false;
278
+ if(neg = n < 0) {
279
+ n *= -1;
280
+ }
281
+ n = Math.round(n * 100) / 100;
282
+ if(!dec) {
283
+ dec = n == Math.floor(n) ? -1 : 1;
284
+ }
285
+ var ret = Math.floor(n).toString();
286
+ while(ret.match(/\d{4}/)) {
287
+ ret = ret.replace(/^(.*\d)(\d{3})(,|$)/, '$1,$2$3');
288
+ }
289
+ if(dec > 0) {
290
+ ret += '.' + n.toFixed(2).toString().replace(/\d+\./, '');
291
+ }
292
+ return symbol + (neg ? '-' : '') + ret;
293
+ };
294
+
295
+ nf.ucfirst = function(str) {
296
+ if(typeof str !== 'string') {
297
+ str = str.toString();
298
+ }
299
+ if(str == '') {
300
+ return '';
301
+ }
302
+ var ret = str.substr(0, 1).toUpperCase();
303
+ if(str.length > 1) {
304
+ ret += str.substr(1).toLowerCase();
305
+ }
306
+ return ret;
307
+ };
308
+
309
+ nf.base64 = {
310
+ pool: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
311
+ encode: function(input) {
312
+ var output = "", c = [], e, i = 0, j;
313
+ while(i < input.length) {
314
+ for(j = 0; j < 3; j++) {
315
+ c[j] = input.charCodeAt(i++);
316
+ }
317
+ e = [c[0] >> 2, ((c[0] & 3) << 4) | (c[1] >> 4), ((c[1] & 0xF) << 2) | (c[2] >> 6), c[2] & 0x3F];
318
+ if(isNaN(c[1])) {
319
+ e[2] = e[3] = 64;
320
+ }
321
+ else if(isNaN(c[2])) {
322
+ e[3] = 64;
323
+ }
324
+ for(j = 0; j < 4; j++) {
325
+ output += this.pool.charAt(e[j]);
326
+ }
327
+ }
328
+ return output;
329
+ },
330
+ decode: function(input) {
331
+ var output = "", c, e = [], i = 0, j;
332
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
333
+ while(i < input.length) {
334
+ for(j = 0; j < 4; j++) {
335
+ e[j] = this.pool.indexOf(input.charAt(i++));
336
+ }
337
+ c = [(e[0] << 2) | (e[1] >> 4), ((e[1] & 0xF) << 4) | (e[2] >> 2), ((e[2] & 3) << 6) | e[3]];
338
+ for(j = 0; j < 3; j++) {
339
+ if(!j || e[j + 1] != 64) {
340
+ output += String.fromCharCode(c[j]);
341
+ }
342
+ }
343
+ }
344
+ return output;
345
+ },
346
+ validate: function(input) {
347
+ return !!input.toString().match(/^(?:[/+a-z0-9]{4})*(?:[/+a-z0-9]{2}[=/+a-z0-9]{2})?$/i);
348
+ }
349
+ };
350
+
351
+ nf.md5 = function(string, raw) {
352
+
353
+ var s = arguments.callee.support,
354
+ x = s.toWordArray(string),
355
+ l = x.length, f = raw ? s.wordToString : s.wordToHex,
356
+ k, A, B, C, D, a, b, c, d,
357
+ S11 = 7, S12 = 12, S13 = 17, S14 = 22,
358
+ S21 = 5, S22 = 9 , S23 = 14, S24 = 20,
359
+ S31 = 4, S32 = 11, S33 = 16, S34 = 23,
360
+ S41 = 6, S42 = 10, S43 = 15, S44 = 21;
361
+
362
+ a = 0x67452301;
363
+ b = 0xEFCDAB89;
364
+ c = 0x98BADCFE;
365
+ d = 0x10325476;
366
+
367
+ for(k = 0; k < l; k += 16) {
368
+ A = a;
369
+ B = b;
370
+ C = c;
371
+ D = d;
372
+ a = s.f(a, b, c, d, x[k + 0], S11, 0xD76AA478);
373
+ d = s.f(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
374
+ c = s.f(c, d, a, b, x[k + 2], S13, 0x242070DB);
375
+ b = s.f(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
376
+ a = s.f(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
377
+ d = s.f(d, a, b, c, x[k + 5], S12, 0x4787C62A);
378
+ c = s.f(c, d, a, b, x[k + 6], S13, 0xA8304613);
379
+ b = s.f(b, c, d, a, x[k + 7], S14, 0xFD469501);
380
+ a = s.f(a, b, c, d, x[k + 8], S11, 0x698098D8);
381
+ d = s.f(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
382
+ c = s.f(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
383
+ b = s.f(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
384
+ a = s.f(a, b, c, d, x[k + 12], S11, 0x6B901122);
385
+ d = s.f(d, a, b, c, x[k + 13], S12, 0xFD987193);
386
+ c = s.f(c, d, a, b, x[k + 14], S13, 0xA679438E);
387
+ b = s.f(b, c, d, a, x[k + 15], S14, 0x49B40821);
388
+ a = s.g(a, b, c, d, x[k + 1], S21, 0xF61E2562);
389
+ d = s.g(d, a, b, c, x[k + 6], S22, 0xC040B340);
390
+ c = s.g(c, d, a, b, x[k + 11], S23, 0x265E5A51);
391
+ b = s.g(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
392
+ a = s.g(a, b, c, d, x[k + 5], S21, 0xD62F105D);
393
+ d = s.g(d, a, b, c, x[k + 10], S22, 0x2441453);
394
+ c = s.g(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
395
+ b = s.g(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8);
396
+ a = s.g(a, b, c, d, x[k + 9], S21, 0x21E1CDE6);
397
+ d = s.g(d, a, b, c, x[k + 14], S22, 0xC33707D6);
398
+ c = s.g(c, d, a, b, x[k + 3], S23, 0xF4D50D87);
399
+ b = s.g(b, c, d, a, x[k + 8], S24, 0x455A14ED);
400
+ a = s.g(a, b, c, d, x[k + 13], S21, 0xA9E3E905);
401
+ d = s.g(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8);
402
+ c = s.g(c, d, a, b, x[k + 7], S23, 0x676F02D9);
403
+ b = s.g(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A);
404
+ a = s.h(a, b, c, d, x[k + 5], S31, 0xFFFA3942);
405
+ d = s.h(d, a, b, c, x[k + 8], S32, 0x8771F681);
406
+ c = s.h(c, d, a, b, x[k + 11], S33, 0x6D9D6122);
407
+ b = s.h(b, c, d, a, x[k + 14], S34, 0xFDE5380C);
408
+ a = s.h(a, b, c, d, x[k + 1], S31, 0xA4BEEA44);
409
+ d = s.h(d, a, b, c, x[k + 4], S32, 0x4BDECFA9);
410
+ c = s.h(c, d, a, b, x[k + 7], S33, 0xF6BB4B60);
411
+ b = s.h(b, c, d, a, x[k + 10], S34, 0xBEBFBC70);
412
+ a = s.h(a, b, c, d, x[k + 13], S31, 0x289B7EC6);
413
+ d = s.h(d, a, b, c, x[k + 0], S32, 0xEAA127FA);
414
+ c = s.h(c, d, a, b, x[k + 3], S33, 0xD4EF3085);
415
+ b = s.h(b, c, d, a, x[k + 6], S34, 0x4881D05);
416
+ a = s.h(a, b, c, d, x[k + 9], S31, 0xD9D4D039);
417
+ d = s.h(d, a, b, c, x[k + 12], S32, 0xE6DB99E5);
418
+ c = s.h(c, d, a, b, x[k + 15], S33, 0x1FA27CF8);
419
+ b = s.h(b, c, d, a, x[k + 2], S34, 0xC4AC5665);
420
+ a = s.i(a, b, c, d, x[k + 0], S41, 0xF4292244);
421
+ d = s.i(d, a, b, c, x[k + 7], S42, 0x432AFF97);
422
+ c = s.i(c, d, a, b, x[k + 14], S43, 0xAB9423A7);
423
+ b = s.i(b, c, d, a, x[k + 5], S44, 0xFC93A039);
424
+ a = s.i(a, b, c, d, x[k + 12], S41, 0x655B59C3);
425
+ d = s.i(d, a, b, c, x[k + 3], S42, 0x8F0CCC92);
426
+ c = s.i(c, d, a, b, x[k + 10], S43, 0xFFEFF47D);
427
+ b = s.i(b, c, d, a, x[k + 1], S44, 0x85845DD1);
428
+ a = s.i(a, b, c, d, x[k + 8], S41, 0x6FA87E4F);
429
+ d = s.i(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0);
430
+ c = s.i(c, d, a, b, x[k + 6], S43, 0xA3014314);
431
+ b = s.i(b, c, d, a, x[k + 13], S44, 0x4E0811A1);
432
+ a = s.i(a, b, c, d, x[k + 4], S41, 0xF7537E82);
433
+ d = s.i(d, a, b, c, x[k + 11], S42, 0xBD3AF235);
434
+ c = s.i(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB);
435
+ b = s.i(b, c, d, a, x[k + 9], S44, 0xEB86D391);
436
+ a = s.add(a, A);
437
+ b = s.add(b, B);
438
+ c = s.add(c, C);
439
+ d = s.add(d, D);
440
+ }
441
+
442
+ return f(a) + f(b) + f(c) + f(d);
443
+ }
444
+
445
+ nf.md5.support = {
446
+ rotate: function(v, o) {
447
+ return (v << o) | (v >>> (32 - o));
448
+ },
449
+
450
+ add: function(lX, lY) {
451
+ var lX4, lY4, lX8, lY8, r;
452
+ lX8 = (lX & 0x80000000);
453
+ lY8 = (lY & 0x80000000);
454
+ lX4 = (lX & 0x40000000);
455
+ lY4 = (lY & 0x40000000);
456
+ r = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
457
+ if(lX4 & lY4) {
458
+ return (r ^ 0x80000000 ^ lX8 ^ lY8);
459
+ }
460
+ if(lX4 | lY4) {
461
+ if(r & 0x40000000) {
462
+ return (r ^ 0xC0000000 ^ lX8 ^ lY8);
463
+ } else {
464
+ return (r ^ 0x40000000 ^ lX8 ^ lY8);
465
+ }
466
+ } else {
467
+ return (r ^ lX8 ^ lY8);
468
+ }
469
+ },
470
+
471
+ F: function(x, y, z) {
472
+ return (x & y) | ((~x) & z);
473
+ },
474
+ G: function(x, y, z) {
475
+ return (x & z) | (y & (~z));
476
+ },
477
+ H: function(x, y, z) {
478
+ return (x ^ y ^ z);
479
+ },
480
+ I: function(x, y, z) {
481
+ return (y ^ (x | (~z)));
482
+ },
483
+
484
+ f: function(a, b, c, d, x, s, ac) {
485
+ return this.z(a, b, c, d, x, s, ac, this.F);
486
+ },
487
+
488
+ g: function(a, b, c, d, x, s, ac) {
489
+ return this.z(a, b, c, d, x, s, ac, this.G);
490
+ },
491
+
492
+ h: function(a, b, c, d, x, s, ac) {
493
+ return this.z(a, b, c, d, x, s, ac, this.H);
494
+ },
495
+
496
+ i: function(a, b, c, d, x, s, ac) {
497
+ return this.z(a, b, c, d, x, s, ac, this.I);
498
+ },
499
+
500
+ z: function(a, b, c, d, x, s, ac, f) {
501
+ return this.add(this.rotate(this.add(a, this.add(this.add(f(b, c, d), x), ac)), s), b);
502
+ },
503
+
504
+ toWordArray: function(string) {
505
+ var c,
506
+ l = string.length,
507
+ n1 = l + 8,
508
+ n2 = (n1 - (n1 % 64)) / 64,
509
+ n = (n2 + 1) * 16,
510
+ a = Array(n - 1),
511
+ bp = 0,
512
+ bc = 0;
513
+ while(bc < l) {
514
+ c = (bc - (bc % 4)) / 4;
515
+ bp = (bc % 4) * 8;
516
+ a[c] = (a[c] | (string.charCodeAt(bc) << bp));
517
+ bc++;
518
+ }
519
+ c = (bc - (bc % 4)) / 4;
520
+ bp = (bc % 4) * 8;
521
+ a[c] = a[c] | (0x80 << bp);
522
+ a[n - 2] = l << 3;
523
+ a[n - 1] = l >>> 29;
524
+ return a;
525
+ },
526
+
527
+ wordToHex: function(l) {
528
+ var r = "", t = "", b, c;
529
+ for(c = 0; c < 4; c++) {
530
+ b = (l >>> (c * 8)) & 255;
531
+ t = "0" + b.toString(16);
532
+ r = r + t.substr(t.length - 2, 2);
533
+ }
534
+ return r;
535
+ },
536
+
537
+ wordToString: function(l) {
538
+ var r = '', i;
539
+ for(i = 0; i < 4; i++) {
540
+ r += String.fromCharCode((l >> (i * 8)) & 0xFF);
541
+ }
542
+ return r;
543
+ }
544
+
545
+ };
546
+
547
+ nf.timeString = function() {
548
+ var d = new Date();
549
+ return ((d.getHours() + 11) % 12 + 1) + ':' +
550
+ d.getMinutes().toString().replace(/^(\d)$/, '0$1') + ':' +
551
+ d.getSeconds().toString().replace(/^(\d)$/, '0$1') +
552
+ (d.getHours() < 12 ? 'am' : 'pm');
553
+ };
554
+
555
+ Date.prototype.toJSON = function() {
556
+ return (this.getUTCFullYear() + '-' +
557
+ (this.getUTCMonth() + 1) + '-' +
558
+ this.getUTCDate() + 'T' +
559
+ this.getUTCHours() + ':' +
560
+ this.getUTCMinutes() + ':' +
561
+ this.getUTCSeconds() + 'Z')
562
+ .replace(/([^\d])(\d)([^\d])/g, '$10$2$3');
563
+ };
564
+
565
+ if(!String.prototype.trim) {
566
+ String.prototype.trim = function() {
567
+ return this.replace(/(^\s+|\s+$)/g, '');
568
+ };
569
+ }
570
+
571
+ if(!Array.prototype.forEach) {
572
+ Array.prototype.forEach = function(func, scope) {
573
+ scope = scope || this;
574
+ for(var i = 0, l = this.length; i < l; i++) {
575
+ func.call(scope, this[i], i, this);
576
+ }
577
+ };
578
+ }
579
+
580
+ if(!Array.prototype.filter) {
581
+ Array.prototype.filter = function(func, scope) {
582
+ scope = scope || this;
583
+ var ret = [];
584
+ for(var i = 0, l = this.length; i < l; i++) {
585
+ if(func.call(scope, this[i], i, this)) {
586
+ ret.push(this[i]);
587
+ }
588
+ }
589
+ return ret;
590
+ };
591
+ }
592
+
593
+ if(!Array.prototype.map) {
594
+ Array.prototype.map = function(func, scope) {
595
+ scope = scope || this;
596
+ var ret = [];
597
+ for(var i = 0, l = this.length; i < l; i++) {
598
+ ret.push(func.call(scope, this[i], i, this));
599
+ }
600
+ return ret;
601
+ };
602
+ }
603
+
604
+ if(!String.prototype.toHTML) {
605
+ String.prototype.toHTML = function() {
606
+ return this
607
+ .replace('&', '&#x26;')
608
+ .replace('<', '&#x3C;')
609
+ .replace('>', '&#x3E;')
610
+ .replace('"', '&#x22;')
611
+ };
612
+ }
613
+
614
+ if(!Array.prototype.indexOf) {
615
+ Array.prototype.indexOf = function(elt) {
616
+ var len = this.length;
617
+
618
+ var from = Number(arguments[1]) || 0;
619
+ from = (from < 0)
620
+ ? Math.ceil(from)
621
+ : Math.floor(from);
622
+ if(from < 0) {
623
+ from += len;
624
+ }
625
+
626
+ for(; from < len; from++) {
627
+ if(from in this && this[from] === elt) {
628
+ return from;
629
+ }
630
+ }
631
+
632
+ return -1;
633
+ };
634
+ }
635
+
636
+ nf.api.findEndpoint();