forked from PQYPLZXHGF/drawshield
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemopage.html
134 lines (133 loc) · 4.63 KB
/
demopage.html
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
<!DOCTYPE
html
PUBLIC
"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
<!-- Assumes shield directory is in /include, change below if not -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>
Drawshield Demonstration
</title>
</head>
<body>
<h1>
Draw a Shield
</h1>
<p>
Enter a
<strong>
blazon
</strong>
into the box and click the
<code>
Create!
</code>
button.
</p>
<form action="POST" id="myform">
<table style="width:600px" summary="shield table">
<tr>
<td rowspan="3" style="width: 459px; text-align:center">
<textarea name="blazon" rows="5" cols="50"></textarea>
</td>
<td style="width: 81px">
<input type="button" name="createbutton" value="Create!" style="width: 90px"/>
</td>
</tr>
<tr>
<td style="width: 90px">
<input type="button" name="textbutton" value="Save As File" style="width: 90px"/>
</td>
</tr>
<tr>
<td style="width: 90px">
<select name="format" size="1">
<option value="svg" selected="selected">
SVG
</option>
<option value="blazonml">
BlazonML
</option>
<option value="prepro">
Prepro
</option>
<option value="svgtext">
SVG(text)
</option>
</select>
</td>
</tr>
<tr>
<td style="text-align:center" colspan="2">
<div id="shieldimg">
</div>
<p id="shieldcaption">
Your shield here
</p>
</td>
</tr>
</table>
</form>
<script type="text/javascript" src="XMLHttpRequest.js"></script>
<script type="text/javascript">
//<![CDATA[
var xmlhttp = new XMLHttpRequest();
var incDir = '/include/';
var asText;
var useId;
function showerrors(evt) {
var errorbox = document.getElementById("errorbox");
if ( errorbox.getAttribute("visibility") == "hidden" ) {
errorbox.setAttribute("visibility","visible");
} else {
errorbox.setAttribute("visibility","hidden");
}
}
function updateSVG() { // Simple AJAX updater
if ( xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
var shieldImg = document.getElementById(useId);
while ( shieldImg.hasChildNodes() ) {
shieldImg.removeChild(shieldImg.firstChild);
}
if ( xmlhttp.responseXML == null ) {
errorText = document.createTextNode(xmlhttp.responseText);
errorPara = document.createElement('p');
errorPara.appendChild(errorText);
shieldImg.insertBefore(errorPara,null);
} else {
if ( (navigator.userAgent.indexOf( "iPad" ) > 0) ||
(navigator.userAgent.indexOf( "iPod" ) > 0) ||
(navigator.userAgent.indexOf( "iPhone" ) > 0)
) {
newNode = document.importNode(xmlhttp.responseXML.firstChild, true);
shieldImg.appendChild(newNode);
} else {
shieldImg.innerHTML = xmlhttp.responseText;
}
}
}
}
function requestSVG(url,id) {
useId = id;
xmlhttp.open('GET', url, true);
xmlhttp.onreadystatechange = updateSVG;
xmlhttp.send(null);
}
// Set button actions
document.forms['myform'].createbutton.onclick = function () {
shieldCaption = document.getElementById('shieldcaption');
shieldCaption.firstChild.nodeValue= document.forms['myform'].blazon.value;
choice = document.forms['myform'].format.options.selectedIndex;
format = document.forms['myform'].format.options[choice].value;
requestSVG( incDir + 'shield/drawshield.php?nolog=1&format=' + format + '&blazon=' + encodeURIComponent(document.forms['myform'].blazon.value),'shieldimg');
};
document.forms['myform'].textbutton.onclick = function () {
window.location.replace( incDir + 'shield/drawshield.php?asfile=1&nolog=1&blazon=' + encodeURIComponent(document.forms['myform'].blazon.value));
};
// Run automatically
window.onload=requestSVG( incDir + 'shield/drawshield.php?nolog=1&blazon=' + encodeURIComponent( 'Argent the word shield; in chief the word Your; in base the word here sable'),'shieldimg');
//]]>
</script>
</body>
</html>