Subversion Repositories munaweb

Rev

Rev 36 | Rev 53 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36 Rev 40
Line 1211... Line 1211...
1211
 
1211
 
1212
    checkListingsToFind();
1212
    checkListingsToFind();
1213
}
1213
}
1214
 
1214
 
1215
const findShopifyListing = stopcock(function request(itemId, title) {
1215
const findShopifyListing = stopcock(function request(itemId, title) {
-
 
1216
    var len, flag = false;
-
 
1217
    
-
 
1218
    if (!isAsciiOnly(title)) {
-
 
1219
        flag = true;
-
 
1220
    }
-
 
1221
    
1216
	var xhttp = new XMLHttpRequest();
1222
	var xhttp = new XMLHttpRequest();
1217
	xhttp.onreadystatechange = function() {
1223
	xhttp.onreadystatechange = function() {
1218
		if (this.readyState == 4 && this.status == 200) {
1224
		if (this.readyState == 4 && this.status == 200) {
1219
			var json = JSON.parse(this.responseText);
1225
			var json = JSON.parse(this.responseText);
1220
			if (json.count !== undefined) {
1226
			if (json.count !== undefined) {
Line 1225... Line 1231...
1225
            return Promise.resolve(true);
1231
            return Promise.resolve(true);
1226
		}
1232
		}
1227
	};
1233
	};
1228
 
1234
 
1229
	xhttp.open("GET", configProxyUrl, true);
1235
	xhttp.open("GET", configProxyUrl, true);
-
 
1236
    len = title.indexOf( '(');
-
 
1237
    if (len > 0) {
-
 
1238
        title = title.substr(0, len - 1);
-
 
1239
    }
-
 
1240
	title = title.replace(/ /g, "_");
-
 
1241
	if (flag) { title = encodeURI(title); }
1230
	xhttp.setRequestHeader("X-Proxy-Url", configShopifyUrl + configShopifyProductCountUrl + '?title=' + encodeURI(title));
1242
	xhttp.setRequestHeader("X-Proxy-Url", configShopifyUrl + configShopifyProductCountUrl + '?title=' + title);
1231
	xhttp.setRequestHeader("X-LEAVE-ENCODED", "1");
1243
	xhttp.setRequestHeader("X-LEAVE-ENCODED", "1");
1232
	xhttp.send();
1244
	xhttp.send();
1233
});
1245
});
-
 
1246
 
-
 
1247
function isAsciiOnly(str) {
-
 
1248
    for (var i = 0; i < str.length; i++)
-
 
1249
        if (str.charCodeAt(i) > 255)
-
 
1250
            return false;
-
 
1251
    return true;
-
 
1252
}
1234
 
1253
 
1235
function fillSorterListing(itemIdList) {
1254
function fillSorterListing(itemIdList) {
1236
    var i;
1255
    var i;
1237
    var xml;
1256
    var xml;
1238
 
1257