-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
180 lines (171 loc) · 5.86 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE HTML>
<html>
<head>
<title>DuckMarker - Generate a Cyberduck bookmark to your CSCS container</title>
<style>
* {
box-sizing: border-box;
font-family: Inter, Helvetica, Arial, sans-serif;
}
body {
padding-top: 50px;
background-color: darkslateblue;
}
input[type=text] {
width: 100%;
padding: 6px;
border: 1px solid #ccc;
border-radius: 5px;
resize: vertical;
}
input[type=submit] {
background-color: #fecd07;
color: black;
font-size: 0.95em;
font-weight: bold;
padding: 12px 100px;
border: 1px solid orange;
border-radius: 5px;
cursor: pointer;
margin-right: 10px;
margin-top: 20px;
margin-bottom: 10px;
float: none;
}
input[type=submit]:hover {
background-color: orange;
}
.container {
border-radius: 5px;
background-color: #f2f2f2;
padding: 25px;
margin: auto;
}
.col-40 {
float: left;
width: 40%;
margin-top: 6px;
}
.col-60 {
float: left;
width: 60%;
margin-top: 6px;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
p, h3{
margin: 16px;
}
b{
font-size: 1.1em;
}
</style>
<script>
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}
function getProject(){
let SPdict = {"EBRAINS":"ebrain01",
"SP1":"bp00sp01",
"SP2":"bp00sp02",
"SP3":"bp00sp03",
"SP4":"bp00sp04",
"SP5":"bp00sp05",
"SP6":"bp00sp06",
"SP8":"bp00sp08",
"External":"bp00ext"
};
let SPname = document.getElementById("sp").value;
return SPdict[SPname];
}
function genXML(){
let xml=`<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Protocol</key>
<string>swift</string>
<key>Provider</key>
<string>openstack-keystone3</string>
<key>Nickname</key>
<string>${document.getElementById("cont").value}</string>
<key>UUID</key>
<string>${uuidv4()}</string>
<key>Hostname</key>
<string>ksproxy.cscs.ch</string>
<key>Port</key>
<string>13000</string>
<key>Username</key>
<string>${getProject()}:cscs:${document.getElementById("usr").value}</string>
<key>Path</key>
<string>/${document.getElementById("cont").value}</string>
<key>Access Timestamp</key>
<string>${Date.now()}</string>
</dict>
</plist>`;
return xml;
}
function saveFile(){
let blob = new Blob([genXML()], {type: "text/xml"});
let url = URL.createObjectURL(blob);
let a = document.createElement("a");
a.href = url;
let fname = document.getElementById("cont").value + "-" + document.getElementById("usr").value + ".duck"
a.download = fname;
a.click();
URL.revokeObjectURL(url);
}
</script>
</head>
<body>
<h1 style="text-align: center; color:#fecd07;">DuckMarker</h2>
<h2 style="text-align: center; color:#f2f2f2;">Generate a Cyberduck bookmark to your CSCS container</h2>
<br/>
<div class="container" style="width: 650px;">
<div class="row" style="width: 600px">
<div class="col-40">
<label for="sp">Select HBP subproject (SP): </label>
</div>
<div class="col-60">
<input type="text" list="projects" name="sp" id="sp">
<datalist id="projects">
<option value="EBRAINS">
<option value="SP1">
<option value="SP2">
<option value="SP3">
<option value="SP4">
<option value="SP5">
<option value="SP6">
<option value="SP8">
<option value="External">
</datalist>
</div>
</div>
<div class="row">
<div class="col-40">
<label for="usr">CSCS user name: </label>
</div>
<div class="col-60">
<input type="text" id="usr" name="usr">
</div>
</div>
<div class="row">
<div class="col-40">
<label for="cont">Container name: </label>
</div>
<div class="col-60">
<input type="text" id="cont" name="cont">
</div>
</div>
<div class="row" style="text-align: center">
<input type="submit" value="Save bookmark" onclick="saveFile()">
</div>
</div>
</body>
</html>