Subversion Repositories munaweb

Rev

Rev 2 | Rev 68 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 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");
30 - 34
        var str = '<div class="alert alert-danger' alert-dismissible">';
35
        str += '<button type="button" class="close" data-dismiss="alert">×</button>';
36
		str += "<h2>eBay API Error<h2>";
37
		str += "<ul>"
38
		str += "<li>Id: " + root.Errors[0].ErrorCode + "</li>";
39
		str += "<li>Domain: " + root.Errors[0].ErrorClassification + "</li>";
40
		str += "<li>Severity: " + root.Errors[0].SeverityCode + "</li>";
41
		str += "<li>Category: " + root.Errors[0].category + "</li>";
42
		str += "<li>Short Message: " + root.Errors[0].ShortMessage + "</li>";
43
		str += "<li>Long Message: " + root.Errors[0].LongMessage + "</li>";
44
		str += "<li>Build/Version: " + root.Build + '/' + root.Version + "</li>";
45
		str += "</ul>"
46
		str += "<p>URL: " + "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>" + "</p>";
47
		str += "</div>"
2 - 48
 
30 - 49
    	x.innerHTML = str;
50
    	x.className = x.className.replace(" invisible", " visible");
2 - 51
 
52
		if (ack == 'Failure' || ack == 'PartialFailure') {
53
			x.scrollIntoView(true);
54
			return;
55
		}
56
	}
57
 
58
	var str = "";
59
	var i = 0;
60
 
61
	var JsonObj = typeof root.Product != 'object' ? JSON.parse(root.Product) : root.Product;
62
	var Title = JsonObj[0].Title;
63
 
64
	str = '<!DOCTYPE html>';
65
	str += '<html lang="en">';
66
	str += '<head>';
67
	str += '<title>' + Title + '</title>';
68
	str += '<meta charset="UTF-8">';
69
	str += '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
70
	str += '<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">';
71
	str += '<link rel="icon" href="favicon.ico" type="image/x-icon">';
30 - 72
	str += '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">';
73
	str += '<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"><\/script>';
74
	str += '<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"><\/script>';
2 - 75
	str += '<link rel="stylesheet" href="css/style.css">';
30 - 76
	str += '<script src="js/muna-tools.js"><\/script>';
2 - 77
	str += '</head>';
78
	str += '<body>';
30 - 79
	str += '<div class="container-fluid">';
80
	str += '<div class="container-fluid border bg-secondary">';
81
	str += '<div class="clearfix">';
82
	str += '<img class="img-fluid float-right" src="images/MUNA%20-%20Logo%20100x100.png" alt="MUNA Trading Logo">';
83
	str += '<h2>' + Title + '</h2>';
2 - 84
	str += '</div>';
30 - 85
	str += '</div>';
2 - 86
 
30 - 87
	str += '<div class="container-fluid border bg-light">';
88
	str += '<div class="row">';
89
	str += '<div class="col">';
2 - 90
 
91
	str += '<h2>Detailed Product Information</h2>';
92
 
93
	if (JsonObj[0].StockPhotoURL) {
94
		str += '<a href="' + JsonObj[0].DetailsURL + '" target="_blank">';
95
		str += '<img src="' + JsonObj[0].StockPhotoURL + '">';
96
		str += '</a>';
97
	}
98
 
99
	if (JsonObj[0].ItemSpecifics) {
100
		str += '<p>';
101
		for (i = 0; i < JsonObj[0].ItemSpecifics.NameValueList.length; i++) {
102
			str += JsonObj[0].ItemSpecifics.NameValueList[i].Name + ': ' + JsonObj[0].ItemSpecifics.NameValueList[i].Value + '<br/>';
103
		}
104
		str += '</p>';
105
	}
106
 
107
	if (JsonObj[0].ProductID) {
108
		str += '<p>';
109
		for (i = 0; i < JsonObj[0].ProductID.length; i++) {
110
			str += JsonObj[0].ProductID[i].Type + ': ' + JsonObj[0].ProductID[i].Value + '<br/>';
111
		}
112
		str += '</p>';
113
	}
114
 
115
	str += '</div>';
116
	str += '</div>';
117
	str += '</div>';
118
 
30 - 119
	str += '<footer class="container-fluid text-center border border-bottom-0 border-left-0 border-right-0">';
2 - 120
	str += 'Copyright &#169; ' + new Date().getFullYear() + ' MUNA Trading. All rights reserved.';
121
	str += '</footer>';
122
	str += '</div>';
123
	str += '</body>';
124
	str += '</html>';
125
 
126
	var newWin = window.open("", Title);
127
	if (newWin) {
128
		newWin.document.open().write(str);
129
		newWin.document.close();
130
	}
131
}
132