PageSourceSearch

https://snow-moon-flower.jp/wp/wp-content/plugins/booking-package/js/XMLHttp.js?ver=1.7.28&date=1790311315

js snow-moon-flower.jp collected 2026-09-25 04:42:14 UTC 5,735 bytes, 281 lines download raw bytes

1	
2	function Booking_App_Fetch() {
3		
4		
5		
6	}
7	
8	function Booking_App_XMLHttp(url, data, webApp, callback, responseCallback) {
9		
10		if(webApp == true){
11			
12			data.app = 'json';
13			
14		}
15		
16		this._error = false;
17		this._count = 0;
18		
19		var object = this;
20		object.request(url, data, callback, responseCallback);
21		
22	}
23	
24	Booking_App_XMLHttp.prototype.setError = function(error) {
25		
26		this._error = error;
27		
28	}
29	
30	Booking_App_XMLHttp.prototype.getError = function() {
31		
32		return this._error;
33		
34	}
35	
36	Booking_App_XMLHttp.prototype.addCount = function() {
37		
38		this._count++;
39		
40	}
41	
42	Booking_App_XMLHttp.prototype.getCount = function() {
43		
44		return this._count;
45		
46	}
47	
48	Booking_App_XMLHttp.prototype.setStatus = function(status){
49		
50		this._status = status;
51		
52	}
53	
54	Booking_App_XMLHttp.prototype.getStatus = function(){
55		
56		return this._status;
57		
58	}
59	
60	Booking_App_XMLHttp.prototype.requestCreate = function(){
61		
62		try{
63			
64			return new XMLHttpRequest();
65			
66		}catch(e){}
67		
68		return null;
69			
70	}
71	
72	Booking_App_XMLHttp.prototype.request = function(url, data, callback, responseCallback){
73		
74		var object = this;
75		try {
76			
77			var xhr = new XMLHttpRequest();
78			xhr.onreadystatechange = function(){
79				
80				switch (xhr.readyState) {
81				
82					case 4:
83					if (xhr.status == 0) {
84					
85						//callback({status: "ERROR"});
86					
87					} else {
88					
89						if ((200 <= xhr.status && xhr.status < 300) || (xhr.status == 304)) {
90							
91							
92							
93						} else {
94							
95							//callback({status: "ERROR"});
96							
97						}
98					
99					}
100					
101					break;
102					
103				}
104				
105			};
106			
107			xhr.onload = function(e){
108				
109				object.setStatus(xhr.status);
110				if (responseCallback != null && typeof responseCallback == "function") {
111					
112					responseCallback(xhr.responseText);
113					
114				}
115				
116				if (xhr.status == 401) {
117					
118					window.alert("Failed to load resource: the server responded with a status of 401 (Authorization Required). In order to use Booking Package, you need to cancel Basic Authentication. Basic authentication URL: " + url);
119					
120				}
121				
122				//var bool = object.isJSON(xhr.responseText);
123				var bool = true;
124				if (xhr.status == 200 || xhr.status == 304) {
125					
126					if (object.isJSON(xhr.responseText) === true) {
127						
128						var responseJson = JSON.parse(xhr.responseText);
129						callback(responseJson);
130						
131					} else {
132						
133						object.errorJSONFormat(xhr.responseText, xhr.status, 'errorJsonFormat');
134						
135					}
136					
137				} else {
138					
139					console.log(xhr.responseText);
140					if (object.isJSON(xhr.responseText) === true) {
141						
142						var responseJson = JSON.parse(xhr.responseText);
143						callback(responseJson);
144						
145					} else {
146						
147						object.errorJSONFormat(xhr.responseText, xhr.status, 'errorInServer');
148						
149					}
150					
151					
152				}
153				
154				
155			}
156			
157			xhr.onerror = function(e){
158				
159				console.log(e);
160				object.setError(true);
161				var count = object.getCount();
162				if (count < 10) {
163					
164					var timer = setInterval(function() {
165                        
166                        object.addCount();
167						object.request(url, data, callback, responseCallback);
168                        clearInterval(timer);
169                        
170                    }, 500);
171					
172				} else {
173					
174					callback({status: "ERROR"});
175					
176				}
177				
178			}
179			
180			xhr.open("POST", url);
181			xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
182			
183			if (data.booking_package_wp_rest_nonce != null) {
184				
185				xhr.setRequestHeader('X-WP-Nonce', data.booking_package_wp_rest_nonce);
186				xhr.withCredentials = true;
187				
188			}
189			
190			xhr.send(this.encodeHTMLForm(data));
191			
192		} catch(e) {
193			
194		} finally {
195			
196		}
197		
198		return null;
199			
200	}
201		
202	Booking_App_XMLHttp.prototype.encodeHTMLForm = function(data){
203		
204    	var params = [];
205		
206		for( var name in data ){
207			
208        	var value = data[ name ];
209			var param = encodeURIComponent( name ) + '=' + encodeURIComponent( value );
210			
211			params.push( param );
212    	}
213		
214		return params.join( '&' ).replace( /%20/g, '+' );
215		
216	}
217	
218	Booking_App_XMLHttp.prototype.isJSON = function(jsonString){
219		
220		try {
221			JSON.parse(jsonString);
222			return true;
223		} catch (error) {
224			return false;
225		}
226		
227		/**
228		arg = (typeof arg === "function") ? arg() : arg;
229	    if(typeof arg  !== "string") {
230	        return false;
231	    }
232	    
233	    try{
234	    	arg = (!JSON) ? eval("(" + arg + ")") : JSON.parse(arg);
235			return true;
236	    }catch(e){
237			return false;
238	    }
239		**/
240		
241	}
242	
243	
244	Booking_App_XMLHttp.prototype.errorJSONFormat = function(jsonString, status, errorType){
245		
246		var object = this;
247		var statusMessage = 'JSON format error.';
248		if (errorType == 'errorInServer') {
249			
250			statusMessage = 'During the communication (AJAX) between this browser and the server, the server returned an HTTP status code ' + status + ". To resolve this issue, please contact the server administrator. \n\n";
251			
252		}
253		console.log(jsonString);
254		var booking_package_json_format_error_panel = document.getElementById('booking_package_json_format_error_panel');
255		if (booking_package_json_format_error_panel != null) {
256			
257			booking_package_json_format_error_panel.classList.remove('hidden_panel');
258			var errorPanel = booking_package_json_format_error_panel.getElementsByTagName('p')[0];
259			if (errorPanel !=  null) {
260				
261				errorPanel.textContent = statusMessage;
262				
263			}
264			
265			errorPanel = booking_package_json_format_error_panel.getElementsByTagName('p')[1];
266			if (errorPanel !=  null) {
267				
268				errorPanel.textContent = jsonString;
269				
270			}
271			
272			document.getElementById('bookingBlockPanel').classList.add('hidden_panel');
273			
274		} else {
275			
276			window.alert(statusMessage + ': ' + jsonString);
277			
278		}
279		
280	};
281	

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.