-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
159 lines (130 loc) · 6.26 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>No-code development platform</title>
<meta http-equiv="X-UA-Compatible" content="ie=edge;ie=10;chrome=1" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link type="text/css" href="https://cdn.front.nu/dist/front.css" rel="stylesheet">
<link type="text/css" href="https://cdn.front.nu/dist/design/material/theme/material.css" rel="stylesheet">
<link type="text/css" href="assets/theme.css" rel="stylesheet">
<script src="https://cdn.front.nu/dist/front.js"></script>
<script src="https://cdn.front.nu/dist/src/js/json.js"></script>
<script>
var HtmlAppBuilder;
var fileSelector;
window.onload = function(){
HtmlAppBuilder = document.getElementById('builder').cloneNode(true);
}
var openFile = function(event) {
var input = event.target;
var reader = new FileReader();
reader.onload = function(){
var result = reader.result;
parser = new DOMParser();
HtmlApp = parser.parseFromString(result, "text/html");
var bodyParse = HtmlApp.body.innerHTML;
document.body.innerHTML = bodyParse;
document.body.appendChild(HtmlAppBuilder);
};
//reader.readAsDataURL(input.files[0]);
reader.readAsText(input.files[0]);
};
function onDragStart(event, action) {
event.dataTransfer.effectAllowed = 'copy';
event.dataTransfer.setData('text', event.target.id);
}
function onDragOver(event) {
event.preventDefault();
}
function onDrop(event) {
var id = event.dataTransfer.getData('text');
var draggableElement = document.getElementById(id);
var dropzone = event.target;
if (draggableElement.getAttribute("id").startsWith("clone-")) {
dropzone.appendChild(draggableElement);
} else {
var el = document.getElementById(id);
var elClone = el.cloneNode(true);
var eId = Math.random().toString(36).slice(-5);
elClone.id = "clone-" + eId;
dropzone.appendChild(elClone);
}
//event.dataTransfer.clearData();
}
function savePage() {
var HtmlHead = document.head.innerHTML;
var HtmlBody = document.body.innerHTML;
var HTML = HtmlHead + HtmlBody + "</html>";
localStorage.setItem("PageDefault", HTML);
}
function buildPage() {
var html;
var divBuilder = document.getElementById('builder');
var header = document.getElementsByTagName("header");
var aside = document.getElementsByTagName("aside");
html = divBuilder.innerHTML + header.innerHTML + aside.innerHTML;
//html += localStorage.getItem("PageDefault");
return html;
}
function clearPage() {
var lista = document.body.childNodes;
for (var i = lista.length - 1; i >= 0; i--) {
document.body.removeChild(lista[i])
}
}
function loadPage() {
clearPage();
document.body.innerHTML = localStorage.getItem("PageDefault");
}
</script>
</head>
<body>
<div id="builder" class="lightdark-">
<div id="toolbar" class="pf h2 t0 w100 zi100">
<nav class="topbar h2 gap2-">
<a onclick="savePage()">Save</a>
<a onclick="loadPage()">Load</a>
<input type="file" accept="html/*" onchange="openFile(event)" style="min-height: 1rem"><br>
</nav>
<form>
<button>Preview</button>
<button>Publish</button>
</form>
</div>
<div id="toolbox" class="pf w10 t2 r0 z7- m05- fww zi50">
<nav id="bar" draggable="true" ondragstart="onDragStart(event)" class="topbar gap2-">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
</nav>
<button id="button" draggable="true" ondragstart="onDragStart(event)">Button</button>
<select id="bar" draggable="true" ondragstart="onDragStart(event)" class="topbar gap2-">
<option>Select 1</option>
<option>Select 2</option>
</select>
<input type="text" class="w100" placeholder="Text field" disabled id="textfield" draggable="true" ondragstart="onDragStart(event)">
<figure id="card" class="card w10" draggable="true" ondragstart="onDragStart(event)">
<i class="icon">📺</i>
<figcaption>Card</figcaption>
<p>Normal text</p>
<small>Small text</small>
</figure>
<p id="p" draggable="true" ondragstart="onDragStart(event)">Text</p>
<a id="link" draggable="true" ondragstart="onDragStart(event)">Link</a>
<h1 id="h1" draggable="true" ondragstart="onDragStart(event)">h1</h1>
<h2 id="h2" draggable="true" ondragstart="onDragStart(event)">h2</h2>
<h3 id="h3" draggable="true" ondragstart="onDragStart(event)">h3</h3>
<h4 id="h4" draggable="true" ondragstart="onDragStart(event)">h4</h4>
<h5 id="h5" draggable="true" ondragstart="onDragStart(event)">h5</h5>
<h6 id="h6" draggable="true" ondragstart="onDragStart(event)">h6</h6>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>.<br>.<br>.<br>.
</div>
</div>
<header contentEditable="true" ondragover="onDragOver(event)" ondrop="onDrop(event)"></header>
<nav contentEditable="true" ondragover="onDragOver(event)" ondrop="onDrop(event)"></nav>
<aside contentEditable="true" ondragover="onDragOver(event)" ondrop="onDrop(event)"></aside>
<main contentEditable="true" ondragover="onDragOver(event)" ondrop="onDrop(event)"></main>
<aside contentEditable="true" ondragover="onDragOver(event)" ondrop="onDrop(event)"></aside>
<footer contentEditable="true" ondragover="onDragOver(event)" ondrop="onDrop(event)"></footer>
</body>
</html>