Subversion Repositories munaweb

Rev

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