-
Notifications
You must be signed in to change notification settings - Fork 0
/
getPriceHistory.js
executable file
·176 lines (134 loc) · 3.22 KB
/
getPriceHistory.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
var url = "../priceHistory.php?js=true&iid="; // The server-side script
function handleHttpResponse() {
if (http.readyState == 4) {
results = http.responseText;
makeDiv(results);
}
}
var elem;
function getPrice(iid,element) {
elem = element;
http.open("GET", url + escape(iid), true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
return false;
}
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
function makeDiv(result)
{
var body = document.getElementsByTagName("body")[0];
var div = document.createElement("div");
div.style.position = "absolute";
div.style.top = findPosY(elem);
div.style.left = findPosX(elem);
div.style.margin = "-50px 0 0 -170px";
div.style.padding = "10px";
div.style.opacity = "1.00";
div.style.backgroundColor = "white";
div.style.borderBottom = "2.5px solid black";
div.style.borderRight = "2.5px solid black";
div.style.borderTop = "1px solid black";
div.style.borderLeft = "1px solid black";
div.style.textAlign = "left";
body.appendChild(div);
div.innerHTML = result;
div.innerHTML = div.innerHTML + "<p>";
var link=document.createElement("a");
var close = document.createTextNode('close (x)')
link.appendChild(close);
div.appendChild(link);
link.href="javascript:doNothing()";
link.focus();
link.onclick = function(e)
{
opacityDown(this.parentNode);
}
link.onblur = function(e)
{
opacityDown(this.parentNode);
}
// div.onmouseout = function(e)
// {
// opacityDown(this);
// }
};
function doNothing(){}
function opacityDown(theElement)
{
var opacity = parseFloat(theElement.style.opacity);
if (opacity < 0.08)
{
theElement.parentNode.removeChild(theElement);
}
else
{
opacity -= 0.2;
theElement.style.opacity = opacity;
setTimeout(function(){opacityDown(theElement);}, 50);
}
return true;
};
function verticalAlign(theElement, pixelSize)
{
theElement.parentNode.style.top = document.documentElement.scrollTop + window.innerHeight/2 + "px";
theElement.style.fontSize = pixelSize + "px";
theElement.style.lineHeight = pixelSize + "px";
var height = theElement.clientHeight;
theElement.style.marginTop = -parseInt(height / 2) + "px";
return true;
};
function findPosX(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}
function findPosY(obj)
{
var curtop = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}