1/* 2 * Copyright 2023 Anyware Services 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17AmetysFront = { 18 19 _appParams: {}, 20 21 _displayMode: undefined, 22 23 setAppParameter: function (name, value) 24 { 25 this._appParams[name] = value; 26 }, 27 28 CONTEXT_PATH : "", 29 30 ABSOLUTE_CONTEXT_PATH: "", 31 32 URI_PREFIX: "", 33 34 ABSOLUTE_URI_PREFIX: "", 35 36 MAX_UPLOAD_SIZE: 1000000, 37 38 getPluginDirectPrefix: function (plugin) 39 { 40 return [AmetysFront.URI_PREFIX, '_plugins', plugin].join('/'); 41 }, 42 43 getAbsolutePluginDirectPrefix: function (plugin) 44 { 45 return [AmetysFront.ABSOLUTE_URI_PREFIX, '_plugins', plugin].join('/'); 46 }, 47 48 getPluginResourcesPrefix: function (plugin) 49 { 50 return [AmetysFront.CONTEXT_PATH, 'plugins', plugin, 'resources'].join('/'); 51 }, 52 53 getAbsolutePluginResourcesPrefix: function (plugin) 54 { 55 return [AmetysFront.ABSOLUTE_CONTEXT_PATH, 'plugins', plugin, 'resources'].join('/'); 56 }, 57 58 getAppParameters: function() 59 { 60 return this._appParams; 61 }, 62 63 getAppParameter: function(name) 64 { 65 return this._appParams[name]; 66 }, 67 68 _mediaDisplayModeBrowser: window.matchMedia("(display-mode: browser)"), 69 _mediaDisplayModeFullscreen: window.matchMedia("(display-mode: fullscreen)"), 70 _mediaDisplayModeStandalone: window.matchMedia("(display-mode: standalone)"), 71 _mediaDisplayModeMinimalUI: window.matchMedia("(display-mode: minimal-ui)"), 72 73 getDisplayMode: function() 74 { 75 if (AmetysFront._displayMode === undefined) 76 { 77 if (AmetysFront._mediaDisplayModeBrowser.matches) 78 { 79 AmetysFront._displayMode = 'browser'; 80 } 81 else if (AmetysFront._mediaDisplayModeFullscreen.matches) 82 { 83 AmetysFront._displayMode = 'fullscreen'; 84 } 85 else if (AmetysFront._mediaDisplayModeStandalone.matches) 86 { 87 AmetysFront._displayMode = 'standalone'; 88 } 89 else // if (AmetysFront._mediaDisplayModeMinimalUI.matches) 90 { 91 AmetysFront._displayMode = 'minimal-ui'; 92 } 93 } 94 95 return AmetysFront._displayMode; 96 }, 97 98 _displayModeChangeListeners: [], 99 _callDisplayModeChangeListeners: function() 100 { 101 for (let displayModeChangeListener of AmetysFront._displayModeChangeListeners) 102 { 103 displayModeChangeListener(AmetysFront._displayMode); 104 } 105 }, 106 107 onDisplayModeChange: function(callback) 108 { 109 AmetysFront._displayModeChangeListeners.push(callback); 110 callback(AmetysFront.getDisplayMode()); 111 } 112} 113 114AmetysFront._mediaDisplayModeBrowser.addEventListener("change", function(e) { if (e.matches) { AmetysFront._displayMode = 'browser'; AmetysFront._callDisplayModeChangeListeners(); } }); 115AmetysFront._mediaDisplayModeFullscreen.addEventListener("change", function(e) { if (e.matches) { AmetysFront._displayMode = 'fullscreen'; AmetysFront._callDisplayModeChangeListeners(); } }); 116AmetysFront._mediaDisplayModeStandalone.addEventListener("change", function(e) { if (e.matches) { AmetysFront._displayMode = 'standalone'; AmetysFront._callDisplayModeChangeListeners(); } }); 117AmetysFront._mediaDisplayModeMinimalUI.addEventListener("change", function(e) { if (e.matches) { AmetysFront._displayMode = 'minimal-ui';
117 AmetysFront._callDisplayModeChangeListeners(); } });
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.