This repository has been archived by the owner on Dec 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdepartments.html
63 lines (63 loc) · 2.57 KB
/
departments.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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href = "assets/css/bootstrap.min.css">
<link rel="stylesheet" href = "assets/css/font-awesome.min.css">
<link rel = "stylesheet" href = "css/global.css">
<script src = "assets/js/jquery.js" onload = "window.$ = window.jQuery = module.exports;"></script>
<script src = "assets/js/bootstrap.js"></script>
<script src = "assets/js/vue.js"></script>
<script src = "js/globals.js"></script>
<script src = "js/jumpstart.js" defer></script>
<script>
// https://stackoverflow.com/a/2970667
function camelize(str) {
return str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function(match, index) {
if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces
return index == 0 ? match.toLowerCase() : match.toUpperCase();
});
}
bus.$on("save", () => {
let departmentsJSON = vm.$children[1].rootJson.departments.departments;
let names = departmentsJSON.map((department) => department.name);
let sublinks = [];
for (i in names) {
let name = names[i];
sublinks.push({
"name": name,
"nav": camelize(name)
});
}
let globalsJSON = ipcRenderer.sendSync("getJSONForPage", "globals");
globalsJSON["navbar"]["links"][1]["subLinks"] = sublinks;
console.log(JSON.stringify(globalsJSON));
ipcRenderer.send("setJSONForPage", "globals", globalsJSON);
});
</script>
<style type = "text/css">
textarea {
height: 25vh !important;
}
</style>
<title>Editor</title>
</head>
<body>
<div id = "main">
<navbar preview-page = "academics"></navbar>
<div class = "container-fluid">
<json-form page = "academics">
<json-string name = "Section Name" path = "['departments']['name']"></json-string>
<json-string name = "Section Lead" path = "['departments']['lead']"></json-string>
<json-repeat name = "Departments" path = "['departments']['departments']" help="Please do not include any special characters in department names (&, +, /, \, etc.) as this prevents most browsers from navigating to the desired section from the dropdown menu in the navbar.">
<template scope = "parent">
<json-string name = "Name" :path = "`['departments']['departments'][${parent.index}]['name']`"></json-string>
<json-string name = "Lead" :path = "`['departments']['departments'][${parent.index}]['lead']`"></json-string>
<json-string name = "Description" :path = "`['departments']['departments'][${parent.index}]['description']`" big = true></json-string>
<b>{{ parent.item.courses.length }} Course(s)</b>
</template>
</json-repeat>
</json-form>
</div>
</div>
</body>
</html>