-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
127 lines (105 loc) · 2.62 KB
/
main.js
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
// main initialisation routines for ElkJs
// written by Darren Coles
var elkjs = null;
function reset() {
elkjs.reset();
}
function pauseResume() {
var running = elkjs.pauseResume();
if (running) {
$("#btnPause span").text("Pause");
}
else {
$("#btnPause span").text("Resume");
}
}
function changeLoadSpeed() {
elkjs.setLoadSpeed($("#loadSpeed").val());
}
function fileSelected(evt) {
var files = evt.target.files;
if (files.length>0) {
$("#btnTape").removeAttr('disabled');
elkjs.openFile(files[0]);
}
}
function changeAutoLoad() {
elkjs.setAutoLoad($('#autoLoad').prop('checked'));
}
function soundToggle() {
var sound = elkjs.soundToggle();
if (sound) {
$("#btnSound span").text("Turn sound off");
}
else {
$("#btnSound span").text("Turn sound on");
}
}
function toggleTapeDialog() {
if ($("#tapeDialogMain").dialog("isOpen")) {
$("#tapeDialogMain").dialog("close");
}
else {
$("#tapeDialogMain").dialog("open");
elkjs.refreshTapeDialog("tapeDialogMain");
}
}
function toggleGamesDialog() {
if ($("#gamesDialogMain").dialog("isOpen")) {
$("#gamesDialogMain").dialog("close");
}
else {
$("#gamesDialogMain").dialog("open");
}
}
function tapeFwd() {
elkjs.tapeFwd();
}
function tapeRew() {
elkjs.tapeRew();
}
function tapeFirst() {
elkjs.tapeFirst();
}
function tapeLast() {
elkjs.tapeLast();
}
function tapeEject() {
elkjs.tapeEject();
$("#btnTape").attr('disabled','disabled');
}
function fullScreen() {
if ($('#accordion').is(':hidden')) {
$("#accordion").show();
$("#ElkJsOutput").height(512);
$("#elkjs").css("left", 420);
$("#btnFullscreen span").text("Expand");
}
else {
$("#accordion").hide();
$("#ElkJsOutput").height(window.innerHeight - 80);
$("#elkjs").css("left", 20);
$("#btnFullscreen span").text("Shrink");
}
}
function saveSnapshot() {
var bytes = elkjs.saveSnapshot();
var binary = '';
var len = bytes.length;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
filedata = 'data:application/octet-stream;base64,'
+ encodeURIComponent(window.btoa(binary));
var pom = document.createElement('a');
pom.setAttribute('href', filedata);
pom.setAttribute('download', 'snapshot.uef');
if (document.createEvent) {
var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true);
pom.dispatchEvent(event);
}
else {
pom.click();
}
}