diff --git a/base.css b/base.css
new file mode 100644
index 0000000..6fe47f3
--- /dev/null
+++ b/base.css
@@ -0,0 +1 @@
+body{margin:0 auto;padding:12vmin 10vmin;max-width:35em;line-height:1.5em;font-family: -apple-system,BlinkMacSystemFont,sans-serif;word-wrap: break-word;}
\ No newline at end of file
diff --git a/edit.js b/edit.js
index a2b6f69..3da2282 100644
--- a/edit.js
+++ b/edit.js
@@ -8,7 +8,7 @@ var DATA_PREFIX_BAZE = 'data:text/html;charset=utf-8;baze64,'
var content = undefined
window.onload = function() {
window.onpopstate = function(e) { setContent(e.state) }
-
+ window.onhashchange = function(e) { console.log("hash", e); location.reload() }
document.body.ondragenter = function(e) { document.body.classList.add("drag"); };
document.body.ondragleave = function(e) { document.body.classList.remove("drag"); };
document.body.onclick = function(e) { if (e.target == document.body) content.focus() };
@@ -58,7 +58,7 @@ function handleDrop(e) {
console.log("Compressed to", url.length / length)
if (e.altKey) url = url.replace(DATA_PREFIX_BAZE, "!")
updateLink(url, true)
- setContent(' đ' + file.name + '
');
+ setFileContent('đ' + file.name)
})
}, false);
reader.readAsDataURL(file);
@@ -66,6 +66,10 @@ function handleDrop(e) {
document.body.classList.remove("drag")
}
+function setFileContent(name) {
+ setContent(' ' + name + '
');
+}
+
function handleKey(e) {
var code = e.which;
var handled = false;
@@ -98,11 +102,12 @@ function handlePaste(e) {
var clipboard = window.clipboardData || e.clipboardData
var text = clipboard.getData('Text') || clipboard.getData('text/plain')
if (match = text.match(codepenRE)) {
- console.log(match)
fetchCodepen(match[0])
}
}
+
+var TEMPLATE_MARKER = "/*use-itty-bitty-template*/"
function fetchCodepen(url) {
var h, c, j;
$.when(
@@ -110,10 +115,15 @@ function fetchCodepen(url) {
$.get(url + ".css", function(css) { c = css; }),
$.get(url + ".js", function(js) { j = js; })
).then(function() {
+ var useTemplate = c.indexOf(TEMPLATE_MARKER) >= 0
var string = '' + h + ''
- content.innerText = string
- updateBodyClass()
- handleInput()
+ console.log(c, c.indexOf(TEMPLATE_MARKER))
+ stringToZip(string, function(zip) {
+ setFileContent('âď¸' + url)
+ setTimeout(function() {
+ updateLink((useTemplate ? "," : DATA_PREFIX_BAZE) + zip)
+ }, 300);
+ });
});
}
@@ -158,7 +168,7 @@ function updateLink(url, push) {
window.history.replaceState(content.innerHTML, null, url);
}
var length = location.href.length
-console.log(length)
+
$('#length')[0].innerText = length + " bytes"
$('#length')[0].href = url
for (var key in maxLengths) {
diff --git a/firebase.json b/firebase.json
index e67789d..148d67f 100644
--- a/firebase.json
+++ b/firebase.json
@@ -16,4 +16,4 @@
"cleanUrls": true,
"trailingSlash": false
}
-}
+}
\ No newline at end of file
diff --git a/index.html b/index.html
index a9274d9..423da97 100644
--- a/index.html
+++ b/index.html
@@ -12,6 +12,7 @@