PageSourceSearch

https://shop.skinnyraven.com/assets/admin/scripts/service.js?v=1.2.0

js skinnyraven.com collected 2026-09-26 01:39:45 UTC 6,067 bytes, 186 lines download raw bytes

1
2function resolveNoAccessMessage() {
3	var root = typeof window !== "undefined" ? window : (typeof globalThis !== "undefined" ? globalThis : null);
4	if (root && root.RunFreeShared && root.RunFreeShared.errorMessages && root.RunFreeShared.errorMessages.NO_ACCESS) {
5		return root.RunFreeShared.errorMessages.NO_ACCESS;
6	}
7	if (root && root.Errors && root.Errors.noaccess && root.Errors.noaccess.error) {
8		return root.Errors.noaccess.error;
9	}
10	return "You do not have access to perform this action.";
11}
12
13var service = {
14	host: location.protocol+"//"+window.location.hostname+((window.location.port)?":"+window.location.port:""),
15	base: "api",
16	noAccessMessage: resolveNoAccessMessage(),
17	isRedirectingToLogin: false,
18	call: function(name, params, returnTo, type, handleError) {
19		if (!type) type = "POST";
20		var append = "";
21		var paramString = null;
22		if (type=="GET") {
23			var index = 0;
24			for (var key in params) {
25				if (index==0) append += "?";
26				if (params.hasOwnProperty(key)) {
27					append += ((index>0)?"&":"")+key+"="+params[key];
28				}
29				index++;
30			}
31			params = null;
32		} else paramString = JSON.stringify(params);
33		if (handleError == null) {
34			handleError = (e) => {
35				// Process Error
36				if (console) console.log("Severe Error: "+JSON.stringify(e));
37				// growler.error("A severe error occurred, please contact the store administrator and let them know. You can refresh your window and try again.")
38				if (page&&page.handlerServiceError) page.handlerServiceError(e);
39				$(".loader").removeClass("open");
40				$(".fullLoading").removeClass("open");
41				$("#ActionButton").prop("disabled",false);
42			}
43		}
44		$.ajax({
45			type: type,
46			contentType: "application/json",
47			dataType: "json",
48			url: service.host+"/"+service.base+"/"+name+append,
49			data: paramString,
50			async: true,
51			beforeSend: function(e) {
52				// Set indication of operation
53			}, 
54			error: handleError,
55			complete: function(e) {
56				// Set indication of operation Complete
57			},
58			success: function(result) {
59				if (service.interceptNoAccessResponse(result, returnTo)) return;
60				if (returnTo) returnTo(result);
61			}
62		});
63	},
64    getSet: function(variable, name, options) {
65        var params = {
66            feature: name,
67            variable: variable, 
68            options: options
69        };
70        service.call("getset", params, (e) => {
71            if (e.error) growler.error(e.error);
72            else context.set(e.variable, e.data);
73        });
74    },
75	get: (name, json, returnTo) => {
76		$.ajax({
77			type: "GET",
78			contentType: "application/json",
79			dataType: "json",
80			url: service.host+"/"+service.base+"/"+name,
81			async: true,
82			data: json,
83			beforeSend: function(e) {}, 
84			error: function(e) {
85				if (console) console.log("Severe Error: "+JSON.stringify(e));
86				if (page&&page.handlerServiceError) page.handlerServiceError(e);
87			},
88			complete: service.complete,
89			success: function(result) {
90				if (service.interceptNoAccessResponse(result, returnTo)) return;
91				if (returnTo) returnTo(result);
92			}
93		}); 
94	},
95	post: (name, json, returnTo) => {
96		$.ajax({
97			type: "POST",
98			contentType: "application/json",
99			dataType: "json",
100			url: service.host+"/"+service.base+"/"+name,
101			data: JSON.stringify(json),
102			async: true,
103			beforeSend: function(e) {}, 
104			error: function(e) {
105				if (console) console.log("Severe Error: "+JSON.stringify(e));
106				if (page&&page.handlerServiceError) page.handlerServiceError(e);
107			},
108			complete: service.complete,
109			success: function(result) {
110				if (service.interceptNoAccessResponse(result, returnTo)) return;
111				if (returnTo) returnTo(result);
112			}
113		});
114	},
115	delete: (name, json, returnTo) => {
116		$.ajax({
117			type: "DELETE",
118			contentType: "application/json",
119			dataType: "json",
120			url: service.host+"/"+service.base+"/"+name,
121			data: JSON.stringify(json),
122			async: true,
123			beforeSend: function(e) {}, 
124			error: function(e) {
125				if (console) console.log("Severe Error: "+JSON.stringify(e));
126				if (page&&page.handlerServiceError) page.handlerServiceError(e);
127			},
128			complete: service.complete,
129			success: function(result) {
130				if (service.interceptNoAccessResponse(result, returnTo)) return;
131				if (returnTo) returnTo(result);
132			}
133		});
134	},
135	log: function(data) {
136		service.call("log/console", {data: data}, (e) => {
137			console.log(e);
138		});
139	},
140	extractErrorMessage: function(response) {
141		if (response == null) return null;
142		if (typeof response === "string") return response;
143		if (typeof response.error === "string") return response.error;
144		if (response.error && typeof response.error === "object") {
145			if (typeof response.error.error === "string") return response.error.error;
146			if (typeof response.error.message === "string") return response.error.message;
147		}
148		if (typeof response.message === "string") return response.message;
149		return null;
150	},
151	isNoAccessResponse: function(response) {
152		var message = service.extractErrorMessage(response);
153		return message === service.noAccessMessage;
154	},
155	interceptNoAccessResponse: function(response, forward) {
156		if (!service.isNoAccessResponse(response)) return false;
157		service.checkSessionStatus(function(isActive) {
158			if (!isActive) {
159				service.redirectToLogin();
160			} else if (typeof forward === "function") {
161				forward(response);
162			}
163		});
164		return true;
165	},
166	checkSessionStatus: function(callback) {
167		$.ajax({
168			type: "GET",
169			contentType: "application/json",
170			dataType: "json",
171			url: service.host+"/"+service.base+"/checkSession",
172			async: true,
173			success: function(result) {
174				if (typeof callback === "function") callback(!!(result && result.isActive));
175			},
176			error: function() {
177				if (typeof callback === "function") callback(true);
178			}
179		});
180	},
181	redirectToLogin: function() {
182		if (service.isRedirectingToLogin) return;
183		service.isRedirectingToLogin = true;
184		window.location.href = "/login";
185	}
186};

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.