This repository was archived by the owner on Dec 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathnwjs.html
108 lines (101 loc) · 2.42 KB
/
nwjs.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
<html>
<head>
<link rel="shortcut icon" type="image/png" href="./static/assets/icon.png"/>
<link href='./static/assets/fonts/Lato.css' rel='stylesheet' type='text/css'>
<style>
body, html {
padding: 0;
margin: 0;
color: #333;
background: #eee;
font-family: Lato;
}
h1 {
}
h2 {
font-weight: normal;
}
#wrapper {
font-size: 1.4em;
text-align: center;
padding: 10px;
}
.buttons {
padding: 1em;
}
.buttons a {
background: #000;
color: #fff;
font-size: 1.4em;
padding: 0.2em 0.8em;
border-radius: 0.1em;
text-decoration: none;
}
.buttons a:hover {
background: #f90;
}
#loading {
padding: 100px 0;
}
</style>
</head>
<body>
<div id="wrapper">
<section id="intro">
<h1>Diaporama Maker</h1>
<blockquote>
To start, please select a folder containing images to use for your slideshow.
</blockquote>
<div class="buttons">
<a id="imagesfolder" href="#">Open Images Folder</a>
</div>
</section>
<section id="loading" hidden>
<h1>Diaporama Maker</h1>
<h2>Loading...</h2>
</section>
</div>
<input
style="display:none"
type="file"
id="ctrl"
nwdirectory
/>
<script>
var Q = require("q");
var _ = require("lodash");
var fs = require("./server/fs");
var Diaporama = require("./server/Diaporama");
var server = require("./server");
function onPickDir (dir) {
intro.setAttribute("hidden", "hidden");
loading.removeAttribute("hidden");
function edit (diaporama) {
return Q.fcall(server, diaporama).then(function (href) {
window.location = href;
});
}
fs.readdir(dir)
.then(function (files) {
if (!_.contains(files, Diaporama.jsonfile)) {
return edit(Diaporama.genEmpty(dir));
}
else {
return Diaporama.fromDirectory(dir)
.then(edit);
}
})
.done();
}
function openfolder (e) {
e.preventDefault();
ctrl.click();
}
ctrl.addEventListener("change", function (e) {
imagesfolder.removeEventListener("click", openfolder);
onPickDir(this.value);
});
imagesfolder.addEventListener("click", openfolder);
</script>
</body>
</html>