PageSourceSearch

https://hmg.com/_catalogs/masterpage/Design_2023/AngularJS/Common.js

js hmg.com collected 2026-09-25 10:38:58 UTC 9,366 bytes, 291 lines download raw bytes

1var app = angular.module("extApp", ['ngSanitize', 'angularUtils.directives.dirPagination']);
2function GetListItem(listname, query, complete, failure, isAsync) {
3    // Getting our list items
4    $.ajax({
5        url: "/_api/web/lists/getbytitle('" + listname + "')/items" + query,
6        method: "GET",
7        headers: {
8            "Accept": "application/json; odata=verbose"
9        },
10        async: isAsync,
11        success: function (data) {
12            // Returning the results
13            complete(data);
14        },
15        error: function (data) {
16            failure(data);
17        }
18    });
19}
20
21function GetListItem_Ar(listname, query, complete, failure, isAsync) {
22    // Getting our list items
23    $.ajax({
24        url: "/ar/_api/web/lists/getbytitle('" + listname + "')/items" + query,
25        method: "GET",
26        headers: {
27            "Accept": "application/json; odata=verbose"
28        },
29        async: isAsync,
30        success: function (data) {
31            // Returning the results
32            complete(data);
33        },
34        error: function (data) {
35            failure(data);
36        }
37    });
38}
39
40
41function GetMagPages_Ar(listname, query, complete, failure, isAsync) {
42    // Getting our list items
43    $.ajax({
44        url: query, //"/ar/_api/web/lists/getbytitle('" + listname + "')/items" + query,
45        method: "GET",
46        headers: {
47            "Accept": "application/json; odata=verbose"
48        },
49        async: isAsync,
50        success: function (data) {
51            // Returning the results
52            complete(data);
53        },
54        error: function (data) {
55            failure(data);
56        }
57    });
58}
59
60
61function GetMagazines_Ar(listname, query, complete, failure, isAsync) {
62    // Getting our list items
63    $.ajax({
64        url: "/ar/_api/web/lists/getbytitle('" + listname + "')/items" + query,
65        method: "GET",
66        headers: {
67            "Accept": "application/json; odata=verbose"
68        },
69        async: isAsync,
70        success: function (data) {
71            // Returning the results
72            complete(data);
73        },
74        error: function (data) {
75            failure(data);
76        }
77    });
78}
79
80
81function GetListItemsWithQuery(listname, query, complete, failure, isAsync) {
82    // Getting our list items
83    $.ajax({
84        url: "/_api/web/lists/getbytitle('" + listname + "')/GetItems" + query,
85        type: "POST",
86        headers: {
87            "Accept": "application/json;odata=verbose",
88            "X-RequestDigest": $("#__REQUESTDIGEST").val()
89        },
90        async: isAsync,
91        success: function (data) {
92            // Returning the results
93            complete(data);
94        },
95        error: function (data) {
96            failure(data);
97        }
98    });
99}
100function GetListChoiceField(listTitle, FieldName, complete, failure, isAsync) {
101    requestURL = "/_api/web/lists/GetByTitle('" + listTitle + "')/fields";
102    if (FieldName != null)
103        requestURL += "?$filter=EntityPropertyName eq '" + FieldName + "'"
104    $.ajax({
105        url: requestURL,
106        type: "GET",
107        headers: {
108            "accept": "application/json;odata=verbose",
109        },
110        async: isAsync,
111        success: function (data) {
112        complete(data.d.results[0].Choices.results);
113        },
114        error: function (error) {
115            failure(data);
116        }
117    });
118}
119function GetList(listid, query, complete, failure, isAsync) {
120    // Getting our list items
121    $.ajax({
122        url: "/_api/web/lists(guid'" + listid + "')" + query,
123        method: "GET",
124        headers: {
125            "Accept": "application/json; odata=verbose"
126        },
127        async: isAsync,
128        success: function (data) {
129        complete(data);
130        },
131        error: function (data) {
132            failure(data);
133        }
134    });
135}
136function GetListbyTitle(ListName, query, complete, failure, isAsync) {
137    // Getting our list items
138    $.ajax({
139        url: "/_api/web/lists/GetByTitle('" + ListName + "')" + query,
140        method: "GET",
141        headers: {
142            "Accept": "application/json; odata=verbose"
143        },
144        async: isAsync,
145        success: function (data) {
146        complete(data);
147        },
148        error: function (data) {
149        failure(data);
150        }
151    });
152}
153// Getting the item type for the list
154function getListItemType(name) {
155    return "SP.Data." + name[0].toUpperCase() + name.substring(1) + "ListItem";
156}
157function getParameterByName(name) {
158    var url = window.location.href.toLowerCase();
159    name = name.replace(/[\[\]]/g, "\\$&");
160    var regex = new RegExp("[?&]" + name.toLowerCase() + "(=([^&#]*)|&|#|$)"),
161        results = regex.exec(url);
162    if (!results) return null;
163    if (!results[2]) return '';
164    return decodeURIComponent(results[2].replace(/\+/g, " "));
165}
166
167function getSiteCollUrl() {
168    return _spPageContextInfo.siteAbsoluteUrl.replace("http://", "https://");
169}
170function redirectToPageUrl(pageUrl) {
171    if (pageUrl != null && pageUrl != '') {
172        if(pageUrl.toLowerCase().indexOf('.pdf') > -1){
173            var tempWebUrl = _spPageContextInfo.webAbsoluteUrl;
174            if(!isArabicSite){
175                tempWebUrl = tempWebUrl.replace('/en', '');
176            }
177            else{
178                tempWebUrl = tempWebUrl.replace('/ar', '');
179            }
180            openWindow(tempWebUrl + pageUrl);
181        }
182        else if (pageUrl.toLowerCase().indexOf('http://') > -1 || pageUrl.toLowerCase().indexOf('https://') > -1) {
183            openWindow(pageUrl);
184        }
185        else {
186            var tempWebUrl = _spPageContextInfo.webAbsoluteUrl;
187            if (tempWebUrl.indexOf("hmg.com") >= 0) {
188                tempWebUrl = tempWebUrl.replace(':1300', '');
189            }
190            openWindow(tempWebUrl + pageUrl); 
191        }
192    }
193}
194function openWindow(pageUrl) {
195    var isSafari = navigator.vendor && navigator.vendor.indexOf('Apple') > -1 &&
196    navigator.userAgent &&
197    navigator.userAgent.indexOf('CriOS') == -1 &&
198    navigator.userAgent.indexOf('FxiOS') == -1;
199    if (pageUrl.indexOf("hmg.com") >= 0 || pageUrl.indexOf("raysppweb02") >= 0){
200        if(pageUrl == 'https://academy.hmg.com/'){
201            window.open(pageUrl, '_blank');
202        }
203        else{
204            window.location = pageUrl;
205        }
206    }
207    else {
208        if (isSafari)
209        {
210           window.location = pageUrl;
211        }
212        else{
213           window.open(pageUrl, '_blank');
214        }
215    }
216}
217function getParameterByName(name) {
218    var url = window.location.href.toLowerCase();
219    name = name.replace(/[\[\]]/g, "\\$&");
220    var regex = new RegExp("[?&]" + name.toLowerCase() + "(=([^&#]*)|&|#|$)"),
221        results = regex.exec(url);
222    if (!results) return null;
223    if (!results[2]) return '';
224    return decodeURIComponent(results[2].replace(/\+/g, " "));
225}
226document.addEventListener('DOMContentLoaded', () => {
227    if (window.innerWidth < 1000) {
228        document.getElementById('ms-designer-ribbon').style.display = 'none'
229    }
230    function aos_init() {
231        AOS.init({
232            duration: 1000,
233            easing: 'ease-in-out',
234            once: true,
235            mirror: false
236        });
237    }
238    window.addEventListener('load', () => {
239        aos_init();
240    });
241    function aos_refresh() {
242        AOS.refresh({
243            duration: 1000,
244            easing: 'ease-in-out',
245            once: true,
246            mirror: false
247        });
248    }
249    document.getElementById("s4-workspace").addEventListener("scroll", myFunction);
250    function myFunction() {
251        aos_refresh();
252    }
253});
254function stuffToRunAfterSP_JS() {
255    if (window.outerWidth < 600) {
256        var element = document.getElementById('s4-workspace');
257        element.style.width = null;
258    }
259}
260function redirectToAPPStore(btnName) {
261
262    GetListItem('AppStore', "?$select=Title,Link,DeviceType",
263        function (data) {
264            var isSafari = false
265            var tempGroup = [];
266            tempGroup = data.d.results;
267            var ua = navigator.userAgent;
268            if (/Android/i.test(ua)) { 
269                tempGroup = tempGroup.filter(e => e.Title == btnName && e.DeviceType == 'Android');
270                redirectToPageUrl(tempGroup[0].Link)
271            }
272            else if (/iPad|iPhone|iPod/i.test(ua)) { 
273                 tempGroup = tempGroup.filter(e => e.Title == btnName && e.DeviceType == 'Apple');
274                redirectToPageUrl(tempGroup[0].Link)
275            }
276            else if (/Chrome/i.test(ua)) {
277                tempGroup = tempGroup.filter(e => e.Title == btnName && e.DeviceType == 'Web');
278                redirectToPageUrl(tempGroup[0].Link)
279            }
280            else{
281                tempGroup = tempGroup.filter(e => e.Title == btnName && e.DeviceType == 'Web');
282            redirectToPageUrl(tempGroup[0].Link);
283            }
284        }, function (error) {
285            console.log(error);
286        }, true);
287
288}
289SP.SOD.executeFunc('sp.js', 'SP.ClientContext', stuffToRunAfterSP_JS);
290var isArabicSite = window.location.href.toLowerCase().indexOf('/ar/') > -1;
291

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.