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