Added files fn

This commit is contained in:
neauoire
2020-05-19 07:02:15 +09:00
parent 660180d6b8
commit da839efa8f
4 changed files with 36 additions and 20 deletions

View File

@@ -158,17 +158,7 @@ function Client () {
this.mouseOrigin = null
}
this.onDrag = (e) => {
e.stopPropagation()
e.preventDefault()
e.dataTransfer.dropEffect = 'copy'
}
this.onDrop = (e) => {
e.preventDefault()
e.stopPropagation()
const file = e.dataTransfer.files[0]
this.parseFile = (file) => {
if (file.name.indexOf('.lisp') > -1) {
this.source.read(file, this.whenOpen)
this.log('Loaded ' + file.name)
@@ -185,6 +175,20 @@ function Client () {
}
}
this.onDrag = (e) => {
e.stopPropagation()
e.preventDefault()
e.dataTransfer.dropEffect = 'copy'
}
this.onDrop = (e) => {
e.preventDefault()
e.stopPropagation()
for (const file of e.dataTransfer.files) {
this.parseFile(file)
}
}
this.cache = {
data: {},
set: (key, content) => {

View File

@@ -25,6 +25,10 @@ function Library (client) {
client.source.write('ronin', format, client.surface.el.toDataURL(type, quality), type)
}
this.files = () => {
return Object.keys(client.cache.data)
}
// Shapes
this.pos = (x = 0, y = 0) => { // Returns a position shape.