Added Coins

This commit is contained in:
silas
2018-09-20 14:20:13 +02:00
parent f729bd487a
commit e56ed8fcb8
13 changed files with 187 additions and 72 deletions

View File

@@ -1,21 +1,10 @@
class SystemSettings {
static setBasePath(basePath)
{
SystemSettings._basePath = basePath;
}
static getBasePath()
{
return SystemSettings._basePath;
}
}
SystemSettings.setBasePath("/");
class MenuAction {
constructor(title, callback, showFor, order) {
this.title = Helper.nonNull(title, null);
this.callback = callback;
this.showFor = Helper.nonNull(showFor, MenuAction.SHOW_FOR_MEDIUM);
this.order = Helper.nonNull(order, 1000);
this._liClass = "";
this._menu = null;
this._activated = true;
@@ -112,6 +101,7 @@ class MenuAction {
copy.callback = this.callback;
copy.showFor = this.showFor;
copy.order = this.order;
copy._liClass = this._liClass;
copy._activated = this._activated;
copy._visible = this._visible;
@@ -174,8 +164,7 @@ class Menu {
}
}
copy(instance)
{
copy(instance) {
instance = Helper.nonNull(instance, new Menu([]));
instance.actions = [];
@@ -261,19 +250,16 @@ class Menu {
let iconElement = document.createElement("img");
iconElement.src = action.getIcon();
iconElement.classList.add('action-image');
if (action.getShouldTranslate())
{
if (action.getShouldTranslate()) {
iconElement.dataset["translationTitle"] = action.title;
}
aElement.appendChild(iconElement);
}
let title = action.getTitle();
if (action.getShouldTranslate())
{
if (action.getShouldTranslate()) {
title = Translator.makePersistentTranslation(title);
}
else
{
else {
title = document.createTextNode(title);
}
aElement.appendChild(title);
@@ -285,14 +271,16 @@ class Menu {
renderLiElement(aElement, action) {
let liElement = document.createElement("li");
liElement.classList.add('action');
if (action._liClass.trim() !== "") {
liElement.classList.add(action._liClass);
}
liElement.appendChild(aElement);
liElement.dataset["id"] = action.id;
if (Helper.isNotNull(action.getIcon())) {
liElement.classList.add("img");
}
if (!action.getVisible())
{
if (!action.getVisible()) {
liElement.classList.add("hidden");
}
@@ -312,21 +300,18 @@ class Menu {
});
}
_getElementsForAction(action){
_getElementsForAction(action) {
let elements = [];
for (let i = 0; i < this.parentElements.length; i++) {
let elem = this.parentElements[i].querySelector("[data-id=\""+action.getId()+"\"]");
let elem = this.parentElements[i].querySelector("[data-id=\"" + action.getId() + "\"]");
Helper.isNull(elem) || elements.push(elem);
}
return elements
}
updateAction(action)
{
console.log("update action here!");
updateAction(action) {
let oldElements = this._getElementsForAction(action);
if (oldElements.length === 0)
{
if (oldElements.length === 0) {
return;
}
@@ -338,11 +323,9 @@ class Menu {
}
}
removeAction(action)
{
removeAction(action) {
let index = this.actions.indexOf(action);
if (index > 0)
{
if (index > 0) {
this.actions.splice(index, 1);
let oldElements = this._getElementsForAction(action);
for (let i = 0, n = oldElements.length; i < n; i++) {
@@ -1291,6 +1274,31 @@ class Helper {
}
Helper.init();
class SystemSettings {
static setBasePath(basePath) {
SystemSettings._basePath = basePath;
}
static getBasePath() {
return SystemSettings._basePath;
}
static set(key, value) {
SystemSettings._settings[key] = value;
}
static get(key, defaultValue) {
return Helper.nonNull(SystemSettings._settings[key], defaultValue);
}
static has(key){
return Helper.nonNull(SystemSettings._settings[key]);
}
}
SystemSettings.setBasePath("/");
SystemSettings._settings = {};
class ThemeManager {
static init() {
ThemeManager.loadCurrentTheme();