-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprogram.html
140 lines (121 loc) · 4.9 KB
/
program.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Karel IDE</title>
<script src="./js/html/websiteImports.js"></script>
<script>importCss();</script>
<script>importJs();</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-25118186-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<script>importWebsiteHeader('program.html');</script>
<p id="programTitle">Loading</p>
<div id="programButtonBar">
<div id="programButtonBarInner">
</div>
</div>
<div id ='content'>
</div>
<script>
function init() {
var PROGRAM_PROPORTION = 0.95
var plate = null;
var programElement = null;
var buttonBar = null;
function loadProgram(url) {
}
function updateTitle(programObject){
var newTitle = programObject.title + ' by ' + programObject.author;
$('#programTitle').html(newTitle);
}
function extend() {
var url = 'http://'+ document.location.hostname + '/ide.html#/' + Server.getProgramKey();
window.location = url;
}
function programLoaded(data){
//alert(data);
var programObject = JSON.parse(data);
updateTitle(programObject);
var programDim = {
left : (1-PROGRAM_PROPORTION)/2,
top: 0,
width:PROGRAM_PROPORTION,
height:PROGRAM_PROPORTION + (1-PROGRAM_PROPORTION)/2
}
var startWorld = programObject.world;
var code = programObject.code;
programElement = ProgramElement(programDim, 'content', startWorld, code);
createButtonBar(startWorld);
$("[title]").tooltip({ position: "bottom center", opacity: 0.9});
window.onresize();
}
function createButtonBar(startWorld) {
buttonBar = document.getElementById('programButtonBarInner');
var playButton = createImageButton(buttonBar, 'images/playButton.png', 'playButton', 'Run', 'programButton');
var stopButton = createImageButton(buttonBar, 'images/stopButton.png', 'stopButton', 'Reset', 'programButton');
var extendButton = createImageButton(buttonBar, 'images/fast.png', 'extendButton', 'Extend', 'programButton');
worldSelector = addWorldDropDown(buttonBar, 'programWorldDrop');
playButton.onclick = function() {
if(programElement)programElement.run();
}
stopButton.onclick = function() {
if(programElement)programElement.getIde().stopButton();
}
extendButton.onclick = extend;
$('#worldSelector').change(
function() {
var worldName = $("#worldSelector option:selected").text();
programElement.getIde().changeWorld(worldName);
}
);
for(var i = 0; i < worldSelector.length; i++) {
if(worldSelector[i].text == startWorld) {
worldSelector.selectedIndex = i;
}
}
}
function centerButtonBar() {
if (!buttonBar) return;
var windowWidth = $(window).width() - 1;
windowWidth = Math.max(windowWidth, Const.MIN_IDE_WIDTH + Const.PADDING * 2);
var buttonBarWidth = $('#programButtonBarInner').width();
buttonBar.style.left = (windowWidth - buttonBarWidth)/2 + 'px'
}
window.onload = function() {
initTabs();
plate = document.getElementById('content');
window.onresize();
Server.loadProgramFromHash(programLoaded);
$("[title]").tooltip({ position: "bottom center", opacity: 0.9});
}
window.onhashchange = function() {
Server.loadProgramFromHash(programLoaded);
}
window.onresize = function(){
var windowHeight = $(window).height() - 1;
var windowWidth = $(window).width() - 1;
var programHeight = windowHeight - Const.PROGRAM_HEADER_HEIGHT;
if (plate){
plate.style.height = (programHeight)+ 'px';
plate.style.width = (windowWidth)+ 'px';
}
if (programElement) {
programElement.resize();
}
ReferenceDialog.resize();
centerButtonBar();
}
}
init();
</script>
</body>
</html>