PageSourceSearch

https://www.osakacastlepark.jp/cms/public/api/js/const.js

js osakacastlepark.jp collected 2026-10-03 19:21:24 UTC 8,029 bytes, 308 lines download raw bytes

1/* JavaScript INFORMATION -=============================================
2File name : const.js
3Description : This file should NOT depend on any file.
4===================================================================== */
5'use strict';
6/* =====================================================================
7*  Global Constants
8* =================================================================== */
9var CONST = {
10  'APP' : {
11    'ENV' : 'prod', // e.g. dev, test, prod
12    'NAME' : "特別史跡 大阪城公園",
13    'URL' : "https://www.osakacastlepark.jp",
14  },
15  'CSRF' : {
16    'TOKEN' : {
17      'NAME' : "csrf_token", // csrf_token field name
18    },
19  },
20  'ITEMLIST' : {
21    'JSON' : {
22      'PATH' : "/cms/public/api/v1/",
23      'TAKE' : {
24        'TOP' : {
25          'SLIDERS'  : 10,
26          'BANNERS'  : 0,
27          'FLOWERS'  : 3,
28          'EVENTS'   : 2,
29          'INFORMATIONS' : {
30            'STANDARD'  : 10,
31            'IMPORTANT' : 30,
32          },
33          'ARTICLES' : 6,
34          'GENRES'   : 3,
35        }
36      },
37    },
38  },
39  'MAP' : {
40    'API' : {
41      'KEY' : "GOOGLE MAP JAVASCRIPT API KEY WRITE HERE IF YOU USE",
42    },
43  },
44  'ROUTE' : {
45    'NAME' : {
46      'EVENTS' : "events",
47      'INFORMATIONS' : "news",
48      'ARTICLES' : "articles",
49      'FLOWERS' : "flower",
50      'PLUM_GROVE': "flower/plum_grove.html",
51      'PLUM_GROVE2026' : "flower/plum_grove2026.html",
52    },
53  },
54  'LANG' : {
55    'CODES' : ['ja', 'en', 'ko', 'zh-CN', 'zh-TW'],
56    'CODES_FB' : { 'ja' : 'ja_JP', 'en' : 'en_US', 'ko' : 'ko_KR', 'zh-CN' : 'zh-CN', 'zh-TW' : 'zh-TW' },
57  }
58};
59
60Object.freeze(CONST);
61/* =====================================================================
62*  Global Common Functions
63* =================================================================== */
64function appEnv()
65{
66  return CONST.APP.ENV;
67}
68
69function isProd()
70{
71  return (appEnv() === 'prod');
72}
73
74function isTesting()
75{
76  return (appEnv() === 'test');
77}
78
79function isLocal()
80{
81  return (appEnv() === 'dev');
82}
83
84/* =====================================================================
85*  Global Helper Functions
86* =================================================================== */
87function isset(data)
88{
89  if(data == "" || data == null || data == undefined){
90    return false;
91  }
92
93  return true;
94}
95
96function nl2br(str)
97{
98  return str.replace(/\r?\n/g, "<br>");
99}
100
101function dblSlash2br(str)
102{
103  return str.replace("//", "<br>");
104}
105
106function dblSlash2nbsp(str)
107{
108  return str.replace("//", " ");
109}
110
111function escapeHtml(text)
112{
113  var map = {
114    '&' : '&amp;',
115    '<' : '&lt;',
116    '>' : '&gt;',
117    '"' : '&quot;',
118    "'" : '&#039;'
119  };
120  return text.replace(/[&<>"']/g, function(m) { return map[m]; });
121}
122
123function decodeHtml(text)
124{
125  var map = {
126    '&amp;' : '&',
127    '&lt;' : '<',
128    '&gt;' : '>',
129    '&quot;' : '"',
130    '&#039;' : "'"
131  };
132  return text.replace(/&amp;|&lt;|&gt;|&quot;|&#039;/g, function(m) { return map[m]; });
133}
134
135/**
136 * Get All Query Parameter As Object From Current Url.
137 * USAGE:
138 *   getAllUrlParams(); // [object]
139 *   getAllUrlParams().id; // ?id=1 => '1'
140 *   getAllUrlParams().lang; // ?lang=ja => 'ja'
141 *   getAllUrlParams().category; // ?category[]=events&category[]=sports => ['events','sports']
142 *   getAllUrlParams().test; // ?test => true
143 *   getAllUrlParams().nonexistent; // ? => undefined
144 *   getAllUrlParams('http://test.com/?a=abc').a; // 'abc'
145 *
146 * @param string url
147 * @return object
148 * @link https://www.sitepoint.com/get-url-parameters-with-javascript/
149 */
150function getAllUrlParams(url)
151{
152  var queryString = url ? url.split('?')[1] : window.location.search.slice(1);
153  var obj = {};
154
155  if(queryString){
156    // stuff after # is not part of query string, so get rid of it
157    queryString = queryString.split('#')[0];
158    // split our query string into its component parts
159    var arr = queryString.split('&');
160
161    for(var i = 0; i < arr.length; i++){
162      // separate the keys and the values
163      var a = arr[i].split('=');
164
165      // set parameter name and value (use 'true' if empty)
166      var paramName = a[0];
167      var paramValue = typeof (a[1]) === 'undefined' ? true : a[1];
168
169      // decode square brackets
170      paramName = paramName.replace(/%5B/g, '[').replace(/%5D/g, ']'); // e.g. category%5B%5D -> category[]
171
172      // keep case consistent
173      //paramName = paramName.toLowerCase();
174      //if(typeof paramValue === 'string'){
175      //  paramValue = paramValue.toLowerCase();
176      //}
177
178      // if the paramName ends with square brackets, e.g. category[] or category[sports]
179      if(paramName.match(/\[(\d+)?\]$/)){
180        // create key if it doesn't exist
181        var key = paramName.replace(/\[(\d+)?\]/, '');
182        if(!obj[key]){
183          obj[key] = [];
184        }
185
186        // if it's an indexed array e.g. colors[2]
187        if(paramName.match(/\[\d+\]$/)){
188          // get the index value and add the entry at the appropriate position
189          var index = /\[(\d+)\]/.exec(paramName)[1];
190          obj[key][index] = paramValue;
191        }
192        else {
193          // otherwise add the value to the end of the array
194          obj[key].push(paramValue);
195        }
196      }
197      else {
198        // if query parameter is string e.g. id or lang
199        if(!obj[paramName]){
200          // if it doesn't exist, create property
201          obj[paramName] = paramValue;
202        }
203        else if(obj[paramName] && typeof obj[paramName] === 'string'){
204          // if property does exist and it's a string, convert it to an array
205          obj[paramName] = [obj[paramName]];
206          obj[paramName].push(paramValue);
207        }
208        else {
209          // otherwise add the property
210          obj[paramName].push(paramValue);
211        }
212      }
213    }
214  }
215
216  return obj;
217}
218
219/**
220 * Add / Update a key-value pair in the URL query parameters
221 *
222 * @param string uri e.g. "http://example.com/index.html?key=value#hash1"
223 * @param string key e.g. "foo"
224 * @param string value e.g. "bar"
225 * @return string e.g. "http://example.com/index.html?key=value&foo=bar#hash1"
226 */
227function updateUrlParameter(uri, key, value)
228{
229  // remove the hash part before operating on the uri
230  var i = uri.indexOf('#');
231  var hash = i === -1 ? ''  : uri.substr(i);
232  uri = i === -1 ? uri : uri.substr(0, i);
233
234  var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
235  var separator = uri.indexOf('?') !== -1 ? "&" : "?";
236
237  if(!value){
238    // remove key-value pair if value is empty
239    uri = uri.replace(new RegExp("([?&]?)" + key + "=[^&]*", "i"), '');
240    if(uri.slice(-1) === '?') {
241      uri = uri.slice(0, -1);
242    }
243    // replace first occurrence of & by ? if no ? is present
244    if (uri.indexOf('?') === -1){
245      uri = uri.replace(/&/, '?');
246    }
247  }
248  else if (uri.match(re)) {
249    uri = uri.replace(re, '$1' + key + "=" + value + '$2');
250  }
251  else {
252    uri = uri + separator + key + "=" + value;
253  }
254
255  return uri + hash;
256}
257
258/**
259 * Redirect To Url With Referrer Informations.
260 *
261 * @param string targetUrl e.g. "http://example.com/index.html"
262 * @param boolean withQuery [true, false]
263 * @param boolean true
264 */
265function redirectTo(targetUrl, withQuery)
266{
267  var withQuery = isset(withQuery) && withQuery == true ? true : false;
268  var redirectUrl = withQuery ? targetUrl + window.location.search : targetUrl;
269
270  if(document.referrer){
271    var myReferrer = "referrer=" + encodeURIComponent(document.referrer);
272    redirectUrl = redirectUrl + (window.location.search ? '&' : '?') + myReferrer;
273  }
274
275  location.href = redirectUrl;
276  return true;
277}
278
279/**
280 * Check specified anchor tag href attribute is external link or internal.
281 *
282 * @param object linkElem
283 * @return boolean
284 */
285function isExternalLink(linkElem)
286{
287  return (linkElem.host !== window.location.host);
288}
289
290function isHtml(str)
291{
292  var a = document.createElement('div');
293  a.innerHTML = str;
294
295  for(var c = a.childNodes, i = c.length; i--;){
296    if(c[i].nodeType == 1){
297      return true;
298    }
299  }
300
301  return false;
302}
303
304function isInt(val)
305{
306  var x = parseFloat(val);
307  return !isNaN(val) && (x | 0) === x;
308}

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.