-
Notifications
You must be signed in to change notification settings - Fork 0
/
testurls.php
153 lines (118 loc) · 2.75 KB
/
testurls.php
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
<?php
require_once("utils.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>SpriteMe testurls</title>
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
<style>
<?php
echo spritemeStyle();
?>
</style>
</head>
<body>
<?php
echo spritemeHeader("testurls");
?>
<div id=contents class=contents>
<?php
echo spritemeNav("testurls");
?>
<br>
<div style="margin-bottom: 20px;">
<input type=button value="Start Test" onclick="startTest()">
<input type=button value="Stop Test" onclick="stopTest()" style="margin-left: 12px;">
<input type=button value="Continue" onclick="continueTest()" style="margin-left: 12px;">
<p>
test name: <input type=text size=32 id=testname name=testname value=""> (if you use this, run from spriteme.org)
<p>
delay interval: <input type=text size=5 id=delay value=15000> milliseconds
</div>
<div style="float: right; width: 400px; margin: 20px; border: 1px solid #AAA; padding: 8px; background: #EEE;">
This page is to be used to test changes to the SpriteMe.js logic.
If you specify a test name, you can use the savings diff page to compare results.
</div>
<div id=urls>
<form name=form1>
<?php
for ( $i = 0; $i < count($gaUrls); $i++ ) {
$url = $gaUrls[$i];
echo "<input type=radio name=starturl value=$i" .
($i == 0 ? " checked" : "" ) . "> " . ($i+1) . ". <a href='$url' id=url$i target='testwin'>$url</a><br>\n";
}
?>
</form>
</div>
<?php
echo spritemeFooter();
?>
</div> <!-- contents -->
<script>
var aUrls;
var gStop = false;
var giUrl = 0;
var gTestname = "";
function startTest() {
gStop = false;
giUrl = 0;
var testname = document.getElementById('testname').value;
if ( testname != gTestname ) {
// set a cookie
gTestname = testname;
document.cookie = "testname=" + gTestname;
}
var urlsDiv = document.getElementById('urls');
if ( urlsDiv ) {
aUrls = urlsDiv.getElementsByTagName('a');
setStartUrl();
loadUrl();
}
}
function setStartUrl() {
var aRadios = document.form1.starturl;
var iUrl = 0;
for ( var i = 0; i < aRadios.length; i++ ) {
var radio = aRadios[i];
if ( radio.checked ) {
iUrl = i;
break;
}
else {
markUrl("url" + i);
}
}
giUrl = i;
}
function stopTest() {
gStop = true;
}
function continueTest() {
gStop = false;
loadUrl();
}
function loadUrl() {
if ( gStop ) {
return;
}
var a = aUrls[giUrl];
markUrl(a);
var url = a.href;
giUrl++;
window.open(url, "testwin");
var delay = document.getElementById('delay').value;
setTimeout(loadUrl, delay);
}
function markUrl(IdOrElem) {
var anchor = IdOrElem;
if ( "object" !== typeof(IdOrElem) ){
anchor = document.getElementById(IdOrElem);
}
if ( anchor ) {
anchor.style.color = "#A55";
}
}
</script>
</body>
</html>