PageSourceSearch

https://fxboss.firstcitizens.com/app/assets/angular-translate/angu…-translate-storage-local.js?v=31082026-1758

js firstcitizens.com collected 2026-09-24 21:52:16 UTC 3,636 bytes, 123 lines download raw bytes

1/*!
2 * angular-translate - v2.18.4 - 2021-01-14
3 * 
4 * Copyright (c) 2021 The angular-translate team, Pascal Precht; Licensed MIT
5 */
6(function (root, factory) {
7  if (typeof define === 'function' && define.amd) {
8    // AMD. Register as an anonymous module unless amdModuleId is set
9    define([], function () {
10      return (factory());
11    });
12  } else if (typeof module === 'object' && module.exports) {
13    // Node. Does not work with strict CommonJS, but
14    // only CommonJS-like environments that support module.exports,
15    // like Node.
16    module.exports = factory();
17  } else {
18    factory();
19  }
20}(this, function () {
21
22$translateLocalStorageFactory.$inject = ['$window', '$translateCookieStorage'];
23angular.module('pascalprecht.translate')
24
25/**
26 * @ngdoc object
27 * @name pascalprecht.translate.$translateLocalStorage
28 * @requires $window
29 * @requires $translateCookieStorage
30 *
31 * @description
32 * Abstraction layer for localStorage. This service is used when telling angular-translate
33 * to use localStorage as storage.
34 *
35 */
36.factory('$translateLocalStorage', $translateLocalStorageFactory);
37
38function $translateLocalStorageFactory($window, $translateCookieStorage) {
39
40  'use strict';
41
42  // Setup adapter
43  var localStorageAdapter = (function(){
44    var langKey;
45    return {
46      /**
47       * @ngdoc function
48       * @name pascalprecht.translate.$translateLocalStorage#get
49       * @methodOf pascalprecht.translate.$translateLocalStorage
50       *
51       * @description
52       * Returns an item from localStorage by given name.
53       *
54       * @param {string} name Item name
55       * @return {string} Value of item name
56       */
57      get: function (name) {
58        if(!langKey) {
59          langKey = $window.localStorage.getItem(name);
60        }
61
62        return langKey;
63      },
64      /**
65       * @ngdoc function
66       * @name pascalprecht.translate.$translateLocalStorage#set
67       * @methodOf pascalprecht.translate.$translateLocalStorage
68       *
69       * @description
70       * Sets an item in localStorage by given name.
71       *
72       * @deprecated use #put
73       *
74       * @param {string} name Item name
75       * @param {string} value Item value
76       */
77      set: function (name, value) {
78        langKey=value;
79        $window.localStorage.setItem(name, value);
80      },
81      /**
82       * @ngdoc function
83       * @name pascalprecht.translate.$translateLocalStorage#put
84       * @methodOf pascalprecht.translate.$translateLocalStorage
85       *
86       * @description
87       * Sets an item in localStorage by given name.
88       *
89       * @param {string} name Item name
90       * @param {string} value Item value
91       */
92      put: function (name, value) {
93        langKey=value;
94        $window.localStorage.setItem(name, value);
95      }
96    };
97  }());
98
99  var hasLocalStorageSupport = 'localStorage' in $window;
100  if (hasLocalStorageSupport) {
101    var testKey = 'pascalprecht.translate.storageTest';
102    try {
103      // this check have to be wrapped within a try/catch because on
104      // a SecurityError: Dom Exception 18 on iOS
105      if ($window.localStorage !== null) {
106        $window.localStorage.setItem(testKey, 'foo');
107        $window.localStorage.removeItem(testKey);
108        hasLocalStorageSupport = true;
109      } else {
110        hasLocalStorageSupport = false;
111      }
112    } catch (e){
113      hasLocalStorageSupport = false;
114    }
115  }
116  var $translateLocalStorage = hasLocalStorageSupport ? localStorageAdapter : $translateCookieStorage;
117  return $translateLocalStorage;
118}
119
120$translateLocalStorageFactory.displayName = '$translateLocalStorageFactory';
121return 'pascalprecht.translate';
122
123}));

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.