throw away this stupid bootstrap shit and build it with plain HTML
This commit is contained in:
50
static/js/create.js
Normal file
50
static/js/create.js
Normal file
@ -0,0 +1,50 @@
|
||||
window.onload = function () {
|
||||
catList = document.getElementById("categories_list")
|
||||
categories = sortCategories(global_categories)
|
||||
for(var key in categories) {
|
||||
var a = document.createElement("a")
|
||||
var li = document.createElement("li")
|
||||
li.setAttribute("role", "presentation")
|
||||
li.addEventListener("click", function(){fillSubCategorie(this.children[0].text); setDropdownText(this)})
|
||||
a.setAttribute("role", "menuitem")
|
||||
a.tabIndex = "-1"
|
||||
a.href = "#"
|
||||
a.innerHTML = getLocalString("english", categories[key])
|
||||
li.appendChild(a)
|
||||
catList.appendChild(li)
|
||||
a = undefined
|
||||
li = undefined
|
||||
}
|
||||
}
|
||||
|
||||
function sortCategories(categories) {
|
||||
var sortedCategories = []
|
||||
for(var key in categories) {
|
||||
sortedCategories.push(key)
|
||||
}
|
||||
sortedCategories.sort()
|
||||
return sortedCategories
|
||||
}
|
||||
|
||||
function setDropdownText(liElement) {
|
||||
liElement.parentNode.parentNode.childNodes[1].childNodes[0].textContent = liElement.children[0].text + " "
|
||||
}
|
||||
|
||||
function fillSubCategorie(categorie) {
|
||||
subCategory = getDescriptorByLocalString("english", categorie)
|
||||
catList = document.getElementById("subcategory_list")
|
||||
catList.innerHTML = ""
|
||||
categories = global_categories[subCategory].sort()
|
||||
for(var key in categories) {
|
||||
var a = document.createElement("a")
|
||||
var li = document.createElement("li")
|
||||
li.setAttribute("role", "presentation")
|
||||
li.addEventListener("click", function(){setDropdownText(this)})
|
||||
a.setAttribute("role", "menuitem")
|
||||
a.tabIndex = "-1"
|
||||
a.href = "#"
|
||||
a.innerHTML = getLocalString("english", categories[key])
|
||||
li.appendChild(a)
|
||||
catList.appendChild(li)
|
||||
}
|
||||
}
|
16
static/js/main.js
Normal file
16
static/js/main.js
Normal file
@ -0,0 +1,16 @@
|
||||
function getLocalString(language, descriptor){
|
||||
if(global_strings[language]){
|
||||
return global_strings[language][descriptor] || global_strings["english"][descriptor] || descriptor
|
||||
} else {
|
||||
return descriptor
|
||||
}
|
||||
}
|
||||
|
||||
function getDescriptorByLocalString(language, localString){
|
||||
for(string in global_strings[language]){
|
||||
if(global_strings[language][string] == localString){
|
||||
return string
|
||||
}
|
||||
}
|
||||
return localString
|
||||
}
|
Reference in New Issue
Block a user