2018-03-05 00:44:17 +00:00
|
|
|
console.log("app.js loaded");
|
|
|
|
|
2018-10-10 16:13:38 +01:00
|
|
|
var getTemplateHtml = (template, primary_color="#ffffff", secondary_color="#ffffff") => {
|
2018-03-05 01:06:06 +00:00
|
|
|
document.getElementById('iframe').src = "about:blank";
|
|
|
|
fetch('template/'+template+'.html')
|
2018-03-05 00:44:17 +00:00
|
|
|
.then(function(response) {
|
|
|
|
return response.text()
|
|
|
|
})
|
|
|
|
.then(function(html) {
|
|
|
|
document.getElementById('iframe').contentWindow.document.write(html);
|
2018-10-09 13:31:11 +01:00
|
|
|
// console.log(document.getElementById('iframe').contentWindow.document)
|
2018-10-10 16:13:38 +01:00
|
|
|
primary_elements = document.getElementById('iframe').contentWindow.document.getElementsByClassName("primary_color");
|
|
|
|
applyColor(primary_elements, primary_color);
|
2018-10-09 13:31:11 +01:00
|
|
|
|
2018-10-10 16:13:38 +01:00
|
|
|
secondary_elements = document.getElementById('iframe').contentWindow.document.getElementsByClassName("secondary_color");
|
|
|
|
applyColor(secondary_elements, secondary_color);
|
|
|
|
document.getElementById("primary").value = primary_color
|
|
|
|
document.getElementById("secondary").value = secondary_color
|
2018-03-05 00:44:17 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-10-10 16:13:38 +01:00
|
|
|
var changeColor = (el) => {
|
|
|
|
color = el.value
|
|
|
|
iframe_doc = document.getElementById('iframe').contentWindow.document
|
|
|
|
if(el.id == "primary")
|
|
|
|
{
|
|
|
|
divs = iframe_doc.getElementsByClassName("primary_color")
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
divs = iframe_doc.getElementsByClassName("secondary_color")
|
|
|
|
}
|
|
|
|
applyColor(divs, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
var applyColor = (elements, color) => {
|
|
|
|
var i;
|
|
|
|
for (i = 0; i < elements.length; i++) {
|
|
|
|
elements[i].style["background-color"] = color;
|
|
|
|
}
|
|
|
|
}
|
2018-03-05 00:44:17 +00:00
|
|
|
var valueChange = value => {
|
|
|
|
var iframehtml = document.getElementById('iframe').contentWindow.document.getElementById(value);
|
|
|
|
val = document.getElementById(value).value;
|
|
|
|
iframehtml.innerHTML = val
|
2018-03-10 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var downloadPage = () => {
|
|
|
|
var pageContents = new XMLSerializer().serializeToString(document.getElementById('iframe').contentWindow.document)
|
|
|
|
pageContents = pageContents.replace("rep_DEVNAME", document.getElementById("devname").value)
|
|
|
|
pageContents = pageContents.replace("rep_SNAME", document.getElementById("sitename").value)
|
|
|
|
pageContents = pageContents.replace("rep_SURL", document.getElementById("url").value)
|
|
|
|
|
|
|
|
download(pageContents, "index.html", "text/html")
|
2018-10-09 03:37:06 +01:00
|
|
|
}
|
|
|
|
getTemplateHtml("original");
|