aboutsummaryrefslogtreecommitdiff
path: root/client/js/arching-kaos-generator.js
blob: a93199dd5df063797db2be4a5697de7ad130f910 (plain)
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
/* Arching Kaos Generator
 *
 * Kaotisk Hund - 2024
 *
 * @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
 *
 */
function makeElement(obj, attachTo)
{
    if (obj.element !== 'head' && obj.element !== 'body' )
    {
        var temp = document.createElement(obj.element);
    }
    else if ( obj.id !== null && document.querySelector('#'+obj.id) )
    {
        var temp = document.querySelector('#'+obj.id);
    }
    else
    {
        var temp = document.querySelector(obj.element);
    }
    if ( obj.id !== undefined ) temp.id = obj.id;
    if ( obj.name !== undefined ) temp.name = obj.name;
    if ( obj.type !== undefined ) temp.type = obj.type;
    if ( obj.content !== undefined ) temp.content = obj.content;
    if ( obj.property !== undefined ) temp.property = obj.property;
    if ( obj.className !== undefined ) temp.className = obj.className;
    if ( obj.rel !== undefined ) temp.rel = obj.rel;
    if ( obj.href !== undefined ) temp.href = obj.href;
    if ( obj.src !== undefined ) temp.src = obj.src;
    if ( obj.as !== undefined ) temp.as = obj.as;
    if ( obj.target !== undefined ) temp.target = obj.target;
    if ( obj.alt !== undefined ) temp.alt = obj.alt;
    if ( obj.charset !== undefined ) temp.charset = obj.charset;
    if ( obj.value !== undefined ) temp.value = obj.value;
    if ( obj.controls !== undefined ) temp.controls = obj.controls;
    if ( obj.hidden !== undefined ) temp.hidden = obj.hidden;
    if ( obj.placeholder !== undefined ) temp.placeholder = obj.placeholder;
    if ( obj.classes !== undefined ) temp.classList = obj.classes;
    if ( obj.innerText !== undefined ) temp.innerText = obj.innerText;
    if ( obj.innerHTML !== undefined && Array.isArray(obj.innerHTML) )
    {
        obj.innerHTML.forEach((value)=>{makeElement(value, temp)});
    }
    else if ( obj.innerHTML !== undefined && typeof(obj.innerHTML) === "string" )
    {
        temp.innerHTML = obj.innerHTML;
    }
    attachTo.appendChild(temp);
}

function makeUpSite(tree, root){
    if ( tree !== undefined && Array.isArray(tree) )
    {
        for (var i = 0; i < tree.length; i++)
        {
            makeElement(tree[i], root)
        }
    }
}

// @license-end