mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Refactor Plugin change event handlers
This commit is contained in:
@@ -1,18 +1,4 @@
|
||||
'use strict';
|
||||
function onPluginMessageChange(evt) {
|
||||
document.getElementById('filterTotalMessageNo').textContent = parseInt(document.getElementById('filterTotalMessageNo').textContent, 10) + evt.detail.totalDiff;
|
||||
document.getElementById('totalMessageNo').textContent = parseInt(document.getElementById('totalMessageNo').textContent, 10) + evt.detail.totalDiff;
|
||||
document.getElementById('totalWarningNo').textContent = parseInt(document.getElementById('totalWarningNo').textContent, 10) + evt.detail.warningDiff;
|
||||
document.getElementById('totalErrorNo').textContent = parseInt(document.getElementById('totalErrorNo').textContent, 10) + evt.detail.errorDiff;
|
||||
}
|
||||
function onPluginIsDirtyChange(evt) {
|
||||
if (evt.detail.isDirty) {
|
||||
document.getElementById('dirtyPluginNo').textContent = parseInt(document.getElementById('dirtyPluginNo').textContent, 10) + 1;
|
||||
} else {
|
||||
document.getElementById('dirtyPluginNo').textContent = parseInt(document.getElementById('dirtyPluginNo').textContent, 10) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
function saveFilterState(evt) {
|
||||
loot.query('saveFilterState', evt.target.id, evt.target.checked).catch(handlePromiseError);
|
||||
}
|
||||
|
||||
@@ -93,8 +93,8 @@
|
||||
document.getElementById('cardsNav').addEventListener('dblclick', onSidebarClick);
|
||||
|
||||
/* Set up handler for plugin message and dirty info changes. */
|
||||
document.addEventListener('loot-plugin-message-change', onPluginMessageChange);
|
||||
document.addEventListener('loot-plugin-isdirty-change', onPluginIsDirtyChange);
|
||||
document.addEventListener('loot-plugin-message-change', Plugin.onMessageChange);
|
||||
document.addEventListener('loot-plugin-isdirty-change', Plugin.onIsDirtyChange);
|
||||
|
||||
/* Set up event handlers for game member variable changes. */
|
||||
document.addEventListener('loot-game-folder-change', Game.onFolderChange);
|
||||
|
||||
@@ -306,5 +306,19 @@
|
||||
getCardContent(filters) {
|
||||
return new PluginCardContent(this, filters);
|
||||
}
|
||||
|
||||
static onMessageChange(evt) {
|
||||
document.getElementById('filterTotalMessageNo').textContent = parseInt(document.getElementById('filterTotalMessageNo').textContent, 10) + evt.detail.totalDiff;
|
||||
document.getElementById('totalMessageNo').textContent = parseInt(document.getElementById('totalMessageNo').textContent, 10) + evt.detail.totalDiff;
|
||||
document.getElementById('totalWarningNo').textContent = parseInt(document.getElementById('totalWarningNo').textContent, 10) + evt.detail.warningDiff;
|
||||
document.getElementById('totalErrorNo').textContent = parseInt(document.getElementById('totalErrorNo').textContent, 10) + evt.detail.errorDiff;
|
||||
}
|
||||
static onIsDirtyChange(evt) {
|
||||
if (evt.detail.isDirty) {
|
||||
document.getElementById('dirtyPluginNo').textContent = parseInt(document.getElementById('dirtyPluginNo').textContent, 10) + 1;
|
||||
} else {
|
||||
document.getElementById('dirtyPluginNo').textContent = parseInt(document.getElementById('dirtyPluginNo').textContent, 10) - 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user