This repository has been archived by the owner on Jan 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.html
105 lines (91 loc) · 3.18 KB
/
index.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
---
layout: default
---
<div class="panel-container">
<div id="editor" class="panel-left content"/>
</div>
<div class="splitter">
</div>
<div class="panel-right">
<div class="term1"></div>
</div>
</div>
<script>
(function() {
var font3 = document.createElement('link');
font3.type = 'text/css';
font3.rel = 'stylesheet';
font3.href = '{{site.baseurl}}/css/syntax-highlighting.css';
var q = document.getElementsByTagName('link')[0];
q.parentNode.insertBefore(font3, q);
})();
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="https://rawgit.com/RickStrahl/jquery-resizable/master/dist/jquery-resizable.min.js"></script>
<script src="https://cdn.rawgit.com/play-with-docker/sdk/6f5f37c1e067eb778efecd93e58b25b2457695ef/dist/pwd.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.7/ace.js"></script>
<script>
pwd.newSession([{selector: '.term1'}], {ImageName: 'franela/pwm'});
$(".panel-left").resizable({
handleSelector: ".splitter",
resizeHeight: false,
onDragEnd: pwd.resize.bind(pwd)
});
var editor = ace.edit("editor");
editor.setTheme("ace/theme/tomorrow_night_eighties");
editor.session.setMode("ace/mode/yaml");
editor.setShowPrintMargin(false);
var build = function() {
var blobAttrs = { type: "text/plain" };
var content = editor.getValue();
var blob = new Blob([content], blobAttrs);
blob.lastModifiedDate = new Date();
var formData = new FormData();
formData.append("upload", blob, "os.yml");
pwd.upload(Object.keys(pwd.instances)[0], formData, function(err) {
if (!err) {
var instanceName = Object.keys(pwd.instances)[0];
pwd.socket.emit('instance terminal in', instanceName, 'moby build os.yml\n');
} else {
console.log(err);
alert('Error trying to build');
}
});
};
var run = function() {
var instanceName = Object.keys(pwd.instances)[0];
pwd.socket.emit('instance terminal in', instanceName, 'linuxkit run os\n');
};
var share = function() {
var content = editor.getValue();
$.post( "http://api.play-with-moby.com/shares", content, function(data) {
var shareElm = document.getElementById('shareInput');
shareElm.value = 'http://play-with-moby.com?share='+ data;
shareElm.style.display='inline';
}).fail(function(err) {
console.log(err);
});
};
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
// Hardcode the default code
var shareCode = getParameterByName('share') || "eZWczMlnWd";
if (shareCode) {
$.get( "http://api.play-with-moby.com/shares/"+shareCode, function(data) {
editor.setValue(data, -1);
}).fail(function(err) {
console.log(err);
});
}
window.onbeforeunload = function(e) {
pwd.closeSession(function(){});
return;
}
</script>