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