1(function (define) { 2 define(['jquery'], function ($) { 3 return (function () { 4 var abp = window.abp || {}; 5 6 /* Application paths *****************************************/ 7 8 //Current application root path (including virtual directory if exists). 9 abp.appPath = abp.appPath || '/'; 10 abp.pageLoadTime = new Date(); 11 12 //Converts given path to absolute path using abp.appPath variable. 13 abp.toAbsAppPath = function (path) { 14 if (path.indexOf('/') == 0) { 15 path = path.substring(1); 16 } 17 18 return abp.appPath + path; 19 }; 20 21 /* MULTITENANCY */ 22 23 abp.multiTenancy = abp.multiTenancy || {}; 24 25 abp.multiTenancy.isEnabled = false; 26 abp.multiTenancy.ignoreFeatureCheckForHostUsers = false; 27 28 abp.multiTenancy.sides = { 29 TENANT: 1, 30 HOST: 2 31 }; 32 33 abp.multiTenancy.tenantIdCookieName = 'Abp.TenantId'; 34 35 abp.multiTenancy.setTenantIdCookie = function (tenantId) { 36 if (tenantId) { 37 abp.utils.setCookieValue( 38 abp.multiTenancy.tenantIdCookieName, 39 tenantId.toString(), 40 new Date(new Date().getTime() + 5 * 365 * 86400000), //5 years 41 abp.appPath, 42 abp.domain 43 ); 44 } else { 45 abp.utils.deleteCookie(abp.multiTenancy.tenantIdCookieName, abp.appPath); 46 } 47 }; 48 49 abp.multiTenancy.getTenantIdCookie = function () { 50 var value = abp.utils.getCookieValue(abp.multiTenancy.tenantIdCookieName); 51 if (!value) { 52 return null; 53 } 54 55 return parseInt(value); 56 } 57 58 /* SESSION */ 59 60 abp.session = abp.session || 61 { 62 multiTenancySide: abp.multiTenancy.sides.HOST 63 }; 64 65 /* LOCALIZATION ***********************************************/ 66 //Implements Localization API that simplifies usage of localization scripts generated by Abp. 67 68 abp.localization = abp.localization || {}; 69 70 abp.localization.languages = []; 71 72 abp.localization.currentLanguage = {}; 73 74 abp.localization.sources = []; 75 76 abp.localization.values = {}; 77 78 abp.localization.localize = function (key, sourceName) { 79 sourceName = sourceName || abp.localization.defaultSourceName; 80 81 var source = abp.localization.values[sourceName]; 82 83 if (!source) { 84 abp.log.warn('Could not find localization source: ' + sourceName); 85 return key; 86 } 87 88 var value = source[key]; 89 if (value == undefined) { 90 return key; 91 } 92 93 var copiedArguments = Array.prototype.slice.call(arguments, 0); 94 copiedArguments.splice(1, 1); 95 copiedArguments[0] = value; 96 97 return abp.utils.formatString.apply(this, copiedArguments); 98 }; 99 100 abp.localization.getSource = function (sourceName) { 101 return function (key) { 102 var copiedArguments = Array.prototype.slice.call(arguments, 0); 103 copiedArguments.splice(1, 0, sourceName); 104 return abp.localization.localize.apply(this, copiedArguments); 105 }; 106 }; 107 108 abp.localization.isCurrentCulture = function (name) { 109 return abp.localization.currentCulture 110 && abp.localization.currentCulture.name 111 && abp.localization.currentCulture.name.indexOf(name) == 0; 112 }; 113 114 abp.localization.defaultSourceName = undefined; 115 abp.localization.abpWeb = abp.localization.getSource('AbpWeb'); 116 117 /* AUTHORIZATION **********************************************/ 118 //Implements Authorization API that simplifies usage of authorization scripts generated by Abp. 119 120 abp.auth = abp.auth || {}; 121 122 abp.auth.allPermissions = abp.auth.allPermissions || {}; 123 124 abp.auth.grantedPermissions = abp.auth.grantedPermissions || {}; 125 126 //Deprecated. Use abp.auth.isGranted instead. 127 abp.auth.hasPermission = function (permissionName) { 128 return abp.auth.isGranted.apply(this, arguments); 129 }; 130 131 //Deprecated. Use abp.auth.isAnyGranted instead. 132 abp.auth.hasAnyOfPermissions = function () { 133 return abp.auth.isAnyGranted.apply(this, arguments); 134 }; 135 136 //Deprecated. Use abp.auth.areAllGranted instead. 137 abp.auth.hasAllOfPermissions = function () { 138 return abp.auth.areAllGranted.apply(this, arguments); 139 }; 140 141 abp.auth.isGranted = function (permissionName) { 142 return abp.auth.allPermissions[permissionName] != undefined && 143 abp.auth.grantedPermissions[permissionName] != undefined; 144 }; 145 146 abp.auth.isAnyGranted = function () { 147 if (!arguments || arguments.length <= 0) { 148 return true; 149 } 150 151 for (var i = 0; i < arguments.length; i++) { 152 if (abp.auth.isGranted(arguments[i])) { 153 return true; 154 } 155 } 156 157 return false; 158 }; 159 160 abp.auth.areAllGranted = function () { 161 if (!arguments || arguments.length <= 0) { 162 return true; 163 } 164 165 for (var i = 0; i < arguments.length; i++) { 166 if (!abp.auth.isGranted(arguments[i])) { 167 return false; 168 } 169 } 170 171 return true; 172 }; 173 174 abp.auth.tokenCookieName = 'Abp.AuthToken'; 175 176 abp.auth.setToken = function (authToken, expireDate) {
177 abp.utils.setCookieValue(abp.auth.tokenCookieName, authToken, expireDate, abp.appPath, abp.domain); 178 }; 179 180 abp.auth.getToken = function() { 181 return abp.utils.getCookieValue(abp.auth.tokenCookieName); 182 }; 183 184 abp.auth.clearToken = function() { 185 abp.auth.setToken(); 186 }; 187 188 abp.auth.refreshTokenCookieName = 'Abp.AuthRefreshToken'; 189 190 abp.auth.setRefreshToken = function (refreshToken, expireDate) { 191 abp.utils.setCookieValue(abp.auth.refreshTokenCookieName, refreshToken, expireDate, abp.appPath, abp.domain); 192 }; 193 194 abp.auth.getRefreshToken = function() { 195 return abp.utils.getCookieValue(abp.auth.refreshTokenCookieName); 196 }; 197 198 abp.auth.clearRefreshToken = function() { 199 abp.auth.setRefreshToken(); 200 }; 201 202 /* FEATURE SYSTEM *********************************************/ 203 //Implements Features API that simplifies usage of feature scripts generated by Abp. 204 205 abp.features = abp.features || {}; 206 207 abp.features.allFeatures = abp.features.allFeatures || {}; 208 209 abp.features.get = function (name) { 210 return abp.features.allFeatures[name]; 211 } 212 213 abp.features.getValue = function (name) { 214 var feature = abp.features.get(name); 215 if (feature == undefined) { 216 return undefined; 217 } 218 219 return feature.value; 220 } 221 222 abp.features.isEnabled = function (name) { 223 var value = abp.features.getValue(name); 224 return value == 'true' || value == 'True'; 225 } 226 227 /* SETTINGS **************************************************/ 228 //Implements Settings API that simplifies usage of setting scripts generated by Abp. 229 230 abp.setting = abp.setting || {}; 231 232 abp.setting.values = abp.setting.values || {}; 233 234 abp.setting.get = function (name) { 235 return abp.setting.values[name]; 236 }; 237 238 abp.setting.getBoolean = function (name) { 239 var value = abp.setting.get(name); 240 return value == 'true' || value == 'True'; 241 }; 242 243 abp.setting.getInt = function (name) { 244 return parseInt(abp.setting.values[name]); 245 }; 246 247 /* REALTIME NOTIFICATIONS ************************************/ 248 249 abp.notifications = abp.notifications || {}; 250 251 abp.notifications.severity = { 252 INFO: 0, 253 SUCCESS: 1, 254 WARN: 2, 255 ERROR: 3, 256 FATAL: 4 257 }; 258 259 abp.notifications.userNotificationState = { 260 UNREAD: 0, 261 READ: 1 262 }; 263 264 abp.notifications.getUserNotificationStateAsString = function (userNotificationState) { 265 switch (userNotificationState) { 266 case abp.notifications.userNotificationState.READ: 267 return 'READ'; 268 case abp.notifications.userNotificationState.UNREAD: 269 return 'UNREAD'; 270 default: 271 abp.log.warn('Unknown user notification state value: ' + userNotificationState) 272 return '?'; 273 } 274 }; 275 276 abp.notifications.getUiNotifyFuncBySeverity = function (severity) { 277 switch (severity) { 278 case abp.notifications.severity.SUCCESS: 279 return abp.notify.success; 280 case abp.notifications.severity.WARN: 281 return abp.notify.warn; 282 case abp.notifications.severity.ERROR: 283 return abp.notify.error; 284 case abp.notifications.severity.FATAL: 285 return abp.notify.error; 286 case abp.notifications.severity.INFO: 287 default: 288 return abp.notify.info; 289 } 290 }; 291 292 abp.notifications.messageFormatters = {}; 293 294 abp.notifications.messageFormatters['Abp.Notifications.MessageNotificationData'] = function (userNotification) { 295 return userNotification.notification.data.message || userNotification.notification.data.properties.Message; 296 }; 297 298 abp.notifications.messageFormatters['Abp.Notifications.LocalizableMessageNotificationData'] = 299 function (userNotification) { 300 var message = userNotification.notification.data.message || 301 userNotification.notification.data.properties.Message; 302 var localizedMessage = abp.localization.localize( 303 message.name, 304 message.sourceName 305 ); 306 307 if (userNotification.notification.data.properties) { 308 if ($) { 309 //Prefer to use jQuery if possible 310 $.each(userNotification.notification.data.properties, function (key, value) { 311 localizedMessage = localizedMessage.replace('{' + key + '}', value); 312 }); 313 } else { 314 //alternative for $.each 315 var properties = Object.keys(userNotification.notification.data.properties); 316 for (var i = 0; i < properties.length; i++) { 317 localizedMessage = localizedMessage.replace('{' + properties[i] + '}', 318 userNotification.notification.data.properties[properties[i]]); 319 } 320 } 321 } 322 323 return localizedMessage; 324 }; 325 326 abp.notifications.getFormattedMessageFromUserNotification = function (userNotification) { 327 var formatter = abp.notifications.messageFormatters[userNotification.notification.data.type]; 328 if (!formatter) { 329 abp.log.warn('No message formatter defined for given data type: ' + userNotification.notification.data.type) 330 return '?'; 331 } 332 333 if (!abp.utils.isFunction(formatter)) { 334 abp.log.warn('Message formatter should be a function! It is invali
334d for data type: ' + 335 userNotification.notification.data.type) 336 return '?'; 337 } 338 339 return formatter(userNotification); 340 } 341 342 abp.notifications.showUiNotifyForUserNotification = function (userNotification, options) { 343 var message = abp.notifications.getFormattedMessageFromUserNotification(userNotification); 344 var uiNotifyFunc = abp.notifications.getUiNotifyFuncBySeverity(userNotification.notification.severity); 345 uiNotifyFunc(message, undefined, options); 346 } 347 348 /* LOGGING ***************************************************/ 349 //Implements Logging API that provides secure & controlled usage of console.log 350 351 abp.log = abp.log || {}; 352 353 abp.log.levels = { 354 DEBUG: 1, 355 INFO: 2, 356 WARN: 3, 357 ERROR: 4, 358 FATAL: 5 359 }; 360 361 abp.log.level = abp.log.levels.DEBUG; 362 363 abp.log.log = function (logObject, logLevel) { 364 if (!window.console || !window.console.log) { 365 return; 366 } 367 368 if (logLevel != undefined && logLevel < abp.log.level) { 369 return; 370 } 371 372 console.log(logObject); 373 }; 374 375 abp.log.debug = function (logObject) { 376 abp.log.log("DEBUG: ", abp.log.levels.DEBUG); 377 abp.log.log(logObject, abp.log.levels.DEBUG); 378 }; 379 380 abp.log.info = function (logObject) { 381 abp.log.log("INFO: ", abp.log.levels.INFO); 382 abp.log.log(logObject, abp.log.levels.INFO); 383 }; 384 385 abp.log.warn = function (logObject) { 386 abp.log.log("WARN: ", abp.log.levels.WARN); 387 abp.log.log(logObject, abp.log.levels.WARN); 388 }; 389 390 abp.log.error = function (logObject) { 391 abp.log.log("ERROR: ", abp.log.levels.ERROR); 392 abp.log.log(logObject, abp.log.levels.ERROR); 393 }; 394 395 abp.log.fatal = function (logObject) { 396 abp.log.log("FATAL: ", abp.log.levels.FATAL); 397 abp.log.log(logObject, abp.log.levels.FATAL); 398 }; 399 400 /* NOTIFICATION *********************************************/ 401 //Defines Notification API, not implements it 402 403 abp.notify = abp.notify || {}; 404 405 abp.notify.success = function (message, title, options) { 406 abp.log.warn('abp.notify.success is not implemented!'); 407 }; 408 409 abp.notify.info = function (message, title, options) { 410 abp.log.warn('abp.notify.info is not implemented!'); 411 }; 412 413 abp.notify.warn = function (message, title, options) { 414 abp.log.warn('abp.notify.warn is not implemented!'); 415 }; 416 417 abp.notify.error = function (message, title, options) { 418 abp.log.warn('abp.notify.error is not implemented!'); 419 }; 420 421 /* MESSAGE **************************************************/ 422 //Defines Message API, not implements it 423 424 abp.message = abp.message || {}; 425 426 var showMessage = function (message, title, options) { 427 alert((title || '') + ' ' + message); 428 429 if (!$) { 430 abp.log.warn('abp.message can not return promise since jQuery is not defined!'); 431 return null; 432 } 433 434 return $.Deferred(function ($dfd) { 435 $dfd.resolve(); 436 }); 437 }; 438 439 abp.message.info = function (message, title, options) { 440 abp.log.warn('abp.message.info is not implemented!'); 441 return showMessage(message, title, options); 442 }; 443 444 abp.message.success = function (message, title, options) { 445 abp.log.warn('abp.message.success is not implemented!'); 446 return showMessage(message, title, options); 447 }; 448 449 abp.message.warn = function (message, title, options) { 450 abp.log.warn('abp.message.warn is not implemented!'); 451 return showMessage(message, title, options); 452 }; 453 454 abp.message.error = function (message, title, options) { 455 abp.log.warn('abp.message.error is not implemented!'); 456 return showMessage(message, title, options); 457 }; 458 459 abp.message.confirm = function (message, title, callback, options) { 460 abp.log.warn('abp.message.confirm is not implemented!'); 461 462 var result = confirm(message); 463 callback && callback(result); 464 465 if (!$) { 466 abp.log.warn('abp.message can not return promise since jQuery is not defined!'); 467 return null; 468 } 469 470 return $.Deferred(function ($dfd) { 471 $dfd.resolve(); 472 }); 473 }; 474 475 /* UI *******************************************************/ 476 477 abp.ui = abp.ui || {}; 478 479 /* UI BLOCK */ 480 //Defines UI Block API, not implements it 481 482 abp.ui.block = function (elm) { 483 abp.log.warn('abp.ui.block is not implemented!'); 484 }; 485 486 abp.ui.unblock = function (elm) { 487 abp.log.warn('abp.ui.unblock is not implemented!'); 488 }; 489 490 /* UI BUSY */ 491 //Defines UI Busy API, not implements it 492 493 abp.ui.setBusy = function (elm, optionsOrPromise) { 494 abp.log.warn('abp.ui.setBusy is not implemented!'); 495 }; 496 497 abp.ui.clearBusy = function (elm) { 498 abp.log.warn('abp.ui.clearBusy is not implemented!'); 499 }; 500 501 /* SIMPLE EVENT BUS *****************************************/ 502 503 abp.event = (function () { 504 505 var _callbacks = {}; 506 507 var on = function (eventName, callback) { 508 if (!_callbacks[eventName]) { 509 _callbacks[eventName] = []; 510 } 511 512 _callbacks[eventName].push(callback); 513 }; 514 515 var off = function (eventName, callback) { 516 var callbacks = _callbacks[eventName]; 517 if (!callbacks) { 518 return; 519 } 520 521 var index = -1; 522 for (var i = 0; i < callbacks.length; i++) { 523 if (callbacks[i] === callback) { 524 index = i; 525 break; 526 } 527 } 528 529 if (index < 0) { 530 return; 531 } 532 533 _callbacks[eventName].splice(index, 1); 534 }; 535 536 var trigger = function (eventName) { 537 var callbacks = _callbacks[eventName]; 538 if (!callbacks || !callbacks.length) { 539 return; 540 } 541 542 var args = Array.prototype.slice.call(arguments, 1); 543 for (var i = 0; i < callbacks.length; i++) { 544 callbacks[i].apply(this, args); 545 } 546 }; 547 548 // Public interface /////////////////////////////////////////////////// 549 550 return { 551 on: on, 552 off: off, 553 trigger: trigger 554 }; 555 })(); 556 557 /* UTILS ***************************************************/ 558 559 abp.utils = abp.utils || {}; 560 561 /* Creates a name namespace. 562 * Example: 563 * var taskService = abp.utils.createNamespace(abp, 'services.task'); 564 * taskService will be equal to abp.services.task 565 * first argument (root) must be defined first 566 ************************************************************/ 567 abp.utils.createNamespace = function (root, ns) { 568 var parts = ns.split('.'); 569 for (var i = 0; i < parts.length; i++) { 570 if (typeof root[parts[i]] == 'undefined') { 571 root[parts[i]] = {}; 572 } 573 574 root = root[parts[i]]; 575 } 576 577 return root; 578 }; 579 580 /* Find and replaces a string (search) to another string (replacement) in 581 * given string (str). 582 * Example: 583 * abp.utils.replaceAll('This is a test string', 'is', 'X') = 'ThX X a test string' 584 ************************************************************/ 585 abp.utils.replaceAll = function (str, search, replacement) { 586 var fix = search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); 587 return str.replace(new RegExp(fix, 'g'), replacement); 588 }; 589 590 /* Formats a string just like string.format in C#. 591 * Example: 592 * abp.utils.formatString('Hello {0}','Tuana') = 'Hello Tuana' 593 ************************************************************/ 594 abp.utils.formatString = function () { 595 if (arguments.length < 1) { 596 return null; 597 } 598 599 var str = arguments[0]; 600 601 for (var i = 1; i < arguments.length; i++) { 602 var placeHolder = '{' + (i - 1) + '}'; 603 str = abp.utils.replaceAll(str, placeHolder, arguments[i]); 604 } 605 606 return str; 607 }; 608 609 abp.utils.toPascalCase = function (str) { 610 if (!str || !str.length) { 611 return str; 612 } 613 614 if (str.length === 1) { 615 return str.charAt(0).toUpperCase(); 616 } 617 618 return str.charAt(0).toUpperCase() + str.substr(1); 619 } 620 621 abp.utils.toCamelCase = function (str) { 622 if (!str || !str.length) { 623 return str; 624 } 625 626 if (str.length === 1) { 627 return str.charAt(0).toLowerCase(); 628 } 629 630 return str.charAt(0).toLowerCase() + str.substr(1); 631 } 632 633 abp.utils.truncateString = function (str, maxLength) { 634 if (!str || !str.length || str.length <= maxLength) { 635 return str; 636 } 637 638 return str.substr(0, maxLength); 639 }; 640 641 abp.utils.truncateStringWithPostfix = function (str, maxLength, postfix) { 642 postfix = postfix || '...'; 643 644 if (!str || !str.length || str.length <= maxLength) { 645 return str; 646 } 647 648 if (maxLength <= postfix.length) { 649 return postfix.substr(0, maxLength); 650 } 651 652 return str.substr(0, maxLength - postfix.length) + postfix; 653 }; 654 655 abp.utils.isFunction = function (obj) { 656 if ($) { 657 //Prefer to use jQuery if possible 658 return $.isFunction(obj); 659 } 660 661 //alternative for $.isFunction 662 return !!(obj && obj.constructor && obj.call && obj.apply); 663 }; 664 665 /** 666 * parameterInfos should be an array of { name, value } objects 667 * where name is query string parameter name and value is it's value. 668 * includeQuestionMark is true by default. 669 */ 670 abp.utils.buildQueryString = function (parameterInfos, includeQuestionMark) { 671 if (includeQuestionMark === undefined) { 672 includeQuestionMark = true; 673 } 674 675 var qs = ''; 676 677 function addSeperator() { 678 if (!qs.length) { 679 if (includeQuestionMark) { 680 qs = qs + '?'; 681 } 682 } else { 683 qs = qs + '&'; 684 } 685 } 686 687 for (var i = 0; i < parameterInfos.length; ++i) { 688 var parameterInfo = parameterInfos[i]; 689 if (parameterInfo.value === undefined) { 690 continue; 691 } 692 693 if (parameterInfo.value === null) { 694 parameterInfo.value = ''; 695 } 696 697 addSeperator(); 698 699 if (parameterInfo.value.toJSON && typeof parameterInfo.value.toJSON === "function") { 700 qs = qs + parameterInfo.name + '=' + encodeURIComponent(parameterInfo.value.toJSON()); 701 } else if (Array.isArray(parameterInfo.value) && parameterInfo.value.length) { 702 for (var j = 0; j < parameterInfo.value.length; j++) { 703 if (j > 0) { 704 addSeperator(); 705 } 706 707 qs = qs + parameterInfo.name + '[' + j + ']=' + encodeURIComponent(parameterInfo.value[j]); 708 } 709 } else { 710 qs = qs + parameterInfo.name + '=' + encodeURIComponent(parameterInfo.value); 711 } 712 } 713 714 return qs; 715 } 716 717 /** 718 * Sets a cookie value for given key. 719 * This is a simple implementation created to be used by ABP. 720 * Please use a complete cookie library if you need. 721 * @param {string} key 722 * @param {string} value 723 * @param {Date} expireDate (optional). If not specified the cookie will expire at the end of session. 724 * @param {string} path (optional) 725 * @param {string} domain (optional) 726 * @param {any} attributes (optional) 727 */
728 abp.utils.setCookieValue = function (key, value, expireDate, path, domain, attributes) { 729 var cookieValue = encodeURIComponent(key) + '='; 730 731 if (value) { 732 cookieValue = cookieValue + encodeURIComponent(value); 733 } 734 735 if (expireDate) { 736 cookieValue = cookieValue + "; expires=" + expireDate.toUTCString(); 737 } 738 739 if (path) { 740 cookieValue = cookieValue + "; path=" + path; 741 } 742 743 if (domain) { 744 cookieValue = cookieValue + "; domain=" + domain; 745 } 746 747 for (var name in attributes) { 748 if (!attributes[name]) { 749 continue; 750 } 751 752 cookieValue += '; ' + name; 753 if (attributes[name] === true) { 754 continue; 755 } 756 757 cookieValue += '=' + attributes[name].split(';')[0]; 758 } 759 760 document.cookie = cookieValue; 761 }; 762 763 /** 764 * Gets a cookie with given key. 765 * This is a simple implementation created to be used by ABP. 766 * Please use a complete cookie library if you need. 767 * @param {string} key 768 * @returns {string} Cookie value or null 769 */ 770 abp.utils.getCookieValue = function (key) { 771 var equalities = document.cookie.split('; '); 772 for (var i = 0; i < equalities.length; i++) { 773 if (!equalities[i]) { 774 continue; 775 } 776 777 var splitted = equalities[i].split('='); 778 if (splitted.length != 2) { 779 continue; 780 } 781 782 if (decodeURIComponent(splitted[0]) === key) { 783 return decodeURIComponent(splitted[1] || ''); 784 } 785 } 786 787 return null; 788 }; 789 790 /** 791 * Deletes cookie for given key. 792 * This is a simple implementation created to be used by ABP. 793 * Please use a complete cookie library if you need. 794 * @param {string} key 795 * @param {string} path (optional) 796 */ 797 abp.utils.deleteCookie = function (key, path) { 798 var cookieValue = encodeURIComponent(key) + '='; 799 800 cookieValue = cookieValue + "; expires=" + (new Date(new Date().getTime() - 86400000)).toUTCString(); 801 802 if (path) { 803 cookieValue = cookieValue + "; path=" + path; 804 } 805 806 document.cookie = cookieValue; 807 } 808 809 /** 810 * Gets the domain of given url 811 * @param {string} url 812 * @returns {string} 813 */ 814 abp.utils.getDomain = function (url) { 815 var domainRegex = /(https?:){0,1}\/\/((?:[\w\d-]+\.)+[\w\d]{2,})/i; 816 var matches = domainRegex.exec(url); 817 return (matches && matches[2]) ? matches[2] : ''; 818 } 819 820 /* TIMING *****************************************/ 821 abp.timing = abp.timing || {}; 822 823 abp.timing.utcClockProvider = (function () { 824 825 var toUtc = function (date) { 826 return Date.UTC( 827 date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), 828 date.getUTCSeconds(), date.getUTCMilliseconds() 829 ); 830 } 831 832 var now = function () { 833 return toUtc(new Date()); 834 }; 835 836 var normalize = function (date) { 837 if (!date) { 838 return date; 839 } 840 841 return new Date(toUtc(date)); 842 }; 843 844 // Public interface /////////////////////////////////////////////////// 845 846 return { 847 now: now, 848 normalize: normalize, 849 supportsMultipleTimezone: true 850 }; 851 })(); 852 853 abp.timing.localClockProvider = (function () { 854 855 var toLocal = function (date) { 856 return new Date( 857 date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 858 date.getMilliseconds() 859 ); 860 } 861 862 var now = function () { 863 return toLocal(new Date()); 864 } 865 866 var normalize = function (date) { 867 if (!date) { 868 return date; 869 } 870 871 return toLocal(date); 872 } 873 874 // Public interface /////////////////////////////////////////////////// 875 876 return { 877 now: now, 878 normalize: normalize, 879 supportsMultipleTimezone: false 880 }; 881 })(); 882 883 abp.timing.unspecifiedClockProvider = (function () { 884 885 var now = function () { 886 return new Date(); 887 } 888 889 var normalize = function (date) { 890 return date; 891 } 892 893 // Public interface /////////////////////////////////////////////////// 894 895 return { 896 now: now, 897 normalize: normalize, 898 supportsMultipleTimezone: false 899 }; 900 })(); 901 902 abp.timing.convertToUserTimezone = function (date) { 903 var localTime = date.getTime(); 904 var utcTime = localTime + (date.getTimezoneOffset() * 60000); 905 var targetTime = parseInt(utcTime) + parseInt(abp.timing.timeZoneInfo.windows.currentUtcOffsetInMilliseconds); 906 return new Date(targetTime); 907 }; 908 909 /* CLOCK *****************************************/ 910 abp.clock = abp.clock || {}; 911 912 abp.clock.now = function () { 913 if (abp.clock.provider) { 914 return abp.clock.provider.now(); 915 } 916 917 return new Date(); 918 } 919 920 abp.clock.normalize = function (date) { 921 if (abp.clock.provider) { 922 return abp.clock.provider.normalize(date); 923 } 924 925 return date; 926 } 927 928 abp.clock.provider = abp.timing.unspecifiedClockProvider; 929 930 /* SECURITY ***************************************/ 931 abp.security = abp.security || {}; 932 abp.security.antiForgery = abp.security.antiForgery || {}; 933 934 abp.security.antiForgery.tokenCookieName = 'XSRF-TOKEN'; 935 abp.security.antiForgery.tokenHeaderName = 'X-XSRF-TOKEN'; 936 937 abp.security.antiForgery.getToken = function () { 938 return abp.utils.getCookieValue(abp.security.antiForgery.tokenCookieName); 939 }; 940
941 abp.security.antiForgery.shouldSendToken = function (settings) { 942 if (settings.crossDomain === undefined || settings.crossDomain === null) { 943 return abp.utils.getDomain(location.href) === abp.utils.getDomain(settings.url); 944 } 945 946 return !settings.crossDomain; 947 }; 948 949 return abp; 950 })(); 951 }); 952}(typeof define === 'function' && define.amd 953 ? define 954 : function (deps, factory) { 955 if (typeof module !== 'undefined' && module.exports) { 956 module.exports = factory(require('jquery')); 957 } else { 958 window.abp = factory(window.jQuery); 959 } 960 }));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.