-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathSystem.debug.js
More file actions
3953 lines (3734 loc) · 144 KB
/
System.debug.js
File metadata and controls
3953 lines (3734 loc) · 144 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//============================================================================
// Jocys.com JavaScript.NET Classes (In C# Object Oriented Style)
// Created by Evaldas Jocys <evaldas@jocys.com>
//=============================================================================
// Namespaces
//-----------------------------------------------------------------------------
// <PropertyGroup>
// <RootNamespace>System</RootNamespace>
// <PropertyGroup>
//-----------------------------------------------------------------------------
var System = {};
window.System = {
__namespace: true,
__typeName: "Sys",
getName: function () { return "Sys"; },
__upperCaseTypes: {}
};
//-----------------------------------------------------------------------------
// CLASS: System.Type
//-----------------------------------------------------------------------------
System.Type = function () {
/// <summary>
/// Initializes a new instance of the System.Type class.
/// </summary>
/// <remarks>These XML Comments were created only for IntelliSense.</remarks>
/// <summary>
/// Initializes a new instance of the System.Type class.
/// </summary>
this.Name = "name";
this.Namespace = "";
this.FullName = "";
//---------------------------------------------------------
this.ToString = function () {
/// <summary>
/// Returns a String representing the name of the current Type.
/// </summary>
/// <returns>A String representing the name of the current System.Type.</returns>
return this.FullName;
};
//---------------------------------------------------------
function initialize() {
var tn = "";
tn = arguments[0];
this.FullName = tn;
var ta = [];
if (tn) {
ta = tn.split('.');
this.Name = ta[ta.length - 1];
this.Namespace = ta.slice(0, ta.length - 2).join('.');
//tnarguments[0];
//tn.
//this.Namespace = nspace;
//this.Name = name;
//this.FullName = this.Namespace +"."+ this.Name
}
}
initialize.apply(this, arguments);
};
//-----------------------------------------------------------------------------
System.Type.Inherits = function (d, s) {
for (var property in s) {
if (property === "__typeName") continue;
if (property === "GetType") continue;
d[property] = s[property];
}
return s;
};
//-----------------------------------------------------------------------------
System.Type.RegisterNamespace = function (namespacePath) {
// If Microsoft Ajax function exist then...
if (typeof Type !== "undefined" && typeof Type.registerNamespace === "function") {
// Register namespace.
//Type.registerNamespace.
Type.registerNamespace.apply(this, arguments);
} else {
var rootObject = window;
var namespaceParts = namespacePath.split('.');
for (var i = 0; i < namespaceParts.length; i++) {
var currentPart = namespaceParts[i];
var ns = rootObject[currentPart];
if (!ns) ns = rootObject[currentPart] = {};
ns.__typeName = namespacePath;
ns.__namespace = true;
rootObject = ns;
}
}
};
//-----------------------------------------------------------------------------
System.Type.RegisterClass = function (typeName, baseType, interfaceTypes) {
var o = eval(typeName);
// If Microsoft Ajax function exist then...
if (typeof Type !== "undefined" && typeof Type.registerClass === "function") {
// Register class.
Type.registerClass.apply(o, arguments);
} else {
o.__typeName = typeName;
o.__class = true;
}
o.prototype.GetType = function () { return new System.Type(typeName); };
};
//-----------------------------------------------------------------------------
System.Type.RegisterInterface = function (typeName, baseType) { };
//-----------------------------------------------------------------------------
System.Type.RegisterEnum = function (type, flags) {
// If Microsoft Ajax function exist then...
var o = eval(type);
if (typeof Type !== "undefined" && typeof Type.registerEnum === "function") {
// Register namespace.
Type.registerEnum.apply(o, arguments);
} else {
for (var i in o.prototype) o[i] = o.prototype[i];
o.__enum = true;
o.__flags = flags;
}
};
//-----------------------------------------------------------------------------
System.Type.RegisterProperty = function (name) {
var o = me[name];
me[name] = function (value) {
if (arguments.length === 0) return me[name].get();
if (arguments.length === 1) me[name].set(value);
};
};
//-----------------------------------------------------------------------------
System.Type.RegisterNamespace("System");
System.Type.RegisterClass("System.Type");
//-----------------------------------------------------------------------------
System.Type.GetType = function (typeName) {
/// <summary>
/// Gets the System.Type with the specified name, performing a case-sensitive
/// search.
/// </summary>
/// <param type="string" name="typeName">The name of the System.Type.AssemblyQualifiedName to get.</param>
/// <returns type="System.Type">
/// The System.Type with the specified name, if found; otherwise, null.
/// </returns>
var type = new System.Type(typeName);
return type;
};
//=============================================================================
//=============================================================================
// TypeCode Enum
//-----------------------------------------------------------------------------
System.TypeCode = function () {
/// <summary>Specifies the type of an object.</summary>
/// <field name="Empty" type="Number" integer="true" static="true">A null reference.</field>
/// <field name="Object" type="Number" integer="true" static="true">Represents any reference or value type not represented by another TypeCode.</field>
/// <field name="DBNull" type="Number" integer="true" static="true">A database null (column) value.</field>
/// <field name="Boolean" type="Number" integer="true" static="true">A simple type representing Boolean values of true or false.</field>
/// <field name="Char" type="Number" integer="true" static="true">Unsigned 16-bit integers with values between 0 and 65535.</field>
/// <field name="SByte" type="Number" integer="true" static="true">Signed 8-bit integers with values between -128 and 127.</field>
/// <field name="Byte" type="Number" integer="true" static="true">Unsigned 8-bit integers with values between 0 and 255.</field>
/// <field name="Int16" type="Number" integer="true" static="true">Signed 16-bit integers with values between -32768 and 32767.</field>
/// <field name="UInt16" type="Number" integer="true" static="true">Unsigned 16-bit integers with values between 0 and 65535.</field>
/// <field name="Int32" type="Number" integer="true" static="true">Signed 32-bit integers with values between -2147483648 and 2147483647.</field>
/// <field name="UInt32" type="Number" integer="true" static="true">Unsigned 32-bit integers with values between 0 and 4294967295.</field>
/// <field name="Int64" type="Number" integer="true" static="true">Signed 64-bit integers with values between -9223372036854775808 and 9223372036854775807.</field>
/// <field name="UInt64" type="Number" integer="true" static="true">Unsigned 64-bit integers with values between 0 and 18446744073709551615.</field>
/// <field name="Single" type="Number" integer="true" static="true">A floating point type representing values ranging from approximately 1.5 x 10 -45 to 3.4 x 10 38 with a precision of 7 digits.</field>
/// <field name="Double" type="Number" integer="true" static="true">A floating point type representing values ranging from approximately 5.0 x 10 -324 to 1.7 x 10 308 with a precision of 15-16 digits.</field>
/// <field name="Decimal" type="Number" integer="true" static="true">A simple type representing values ranging from 1.0 x 10 -28 to approximately 7.9 x 10 28 with 28-29 significant digits.</field>
/// <field name="DateTime" type="Number" integer="true" static="true">A type representing a date and time value.</field>
/// <field name="String" type="Number" integer="true" static="true">A sealed class type representing Unicode character strings.</field>
};
System.TypeCode.prototype = {
Empty: 0,
Object: 1,
DBNull: 2,
Boolean: 3,
Char: 4,
SByte: 5,
Byte: 6,
Int16: 7,
UInt16: 8,
Int32: 9,
UInt32: 10,
Int64: 11,
UInt64: 12,
Single: 13,
Double: 14,
Decimal: 15,
DateTime: 16,
String: 18
};
System.Type.RegisterEnum("System.TypeCode");
//=============================================================================
// TimeUnitType Enum
//-----------------------------------------------------------------------------
System.TimeUnitType = function () { };
System.TimeUnitType.prototype = {
Seconds: 0,
Minutes: 1,
Hours: 2,
Days: 3
};
System.Type.RegisterEnum("System.TimeUnitType");
//=============================================================================
// Extensions
//-----------------------------------------------------------------------------
System.SR = function () { };
System.SR.prototype = {
// System.resources
NotReadableStream: "The base stream is not readable.",
NotWriteableStream: "The base stream is not writeable.",
ArgumentOutOfRange_Enum: "Enum value was out of legal range."
};
System.Type.RegisterClass("System.SR");
System.SR.GetString = function (name) {
/// <summary>
/// Searches for a <see cref="T:System.String" /> resource with the specified name.
/// </summary>
/// <param name="name">Name of the resource to search for.</param>
/// <returns>The value of a resource, if the value is a <see cref="T:System.String" />.</returns>
var message = System.SR.prototype[name];
if (!message) message = name;
return message;
};
//=============================================================================
// Extensions
//-----------------------------------------------------------------------------
System.Extensions = function () {
/// <summary>
/// Create class to extend javascript objects. This function will run at the end
/// of this file.
/// </summary>
//---------------------------------------------------------
// METHOD: Apply
//---------------------------------------------------------
this.Apply = function () {
var isServerSide = false;
if (typeof Response === "object") isServerSide = true;
if (!isServerSide) {
// Create function $(...) - Get objects by Ids.
if (typeof this.$ === "undefined") this.$ = function () {
return document.getElementById(arguments[0]);
};
}
// EXTENSIONS: Object
//Object.prototype.ToTrace = function(){ System.Class.ListProperties(this,this.toString());};
// Object.prototype.GetType = function(){
// //if (typeof(this.GetType) == "function") return this.GetType();
// var type = new System.Type();
// type.Name = typeof(this);
// return type;
// }
// EXTENSIONS: Date
Date.prototype.SubtractDays = System.DateTime.SubtractDays;
Date.prototype.SubtractMonths = System.DateTime.SubtractMonths;
Date.prototype.GetFromString = System.DateTime.GetFromString;
Date.prototype.GetFromUtcString = System.DateTime.GetFromUtcString;
Date.prototype.DefaultFormat = "yyyy-MM-dd HH:mm:ss";
Date.prototype.ToString = System.DateTime.ToString;
Date.prototype.Subtract = System.DateTime.Subtract;
Date.prototype.Ticks = System.DateTime.Ticks;
Date.prototype.ToUniversalTime = System.DateTime.ToUniversalTime;
Number.prototype.ToString = Number.prototype.toString;
// EXTENSIONS: String
String.prototype.Trim = function (string) { return System.Text.Trim(this, string); };
String.prototype.ToCamelCase = function () { return System.Text.ToCamelCase(this); };
String.Format = function (format, args) {
/// <summary>Appends the string returned by processing a composite format string.</summary>
/// <param name="format">A composite format string.</param>
/// <param name="An array of objects to format.">A composite format string.</param>
/// <returns>A reference to this instance with format appended.</returns>
//
// Sync this method with String.Format later.
args = Array.prototype.slice.call(arguments, 1);
var value = format.replace(/{(\d+)(:([xX]?\d+))?(,([-]?\d+))?}/g,
function (matchString, number) {
var value = typeof args[number] !== 'undefined' ? args[number] : matchString;
var hexMatch = matchString.match(":([xX])(\\d+)");
if (hexMatch) {
value = value.toString(16);
// Change case.
value = hexMatch[1] === "x"
? value.toLowerCase()
: value.toUpperCase();
// Add zeros.
num = parseInt(hexMatch[2]);
var z = "";
for (i = value.length; i < num; i++)
z += "0";
value = z + value;
}
var padMatch = matchString.match(",([-]?\\d+)");
var num;
if (padMatch) {
num = parseInt(padMatch[1]);
value = value.toString();
var ln = Math.abs(num);
var s = "";
for (i = value.length; i < ln; i++)
s += " ";
value = num >= 0
? s + value
: value + s;
}
return value;
});
return value;
};
String.Join = function (separator, value, startIndex, count) {
if (!separator) separator = "";
if (!startIndex) startIndex = 0;
if (!count) count = value.length;
if (count === 0) return "";
var length = 0;
var end = startIndex + count - 1;
var s = "";
for (var i = startIndex; i <= end; i++) {
if (i > startIndex) s += separator;
s += value[i];
}
return s;
};
// EXTENSIONS: Array
Array.prototype.Clone = function () {
var buffer = this.slice(0, this.length);
for (var i = 0; i < this.length; i++) buffer[i] = this[i];
return buffer;
};
// // Firefox InnerText
// if (typeof HTMLElement != "undefined" && typeof HTMLElement.prototype.__defineGetter__ != "undefined"){
// HTMLElement.prototype.__defineGetter__("innerText", function(){ return this.textContent; });
// HTMLElement.prototype.__defineSetter__("innerText", function(sText){ this.innerHTML = sText.textContent; });
// }
};
};
System.Type.RegisterClass("System.Extensions");
//=============================================================================
// CLASS: System.IO.Compression.DeflateStream
//-----------------------------------------------------------------------------
System.AsyncCallback = function (ar) {
/// <summary>
/// References a method to be called when a corresponding asynchronous operation completes.
/// </summary>
/// <param name="ar">The result of the asynchronous operation.</param>
};
System.Type.RegisterClass("System.AsyncCallback");
System.AsyncWriteDelegate = function (array, offset, count, isAsync) {
// internal delegate void AsyncWriteDelegate(byte[] array, int offset, int count, bool isAsync);
};
System.Type.RegisterClass("System.AsyncWriteDelegate");
//=============================================================================
// Client side extensions
//-----------------------------------------------------------------------------
System.GetScriptsPath = function () {
var url = "";
var i;
var match;
var rx = new RegExp("System(\.debug)?\.js", "gi");
var head = document.getElementsByTagName("head")[0];
var scripts = head.getElementsByTagName("script");
for (i = 0; i < scripts.length; i++) {
match = scripts[i].src.match(rx);
if (match) {
url = scripts[i].src.replace(rx, "");
break;
}
}
// If url is still empty then...
if (url.length === 0) {
scripts = document.getElementsByTagName("script");
for (i = 0; i < scripts.length; i++) {
match = scripts[i].src.match(rx);
if (match) {
url = scripts[i].src.replace(rx, "");
break;
}
}
}
return url;
};
// Make this class static.
System.Extensions = new System.Extensions();
// Use this to apply extensions to current context.
// System.Extensions.Apply.apply(this);
//=============================================================================
// System.Type.Class
//-----------------------------------------------------------------------------
/* Every JavaScript object has a prototype property. This property is what makes
OOP possible in JavaScript, but it is a bit unusual if you come from other
OO languages. Here's how it works. When you access an object property, the
interpreter will look at the current object's properties to see if one by that
name exists. If the name does not exist there, then the interpreter looks at the
prototype property of the object to see if that object, the one pointed to by
the prototype property, has the named property. If there is no property there,
then the interpreter looks to see if the prototype property has a prototype
property. If it does, then this process continues until either the property is
found or until there are no more prototype properties to search. */
System.Type.Class = System.Type.Class ? System.Type.Class : {};
System.Type.Class.Root = this;
System.Type.Class.Inherit = function () {
/// <summary>
///
/// </summary>
/// <returns>void</returns>
Trace.Write("exec System.Class.Inherit(arguments){", 1);
// Create object
this.Classes = [];
this.Objects = [];
var i;
for (i = 0; i < arguments.length; i++) {
// We need to tell to class to skip initialization.
arguments[i].prototype.NoInit = true;
this.Objects.push(new arguments[i]);
arguments[i].prototype.NoInit = false;
this.Classes.push(arguments[i]);
}
for (i = 0; i < this.Objects.length; i++) {
if (i === 0) {
Trace.Write("Inherit: '" + this.Objects[i].Type + "' Class From: ", 1);
} else {
Trace.Write(this.Objects[i].Type);
}
}
Trace.Write("Done", -2);
var finClass = this.Classes[0];
var finObject = this.Objects[0];
for (var cid = this.Classes.length - 1; cid > 0; cid--) {
var srcClass = this.Classes[cid];
var srcObject = this.Objects[cid];
var dstObject = this.Objects[cid - 1];
var dstClass = this.Classes[cid - 1];
Trace.Write("// Inherit: '" + dstObject.Type + "' From: '" + srcObject.Type + "'");
//Trace.Write("Inherit: "+dstClass+" From: "+srcClass);
//METHOD1: Copy properties one by one into destination class prototype object.
finClass.prototype = srcObject;
Trace.Write("1. Import Class Properties: " + finObject.Type + ".prototype <- " + srcObject.Type, 1);
// Copy one by one method.
//for (var property in srcObject){
// Trace.Write("."+property+"");
// finClass.prototype[property] = srcObject[property];
//}
Trace.Write("End Import", -2);
// The constructor property is used in scripts to determine an object's
// type. When we redefined the destinationClass prototype, we effectively
// changed the constructor to sourceClass. We need to fix this and
// Update subclass properties and methods.
Trace.Write("2. Fix Prototype Constructor", 1);
finClass.prototype.constructor = finClass;
// Copy one by one method.
//Trace.Write("Assign property: "+finObject.Type+" <- "+srcObject.Type+"["+property+"]");
//for (var property in finObject){
// finClass.prototype.constructor[property] = finObject[property];
//}
Trace.Write("End Fix", -2);
// Allow to call methods in a superclass that are hidden by redefined methods in a subclass.
Trace.Write("3. Allow to call methods in a superclass", 1);
//destinationClass.superclass = sourceClass.prototype;
Trace.Write("Import Superclass Properties: " + finObject.Type + ".superclass <- " + srcObject.Type + ".prototype");
finClass.superclass = srcClass.prototype;
// Copy one by one method.
//for (var property in srcClass.prototype){
// //Trace.Write("Assign property: "+finObject.Type+" <- "+srcObject.Type+"["+property+"]");
// finClass.superclass[property] = srcClass.prototype[property];
//}
Trace.Write("End Import", -2);
//System.Class.ListProperties(finClass,"finClass");
}
Trace.Write("} //System.Class.Inherit(arrguments)", -2);
};
System.Type.Class.Inherit = function (classTo, classFrom) {
/// <summary>
/// Inherit one class (subclass) from another (superclass);
/// </summary>
/// <returns>void</returns>
classTo.prototype = new classFrom();
// Update subclass properties and methods.
classTo.prototype.constructor = classTo;
// Allow to call methods in a superclass that are hidden by redefined methods in a subclass.
classTo.superclass = classFrom.prototype;
};
System.Type.Class.Exists = function (path) {
/// <summary>
/// Check if namespace exists.
/// </summary>
/// <returns>
/// True if namespace exists, false if not.
/// </returns>
var rootObject;
// If this is server side then...
if (typeof Response === "object") {
rootObject = System.Class.Root;
} else {
rootObject = System.Class.Root; //window;
}
var exists = true;
var parts = path.split('.');
for (var i = 0; i < parts.length; i++) {
var part = parts[i];
// If namespace does not exists then...
//Trace.Write("Part: "+part);
if (!rootObject[part]) {
// return false.
exists = false;
break;
}
rootObject = rootObject[part];
}
return exists;
};
// Added for compatibility only. Will be removed later.
// Make sure that the sub namespace Client exists.
System.Class = System.Class ? System.Class : {};
System.Class.Inherit = System.Type.Class.Inherit;
System.Class.Root = this;
//=============================================================================
// CLASS: Uri
//-----------------------------------------------------------------------------
System.Uri = function (uriString) {
/// <summary>
/// Initializes a new instance of the System.Uri class with the specified URI.
/// </summary>
/// <param type="string" name="uriString">A URI</param>
//---------------------------------------------------------
// http://www.domain.com:80/default.aspx?AudioMin=0&AudioMax=100
this.OriginalString;
// http://www.domain.com:80/default.aspx
this.AbsolutePath;
// ?AudioMin=0&AudioMax=100
this.Query;
this.QueryParams;
this.GetType = function () { return new System.Type("System.Uri"); };
//---------------------------------------------------------
this.GetQueryValue = function (name, ignoreCase) {
var value = null;
var pName;
if (ignoreCase === true) name = name.toLowerCase();
for (var property in this.QueryParams) {
pName = property;
if (ignoreCase === true) pName = property.toLowerCase();
if (name === pName) {
value = this.QueryParams[property];
break;
}
}
return value;
};
//---------------------------------------------------------
this.GetParameters = function (uri) {
var results = {};
if (uri === null) return results;
var query = uri.substring(uri.indexOf("?") + 1, uri.length);
var arr = query.split("&");
var item;
var name;
var value;
for (var i = 0; i < arr.length; i++) {
item = arr[i];
name = item.substring(0, item.indexOf("="));
value = item.substring(item.indexOf("=") + 1, item.length);
value = unescape(value);
results[name] = value;
}
return results;
};
//---------------------------------------------------------
function initialize() {
// Turn argument into a string type.
var u = arguments[0] + "";
this.OriginalString = u;
this.AbsolutePath = u.indexOf("?") > -1 ? u.substring(0, u.indexOf("?")) : u;
this.Query = u.indexOf("?") > -1 ? u.substring(u.indexOf("?"), u.length) : null;
this.QueryParams = this.GetParameters(this.Query);
}
initialize.apply(this, arguments);
};
System.Type.RegisterClass("System.Uri");
//=============================================================================
// CLASS: EventItem
//-----------------------------------------------------------------------------
//Using Delegates (C# Programming Guide)
// http://msdn2.microsoft.com/en-us/library/ms173172.aspx
System.EventItem = function () {
this.Node;
this.Name;
this.Handler;
this.Capture;
};
System.Type.RegisterClass("System.EventItem");
//=============================================================================
// CLASS: EventHandler (Delegate)
//-----------------------------------------------------------------------------
System.EventHandler = function (target, method, timeout) {
/// <summary>
/// This helper class simulates .NET concept of event delegate. (EventHandler)
/// </summary>
/// <param type="function" name="method">Method represented by Delegate.<param>
/// <param type="object" name="target">Context on which delegate invokes the instance method.<param>
/// <param type="int" name="timout">Add delay (in miliseconds) between event notification from source object and call of recipient object that have registered to receive that event.</param>
var me = this;
//---------------------------------------------------------
this.Method = null;
this.Target = null;
this.Timeout = null;
//---------------------------------------------------------
this.Invoke = function () {
if (typeof this.Timeout === "number") {
setTimeout(function () { return this.Method.apply(this.Target, arguments); }, this.Timeout);
} else {
return this.Method.apply(this.Target, arguments);
}
};
//---------------------------------------------------------
this.InvokeNative = function () {
var e = arguments[0] || window.event;
var sender = e.target || e.srcElement;
var args = new Array(2);
args[0] = sender;
args[1] = e;
if (typeof timeout === "number") {
setTimeout(function () { return method.apply(target, args); }, timeout);
} else {
return method.apply(target, args);
}
};
//---------------------------------------------------------
this.Initialize = function () {
this.Target = target;
this.Method = method;
//System.Class.Properties.ToTrace(me);
//Trace.Write(typeof(me.Target)+": "+nativeEvent);
};
this.Initialize();
};
System.Type.RegisterClass("System.EventHandler");
//=============================================================================
// CLASS: Event
//-----------------------------------------------------------------------------
System.Event = function (name) {
/// <summary>
/// This class simulates .NET eventing. (event delegate)
/// </summary>
//---------------------------------------------------------
this.args = {};
this._delegates = [];
this.name = name;
//---------------------------------------------------------
this.Add = function (delegate) {
/// <summary>
/// This function is used to add a callback object.
/// and a method.
/// </summary>
this._delegates[this._delegates.length] = delegate;
};
//---------------------------------------------------------
this.Remove = function (delegate) {
/// <summary>
/// This function is used to remove a callback object.
/// and a method.
/// </summary>
for (i = this._delegates.length - 1; i >= 0; i = i - 1) {
if (delegate === this._delegates[i]) {
this._delegates.splice(i, 1);
}
}
};
//---------------------------------------------------------
this.Fire = function (sender, eventArgs) {
/// <summary>
/// This function makes a call back into the object
/// that has registered for the event.
/// </summary>
for (var i = 0; i < this._delegates.length; i++) {
this._delegates[i].Invoke(sender, eventArgs);
}
};
};
System.Type.RegisterClass("System.Event");
//=============================================================================
// CLASS: EventArgs
//-----------------------------------------------------------------------------
System.EventArgs = function (name) {
/// <summary>
/// Event arguments.
/// </summary>
/// <param name="name">Name of event</param>
this.Name = "";
//---------------------------------------------------------
this.ToString = function () {
/// <summary>
/// Convert this object to string representation.
/// </summary>
var results = "";
for (var property in this) {
var skip = false;
// Don't show own methods.
skip = skip || property === "Initialize";
skip = skip || property === "ToString";
if (!skip) results += property + "='" + this[property] + "';";
}
results = "e[" + results + "]";
return results;
};
//---------------------------------------------------------
this.Initialize = function (name) {
this.Name = name ? name : "";
};
this.Initialize.apply(this, arguments);
};
System.Type.RegisterClass("System.EventArgs");
//=============================================================================
// CLASS: EventsManager
//-----------------------------------------------------------------------------
System.EventsManager = function (context) {
/// <summary>
/// Provides a way for automagically removing events from nodes and thus preventing memory leakage.
/// </summary>
/// <param name="context">Optional context of events. Default: window</param>
/// <example>
/// // Attach SomeButton_Click function to "click" event of "SomeButton" button.
/// Events.Add("SomeButton", "click", SomeButton_Click, false);
/// // Attach ButtonWithDelay_Click function to event "click" of "ButtonWithDelay" button.
/// // Delay execution by 2 seconds and run ButtonWithDelay_Click in this context.
/// Events.Add("ButtonWithDelay", "click", ButtonWithDelay_Click, false, this, 2000);
/// </example>
/// <remarks>
/// Original Idea by Mark Wubben
/// Rewriten as class by Evaldas Jocys [evaldas@jocys.com]
/// See http://novemberborn.net/javascript/event-cache for more information.
/// </remarks>
//---------------------------------------------------------
// Public properties.
//---------------------------------------------------------
// An array whose items are arrays which contain the information in the
// following order: node, eventName, eventHandler, capture.
this.Items = null;
this.Context = null;
//---------------------------------------------------------
// Private properties.
//---------------------------------------------------------
var me = this;
//---------------------------------------------------------
// METHOD: Add
//---------------------------------------------------------
this.Add = function (node, eventName, eventHandler, capture) {
/// <param type="bool" name="capture">true or false if we need to atach something to native DOM object.</param>
var success = true;
var id;
if (typeof node === "string") {
node = this.Context.document.getElementById(node);
id = node;
} else {
id = node.id;
}
var traceFound = typeof Trace !== "undefined";
if (traceFound) {
Trace.Write("call " + this.GetType().Name + ".Add(node, '" + eventName + "', eventHandler, " + capture + ")");
}
if (node) {
if (typeof capture !== "boolean") {
node[eventName].Add(eventHandler);
} else {
if (eventHandler.GetType && eventHandler.GetType().FullName === "System.EventHandler") eventHandler = eventHandler.InvokeNative;
// Attach handler to native DOM object.
if (node.addEventListener) {
node.addEventListener(eventName, eventHandler, capture);
} else if (node.attachEvent) {
if (traceFound) Trace.Write("thru System.EventHandler: " + eventHandler.Type);
var r = node.attachEvent("on" + eventName, eventHandler);
} else { /* */ }
this.AddItem(node, eventName, eventHandler, capture);
}
} else {
if (traceFound) Trace.Write("Error: " + this.GetType().Name + ".Add(...) - node '" + id + "' was not found!");
success = false;
}
return success;
};
//---------------------------------------------------------
// METHOD: Remove
//---------------------------------------------------------
// Use value returned by by this.Add if you want to remove same function.
this.Remove = function (node, eventName, eventHandler) {
if (typeof node === "string") node = this.Context.document.getElementById(node);
this.RemoveItem(node, eventName, eventHandler);
};
//---------------------------------------------------------
// METHOD: AddItem
//---------------------------------------------------------
// node - A reference to the node on which the event has been set.
// eventName - The name of the event.
// eventHandler - A reference to the function which handles the event.
// capture - determines whether the event is triggered in capture mode
// or not. Does not apply to Internet Explorer.
this.AddItem = function (node, eventName, eventHandler, capture) {
var ev = new System.EventItem();
ev.Node = node;
ev.Name = eventName;
ev.Handler = eventHandler;
ev.Capture = capture;
this.Items.push(ev);
};
//---------------------------------------------------------
// METHOD: RemoveItem
//---------------------------------------------------------
this.RemoveItem = function (node, eventName, eventHandler) {
var i, item;
for (i = this.Items.length - 1; i >= 0; i = i - 1) {
item = this.Items[i];
if (typeof item.Capture !== "boolean") {
item.Node[item.Name].Remove(item.Handler);
} else {
if (eventHandler.GetType && eventHandler.GetType().FullName === "System.EventHandler") eventHandler = eventHandler.InvokeNative;
if (node === item.Node && eventName === item.Name && eventHandler === item.Handler) {
if (item.Node.removeEventListener) {
item.Node.removeEventListener(item.Name, item.Handler, item.Capture);
} else if (item.Node.detachEvent) {
item.Node.detachEvent("on" + item.Name, item.Handler);
}
}
}
}
};
//---------------------------------------------------------
// METHOD: Dispose
//---------------------------------------------------------
// Remove all cached events.
this.Dispose = function () {
var i, item;
for (i = me.Items.length - 1; i >= 0; i = i - 1) {
item = me.Items[i];
if (typeof item.Capture !== "boolean") {
item.Node[item.Name].Remove(item.Handler);
} else {
var eventHandler = item.Handler;
if (eventHandler.GetType && eventHandler.GetType().FullName === "System.EventHandler") eventHandler = eventHandler.InvokeNative;
if (item.Node.removeEventListener) {
item.Node.removeEventListener(item.Name, item.Handler, item.Capture);
} else if (item.Node.detachEvent) {
item.Node.detachEvent("on" + item.Name, item.Handler);
}
}
}
};
//---------------------------------------------------------
// INIT: Class
//---------------------------------------------------------
this.InitializeClass = function () {
this.Context = context ? context : window;
this.Items = [];
this.Add(this.Context, 'unload', new System.EventHandler(this, this.Dispose), false);
};
this.InitializeClass();
};
System.Type.RegisterClass("System.EventsManager");
// If script is not on server side then...
if (typeof Response !== "object") {
var Events = new System.EventsManager();
System.EventsManager.Current = new System.EventsManager();
}
//=============================================================================
// CLASS: Exceptions
//-----------------------------------------------------------------------------
// From MicrosoftAjax.debug.js
Error.create = function (message, errorInfo) {
var err = new Error(message);
err.message = message;
if (errorInfo) {
for (var v in errorInfo) {
err[v] = errorInfo[v];
}
}
err.popStackFrame();
return err;
};
// From MicrosoftAjax.debug.js
Error.prototype.popStackFrame = function () {
if (arguments.length !== 0) throw Error.parameterCount();
if (typeof this.stack === "undefined" || this.stack === null ||
typeof this.fileName === "undefined" || this.fileName === null ||
typeof this.lineNumber === "undefined" || this.lineNumber === null) {
return;
}
var stackFrames = this.stack.split("\n");
var currentFrame = stackFrames[0];
var pattern = this.fileName + ":" + this.lineNumber;
while (typeof currentFrame !== "undefined" &&
currentFrame !== null &&
currentFrame.indexOf(pattern) === -1) {
stackFrames.shift();
currentFrame = stackFrames[0];
}
var nextFrame = stackFrames[1];
if (typeof nextFrame === "undefined" || nextFrame === null) {
return;
}
var nextFrameParts = nextFrame.match(/@(.*):(\d+)$/);
if (typeof nextFrameParts === "undefined" || nextFrameParts === null) {
return;
}
this.fileName = nextFrameParts[1];
this.lineNumber = parseInt(nextFrameParts[2]);
stackFrames.shift();
this.stack = stackFrames.join("\n");
};
/// <summary>Initializes a new instance of the System.Exception class with a specified error message.</summary>
/// <param name="message">The message that describes the error.</param>
System.Exception = function (message) { };
/// <summary>Initializes a new instance of the System.Exception class.</summary>
System.Exception = function () {
switch (arguments.length) {
case 0:
break;
case 1:
if (typeof arguments[0].GetType === "function") return arguments[0];
this.message = arguments[0];
break;
case 2:
break;
default:
break;
}
var err = Error.create(this.message, { name: this.GetType().FullName });
err.popStackFrame();
return err;
};
System.Type.RegisterClass("System.Exception");
System.ArgumentNullException = function (paramName, message) {