This repository has been archived by the owner on Oct 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
createfile.html
127 lines (104 loc) · 4.4 KB
/
createfile.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Create file</title>
<link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css" />
<link rel="stylesheet" href="node_modules/typeface-roboto/index.css" />
<link rel="stylesheet" href="index.css" />
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script>
//window.jQuery = window.$ = require('jquery');
const ipc = require('electron').ipcRenderer;
ipc.on('close-createfile', (event, message) => window.close());
function ok() {
filename = document.getElementById('filename').value;
if (filename.length > 0) {
ext = document.forms.frm.ext.value;
filename = forceExt(filename, ext);
ipc.send('createFile', filename);
}
return false;
}
function cancel() {
window.close();
}
function filenamechanged(self) {
filename = document.getElementById('filename').value;
if (filename.length > 0) {
document.getElementById('okbutton').disabled = false;
} else {
document.getElementById('okbutton').disabled = true;
}
}
function forceExt(filename, ext) {
if (filename.endsWith("." + ext)) return filename;
if (filename.lastIndexOf('.') == -1) filename = filename + ".";
filename = filename.substr(0, filename.lastIndexOf('.')) + "." + ext;
return filename;
}
function extchanged(self) {
filename = document.getElementById('filename').value.toLowerCase();
ext = self.value;
document.getElementById("filename").value = forceExt(filename, ext);
}
</script>
<style>
form {
font-size: 12px;
margin: 20px;
}
.fn {
margin-top: 20px;
}
.type , .fn label {
width: 110px;
display: block;
float: left;
position: relative;
top: 3px;
}
input[type="radio"] {
margin-left: 0;
}
.button {
display: inline-block;
padding: 8px 20px;
background: rgba(255, 255, 255, 0.1);
border: none;
color: #CCC;
}
.button:disabled {
color: black;
}
.buttons {
margin-top: 50px;
text-align: right;
}
#filename {
width: 230px;
}
</style>
</head>
<body>
<div class="titlebar">
<div class="title">Please select a filetype and enter a filename.</div>
</div>
<div>
<form onsubmit="return ok()" method="get" id="frm" name="frm">
<div class="type">File type:</div>
<div class="radio"><input type="radio" id="c" name="ext" value="c" oninput="extchanged(this)" checked> <label for="c">C source file (.c)</label></div>
<div class="type"> </div><div class="radio"><input type="radio" id="h" name="ext" value="h" oninput="extchanged(this)"> <label for="h">C header file (.h)</label></div>
<div class="type"> </div><div class="radio"><input type="radio" id="spr" name="ext" value="spr" oninput="extchanged(this)"> <label for="spr">Sprite sheet (.spr)</label></div>
<div class="type"> </div><div class="radio"><input type="radio" id="map" name="ext" value="map" oninput="extchanged(this)"> <label for="map">Sprite map (.map)</label></div>
<div class="type"> </div><div class="radio"><input type="radio" id="sfx" name="ext" value="sfx" oninput="extchanged(this)"> <label for="sfx">Sound effect (.sfx)</label></div>
<div class="type"> </div><div class="radio"><input type="radio" id="mus" name="ext" value="mus" oninput="extchanged(this)"> <label for="mus">Music track (.mus)</label></div>
<div class="fn"><label for="filename">Filename:</label> <input type="text" id="filename" name="filename" value="file.c" oninput="filenamechanged(this)"></div>
<div class="buttons">
<button class="button" type="button" onclick="cancel()">Cancel</button>
<button class="button" type="submit" id="okbutton">OK</button>
</div>
</form>
</div>
</body>
</html>