-
Notifications
You must be signed in to change notification settings - Fork 78
/
player.js
61 lines (56 loc) · 1.69 KB
/
player.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
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
vars[key] = value;
});
return vars;
}
function processJson(data) {
var machineList = data.machines;
var machineid = getUrlVars()["machine"].replace('#', '');
var playerFrame = document.getElementById("emuframe");
playerFrame.onload = function () {
playerFrame.contentWindow.focus();
}
var standaloneLink = $("#standalone-tab");
for (i = 0; i < machineList.length; i++) {
var machine = machineList[i];
if (machine.id == machineid) {
playerFrame.src = machine.url;
standaloneLink.attr("href", machine.url);
loadIntroduction(machine);
}
}
}
function loadIntroduction(machineConfig) {
$("#player-intro").hide()
var introUrl = "document/pending.md";
if (machineConfig.introduction) {
introUrl = machineConfig.introduction;
}
var showdownConv = new showdown.Converter();
$.get(introUrl,
function (data) {
var htmlContent = showdownConv.makeHtml(data);
$("#player-intro").html(htmlContent);
}
);
}
function matchFrameHeight() {
var frameheight = document.body.clientHeight - 30;
var iFrame = document.getElementById('emuframe');
iFrame.height = frameheight;
}
$(document).ready(function () {
$.ajaxSetup({ cache: false });
$.getJSON("machines.json", processJson);
matchFrameHeight();
$("#showIntro").click(function () {
$(function () {
$("#player-intro").dialog();
});
})
});
$(window).resize(function () {
matchFrameHeight();
});