-
Notifications
You must be signed in to change notification settings - Fork 2
/
edit.html
226 lines (197 loc) · 8.88 KB
/
edit.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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<style> {% include "all.css" %} </style>
<style> {% include "pyalgoviz.css" %} </style>
<title>PyAlgoViz - {{name}}</title>
</head>
<body>
<div class='contents' data-respond>
<table id="grid"><tr>
<td id="td1" class='block'>
<div id="tab1">
<div class=tab_header>
<a href='/'><img class=home src=icon-home.png></a>
<input id='name' onkeyup="doNameChange()" class='nameField' value='{{name}}'>
<button onclick="doSave()" id="saveButton" class="button moveup hidden">Save</button>
<button onclick="doShare()" id="shareButton" class="button moveup">Share</button>
<span class="title moveup">vim:</span>
<input onchange="doToggleVimMode()" type="checkbox" name="vim"/>
<button onclick="doDelete()" id="deleteButton" class="button moveup">Delete</button>
<a href={{logout}} class="logout moveup">logout</a>
<a href="javascript:load_tabs()" class="logout moveup">tabs</a>
</div>
<div class="script">
<textarea id="script" name="script">{{script}}</textarea>
</div>
</div>
</td>
{{nextrow}}
<td id="td2" class='block'>
<div id="tab3">
<table style="margin: 3px 0 0 3px"><tr><td>
<button onclick="doRunScript()" id="runButton" class='button'>Run</button>
</td><td>
<button onclick="doPreviousStep()" id="previousButton" class='button'><</button>
</td><td>
<select id="speed" class="speed">
<option>Fast</option>
<option selected>Medium</option>
<option>Slow</option>
<option>Snail</option>
<option>Molasses</option>
</select>
</td><td>
<div id="slider" class='slider'></div>
</td><td>
<div id="progress" class="progress moveup">Loading...</div>
</td><td>
<button onclick="doNextStep()" id="nextButton" class='button'>></button>
</td><td>
<button onclick="doStop()" id="stopButton" class='button'>Play</button>
</td></tr><tr><td colspan=7>
<div id="rendering" class="rendering"></div>
</td></tr></table>
</div>
</td></tr>
<tr><td id="td3" class='block'>
<div id="tab2">
<table style="margin: 3px 0 0 3px"><tr class=tab_header><td>
<span class="title moveup">Show Visualization Errors:</span>
<input onchange="doToggleShowErrors()" type="checkbox" name="showErrors"/>
</td><td>
{% if share %}
<span class="title">Author: {{author}}</span>
{% endif %}
</td><td>
<button onclick="doVizHelp()" id="helpVizButton" class="button">Help</button>
</td></tr><tr><td colspan=7>
<textarea id="visualization">{{viz}}</textarea>
</td></tr></table>
</div>
</td>
{{nextrow}}
<td id="td4" class='block'>
<div id="tab4" class="output-panel">
<table style="margin: 3px 0 0 3px"><tr class=tab_header><td>
<div class="title output">Output:</div>
</td><td>
{% if share %}
{% include "social.html" %}
{% endif %}
</td></tr><tr><td colspan=7>
<textarea id="output"></textarea>
</td></tr></table>
</div>
</td>
</tr>
</table>
{% if share %}
<div class='block wide'>
<div class='blockHeader indent'>
<h3>Comments and Feedback</h3>
</div>
<div class='clear blockContent indent grow'>
{% include "comments.html" %}
</div>
</div>
<a href="https://plus.google.com/+PyalgovizAppspotPlusPage/posts">+</a>
{% endif %}
</div>
<script>
RENDERING_SCALE = 1.0;
function load_tabs(e) {
var contents = $('.contents');
$('<ul class="tabs"><li><a href="#tab1">Algorithm</a></li><li><a href="#tab2">Script</a></li>' +
'<li><a href="#tab3">Visualization</a></li><li><a href="#tab4">Output</a></li></ul>').appendTo(contents);
var container = $('<div>').addClass("tab_container").appendTo(contents);
$('#tab1').addClass('tab_content').addClass('active').appendTo(container);
$('#tab2').addClass('tab_content').appendTo(container);
$('#tab3').addClass('tab_content').appendTo(container);
$('#tab4').addClass('tab_content').removeClass('output-panel').appendTo(container);
$('#grid').hide();
$('.tab_header').css('display', 'none');
$(".tab_content").hide();
$("ul.tabs li:first").addClass("active").show();
$(".tab_content:first").show();
$('#rendering').empty();
resetEditor(scriptEditor);
resetEditor(vizEditor);
$('<a>')
.appendTo($('body'))
.addClass('load_grid')
.click(load_grid)
.css('text-decoration', 'underline')
.css('cursor', 'pointer')
.css('color', 'blue')
.css('position', 'absolute')
.css('top', '10px')
.css('left', '600px')
.text('grid')
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active");
$(this).addClass("active");
$(".tab_content").hide();
var activeTab = $(this).find("a").attr("href");
$(activeTab).fadeIn();
resetEditor(scriptEditor);
resetEditor(vizEditor);
return false;
});
$('.CodeMirror').css('width', '1200px').css('height', '800px');
$('head').append('<style>' +
'.CodeMirror pre { font-size: 25px; } ' +
'.CodeMirror-linenumber { font-size: 25px; } ' +
'.rendering { width:1180px; height:800px; margin: 3px 0 0 0; } ' +
'.speed { width: 125px; font-size: 110%; margin: 10px 7px 0px 1px; }' +
'.slider { width: 145px; font-size: 100%; margin: 17px 5px 0px 0px; }' +
'.progress {font-size: 100%; width:200px; margin: 19px 5px 0px 0px; }' +
'.vizhead { padding:5px 0 0 10px; background: white; font-size: 22px; }' +
'.viz { padding:3px; padding-top:0; background: white }' +
'.tab_content { padding: 5px 20px 10px 20px; }' +
'</style>');
RENDERING_SCALE = 1.8;
EDITOR_WIDTH = 1180;
EDITOR_HEIGHT = 900;
}
function load_grid(e) {
$('.CodeMirror').css('width', '{{editor_width}}').css('height', '{{editor_height}}px');
$('#tab1').show().removeClass('tab_content').appendTo($('#td1'));
$('#tab3').show().removeClass('tab_content').appendTo($('#td2'));
$('#tab2').show().removeClass('tab_content').appendTo($('#td3'));
$('#tab4').show().removeClass('tab_content').appendTo($('#td4')).addClass('output-panel');
$('#grid').show();
$('.tab_header').show();
$(".tab_content").remove();
$('.tabs').remove();
$('.load_grid').remove();
$('.rendering_canvas').remove();
$('#rendering').empty();
resetEditor(scriptEditor);
resetEditor(vizEditor);
$('head').append('<style>' +
'.CodeMirror pre { font-size: 14px; } ' +
'.CodeMirror-linenumber { font-size: 14px; } ' +
'.rendering { width:{{editor_width}}px; height:{{editor_height}}px; margin: -8px 0 0 0; } ' +
'.speed { width: 85px; font-size: 82%; margin: 0px 7px 0px 1px; }' +
'.slider { width: 105px; font-size: 50%; margin: 7px 7px 0px 1px; }' +
'.progress {font-size: 70%; width:140px; margin: 10px; }' +
'.vizhead { padding:5px 0 0 10px; background: white; font-size: 22px; }' +
'.viz { padding:3px; padding-top:0; background: white }' +
'</style>');
RENDERING_SCALE = 1.0;
EDITOR_WIDTH = {{editor_width}};
EDITOR_HEIGHT = {{editor_height}};
}
function resetEditor(editor) {
// force editor to recompute line heights to correctly position the cursor
var text = editor.getValue();
editor.setValue(text + ' ');
setTimeout(function() { editor.setValue(text); }, 1);
}
</script>
{% include "all.html" %}
</body>
</html>