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