Updates :D
Former-commit-id: 4aab1964b9462d1fdee92999dd5a7d03f17b4457 [formerly 22352202547980b191886cf29f68ce8e9cc4c39b] [formerly 1a66bae34022092936c2912ea3a323a6984fe7e4 [formerly 1e7c4e6468b07dbb2b2726df4ff345371e2ec714]] Former-commit-id: 94170b15369b05e8f4985e88242ba453b5545116 [formerly 2a0b57bebcd48c0189974f4f9e72679b5c67f37b] Former-commit-id: 635be5ad2826c1659670997900122d024a46de24
This commit is contained in:
122
_assets/src/components/MovePrompt.vue
Normal file
122
_assets/src/components/MovePrompt.vue
Normal file
@@ -0,0 +1,122 @@
|
||||
<template>
|
||||
<div class="prompt">
|
||||
<h3>Move</h3>
|
||||
<p>Choose new house for your file(s)/folder(s):</p>
|
||||
|
||||
<ul class="file-list">
|
||||
<li @click="select" @dblclick="next" v-for="item in items" :data-url="item.url">{{ item.name }}</li>
|
||||
</ul>
|
||||
|
||||
<p>Currently navigating on: <code>{{ current }}</code>.</p>
|
||||
|
||||
<div>
|
||||
<button class="ok" @click="move">Move</button>
|
||||
<button class="cancel" @click="cancel">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import page from '../page'
|
||||
|
||||
var $ = window.info
|
||||
|
||||
export default {
|
||||
name: 'move-prompt',
|
||||
data: function () {
|
||||
return {
|
||||
items: [],
|
||||
current: window.location.pathname
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
if (window.location.pathname !== $.baseURL + '/') {
|
||||
this.items.push({
|
||||
name: '..',
|
||||
url: page.removeLastDir(window.location.pathname) + '/'
|
||||
})
|
||||
}
|
||||
|
||||
if ($.req.kind === 'listing') {
|
||||
for (let item of $.req.data.items) {
|
||||
if (!item.isDir) continue
|
||||
|
||||
this.items.push({
|
||||
name: item.name,
|
||||
url: item.url
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
cancel: function (event) {
|
||||
$.showMove = false
|
||||
},
|
||||
move: function (event) {
|
||||
console.log('Move')
|
||||
},
|
||||
next: function (event) {
|
||||
console.log('Next')
|
||||
|
||||
let url = event.currentTarget.dataset.url
|
||||
this.json(url)
|
||||
.then((data) => {
|
||||
this.current = url
|
||||
this.items = []
|
||||
|
||||
if (url !== $.baseURL + '/') {
|
||||
this.items.push({
|
||||
name: '..',
|
||||
url: page.removeLastDir(url) + '/'
|
||||
})
|
||||
}
|
||||
|
||||
let req = JSON.parse(data)
|
||||
for (let item of req.data.items) {
|
||||
if (!item.isDir) continue
|
||||
|
||||
this.items.push({
|
||||
name: item.name,
|
||||
url: item.url
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(e => console.log(e))
|
||||
},
|
||||
json: function (url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let request = new XMLHttpRequest()
|
||||
request.open('GET', url)
|
||||
request.setRequestHeader('Accept', 'application/json')
|
||||
request.onload = () => {
|
||||
if (request.status === 200) {
|
||||
resolve(request.responseText)
|
||||
} else {
|
||||
reject(request.statusText)
|
||||
}
|
||||
}
|
||||
request.onerror = () => reject(request.statusText)
|
||||
request.send()
|
||||
})
|
||||
},
|
||||
select: function (event) {
|
||||
let el = event.currentTarget
|
||||
|
||||
if (el.getAttribute('aria-selected') === 'true') {
|
||||
el.setAttribute('aria-selected', false)
|
||||
return
|
||||
}
|
||||
|
||||
let el2 = this.$el.querySelector('li[aria-selected=true]')
|
||||
if (el2) {
|
||||
el2.setAttribute('aria-selected', false)
|
||||
}
|
||||
|
||||
el.setAttribute('aria-selected', true)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user