PageSourceSearch

https://mairie-grazac31.fr/plugins/link-directory/resources/js/LinkDirectoryHelper.js

js mairie-grazac31.fr collected 2026-10-03 02:48:44 UTC 3,804 bytes, 111 lines download raw bytes

1/*
2 *  Copyright 2018 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
17/**
18 * Helper for link directory
19 */
20var AmetysHelperLinkDirectory = {
21	
22	/**
23     * Save user preference for user directory 
24     * @param {Array} orderedLinks The ordered links list to save. If null, we ignore this user preference. If empty, we set the ordered links user preference to empty.
25     * @param {Array} hiddenLinks The hidden links list to save. If null, we ignore this user preference. If empty, we set the hidden links user preference to empty.
26     * @param {String} siteUriPrefix the site uri prefix
27     * @param {String} lang the current language
28     * @param {String} savingId the saving id, it can be the zone item id or input data id and it can be empty for default input data (the user pref depend of this unique id)
29     * @param {Function} successCB the function which be called if saving the user preference works
30     * @param {Function} errorCB the function which be called if an error occurred saving the user preference
31     */
32	saveUserPrefs: function(orderedLinks, hiddenLinks, siteUriPrefix, lang, savingId, successCB, errorCB)
33	{   
34	    var data = {
35	        'saving-id': savingId,
36            'language': lang
37	    };
38	    
39	    if (orderedLinks != null)
40	    {
41	    	data['ordered-links'] = orderedLinks.join();
42	    }
43	    
44	    if (hiddenLinks != null)
45	    {
46	    	data['hidden-links'] = hiddenLinks.join();
47	    }
48	    
49	    $j.ajax({
50	        url: siteUriPrefix + '/_plugins/link-directory/set-user-preferences',
51	        data: data,
52	        method: 'POST',
53	        success: function(data) { 
54	        	if ($j.isFunction(successCB))
55	        	{
56	        		successCB();
57	        	}
58	    	},
59	        error: function(data) {
60	        	if ($j.isFunction(errorCB))
61	        	{
62	        		errorCB();
63	        	}
64	    	}
65	    });
66	},
67
68	/**
69     * Remove a list of user link 
70     * @param {Array} linksToRemove The list of user links to remove. If null, we do nothing. If empty, the noLinkToRemoveCB will be called.
71     * @param {String} siteUriPrefix the site uri prefix
72     * @param {Function} successCB the function which be called if deleting the user links works
73     * @param {Function} errorCB the function which be called if an error occurred deleting the user links
74     * @param {Function} noLinkToRemoveCB the function which be called if there are no user link to remove
75     */
76	removeUserLinks: function(linksToRemove, siteUriPrefix, successCB, errorCB, noLinkToRemoveCB)
77	{
78		if (linksToRemove != null)
79		{
80		    if (linksToRemove.length > 0)
81		    {
82		        $j.ajax({
83		            url: siteUriPrefix + '/_plugins/link-directory/remove-user-link',
84		            data: {
85		                ids: JSON.stringify(linksToRemove)
86		            },
87		            method: 'POST',
88		            success: function(data) {
89		            	if ($j.isFunction(successCB))
90			        	{
91			        		successCB();
92			        	}
93		            },
94		            error: function(data) {
95		            	if ($j.isFunction(errorCB))
96			        	{
97		            		errorCB();
98			        	}
99		            }
100		        });
101		    }
102		    else
103		    {
104		    	if ($j.isFunction(noLinkToRemoveCB))
105	        	{
106		    		noLinkToRemoveCB();
107	        	}
108		    }
109		}
110    }
111}

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.