forked from Touffy/JSSCxml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewer.html
85 lines (71 loc) · 2.35 KB
/
viewer.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JSSCxml editor</title>
<script src="xhr.js"></script>
<script src="structures.js"></script>
<script src="delays.js"></script>
<script src="SCxml.js"></script>
<script src="SCxmlMutation.js"></script>
<script src="SCxmlDebug.js"></script>
<script src="SCxmlProcessors.js"></script>
<script src="SCxmlDatamodel.js"></script>
<script src="SCxmlEvent.js"></script>
<script src="SCxmlExecute.js"></script>
<script src="SCxmlInvoke.js"></script>
<script src="SCxmlFetch.js"></script>
<script src="SCxmlConnect.js"></script>
<script src="SCxmlSpeak.js"></script>
<link rel="stylesheet" href="SCxmlView.css">
</head>
<body>
<section id="editor"><header>
<h2>SCXML Editor</h2>
<form name="load"><input type="submit" value="Load source"> from <input type="radio" name="sourcetype" value="http" checked><input title="if this URL point outside the jsscxml.org domain, the response must include a CORS header allowing it to be used here" name="src" placeholder="http://" type="text" value="w3c_tests/test405.scxml"> or <input type="radio" name="sourcetype" value="file"><input name="file" type="file"></form>
</header>
</section>
<script>
UI={
code:document.getElementsByTagName("textarea")[0],
parse:document.querySelector("input[name=parse]"),
load:document.querySelector("form[name=load]"),
src:document.querySelector("input[name=src]"),
file:document.querySelector("input[name=file]"),
view:document.getElementById("editor")
}
quri=(quri=window.location.search)
&& (quri=quri.match(/src=([^&]+)/)[1])
&& (UI.src.value=quri=decodeURIComponent(quri))
sc=null
UI.src.onchange=function(e){
this.previousSibling.checked=true
UI.load.firstChild.disabled=!this.value
}
UI.file.onchange=function(e){
this.previousSibling.checked=true
UI.load.firstChild.disabled=!this.files[0]
}
UI.load.onsubmit=function(e)
{
e.preventDefault()
if(sc){ sc.html.removeChild(sc.view.ui); sc.clean() }
if(UI.src.previousSibling.checked)
var src=UI.src.value
else
var src=UI.file.files[0]
var tag=UI.view.appendChild(document.createElement("scxml"))
tag.setAttribute("debug", true)
try{ sc=new SCxml(src, tag, null) }
catch(err){
UI.view.removeChild(tag)
throw err
}
new SCxml.View(sc)
sc.autoPauseBefore=SCxml.ALL_EVENTS
return false
}
if(quri) UI.load.dispatchEvent(new Event("submit"))
</script>
</body>
</html>