-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
524 lines (448 loc) · 22.1 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Easy Viva XMP-Generator</title>
<!--
MIT License
Copyright (c) 2016 Didier Clapasson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<style>
* {box-sizing: border-box;}
h1, h2, h3, p, label, input, select, button, option {font-family: arial, sans-serif;}
h1 {font-size: 24px; margin-bottom: 0;}
h2 {font-size: 19.2px; font-weight: normal;}
h3 {font-size: 19.2px;}
label {display: inline-block; width: 176px; padding: 3.2px 0px;}
input {height: 22px; width: 293px; border: none; background-color: #3cbc8d; padding: 4px;}
select {height: 22px; width: 293px; display: inline-block; border: none; background-color: #3cbc8d;}
button {display: inline-block; border: none; background-color: #3cbc8d; padding: 4px;}
option {padding: 4px;}
pre {background-color: #d9d9d9; padding: 8px; min-height: 235px; width: 100%; margin: 0px; white-space: pre-wrap; word-wrap: break-word;}
span {font-weight: bold; color: red;}
textarea {width: 100%; border-radius: 0px; border: 1px solid #000; margin: 32px 0px 16px 0px;}
#wrapper {background-color: #f1f1f1; overflow: hidden; padding: 8px; width: 1100px;}
#buttonFormularErstellen {float: right; cursor: pointer;}
#xmlHead label {width: 172.8px;}
#formWrapper {width: 494px; float: left; margin-right: 8px;}
#xmlAusgabe {float: left; width: 578px;}
#buttonXMPdateiErstellen {border: 2px solid #000; height: 30px; width: 200px; font-weight: bold; margin-top: 32px; cursor: pointer;}
#version {font-size: 10.4px; float: right;}
#clipboardText {margin: 0 0;}
#clipboardToggle {margin: 22px 0px 5px 0px; font-size: small; float: right; background-color: #3cbc8d; cursor: pointer;}
.plusButton {display: inline-block; font-weight: bold; text-align: center; margin: 0; height: 22px; width: 22px; background-color: red;}
.inputHeader {font-size: 19.2px; width: 80%; float: left; margin-bottom: 15px; margin-top: 5px;}
.moveUpButton {height: 0; width: 0; float: right; border-left: 8px solid transparent;border-right: 8px solid transparent; border-bottom: 16px solid green; margin-top: 5px; cursor: pointer;}
.moveDownButton {height: 0; width: 0; float: right; border-left: 8px solid transparent;border-right: 8px solid transparent; border-top: 16px solid green; margin-top: 5px; cursor: pointer;}
.removeButton {height: 16px; width: 16px; float: right; margin-top: 5px; margin-right: 10px; cursor: pointer; background-color: red; text-align: center; font-weight: bold;}
.clipboardTop {float: left; width: 578px;}
.clipboardFix {width: 578px; left: 518px; position: fixed;}
</style>
</head>
<body>
<div id="wrapper">
<h1>Easy Viva XMP-Generator</h1>
<h2>Mit diesem Programm können Viva-XMP Daten für den Formularmodus des Printplus Druckportal erzeugt werden.</h2>
<hr>
<div id="formWrapper">
<div id="headInfo">
<form id="xmlHead">
<h3>Head Informationen</h3>
<label>viva:title: </label> <input type="text" id="inputVivaTitle" value=""><br>
<label>viva:liste: </label>
<select id="inputVivaListe">
<option value="1">Liste anzeigen</option>
<option value="0">Liste nicht anzeigen</option>
</select><br>
<label>viva:previewWidth: </label> <input type="text" id="inputVivaPreviewWidth" value="680"><br>
<label>viva:previewHeight: </label> <input type="text" id="inputVivaPreviewHeight" value=""><br>
<label>viva:formWidth: </label> <input type="text" id="inputVivaFormWidth" value="500"><br>
<label>viva:productDescription: </label> <input type="text" id="inputVivaProductDescription" value="$Name.Vorname$ $Name.Name$" placeholder=""><br>
</form>
<hr>
</div>
<div id="formularfelder">
</div>
<div>
<h3>Neues Formularfeld hinzufügen</h3>
<select id="newValueSortOf">
<option value="text">Textfeld</option>
<option value="hidden">Verstecktes Feld</option>
<option value="email">E-Mail Feld</option>
<option value="textarea">Mehrzeiliges Formularfeld</option>
<option value="select">Auswahlliste</option>
<option value="upload">File-Upload</option>
</select>
<button id="buttonFormularErstellen" onclick="neuesFormularfeld()">Formularfeld hinzufügen</button>
</div>
<br>
<button id="buttonXMPdateiErstellen" onclick="elementeAbrufen()">XMP-Datei erstellen</button>
<br>
<br>
</div> <!-- end of form-wrapper -->
<div id="clipboard" class="clipboardTop">
<p id="clipboardToggle" onclick="toggleClipboard()">Schweben</p>
<!-- Clipboard -->
<textarea id="clipboardText" placeholder="Clipboard ..." rows="3"></textarea>
</div>
<div id="xmlAusgabe">
<h3>XMP-Datei:</h3>
<pre id="ausgabefeld"></pre>
<p id="version">V.1.6.1<br>24.12.2016</p>
</div> <!-- end of xmlAusgabe -->
</div> <!-- end of wrapper -->
<script type="text/javascript">
// // // TOGGLE CLIPBOARD CLASS
function toggleClipboard() {
var toggleClass = document.getElementById("clipboard");
var toggleText = document.getElementById("clipboardToggle");
toggleClass.className = (toggleClass.className === "clipboardTop") ? "clipboardFix" : "clipboardTop";
toggleText.innerHTML = (toggleText.innerHTML === "Schweben") ? "Oben anheften" : "Schweben";
}
// // // CREATE FORM-FIELDS
// choose which form field you want to create
function neuesFormularfeld() {
var valueNF = document.getElementById("newValueSortOf").value; // 1.
determineNewFormfield(valueNF);
// determine the kind of formfield, that should be created
function determineNewFormfield(valueNF) {
var h3HeaderTitle;
var inputFields;
var inputValue;
switch (valueNF) {
case "text":
h3HeaderTitle = "Textfeld"; // 2.
inputFields = ["name", "default", "label"]; // 3. & 4. (is used for attribut name too)
inputValue = ["", "", ""]; // 5.
break;
case "hidden":
h3HeaderTitle = "Verstecktes Feld";
inputFields = ["name", "default"];
inputValue = ["", ""];
break;
case "email":
h3HeaderTitle = "E-Mail-Feld";
inputFields = ["name", "default", "label", "align"];
inputValue = ["", "", "", "left"];
break;
case "textarea":
h3HeaderTitle = "Mehrzeiliges Formularfeld";
inputFields = ["name", "default", "textrows", "textchars", "label"];
inputValue = ["", "", "", "", ""];
break;
case "select":
h3HeaderTitle = "Auswahlliste";
inputFields = ["name", "title", "value", "title", "value", "label"];
inputValue = ["", "", "", "", "", ""];
break;
case "upload":
h3HeaderTitle = "File-Upload";
inputFields = ["name", "default", "pattern", "label", "help"];
inputValue = ["", "", "jpg|png|gif", "", "Unterstützt werden die Dateiformate jpg, png, gif."];
break;
} // end of switch
// create form-element
var form = document.createElement("FORM");
form.setAttribute("class", valueNF); // 1.
// append new formelement with content to div formularfelder
document.getElementById("formularfelder").appendChild(form);
// create header element
var header = document.createElement("h3");
var headerText = document.createTextNode(h3HeaderTitle); // 2.
form.appendChild(header);
header.appendChild(headerText);
header.setAttribute("class", "inputHeader");
// create move up/move down buttons
var moveDownButton = document.createElement("DIV");
form.appendChild(moveDownButton);
moveDownButton.setAttribute("class", "moveDownButton");
moveDownButton.setAttribute("onclick", "moveUpDown(this, +2)");
moveDownButton.setAttribute("title", "Bewege Feld nach unten");
var moveUpButton = document.createElement("DIV");
form.appendChild(moveUpButton);
moveUpButton.setAttribute("class", "moveUpButton");
moveUpButton.setAttribute("onclick", "moveUpDown(this, -1)");
moveUpButton.setAttribute("title", "Bewege Feld nach oben");
// create remove button
var removeButton = document.createElement("DIV");
var removeButtonText = document.createTextNode("-");
form.appendChild(removeButton);
removeButton.appendChild(removeButtonText);
removeButton.setAttribute("class", "removeButton");
removeButton.setAttribute("title", "Entferne Feld");
removeButton.setAttribute("onclick", "removeInput(this)");
// create input field
for (i = 0; i < inputFields.length; i++) {
var inputLabel = document.createElement("label");
var text = document.createTextNode("viva: " + inputFields[i]); // 3.
form.appendChild(inputLabel);
inputLabel.appendChild(text);
var formName = document.createElement("input");
formName.setAttribute("type", "text");
formName.setAttribute("name", inputFields[i]); // 4.
formName.setAttribute("value", inputValue[i]); // 5.
form.appendChild(formName);
// set condition for the kind of the new select-field
var addInput;
if (inputFields[i] === "default") {
// list all needed input-fields, first element is empty to enable onchange
if (valueNF === "text" || valueNF === "email" || valueNF === "textarea") {
addInput = ["","placeholder", "pattern"];
createNewInput(form, addInput);
} else if (valueNF === "upload") {
addInput = ["", "placeholder"];
createNewInput(form, addInput);
}
} else if (inputFields[i] === "label") {
// if (valueNF === "text" || valueNF === "email" || valueNF === "textarea" || valueNF === "select") {
if (valueNF !== "upload") {
addInput = ["", "help"];
createNewInput(form, addInput);
}
} else if (inputFields[i] === "value") {
addInput = ["", "neue Option"];
createNewInput(form, addInput);
}
// create br-element
var br = document.createElement("br");
form.appendChild(br);
} // end for-loop to create input-field
// append line after new created formelement
var linie = document.createElement("hr");
form.appendChild(linie);
}
// scroll to bottom
window.scrollTo(0, document.body.scrollHeight);
} // end of function neuesFormularfeld
// // /// REMOVE INPUT
function removeInput(obj) {
var parentObj = obj.parentNode;
var grandParentObj = parentObj.parentNode;
if (confirm("Wollen Sie das Input-Feld wirklich entfernen?")) {
grandParentObj.removeChild(parentObj);
} else {
// do nothing!
}
}
// // // MOVE INPUT UP AND DOWN
function moveUpDown(obj, move) {
var grandParentObj = obj.parentNode.parentNode;
var getForm = grandParentObj.getElementsByTagName("form");
var actualPos;
for (i = 0; i < getForm.length; i++) {
if (getForm.item(i) == obj.parentNode) {
actualPos = i;
}
}
if (move === 2 && actualPos === getForm.length-1) {
// move last input-element up to first position if button move-down is pressed
grandParentObj.insertBefore(getForm[actualPos], grandParentObj.children[0]);
} else {
// move input element up or down.
grandParentObj.insertBefore(getForm[actualPos], grandParentObj.children[actualPos+move]);
}
}
// // // FUNCTIONS TO CREATE CHOOSER FOR OPTIONAL INPUT-FIELDS
// create select with option-fields to create a chooser to create new input-fields
function createNewInput(form, addInput) {
var createNewSelect = document.createElement("select");
createNewSelect.setAttribute("onchange", "chooseNewInputSelect(this)");
for (j = 0; j < addInput.length; j++) {
var createNewOption = document.createElement("option");
createNewOption.text = addInput[j];
createNewOption.setAttribute("value", addInput[j]);
createNewSelect.appendChild(createNewOption);
createNewSelect.setAttribute("class", "plusButton");
// hidde first option-element
createNewSelect.firstChild.style.display = "none";
} // end of j-loop
form.appendChild(createNewSelect);
} // end of function createNewInput
// choose kind of input element
function chooseNewInputSelect(obj, createNewSelect, form) {
var newInputValue = obj.options[obj.selectedIndex].value;
// make new option for select-form
if (newInputValue == "neue Option") {
makeNewInputElement(obj, "value");
makeNewInputElement(obj, "title");
obj.parentNode.removeChild(obj);
} else {
// make new option for all other form-fields
makeNewInputElement(obj, newInputValue);
removeElements(obj);
}
} // ende of chooseNewInputSelect
// create new label and new input-field
function makeNewInputElement(obj, newInputValue) {
var makeNewLabel = document.createElement("label");
var text = document.createTextNode("viva: "+ newInputValue);
makeNewLabel.appendChild(text);
var makeNewInput = document.createElement("input");
makeNewInput.setAttribute("type", "text");
makeNewInput.setAttribute("name", newInputValue);
makeNewInput.setAttribute("value", "");
// apend input-field below (this)
obj.parentNode.insertBefore(makeNewInput, obj.nextSibling);
obj.parentNode.insertBefore(makeNewLabel, obj.nextSibling);
} // end of makeNewInputElement
// delete actual option element, delete whole select if only one option exist
function removeElements(obj) {
var getChildrenLen = obj.children.length;
if (getChildrenLen <= 2) {
// lösche select-element
obj.parentNode.removeChild(obj);
} else {
// lösche ausgewähltes option-Element
obj.remove(obj.selectedIndex);
} // ende if else
}
// // // WRITE XML-OUTPUT
// call elements
function elementeAbrufen() {
// change text in button 'XMP-Datei erstellen'
var getButtonXMPdateiErstellen = document.getElementById("buttonXMPdateiErstellen");
if (getButtonXMPdateiErstellen.innerHTML === "XMP-Datei erstellen") {
getButtonXMPdateiErstellen.innerHTML = "XMP-Datei aktualisieren";
}
// get input-information and generate XMP-Output
var formAbrufen = document.getElementById("formularfelder").getElementsByTagName("form");
var inputfieldText = "";
var formOutput = "";
var lz2 = "  ";
var lz4 = lz2 + lz2;
var lz6 = lz2 + lz4;
var lz8 = lz4 + lz4;
var lz10 = lz8 + lz2;
// get head information
var vivaTitle = document.getElementById("inputVivaTitle").value;
var vivaListe = document.getElementById("inputVivaListe").value;
var vivaPreviewWidth = document.getElementById("inputVivaPreviewWidth").value;
var vivaPreviewHeight = document.getElementById("inputVivaPreviewHeight").value;
var vivaFormWidth = document.getElementById("inputVivaFormWidth").value;
var vivaProductDescription = document.getElementById("inputVivaProductDescription").value;
// write head information
var headText =
"<viva:form rdf:parseType=\"Resource\"><br>" +
lz2 + "<viva:title><span>" + vivaTitle + "</span></viva:title><br>" +
lz2 + "<viva:listeAnzeigen><span>" + vivaListe + "</span></viva:listeAnzeigen><br>" +
lz2 + "<viva:previewWidth><span>" + vivaPreviewWidth + "</span></viva:previewWidth><br>" +
lz2 + "<viva:previewHeight><span>" + vivaPreviewHeight + "</span></viva:previewHeight><br>" +
lz2 + "<viva:formWidth><span>" + vivaFormWidth + "</span></viva:formWidth><br>" +
lz2 + "<viva:productDescription><span>" + vivaProductDescription + "</span></viva:productDescription><br>" +
lz2 + "<rdf:value rdf:parseType=\"Resource\"><br>" +
lz4 + "<viva:fields><br>" +
lz6 + "<rdf:Seq><br>";
// write xml-closing information
var closingText =
lz6 + "</rdf:Seq><br>" +
lz4 + "</viva:fields><br>" +
lz2 + "</rdf:value><br>" +
"</viva:form>";
// loop through all user created form-fields
for (i = 0; i < formAbrufen.length; i++) {
var getClassName = formAbrufen[i].className;
var inputAbrufen = formAbrufen[i].getElementsByTagName("input");
var xmlVivaContBasic = "";
var xmlVivaContValue = "";
var xmlVivaContOptions = "";
var xmlVivaOptionsContainer = "";
var xmlVivaValueContainer = "";
// loop through all input-fields inside form-fields
for (j = 0; j < inputAbrufen.length; j++) {
var getInputNameValue = inputAbrufen[j].name;
var getInputValue = inputAbrufen[j].value;
var getClassNameForm = getClassName;
var xmlVivaType = "";
var xmlVivaTypeValue = "";
var xmlVivaTypeOptions = "";
// decide which function to use determined through attribute name
switch (getInputNameValue) {
case "name":
case "default":
case "placeholder":
case "pattern":
case "textrows":
case "textchars":
xmlVivaType =
lz10 + "<viva:" + getInputNameValue + "><span>" +
getInputValue + "</span></viva:" + getInputNameValue + "><br>";
break;
case "label":
case "align":
case "help":
case "description":
xmlVivaTypeValue =
lz10 + lz2 + "<viva:" + getInputNameValue + "><span>" +
getInputValue + "</span></viva:" + getInputNameValue + "><br>";
break;
case "title":
xmlVivaTypeOptions =
lz10 + lz6 + "<rdf:li rdf:parseType=\"Resource\"><br>" +
lz10 + lz8 + "<viva:" + getInputNameValue + "><span>" +
getInputValue + "</span></viva:" + getInputNameValue + "><br>";
break;
case "value":
xmlVivaTypeOptions =
lz10 + lz8 + "<rdf:" + getInputNameValue + "><span>" +
getInputValue + "</span></rdf:" + getInputNameValue + "><br>" +
lz10 + lz6 + "</rdf:li><br>";
break;
default:
xmlVivaType = "Meine Form hat keine Klasse! <br>";
break;
}
xmlVivaContBasic += xmlVivaType;
xmlVivaContValue += xmlVivaTypeValue;
xmlVivaContOptions += xmlVivaTypeOptions;
}
if (xmlVivaContValue === "") {
xmlVivaValueContainer = "";
} else if (xmlVivaContOptions !== ""){
var xmlVivaLabelInOption = xmlVivaTypeValue;
} else {
xmlVivaValueContainer =
lz10 + "<rdf:value rdf:parseType=\"Resource\"><br>" +
xmlVivaContValue +
lz10 + "</rdf:value><br>";
}
if (xmlVivaContOptions === "") {
xmlVivaOptionsContainer = "";
} else {
xmlVivaOptionsContainer =
lz10 + "<rdf:value rdf:parseType=\"Resource\"><br>" +
lz10 + lz2 + "<viva:options><br>" +
lz10 + lz4 + "<rdf:Seq><br>" + xmlVivaContOptions +
lz10 + lz4 + "</rdf:Seq><br>" +
lz10 + lz2 + "</viva:options><br>" +
xmlVivaLabelInOption +
lz10 + "</rdf:value><br>";
}
var inputOutput = xmlVivaContBasic + xmlVivaValueContainer + xmlVivaOptionsContainer;
formOutput +=
lz8 + "<rdf:li rdf:parseType=\"Resource\"><br>" +
lz10 + "<viva:type><span>" + getClassName + "</span></viva:type><br>" +
inputOutput +
lz8 + "</rdf:li><br>";
}
inputfieldText = formOutput;
var printOut = document.getElementById("ausgabefeld").innerHTML = headText + inputfieldText + closingText;
}
</script>
</body>
</html>