mirror of
https://github.com/arfct/itty-bitty.git
synced 2026-03-11 08:54:33 +00:00
IE Fixes
This commit is contained in:
parent
c1aadad477
commit
9e207a57d2
5 changed files with 40 additions and 17 deletions
2
data.js
2
data.js
|
|
@ -72,6 +72,6 @@ function dataURItoBlob(dataURI) {
|
|||
_ia[i] = byteString.charCodeAt(i);
|
||||
}
|
||||
var dataView = new DataView(arrayBuffer);
|
||||
var blob = new Blob([dataView], { type: mimeString });
|
||||
var blob = new Blob([dataView.buffer], { type: mimeString });
|
||||
return blob;
|
||||
}
|
||||
|
|
|
|||
4
edit.css
4
edit.css
|
|
@ -9,7 +9,7 @@ body {
|
|||
h1 { font-weight:400; }
|
||||
h2 { font-weight:500; }
|
||||
|
||||
body.placeholder #placeholder {
|
||||
body:not(.edited) #placeholder {
|
||||
display:block;
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ body.drag #content {
|
|||
}
|
||||
*/
|
||||
|
||||
body.has-content #toolbar {
|
||||
body.edited #toolbar {
|
||||
opacity:1.0;
|
||||
transition: opacity 2s ease-out;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
|
|
@ -17,8 +18,9 @@
|
|||
<button id="copy">Copy Link</button><br>
|
||||
</span>
|
||||
<div id="placeholder">
|
||||
Share itty bitty things<br>with just a link.<br>
|
||||
To get started, type here<br>or drop an HTML file.<br>
|
||||
Itty bitty things<br>
|
||||
can be shared within a link–<br>
|
||||
type to get started.
|
||||
<p><a id="ib-info" contenteditable=false href="http://about.bitty.site">Learn more</a><br>
|
||||
</div>
|
||||
<div id="content"> </div>
|
||||
|
|
|
|||
16
edit.js
16
edit.js
|
|
@ -41,8 +41,11 @@ function setContent(html) {
|
|||
|
||||
function updateBodyClass() {
|
||||
var length = content.innerText.length;
|
||||
document.body.classList.toggle("has-content", length)
|
||||
document.body.classList.toggle("placeholder", !length)
|
||||
if (length) {
|
||||
$('body').addClass("edited")
|
||||
} else {
|
||||
$('body').removeClass("edited")
|
||||
}
|
||||
}
|
||||
|
||||
function handleDrop(e) {
|
||||
|
|
@ -140,7 +143,7 @@ function handleInput(e) {
|
|||
updateBodyClass();
|
||||
var text = content.innerText
|
||||
var strip = false;
|
||||
if (text.includes("</")) {
|
||||
if (text.indexOf("</") > 0) {
|
||||
text = text.replace(/[\n|\t]+/g,' ').replace(/> +</g, '> <')
|
||||
} else {
|
||||
var title = text.split("\n")[0]
|
||||
|
|
@ -173,7 +176,12 @@ function updateLink(url, push) {
|
|||
$('#length')[0].href = url
|
||||
for (var key in maxLengths) {
|
||||
var maxLength = maxLengths[key]
|
||||
$(key)[0].classList.toggle("invalid", length > maxLength)
|
||||
if (length > maxLength) {
|
||||
$(key).addClass("invalid")
|
||||
} else {
|
||||
$(key).removeClass("invalid")
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
29
index.html
29
index.html
|
|
@ -1,3 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmanifest="manifest.appcache">
|
||||
<title>itty bitty</title>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
|
|
@ -12,11 +13,10 @@
|
|||
<button id="edit">Edit</button>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function showEdit() {
|
||||
function showEdit(editable) {
|
||||
var link = document.getElementById('edit');
|
||||
link.onclick = function() { location.href = "/edit" + location.hash }
|
||||
link.style.display = "block";
|
||||
link.style.display = editable ? "block" : "none";
|
||||
}
|
||||
|
||||
var HEAD_TAGS = "PG1ldGEgY2hhcnNldD0idXRmLTgiPjxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lkdGgiPjxiYXNlIHRhcmdldD0iX3RvcCI+PHN0eWxlIHR5cGU9InRleHQvY3NzIj5ib2R5e21hcmdpbjowIGF1dG87cGFkZGluZzoxMnZtaW4gMTB2bWluO21heC13aWR0aDozNWVtO2xpbmUtaGVpZ2h0OjEuNWVtO2ZvbnQtZmFtaWx5OiAtYXBwbGUtc3lzdGVtLEJsaW5rTWFjU3lzdGVtRm9udCxzYW5zLXNlcmlmO3dvcmQtd3JhcDogYnJlYWstd29yZDt9PC9zdHlsZT4g"
|
||||
|
|
@ -35,14 +35,27 @@ window.onhashchange = window.onload = function() {
|
|||
hash = hash.substring(1)
|
||||
preamble = HEAD_TAGS
|
||||
}
|
||||
|
||||
if (!hash.startsWith("data:")) hash = 'data:text/html;charset=utf-8;' + (compressed ? 'baze64,' : 'base64,') + hash;
|
||||
if (hash.indexOf("data:") != 0) hash = 'data:text/html;charset=utf-8;' + (compressed ? 'baze64,' : 'base64,') + hash;
|
||||
// location.href = hash // Redirect to data URI in supported browsers
|
||||
|
||||
link.onclick = function() { location.href = "/edit" + location.hash }
|
||||
|
||||
showEdit(editable)
|
||||
|
||||
var useData = !navigator.userAgent.match(/rv:11/); // || /Edge/.test(navigator.userAgent)
|
||||
decompressDataURI(hash, preamble, function(hash) {
|
||||
if (hash) iframe.src = hash;
|
||||
link.onclick = function() { location.href = "/edit" + location.hash }
|
||||
link.style.display = editable ? "block" : "none";
|
||||
if (!hash) return;
|
||||
if (useData) {
|
||||
if (hash) iframe.src = hash;
|
||||
} else{
|
||||
dataToString(hash, function(content){
|
||||
var doc = iframe.contentWindow.document;
|
||||
doc.open();
|
||||
doc.write(content);
|
||||
doc.close();
|
||||
})
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue