1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | var Prototype = {
|
15 | |
16 |
|
17 |
|
18 | version: "v2.2.2",
|
19 | |
20 |
|
21 |
|
22 |
|
23 |
|
24 | emptyFunction: function () {
|
25 | },
|
26 | |
27 |
|
28 |
|
29 |
|
30 |
|
31 | K: function (x) {
|
32 | return x;
|
33 | }
|
34 | };
|
35 | window.Prototype = Prototype;
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | var Try = {
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 | these: function () {
|
47 | var result;
|
48 | for (var i = 0; i < arguments.length; i++) {
|
49 | var lambda = arguments[i];
|
50 | if (Object.isFunction(lambda)) {
|
51 | try {
|
52 | result = lambda();
|
53 | break;
|
54 | }
|
55 | catch (e) {
|
56 | console.error(e);
|
57 | }
|
58 | }
|
59 | }
|
60 | return result;
|
61 | }
|
62 | };
|
63 | window.Try = Try;
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | var Optional = (function () {
|
69 | |
70 |
|
71 |
|
72 |
|
73 |
|
74 | function Optional(value) {
|
75 | this.value = value;
|
76 | }
|
77 | |
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 | Optional.of = function (value) {
|
84 | return new Optional(value);
|
85 | };
|
86 | |
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | Optional.ofNullable = function (value) {
|
93 | return Object.isUndefinedOrNull(value) ? Optional.empty() : new Optional(value);
|
94 | };
|
95 | |
96 |
|
97 |
|
98 |
|
99 |
|
100 | Optional.empty = function () {
|
101 | return new Optional(null);
|
102 | };
|
103 | |
104 |
|
105 |
|
106 |
|
107 |
|
108 | Optional.prototype.get = function () {
|
109 | if (this.value === null || typeof this.value === 'undefined') {
|
110 | throw "No value present";
|
111 | }
|
112 | return this.value;
|
113 | };
|
114 | |
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 | Optional.prototype.orElse = function (other) {
|
121 | return Object.isUndefinedOrNull(this.value) ? other : this.value;
|
122 | };
|
123 | |
124 |
|
125 |
|
126 |
|
127 |
|
128 | Optional.prototype.isPresent = function () {
|
129 | return Object.isUndefinedOrNull(this.value) === false;
|
130 | };
|
131 | return Optional;
|
132 | }());
|
133 | window.Optional = Optional;
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | Object.type = function (obj) {
|
145 | return typeof obj;
|
146 | };
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 | Object.rawType = function (obj) {
|
154 | return Object.prototype.toString.call(obj).slice(8, -1);
|
155 | };
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | Object.isObject = function (obj) {
|
163 | return obj !== null && typeof obj === "object";
|
164 | };
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 | Object.isPlainObject = function (obj) {
|
172 | return Object.prototype.toString.call(obj) === "[object Object]";
|
173 | };
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 | Object.isMap = function (obj) {
|
181 | return Object.prototype.toString.call(obj) === "[object Map]";
|
182 | };
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 | Object.isSet = function (obj) {
|
190 | return Object.prototype.toString.call(obj) === "[object Set]";
|
191 | };
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 | Object.isFunction = function (obj) {
|
199 | return Object.type(obj) === "function";
|
200 | };
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 | Object.isSymbol = function (obj) {
|
208 | if (typeof obj === "symbol") {
|
209 | return true;
|
210 | }
|
211 | try {
|
212 | var toString_1 = Symbol.prototype.toString;
|
213 | if (typeof obj.valueOf() !== "symbol") {
|
214 | return false;
|
215 | }
|
216 | return /^Symbol\(.*\)$/.test(toString_1.call(obj));
|
217 | }
|
218 | catch (e) {
|
219 | return false;
|
220 | }
|
221 | };
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 | Object.isPromise = function (obj) {
|
229 | return Object.isUndefinedOrNull(obj) === false && Object.isFunction(obj.then) && Object.isFunction(obj.catch);
|
230 | };
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 | Object.isPrimitive = function (obj) {
|
238 | return Object.isBoolean(obj) || Object.isString(obj) || Object.isNumber(obj);
|
239 | };
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 | Object.isArray = function (obj) {
|
247 | return Array.isArray(obj);
|
248 | };
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 | Object.isString = function (obj) {
|
256 | return Object.type(obj) === "string";
|
257 | };
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 | Object.isNumber = function (obj) {
|
265 | return Object.type(obj) === "number";
|
266 | };
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 | Object.isBoolean = function (obj) {
|
274 | return Object.type(obj) === "boolean";
|
275 | };
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 | Object.isRegExp = function (obj) {
|
283 | return Object.rawType(obj) === 'RegExp';
|
284 | };
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 | Object.isFile = function (obj) {
|
292 | return obj instanceof File;
|
293 | };
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 | Object.isWindow = function (obj) {
|
301 | return Object.isUndefinedOrNull(obj) && obj == obj.window;
|
302 | };
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 | Object.isElement = function (obj) {
|
310 | if (Object.isUndefinedOrNull(obj)) {
|
311 | return false;
|
312 | }
|
313 | return !!(obj.nodeType == 1);
|
314 | };
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 | Object.isEvent = function (obj) {
|
322 | return obj instanceof Event;
|
323 | };
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 | Object.isNull = function (obj) {
|
331 | return obj === null;
|
332 | };
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 | Object.isUndefined = function (obj) {
|
340 | return obj === undefined;
|
341 | };
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 | Object.isUndefinedOrNull = function (obj) {
|
349 | return Object.isUndefined(obj) || Object.isNull(obj);
|
350 | };
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 | Object.equals = function (obj1, obj2) {
|
359 | if (obj1 === obj2) {
|
360 | return true;
|
361 | }
|
362 | else if (!(obj1 instanceof Object) || !(obj2 instanceof Object)) {
|
363 | return false;
|
364 | }
|
365 | else if (obj1.constructor !== obj2.constructor) {
|
366 | return false;
|
367 | }
|
368 | else if (Object.isArray(obj1) && Object.isArray(obj2) && obj1.length === obj2.length) {
|
369 | for (var i = 0; i < obj1.length; i++) {
|
370 | if (Object.equals(obj1[i], obj2[i]) === false) {
|
371 | return false;
|
372 | }
|
373 | }
|
374 | }
|
375 | else if (Object.isObject(obj1) && Object.isObject(obj2) && Object.keys(obj1).length === Object.keys(obj2).length) {
|
376 | for (var key in obj1) {
|
377 | if (obj1.hasOwnProperty.call(key)) {
|
378 | if (Object.equals(obj1[key], obj2[key]) === false) {
|
379 | return false;
|
380 | }
|
381 | }
|
382 | }
|
383 | }
|
384 | else {
|
385 | return false;
|
386 | }
|
387 | return true;
|
388 | };
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 | Object.clone = function (obj) {
|
396 | if (Object.isString(obj)) {
|
397 | return String(obj);
|
398 | }
|
399 | else if (Object.isArray(obj)) {
|
400 | return Array.prototype.slice.apply(obj);
|
401 | }
|
402 | else if (Object.isPlainObject(obj)) {
|
403 | var result_1 = Object.create(null);
|
404 | Object.keys(obj).forEach(function (key) {
|
405 | result_1[key] = Object.clone(obj[key]);
|
406 | });
|
407 | return result_1;
|
408 | }
|
409 | return obj;
|
410 | };
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 | Object.omit = function (obj) {
|
419 | var fields = [];
|
420 | for (var _i = 1; _i < arguments.length; _i++) {
|
421 | fields[_i - 1] = arguments[_i];
|
422 | }
|
423 | var result = Object.clone(obj);
|
424 | for (var i = 0; i < fields.length; i++) {
|
425 | var key = fields[i];
|
426 | delete result[key];
|
427 | }
|
428 | return result;
|
429 | };
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 | Array.prototype.isEmpty = function () {
|
440 | return this.length === 0;
|
441 | };
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 | Array.prototype.exists = function (item) {
|
449 | return this.indexOf(item) !== -1;
|
450 | };
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 | Array.prototype.first = function () {
|
457 | if (this.length === 0) {
|
458 | throw "Array index out of range: 0";
|
459 | }
|
460 | return this[0];
|
461 | };
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 | Array.prototype.last = function () {
|
468 | if (this.length === 0) {
|
469 | throw "Array index out of range: 0";
|
470 | }
|
471 | return this[this.length - 1];
|
472 | };
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 | Array.prototype.each = Array.prototype.forEach;
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 | Array.prototype.size = function () {
|
486 | return this.length;
|
487 | };
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 | Array.prototype.merge = Array.prototype.concat;
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 | Array.prototype.compact = function () {
|
500 | return this.filter(function (value) { return Object.isUndefinedOrNull(value); });
|
501 | };
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 | Array.prototype.unique = function () {
|
508 | var temp = new Array();
|
509 | return this.filter(function (v) {
|
510 | var ret = temp.includes(v) === false;
|
511 | temp.push(v);
|
512 | return ret;
|
513 | });
|
514 | };
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 | Array.prototype.without = function () {
|
522 | var values = [];
|
523 | for (var _i = 0; _i < arguments.length; _i++) {
|
524 | values[_i] = arguments[_i];
|
525 | }
|
526 | return this.filter(function (v) {
|
527 | return values.includes(v) === false;
|
528 | });
|
529 | };
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 | Array.prototype.clone = function () {
|
536 | return this.slice(0);
|
537 | };
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 | Array.prototype.clear = function () {
|
544 | this.length = 0;
|
545 | return this;
|
546 | };
|
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 | Date.prototype.isLeapYear = function () {
|
557 | var year = this.getFullYear();
|
558 | return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
559 | };
|
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 | Date.prototype.getSeason = function () {
|
566 | var month = this.getMonth();
|
567 | if (month >= 3 && month <= 5) {
|
568 | return 0;
|
569 | }
|
570 | else if (month >= 6 && month <= 8) {
|
571 | return 1;
|
572 | }
|
573 | else if (month >= 9 && month <= 11) {
|
574 | return 2;
|
575 | }
|
576 | else if (month >= 12 || month <= 2) {
|
577 | return 3;
|
578 | }
|
579 | else {
|
580 | return 0;
|
581 | }
|
582 | };
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 | Date.prototype.getDayOfYear = function () {
|
589 | var month_days = this.isLeapYear() == true ? [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] : [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
590 | var days = this.getDate();
|
591 | for (var m = 0, month = this.getMonth(); m < month; m++) {
|
592 | days += month_days[m];
|
593 | }
|
594 | return days;
|
595 | };
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 | Date.prototype.getDaysOfYear = function () {
|
602 | return this.isLeapYear() ? 366 : 365;
|
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 | Date.prototype.format = function (format) {
|
643 | if (Object.isString(format) === false) {
|
644 | throw "Invalid argument format";
|
645 | }
|
646 | var $this = this;
|
647 | var _season_map = {
|
648 | "N": ["Spring", "Summer", "Autumn", "Winter"],
|
649 | "A": ["\u6625", "\u590f", "\u79cb", "\u51ac"]
|
650 | };
|
651 | var _month_map = {
|
652 | "f": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
653 | "F": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
654 | "C": ["\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u4E03", "\u516B", "\u4E5D", "\u5341", "\u5341\u4E00", "\u5341\u4E8C"]
|
655 | };
|
656 | var _weekday_map = {
|
657 | "W": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
658 | "WW": ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
659 | "WC": ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"]
|
660 | };
|
661 | var season = -1;
|
662 | var seasonFn = function () { return Math.floor(($this.getMonth() + 3) / 3); };
|
663 | var $funcs = {
|
664 |
|
665 | "y": function (pattern) {
|
666 | return ($this.getFullYear() + "").substring(4 - pattern.length);
|
667 | },
|
668 |
|
669 | "n": function () {
|
670 | if (season === -1) {
|
671 | season = seasonFn();
|
672 | }
|
673 | return season;
|
674 | },
|
675 |
|
676 | "N": function () {
|
677 | if (season === -1) {
|
678 | season = seasonFn();
|
679 | }
|
680 | return _season_map["N"][season - 1];
|
681 | },
|
682 |
|
683 | "A": function () {
|
684 | if (season === -1) {
|
685 | season = seasonFn();
|
686 | }
|
687 | return _season_map["A"][season - 1];
|
688 | },
|
689 |
|
690 | "M": function (pattern) {
|
691 | var $month = $this.getMonth() + 1;
|
692 | var result = $month < 10 ? "0" + $month : "" + $month;
|
693 | return result.substring(2 - pattern.length);
|
694 | },
|
695 |
|
696 | "f": function () {
|
697 | var $month = $this.getMonth();
|
698 | return _month_map["f"][$month];
|
699 | },
|
700 |
|
701 | "F": function () {
|
702 | var $month = $this.getMonth();
|
703 | return _month_map["F"][$month];
|
704 | },
|
705 |
|
706 | "C": function () {
|
707 | var $month = $this.getMonth();
|
708 | return _month_map["C"][$month];
|
709 | },
|
710 |
|
711 | "e": function () {
|
712 | return $this.getDay();
|
713 | },
|
714 |
|
715 | "E": function () {
|
716 | return $this.getDay() + 1;
|
717 | },
|
718 |
|
719 | "l": function () {
|
720 | var $weekday = $this.getDay();
|
721 | return _weekday_map["W"][$weekday];
|
722 | },
|
723 |
|
724 | "L": function () {
|
725 | var $weekday = $this.getDay();
|
726 | return _weekday_map["WC"][$weekday];
|
727 | },
|
728 |
|
729 | "w": function () {
|
730 | var $weekday = $this.getDay();
|
731 | return _weekday_map["WC"][$weekday];
|
732 | },
|
733 |
|
734 | "d": function (pattern) {
|
735 | var $date = $this.getDate();
|
736 | var result = $date < 10 ? "0" + $date : "" + $date;
|
737 | return result.substring(2 - pattern.length);
|
738 | },
|
739 |
|
740 | "h": function (pattern) {
|
741 | var $hour = $this.getHours();
|
742 | var result = $hour % 12 === 0 ? "12" : $hour % 12;
|
743 | result = $hour < 10 ? "0" + $hour : "" + $hour;
|
744 | return result.substring(2 - pattern.length);
|
745 | },
|
746 |
|
747 | "H": function (pattern) {
|
748 | var $hour = $this.getHours();
|
749 | var result = $hour < 10 ? "0" + $hour : "" + $hour;
|
750 | return result.substring(2 - pattern.length);
|
751 | },
|
752 |
|
753 | "m": function (pattern) {
|
754 | var $minutes = $this.getMinutes();
|
755 | var result = $minutes < 10 ? "0" + $minutes : "" + $minutes;
|
756 | return result.substring(2 - pattern.length);
|
757 | },
|
758 |
|
759 | "s": function (pattern) {
|
760 | var $seconds = $this.getSeconds();
|
761 | var result = $seconds < 10 ? "0" + $seconds : "" + $seconds;
|
762 | return result.substring(2 - pattern.length);
|
763 | },
|
764 |
|
765 | "S": function (pattern) {
|
766 | var $mise = $this.getMilliseconds();
|
767 | var result = $mise < 10 ? "0" + $mise : "" + $mise;
|
768 | return result.substring(2 - pattern.length);
|
769 | }
|
770 | };
|
771 | return format.replace(/([ynNAMfFCdYTjeElLwWiohHmsSaOPZ])+/g, function (all, t) {
|
772 | var fn = $funcs[t];
|
773 | return Object.isFunction(fn) === true ? fn(all) : all;
|
774 | });
|
775 | };
|
776 |
|
777 |
|
778 |
|
779 |
|
780 | var SameSite;
|
781 | (function (SameSite) {
|
782 | SameSite["NONE"] = "None";
|
783 | SameSite["LAX"] = "Lax";
|
784 | SameSite["STRICT"] = "Strict";
|
785 | })(SameSite || (SameSite = {}));
|
786 | var CookieInstance = (function () {
|
787 | function CookieInstance() {
|
788 | }
|
789 | CookieInstance.prototype.set = function (name, value, options) {
|
790 | var $name = name = encodeURIComponent(name)
|
791 | .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent);
|
792 | var $value = value ? encodeURIComponent(value)
|
793 | .replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent) : '';
|
794 | var stringifiedAttributes = '';
|
795 | if (options) {
|
796 | stringifiedAttributes += options.domain ? '; domain=' + options.domain : '';
|
797 | stringifiedAttributes += options.path ? '; path=' + options.path : '';
|
798 | if (options.expires) {
|
799 | var $expiresDate = options.expires instanceof Date ? options.expires : new Date(Date.now() + options.expires * 864e5);
|
800 | stringifiedAttributes += options.expires ? '; expires=' + $expiresDate.toUTCString() : '';
|
801 | }
|
802 | stringifiedAttributes += options.sameSite ? '; sameSite=' + options.sameSite : '';
|
803 | if (Object.isBoolean(options.secure) && options.secure) {
|
804 | stringifiedAttributes += options.expires ? '; secure' : '';
|
805 | }
|
806 | if (Object.isBoolean(options.httpOnly) && options.httpOnly) {
|
807 | stringifiedAttributes += options.httpOnly ? '; httpOnly' : '';
|
808 | }
|
809 | }
|
810 | return document.cookie = $name + '=' + $value + stringifiedAttributes;
|
811 | };
|
812 | CookieInstance.prototype.get = function (name) {
|
813 | var cookies = document.cookie ? document.cookie.split('; ') : [];
|
814 | for (var i = 0; i < cookies.length; i++) {
|
815 | var parts = cookies[i].split('=');
|
816 | var $name = decodeURIComponent(parts[0]);
|
817 | var $value = parts.slice(1).join('=');
|
818 | if ($name === name) {
|
819 | if ($value[0] === '"') {
|
820 | $value = $value.slice(1, -1);
|
821 | }
|
822 | return $value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
823 | }
|
824 | }
|
825 | return null;
|
826 | };
|
827 | CookieInstance.prototype.delete = function (name, options) {
|
828 | var $options = options ? options : {};
|
829 | $options.expires = -1;
|
830 | this.set(name, '', $options);
|
831 | };
|
832 | return CookieInstance;
|
833 | }());
|
834 |
|
835 |
|
836 |
|
837 |
|
838 |
|
839 | Object.defineProperty(document, "fullScreen", {
|
840 | value: Object.isUndefined(document.fullscreen) === false ? document.fullscreen : (Object.isUndefined(document.mozFullScreen) === false ? document.mozFullScreen : (Object.isUndefined(document.webkitIsFullScreen) === false ? document.webkitIsFullScreen : (Object.isUndefined(document.msFullScreen) === false ? document.msFullScreen : (Object.isUndefined(document.fullscreenElement) === false ? document.fullscreenElement !== null : (Object.isUndefined(document.mozFullScreenElement) === false ? document.mozFullScreenElement !== null : (Object.isUndefined(document.webkitFullscreenElement) === false ? document.webkitFullscreenElement !== null : (Object.isUndefined(document.msFullscreenElement) === false ? document.msFullscreenElement !== null : false))))))),
|
841 | configurable: true,
|
842 | writable: false
|
843 | });
|
844 |
|
845 |
|
846 |
|
847 |
|
848 |
|
849 | Object.defineProperty(document, "fullScreenEnabled", {
|
850 | value: Object.isUndefined(document.mozFullScreenEnabled) === false ? document.mozFullScreenEnabled : (Object.isUndefined(document.webkitFullscreenEnabled) === false ? document.webkitFullscreenEnabled : (Object.isUndefined(document.msFullscreenEnabled) === false ? document.msFullscreenEnabled : (Object.isUndefined(document.fullscreenEnabled) === false ? document.fullscreenEnabled : false))),
|
851 | configurable: true,
|
852 | writable: false
|
853 | });
|
854 |
|
855 |
|
856 |
|
857 |
|
858 |
|
859 | Object.defineProperty(document, "fullScreenElement", {
|
860 | value: Object.isUndefined(document.mozFullScreenElement) === false ? document.mozFullScreenElement : (Object.isUndefined(document.webkitFullscreenElement) === false ? document.webkitFullscreenElement : (Object.isUndefined(document.msFullscreenElement) === false ? document.msFullscreenElement : (Object.isUndefined(document.fullscreenElement) === false ? document.fullscreenElement : null))),
|
861 | configurable: true,
|
862 | writable: false
|
863 | });
|
864 |
|
865 |
|
866 |
|
867 |
|
868 |
|
869 | Object.defineProperty(document, "httpCookie", {
|
870 | value: new CookieInstance(),
|
871 | configurable: true,
|
872 | writable: false
|
873 | });
|
874 |
|
875 |
|
876 |
|
877 |
|
878 |
|
879 | Document.prototype.requestFullscreen = function () {
|
880 | var doc = document.documentElement;
|
881 | if (Object.isFunction(doc.mozRequestFullScreen)) {
|
882 | return doc.mozRequestFullScreen();
|
883 | }
|
884 | else if (Object.isFunction(doc.webkitRequestFullscreen)) {
|
885 | return doc.webkitRequestFullscreen();
|
886 | }
|
887 | else if (Object.isFunction(doc.msRequestFullscreen)) {
|
888 | return doc.msRequestFullscreen();
|
889 | }
|
890 | else {
|
891 | return doc.requestFullscreen();
|
892 | }
|
893 | };
|
894 |
|
895 |
|
896 |
|
897 |
|
898 |
|
899 | Document.prototype.exitFullscreen = function () {
|
900 | if (Object.isFunction(document.mozCancelFullScreen)) {
|
901 | return document.mozCancelFullScreen();
|
902 | }
|
903 | else if (Object.isFunction(document.mozExitFullScreen)) {
|
904 | return document.mozExitFullScreen();
|
905 | }
|
906 | else if (Object.isFunction(document.webkitCancelFullScreen)) {
|
907 | return document.webkitCancelFullScreen();
|
908 | }
|
909 | else if (Object.isFunction(document.webkitExitFullscreen)) {
|
910 | return document.webkitExitFullscreen();
|
911 | }
|
912 | else if (Object.isFunction(document.msExitFullscreen)) {
|
913 | return document.msExitFullscreen();
|
914 | }
|
915 | else {
|
916 | return document.exitFullscreen();
|
917 | }
|
918 | };
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 | Function.prototype.argumentNames = function () {
|
929 | var method = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/);
|
930 | if (method === null) {
|
931 | return null;
|
932 | }
|
933 | var names = method[1].replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, "").replace(/\s+/g, "").split(", ");
|
934 | return names.length === 1 && !names[0] ? [] : names;
|
935 | };
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 | Function.prototype.delay = function (timeout) {
|
943 | var __method = this;
|
944 | var args = Array.prototype.slice.call(arguments, 1);
|
945 | return window.setTimeout(__method.apply(__method, args), timeout * 1000);
|
946 | };
|
947 |
|
948 |
|
949 |
|
950 |
|
951 |
|
952 |
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 | Math.rand = function (min, max) {
|
959 | min = min || 0;
|
960 | max = max || Number.MAX_SAFE_INTEGER;
|
961 | var rand = Math.random() * (max - min + 1) + min;
|
962 | var result = Math.round(rand);
|
963 | if (result < min) {
|
964 | return min;
|
965 | }
|
966 | else if (result > max) {
|
967 | return max;
|
968 | }
|
969 | else {
|
970 | return result;
|
971 | }
|
972 | };
|
973 |
|
974 |
|
975 |
|
976 |
|
977 |
|
978 |
|
979 |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 | Number.prototype.toPaddedString = function (length, radix) {
|
985 | var str = this.toString(radix || 10);
|
986 | return "0".repeat(length - str.length) + str;
|
987 | };
|
988 |
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 | Number.isOdd = function (num) {
|
995 | return num % 2 === 1;
|
996 | };
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 | Number.isEven = function (num) {
|
1004 | return num % 2 === 0;
|
1005 | };
|
1006 |
|
1007 |
|
1008 |
|
1009 |
|
1010 |
|
1011 |
|
1012 |
|
1013 |
|
1014 |
|
1015 | Number.isBetween = function (num, min, max, match) {
|
1016 | if (match === void 0) { match = false; }
|
1017 | min = min || 0;
|
1018 | max = max || 0;
|
1019 | if (min > max) {
|
1020 | min ^= max;
|
1021 | max ^= min;
|
1022 | min ^= max;
|
1023 | }
|
1024 | return match == true ? num >= min && num <= max : num > min && num < max;
|
1025 | };
|
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 | String.prototype.exists = function (str) {
|
1037 | return this.indexOf(str) >= 0;
|
1038 | };
|
1039 |
|
1040 |
|
1041 |
|
1042 |
|
1043 |
|
1044 |
|
1045 | String.prototype.equals = function (str) {
|
1046 | return Object.isUndefinedOrNull(str) == false && this === str;
|
1047 | };
|
1048 |
|
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 | String.prototype.equalsIgnoreCase = function (str) {
|
1055 | return str !== undefined && str !== null && this.toLowerCase() === str.toLowerCase();
|
1056 | };
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 | String.prototype.isEmpty = function () {
|
1063 | return this.length === 0;
|
1064 | };
|
1065 |
|
1066 |
|
1067 |
|
1068 |
|
1069 |
|
1070 | String.prototype.isNotEmpty = function () {
|
1071 | return this.length > 0;
|
1072 | };
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 | String.prototype.isBlank = function () {
|
1079 | return /^\s*$/.test(this.toString());
|
1080 | };
|
1081 |
|
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 | String.prototype.repeat = function (count) {
|
1088 | if (count < 1) {
|
1089 | return "";
|
1090 | }
|
1091 | else {
|
1092 | var s = this.toString();
|
1093 | var result = s;
|
1094 | for (var i = 0; i < count; i++) {
|
1095 | result += s;
|
1096 | }
|
1097 | return result;
|
1098 | }
|
1099 | };
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 | String.prototype.left = function (length) {
|
1107 | return this.substring(0, length);
|
1108 | };
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 | String.prototype.right = function (length) {
|
1116 | return this.substring(this.length - length, this.length);
|
1117 | };
|
1118 |
|
1119 |
|
1120 |
|
1121 |
|
1122 |
|
1123 |
|
1124 |
|
1125 |
|
1126 | String.prototype.truncation = function (length, truncation) {
|
1127 | if (truncation === void 0) { truncation = '...'; }
|
1128 | truncation = truncation || "...";
|
1129 | return this.length > length ? this.slice(0, length <= truncation.length ? length : length - truncation.length) + truncation : String(this);
|
1130 | };
|
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 | String.prototype.ltrim = function () {
|
1137 | return Object.isFunction(this.trimStart) ? this.trimStart() : this.replace(/^\s*/g, "");
|
1138 | };
|
1139 |
|
1140 |
|
1141 |
|
1142 |
|
1143 |
|
1144 | String.prototype.rtrim = function () {
|
1145 | return Object.isFunction(this.trimEnd) ? this.trimEnd() : this.replace(/\s*$/g, "");
|
1146 | };
|
1147 |
|
1148 |
|
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 | String.prototype.startsWith = function (str) {
|
1154 | return this.indexOf(str) === 0;
|
1155 | };
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 | String.prototype.endsWith = function (str) {
|
1163 | var d = this.length - str.length;
|
1164 | return d >= 0 && this.lastIndexOf(str) === d;
|
1165 | };
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 | String.prototype.lcfirst = function () {
|
1172 | return this.charAt(0).toLowerCase() + this.substring(1);
|
1173 | };
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 | String.prototype.ucfirst = function () {
|
1180 | return this.charAt(0).toUpperCase() + this.substring(1);
|
1181 | };
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 | String.prototype.escapeHTML = function () {
|
1188 | return this.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
1189 | };
|
1190 |
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 | String.prototype.unescapeHTML = function () {
|
1196 | return this.replace(/"/g, '"').replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
1197 | };
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 | String.prototype.stripTag = function (tag) {
|
1205 | return this.replace(new RegExp("<" + tag + "(\\s+(\"[^\"]*\"|'[^']*'|[^>])+)?(\/)?>|<\/" + tag + ">", "gi"), "");
|
1206 | };
|
1207 |
|
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 |
|
1213 | String.prototype.stripTags = function (tags) {
|
1214 | if (typeof tags === "string") {
|
1215 | return this.stripTag(tags);
|
1216 | }
|
1217 | else if (Array.isArray(tags)) {
|
1218 | var result = this.toString();
|
1219 | for (var i = 0; i < tags.length; i++) {
|
1220 | result = result.stripTag(tags[i]);
|
1221 | }
|
1222 | return result;
|
1223 | }
|
1224 | else {
|
1225 | return this.toString();
|
1226 | }
|
1227 | };
|
1228 |
|
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 | String.prototype.stripScripts = function () {
|
1234 | return this.replace(/<script[^>]*>([\S\s]*?)<\/script>/img, "");
|
1235 | };
|
1236 |
|
1237 |
|
1238 |
|
1239 |
|
1240 |
|
1241 |
|
1242 | String.prototype.toArray = function (delimiter) {
|
1243 | return this.split(delimiter || "");
|
1244 | };
|
1245 |
|
1246 |
|
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 | String.prototype.inspect = function (useDoubleQuotes) {
|
1252 | var specialChar = { '\b': '\\b', '\t': '\\t', '\r': '\\r', '\n': '\\n', '\f': '\\f', '\\': '\\\\' };
|
1253 | var escapedString = this.replace(/[\x00-\x1f\\]/g, function (character) {
|
1254 | if (character in specialChar) {
|
1255 | return specialChar[character];
|
1256 | }
|
1257 | return '\\u00' + character.charCodeAt(0).toPaddedString(2, 16);
|
1258 | });
|
1259 | if (useDoubleQuotes) {
|
1260 | return '"' + escapedString.replace(/"/g, '\\"') + '"';
|
1261 | }
|
1262 | else {
|
1263 | return "'" + escapedString.replace(/'/g, '\\\'') + "'";
|
1264 | }
|
1265 | };
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 | String.prototype.hashCode = function () {
|
1272 | var result = 0;
|
1273 | if (result === 0 && this.length > 0) {
|
1274 | for (var i = 0; i < this.length; i++) {
|
1275 | result = 31 * result + this.charCodeAt(i);
|
1276 | }
|
1277 | }
|
1278 | return result;
|
1279 | };
|
1280 |
|
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 |
|
1289 |
|
1290 |
|
1291 |
|
1292 | String.random = function (length, type) {
|
1293 | if (type === void 0) { type = "LETTER_NUMERIC"; }
|
1294 | var result = "";
|
1295 | if (type === "CHINESE") {
|
1296 | for (var i = 0; i < length; i++) {
|
1297 | result += String.fromCharCode(Math.rand(19968, 40891));
|
1298 | }
|
1299 | return result;
|
1300 | }
|
1301 | var numeric = "0123456789";
|
1302 | var letter = "abcdefghijklmnopqrstuvwxyz";
|
1303 | var map = {
|
1304 | "NUMERIC": numeric,
|
1305 | "LETTER": letter + letter.toUpperCase(),
|
1306 | "LETTER_NUMERIC": numeric + letter + letter.toUpperCase()
|
1307 | };
|
1308 | if (!map[type]) {
|
1309 | throw "Invalid argument type value, must be: NUMERIC, LETTER, LETTER_NUMERIC or CHINESE";
|
1310 | }
|
1311 | for (var j = 0; j < length; j++) {
|
1312 | result += map[type].charAt(Math.rand(0, map[type].length - 1));
|
1313 | }
|
1314 | return result;
|
1315 | };
|
1316 |
|
1317 |
|
1318 |
|
1319 |
|
1320 | Object.defineProperty(window, "browser", {
|
1321 | value: {
|
1322 | userAgent: navigator.userAgent,
|
1323 | name: navigator.appName,
|
1324 | version: navigator.appVersion,
|
1325 | isMobile: ["Android", "iPhone", "iPod", "Windows Phone", "Mobile", "Coolpad", "mmp", "SmartPhone", "midp", "wap", "xoom", "Symbian", "J2ME", "Blackberry", "Wince"].some(function (value) { return navigator.userAgent.exists(value); }),
|
1326 | isChrome: /\(KHTML, like Gecko\) Chrome\//.test(navigator.userAgent),
|
1327 | isFirefox: navigator.userAgent.exists("Firefox"),
|
1328 | isMozilla: navigator.userAgent.exists("Mozilla"),
|
1329 | isEdge: navigator.userAgent.exists("Edge"),
|
1330 | isMSIE: navigator.userAgent.exists("MSIE") && navigator.userAgent.exists("compatible"),
|
1331 | isOpera: navigator.userAgent.exists("Opera"),
|
1332 | isSafari: navigator.userAgent.exists("Safari"),
|
1333 | isNetscape: /Netscape([\d]*)\/([^\s]+)/i.test(navigator.userAgent)
|
1334 | },
|
1335 | configurable: true,
|
1336 | writable: false
|
1337 | });
|
1338 |
|
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 | Window.prototype.copy = function (str) {
|
1344 | try {
|
1345 | if (Object.isObject(this.clipboardData)) {
|
1346 | this.clipboardData.setData("text", str);
|
1347 | }
|
1348 | else {
|
1349 | var fakeElement = document.createElement("textarea");
|
1350 | fakeElement.style.border = "none";
|
1351 | fakeElement.style.margin = "0";
|
1352 | fakeElement.style.padding = "0";
|
1353 | fakeElement.style.position = "absolute";
|
1354 | fakeElement.style.top = "-9999px";
|
1355 | fakeElement.style.left = "-9999px";
|
1356 | fakeElement.value = str;
|
1357 | fakeElement.setAttribute("readonly", "");
|
1358 | document.body.appendChild(fakeElement);
|
1359 | fakeElement.setSelectionRange(0, str.length);
|
1360 | fakeElement.select();
|
1361 | document.execCommand("copy");
|
1362 | fakeElement.remove();
|
1363 | }
|
1364 | }
|
1365 | catch (e) {
|
1366 | console.error(e);
|
1367 | }
|
1368 | };
|
1369 |
|
1370 |
|
1371 |
|
1372 |
|
1373 |
|
1374 | Location.prototype.getParameters = function () {
|
1375 | var queryString = this.search;
|
1376 | var parameters = {};
|
1377 | if (queryString.indexOf("?") != -1) {
|
1378 | queryString = queryString.substring(1);
|
1379 | var parts = queryString.split("&");
|
1380 | for (var i = 0; i < parts.length; i++) {
|
1381 | var temp = parts[i].split("=");
|
1382 | var val = temp.length == 2 ? encodeURIComponent(temp[1]) : "";
|
1383 | if (Object.isUndefined(parameters[temp[0]])) {
|
1384 | parameters[temp[0]] = val;
|
1385 | }
|
1386 | else {
|
1387 | if (Object.isArray(parameters[temp[0]]) == false) {
|
1388 | var oldVal = parameters[temp[0]];
|
1389 | delete parameters[temp[0]];
|
1390 | parameters[temp[0]] = [oldVal];
|
1391 | }
|
1392 | parameters[temp[0]].push(val);
|
1393 | }
|
1394 | }
|
1395 | }
|
1396 | return parameters;
|
1397 | };
|
1398 |
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 | Location.prototype.getParameter = function (name) {
|
1405 | var parameters = this.getParameters();
|
1406 | return parameters[name];
|
1407 | };
|
1408 |
|