new display system for socials
This commit is contained in:
parent
3c37269075
commit
659a5f0bfc
4 changed files with 66 additions and 12 deletions
|
@ -183,7 +183,6 @@ function highlighter(json, full = true, linkParent = false) {
|
|||
spanEnd -= 1
|
||||
endContent = endContent.substring(0, endContent.length - 1)
|
||||
} else {
|
||||
console.log(newStartContent)
|
||||
spanStart = newSpanStart
|
||||
startContent = newStartContent
|
||||
}
|
||||
|
@ -317,7 +316,7 @@ function converter(html, dynamic = true) {
|
|||
"WEATHER_MODIFIER": randomThemer.returnTheme(),
|
||||
"WEATHER_TEXT": "",
|
||||
"ANNOUNCEMENT": fs.readFileSync(path.join(__dirname, "config/announcement.html")),
|
||||
"SOCIALS": () => {
|
||||
"SOCIALS": (full) => {
|
||||
if (api.lanyard && api.lanyard.socials) {
|
||||
var socials = api.lanyard.socials
|
||||
var html = `<div class="grid-container">`
|
||||
|
@ -330,8 +329,9 @@ function converter(html, dynamic = true) {
|
|||
for (var x = 0; x < sitesTable.length; x++) {
|
||||
var siteName = sitesTable[x]
|
||||
var siteData = sites[siteName]
|
||||
html += `<a class="chip" ${onlyIfExists(`href="${siteData.url}"`, siteData.url)}>${siteName}: <span class="noHighlight">${siteData.name}</span></a>`
|
||||
|
||||
if (siteData.main || full) {
|
||||
html += `<a class="chip ${siteData.pref || ""}pref" ${onlyIfExists(`href="${siteData.url}"`, siteData.url)}>${siteName}: <span class="noHighlight">${siteData.name}</span></a>`
|
||||
}
|
||||
}
|
||||
html += "</div></div>"
|
||||
}
|
||||
|
@ -371,6 +371,9 @@ function converter(html, dynamic = true) {
|
|||
<script src="../js/lanyardSocket.js"></script>
|
||||
<script src="../js/timeFormatter.js"></script>
|
||||
`
|
||||
},
|
||||
"TEST_KEYWORD": (arg1, arg2, arg3) => {
|
||||
return `<p>The arguements you inputted are "${arg1}" and "${arg2}". Wow!</p>`
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -397,10 +400,34 @@ function converter(html, dynamic = true) {
|
|||
|
||||
for (let index = 0; index < rpTable.length; index++) {
|
||||
const text = rpTable[index];
|
||||
if (dynamic) {
|
||||
replacers[text] = himalaya.stringify(highlighter(himalaya.parse(replacers[text])))
|
||||
const braceText = `{${text}}`
|
||||
|
||||
if (typeof replacers[text] == "function" && replacers[text].length == 0) {
|
||||
replacers[text] = replacers[text]()
|
||||
}
|
||||
|
||||
while (html.includes(braceText)) {
|
||||
var posOfKeyword = html.indexOf(braceText)
|
||||
var keywordLength = braceText.length
|
||||
var args = undefined
|
||||
if (html.charAt(posOfKeyword + keywordLength) == "(") {
|
||||
args = html.substring(posOfKeyword + keywordLength + 1)
|
||||
keywordLength = args.substring(0, args.indexOf(")")).length + keywordLength + 2
|
||||
args = args.substring(0, args.indexOf(")"))
|
||||
args = args.split(",").map(item => item.trim())
|
||||
}
|
||||
var fnString = replacers[text]
|
||||
if (typeof fnString == "function") {
|
||||
fnString = fnString.apply(null, args)
|
||||
}
|
||||
|
||||
if (dynamic) {
|
||||
fnString = himalaya.stringify(highlighter(himalaya.parse(fnString)))
|
||||
}
|
||||
|
||||
html = html.substring(0, posOfKeyword) + fnString + html.substring(posOfKeyword + keywordLength)
|
||||
// break
|
||||
}
|
||||
html = html.replaceAll(`{${text}}`, replacers[text])
|
||||
}
|
||||
|
||||
if (!dynamic) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue