Commit 74c5f159 authored by Marco Kellershoff's avatar Marco Kellershoff
Browse files

Komplett-Rundumerneuerung - first steps

Weil aktuell "alle Nase-lang" wieder ein Änderungswunsch für die Signatur
reinkommt und teilweise auch sehr spezielle, für die der Signatur-Generator in
seiner jetzigen Form nie vorgesehen war, musste schon wieder "drangestrickt"
werden. Deshalb wird der Signatur-Generator nun zum 2ten mal komplett
umgeschrieben und ist dann hoffentlich erst mal wieder für eine Weile den
Anforderungen gewachsen.
parent f8f2ca26
(function(window, document){
var query = function(sel) {
return document.querySelector(sel);
};
var queryAll = function(sel) {
return document.querySelectorAll(sel);
};
var createEl = function(nodeName, nodeContents, nodeAttrs) {
var el = document.createElement(nodeName);
if (nodeContents) {
if (typeof nodeContents === 'string') {
el.innerHTML = nodeContents;
} else if (typeof nodeContents === 'object' && nodeContents.length) {
var nodeContentsCallback = function(nodeContent) {
el.appendChild(nodeContent);
};
nodeContents.forEach(nodeContentsCallback);
} else if (typeof nodeContents === 'object' && !nodeContents.length) {
el.appendChild(nodeContents);
}
}
if (nodeAttrs && nodeAttrs.length) {
var nodeAttrsCallback = function(nodeAttr) {
el.setAttribute(nodeAttr[0], nodeAttr[1]);
};
nodeAttrs.forEach(nodeAttrsCallback);
}
return el;
};
var getData = function(url, opts, cb) {
opts = opts || {};
var passToCallback = function(json) {
cb(json);
};
var processData = function(data) {
switch (opts.dataType) {
case 'text':
data.text().then(passToCallback);
break;
case 'blob':
data.blob().then(passToCallback);
break;
default:
data.json().then(passToCallback);
break;
}
};
fetch(url).then(processData);
};
var renderPortalSelection = function() {
var portals = [];
var portalsCallback = function(portal) {
var el = createEl('option', portal.name, [
['value', portal.data]
]);
portals.push(el);
};
var cb = function(json) {
json.portals.forEach(portalsCallback);
var select = createEl('select', portals);
query('#app').appendChild(select);
console.log(portals);
};
getData('portals.json', null, cb);
};
var init = function() {
renderPortalSelection();
};
init();
})(window, document);
{
"moo": "foo"
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Signature Generator</title>
<style type="text/css" media="screen">
</style>
</head>
<body>
<div id="app"></div>
<script src="app.js" charset="utf-8"></script>
</body>
</html>
{
"success": true,
"portals": [
{
"name": "gofeminin.de",
"data": "gofeminin.de.json"
},
{
"name": "onmeda",
"data": "onmeda.json"
}
]
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment