WIP on OpenGraph form; items field complete (#52)
This commit is contained in:
@@ -13,7 +13,7 @@ this.Admin = {
|
||||
* @type {number}
|
||||
*/
|
||||
nextPermalink : 0,
|
||||
|
||||
|
||||
/**
|
||||
* Set the next meta item index
|
||||
* @param {number} idx The index to set
|
||||
@@ -44,23 +44,23 @@ this.Admin = {
|
||||
const removeCol = document.createElement("div")
|
||||
removeCol.className = "col-1 text-center align-self-center"
|
||||
removeCol.appendChild(removeBtn)
|
||||
|
||||
|
||||
return removeCol
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Create a metadata name field
|
||||
* @returns {HTMLInputElement} The name input element
|
||||
*/
|
||||
createMetaNameField() {
|
||||
const nameField = document.createElement("input")
|
||||
|
||||
|
||||
nameField.type = "text"
|
||||
nameField.name = "MetaNames"
|
||||
nameField.id = `metaNames_${this.nextMetaIndex}`
|
||||
nameField.className = "form-control"
|
||||
nameField.placeholder = "Name"
|
||||
|
||||
|
||||
return nameField
|
||||
},
|
||||
|
||||
@@ -82,7 +82,7 @@ this.Admin = {
|
||||
const nameCol = document.createElement("div")
|
||||
nameCol.className = "col-3"
|
||||
nameCol.appendChild(nameFloat)
|
||||
|
||||
|
||||
return nameCol
|
||||
},
|
||||
|
||||
@@ -92,13 +92,13 @@ this.Admin = {
|
||||
*/
|
||||
createMetaValueField() {
|
||||
const valueField = document.createElement("input")
|
||||
|
||||
|
||||
valueField.type = "text"
|
||||
valueField.name = "MetaValues"
|
||||
valueField.id = `metaValues_${this.nextMetaIndex}`
|
||||
valueField.className = "form-control"
|
||||
valueField.placeholder = "Value"
|
||||
|
||||
|
||||
return valueField
|
||||
},
|
||||
|
||||
@@ -124,11 +124,11 @@ this.Admin = {
|
||||
valueHint.innerText = hintText
|
||||
valueFloat.appendChild(valueHint)
|
||||
}
|
||||
|
||||
|
||||
const valueCol = document.createElement("div")
|
||||
valueCol.className = "col-8"
|
||||
valueCol.appendChild(valueFloat)
|
||||
|
||||
|
||||
return valueCol
|
||||
},
|
||||
|
||||
@@ -149,18 +149,18 @@ this.Admin = {
|
||||
document.getElementById("meta_items").appendChild(newRow)
|
||||
this.nextMetaIndex++
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Add a new row for metadata entry
|
||||
*/
|
||||
addMetaItem() {
|
||||
const nameField = this.createMetaNameField()
|
||||
|
||||
|
||||
this.createMetaRow(
|
||||
this.createMetaRemoveColumn(),
|
||||
this.createMetaNameColumn(nameField),
|
||||
this.createMetaValueColumn(this.createMetaValueField(), undefined))
|
||||
|
||||
|
||||
document.getElementById(nameField.id).focus()
|
||||
},
|
||||
|
||||
@@ -226,7 +226,16 @@ this.Admin = {
|
||||
const link = document.getElementById("ChapterEditLink")
|
||||
if (link) link.style.display = src === "none" || src === "external" ? "none" : ""
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Enable or disable OpenGraph fields
|
||||
*/
|
||||
toggleOpenGraphFields() {
|
||||
const disabled = !document.getElementById("AssignOpenGraph").checked
|
||||
let fieldsets = ["og_item"]
|
||||
fieldsets.forEach(it => document.getElementById(it).disabled = disabled)
|
||||
},
|
||||
|
||||
/**
|
||||
* Enable or disable podcast fields
|
||||
*/
|
||||
@@ -244,7 +253,7 @@ this.Admin = {
|
||||
}
|
||||
fields.forEach(it => document.getElementById(it).disabled = disabled)
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Check to enable or disable podcast fields
|
||||
*/
|
||||
@@ -263,7 +272,7 @@ this.Admin = {
|
||||
elt.innerText = "Copied"
|
||||
return false
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Toggle the source of a custom RSS feed
|
||||
* @param {string} source The source that was selected
|
||||
@@ -281,7 +290,7 @@ this.Admin = {
|
||||
tagInput.disabled = false
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Remove a metadata item
|
||||
* @param {number} idx The index of the metadata item to remove
|
||||
@@ -326,12 +335,12 @@ this.Admin = {
|
||||
msgs.forEach(msg => {
|
||||
const parts = msg.split("|||")
|
||||
if (parts.length < 2) return
|
||||
|
||||
|
||||
// Create the toast header
|
||||
const toastType = document.createElement("strong")
|
||||
toastType.className = "me-auto text-uppercase"
|
||||
toastType.innerText = parts[0] === "danger" ? "error" : parts[0]
|
||||
|
||||
|
||||
const closeBtn = document.createElement("button")
|
||||
closeBtn.type = "button"
|
||||
closeBtn.className = "btn-close"
|
||||
@@ -350,7 +359,7 @@ this.Admin = {
|
||||
if (parts.length === 3) {
|
||||
toastBody.innerHTML += `<hr>${parts[2]}`
|
||||
}
|
||||
|
||||
|
||||
// Assemble the toast
|
||||
const toast = document.createElement("div")
|
||||
toast.className = "toast"
|
||||
@@ -361,10 +370,10 @@ this.Admin = {
|
||||
toast.appendChild(toastBody)
|
||||
|
||||
document.getElementById("toasts").appendChild(toast)
|
||||
|
||||
|
||||
let options = { delay: 4000 }
|
||||
if (parts[0] !== "success") options.autohide = false
|
||||
|
||||
|
||||
const theToast = new bootstrap.Toast(toast, options)
|
||||
theToast.show()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user