init
This commit is contained in:
commit
fa6a4c650f
93 files changed
+6555
No files matched your search
@@ -0,0 +1,105 @@
|
||||
window.PagesPathActions = {
|
||||
|
||||
async renameCurrentPath() {
|
||||
|
||||
const currentPath =
|
||||
location.pathname.replace(
|
||||
/^\/e/,
|
||||
"",
|
||||
)
|
||||
|
||||
const nextPath =
|
||||
prompt(
|
||||
"Rename path:",
|
||||
currentPath,
|
||||
)
|
||||
|
||||
if (
|
||||
!nextPath
|
||||
||
|
||||
nextPath === currentPath
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
const res =
|
||||
await fetch(
|
||||
"/_/api/v1/path/rename",
|
||||
{
|
||||
method: "POST",
|
||||
|
||||
headers: {
|
||||
"Content-Type":
|
||||
"application/json",
|
||||
},
|
||||
|
||||
body: JSON.stringify({
|
||||
old_path:
|
||||
currentPath,
|
||||
|
||||
new_path:
|
||||
nextPath,
|
||||
}),
|
||||
},
|
||||
)
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
alert(
|
||||
"rename failed",
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
location.href =
|
||||
"/e" + nextPath
|
||||
},
|
||||
|
||||
async removeCurrentPath() {
|
||||
|
||||
const currentPath =
|
||||
location.pathname.replace(
|
||||
/^\/e/,
|
||||
"",
|
||||
)
|
||||
|
||||
if (
|
||||
!confirm(
|
||||
"Remove path?\n\n" +
|
||||
currentPath,
|
||||
)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
const res =
|
||||
await fetch(
|
||||
"/_/api/v1/path/remove",
|
||||
{
|
||||
method: "POST",
|
||||
|
||||
headers: {
|
||||
"Content-Type":
|
||||
"application/json",
|
||||
},
|
||||
|
||||
body: JSON.stringify({
|
||||
path:
|
||||
currentPath,
|
||||
}),
|
||||
},
|
||||
)
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
alert(
|
||||
"remove failed",
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
location.href = "/"
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user