Subversion Repositories munaweb

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 - 1
function findProductInfo(IDValue) {
2
	// Construct the findProduct request
3
	url = configeBayShopping;
4
	url += "?callname=FindProducts";
5
	url += "&responseencoding=JSON";
6
	url += "&appid=" + configAppid;
7
	url += "&version=1061";
8
	url += "&siteid=0";
9
	url += "&AvailableItemsOnly=true";
10
	url += "&MaxEntries=1";
11
	url += "&ProductID.Type=Reference";
12
	url += "&ProductID.Value=";
13
	url += IDValue;
14
 
15
	// Submit the request
16
	var xhttp = new XMLHttpRequest();
17
 
18
	xhttp.onreadystatechange = function() {
19
    	if (this.readyState == 4) {
20
    		_cb_FindProducts(JSON.parse(this.responseText));
21
        }
22
    };
23
 
24
	xhttp.open("GET", configProxyUrl, true);
25
	xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
26
   	xhttp.send();
27
}
28
 
29
// Create new page for product info
30
function _cb_FindProducts(root) {
31
	var ack = root.Ack;
32
	if (ack != 'Success') {
33
		var x = document.getElementById("warnings");
34
		x.innerHTML = "<h2>eBAy API Error<h2>";
35
		x.innerHTML += "<p>Id: " + root.Errors[0].ErrorCode + "<br/>";
36
		x.innerHTML += "<p>Domain: " + root.Errors[0].ErrorClassification + "<br/>";
37
		x.innerHTML += "<p>Severity: " + root.Errors[0].SeverityCode + "<br/>";
38
		x.innerHTML += "<p>Category: " + root.Errors[0].category + "<br/>";
39
		x.innerHTML += "<p>Short Message: " + root.Errors[0].ShortMessage + "<br/>";
40
		x.innerHTML += "<p>Long Message: " + root.Errors[0].LongMessage + "<br/>";
41
		x.innerHTML += "<p>Build/Version: " + root.Build + '/' + root.Version + "</p>";
42
		x.innerHTML += "<p>URL: " + "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>" + "</p>";
43
 
44
    	x.className = x.className.replace(" invisible", " visible");
45
 
46
		if (ack == 'Failure' || ack == 'PartialFailure') {
47
			x.scrollIntoView(true);
48
			return;
49
		}
50
	}
51
 
52
	var str = "";
53
	var i = 0;
54
 
55
	var JsonObj = typeof root.Product != 'object' ? JSON.parse(root.Product) : root.Product;
56
	var Title = JsonObj[0].Title;
57
 
58
	str = '<!DOCTYPE html>';
59
	str += '<html lang="en">';
60
	str += '<head>';
61
	str += '<title>' + Title + '</title>';
62
	str += '<meta charset="UTF-8">';
63
	str += '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
64
	str += '<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">';
65
	str += '<link rel="icon" href="favicon.ico" type="image/x-icon">';
66
	str += '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">';
67
	str += '<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"><\/script>';
68
	str += '<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"><\/script>';
69
	str += '<link rel="stylesheet" href="css/styleBS.css">';
70
	str += '<script src="js/muna-tools.js"><\/script>';
71
	str += '</head>';
72
	str += '<body>';
73
	str += '<div class="container-fluid">';
74
	str += '<div class="container-fluid border bg-secondary">';
75
	str += '<div class="clearfix">';
76
	str += '<img class="img-fluid float-right" src="images/MUNA%20-%20Logo%20100x100.png" alt="MUNA Trading Logo">';
77
	str += '<h2>' + Title + '</h2>';
78
	str += '</div>';
79
	str += '</div>';
80
 
81
	str += '<div class="container-fluid border bg-light">';
82
	str += '<div class="row">';
83
	str += '<div class="col">';
84
 
85
	str += '<h2>Detailed Product Information</h2>';
86
 
87
	if (JsonObj[0].StockPhotoURL) {
88
		str += '<a href="' + JsonObj[0].DetailsURL + '" target="_blank">';
89
		str += '<img src="' + JsonObj[0].StockPhotoURL + '">';
90
		str += '</a>';
91
	}
92
 
93
	if (JsonObj[0].ItemSpecifics) {
94
		str += '<p>';
95
		for (i = 0; i < JsonObj[0].ItemSpecifics.NameValueList.length; i++) {
96
			str += JsonObj[0].ItemSpecifics.NameValueList[i].Name + ': ' + JsonObj[0].ItemSpecifics.NameValueList[i].Value + '<br/>';
97
		}
98
		str += '</p>';
99
	}
100
 
101
	if (JsonObj[0].ProductID) {
102
		str += '<p>';
103
		for (i = 0; i < JsonObj[0].ProductID.length; i++) {
104
			str += JsonObj[0].ProductID[i].Type + ': ' + JsonObj[0].ProductID[i].Value + '<br/>';
105
		}
106
		str += '</p>';
107
	}
108
 
109
	str += '</div>';
110
	str += '</div>';
111
	str += '</div>';
112
 
113
	str += '<footer class="container-fluid text-center border border-bottom-0 border-left-0 border-right-0">';
114
	str += 'Copyright &#169; ' + new Date().getFullYear() + ' MUNA Trading. All rights reserved.';
115
	str += '</footer>';
116
	str += '</div>';
117
	str += '</body>';
118
	str += '</html>';
119
 
120
	var newWin = window.open("", Title);
121
	if (newWin) {
122
		newWin.document.open().write(str);
123
		newWin.document.close();
124
	}
125
}
126