forked from cory/tildefriends
Remove old, broken drag+drop code.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4390 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
39927e75f2
commit
0d82198849
@ -835,22 +835,6 @@ function send(value) {
|
||||
}
|
||||
}
|
||||
|
||||
function dragHover(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
let input = document.getElementById("input");
|
||||
if (event.type == "dragover") {
|
||||
if (!input.classList.contains("drop")) {
|
||||
input.classList.add("drop");
|
||||
gOriginalInput = input.value;
|
||||
input.value = "drop file to upload";
|
||||
}
|
||||
} else {
|
||||
input.classList.remove("drop");
|
||||
input.value = gOriginalInput;
|
||||
}
|
||||
}
|
||||
|
||||
function fixImage(sourceData, maxWidth, maxHeight, callback) {
|
||||
let result = sourceData;
|
||||
let image = new Image();
|
||||
@ -880,52 +864,6 @@ function sendImage(image) {
|
||||
});
|
||||
}
|
||||
|
||||
function fileDropRead(event) {
|
||||
sendImage(event.target.result);
|
||||
}
|
||||
|
||||
function fileDrop(event) {
|
||||
dragHover(event);
|
||||
|
||||
let done = false;
|
||||
if (!done) {
|
||||
let files = event.target.files || event.dataTransfer.files;
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let file = files[i];
|
||||
if (file.type.substring(0, "image/".length) == "image/") {
|
||||
let reader = new FileReader();
|
||||
reader.onloadend = fileDropRead;
|
||||
reader.readAsDataURL(file);
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!done) {
|
||||
let html = event.dataTransfer.getData("text/html");
|
||||
let match = /<img.*src="([^"]+)"/.exec(html);
|
||||
if (match) {
|
||||
sendImage(match[1]);
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!done) {
|
||||
let text = event.dataTransfer.getData("text/plain");
|
||||
if (text) {
|
||||
send(text);
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function enableDragDrop() {
|
||||
let body = document.body;
|
||||
body.addEventListener("dragover", dragHover);
|
||||
body.addEventListener("dragleave", dragHover);
|
||||
body.addEventListener("drop", fileDrop);
|
||||
}
|
||||
|
||||
function hashChange() {
|
||||
send({event: 'hashChange', hash: window.location.hash});
|
||||
}
|
||||
@ -1118,7 +1056,6 @@ window.addEventListener("load", function() {
|
||||
tag.appendChild(tooltip);
|
||||
}
|
||||
}
|
||||
enableDragDrop();
|
||||
connectSocket(window.location.pathname);
|
||||
|
||||
if (window.localStorage.getItem('editing') == '1') {
|
||||
|
@ -64,11 +64,6 @@ a:active {
|
||||
color: #eee8d5;
|
||||
}
|
||||
|
||||
#input.drop {
|
||||
border: 2px solid;
|
||||
color: #cb4b16;
|
||||
}
|
||||
|
||||
.CodeMirror {
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
|
Loading…
Reference in New Issue
Block a user