var LAST_UPDATE_TIME = {@LAST_UPDATE_TIME};
var URL_LEGACY_MODE = false;
var ENABLE_DEBUG_MODE = {if ENABLE_DEBUG_MODE}true{else}false{/if};
+ var ENABLE_DEVELOPER_TOOLS = {if ENABLE_DEVELOPER_TOOLS}true{else}false{/if};
{if ENABLE_DEBUG_MODE}
{* This constant is a compiler option, it does not exist in production. *}
var LAST_UPDATE_TIME = {@LAST_UPDATE_TIME};
var URL_LEGACY_MODE = false;
var ENABLE_DEBUG_MODE = {if ENABLE_DEBUG_MODE}true{else}false{/if};
+ var ENABLE_DEVELOPER_TOOLS = {if ENABLE_DEVELOPER_TOOLS}true{else}false{/if};
{if ENABLE_DEBUG_MODE}
{* This constant is a compiler option, it does not exist in production. *}
'favico', 'enquire', 'perfect-scrollbar', 'WoltLabSuite/Core/Date/Time/Relative',
'Ui/SimpleDropdown', 'WoltLabSuite/Core/Ui/Mobile', 'WoltLabSuite/Core/Ui/TabMenu', 'WoltLabSuite/Core/Ui/FlexibleMenu',
'Ui/Dialog', 'WoltLabSuite/Core/Ui/Tooltip', 'WoltLabSuite/Core/Language', 'WoltLabSuite/Core/Environment',
- 'WoltLabSuite/Core/Date/Picker', 'EventHandler', 'Core', 'WoltLabSuite/Core/Ui/Page/JumpToTop'
+ 'WoltLabSuite/Core/Date/Picker', 'EventHandler', 'Core', 'WoltLabSuite/Core/Ui/Page/JumpToTop',
+ 'Devtools'
],
function(
favico, enquire, perfectScrollbar, DateTimeRelative,
UiSimpleDropdown, UiMobile, UiTabMenu, UiFlexibleMenu,
UiDialog, UiTooltip, Language, Environment,
- DatePicker, EventHandler, Core, UiPageJumpToTop
+ DatePicker, EventHandler, Core, UiPageJumpToTop,
+ Devtools
)
{
"use strict";
enableMobileMenu: true
}, options);
+ //noinspection JSUnresolvedVariable
+ if (window.ENABLE_DEVELOPER_TOOLS) Devtools._internal_.enable();
+
Environment.setup();
DateTimeRelative.setup();
--- /dev/null
+/**
+ * Developer tools for WoltLab Suite.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2017 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Devtools
+ */
+define([], function() {
+ "use strict";
+
+ if (!COMPILER_TARGET_DEFAULT) {
+ return {
+ toggleEventLogging: function () {},
+ _internal_: {
+ eventLog: function() {}
+ }
+ };
+ }
+
+ var _settings = {
+ editorAutosave: true,
+ eventLogging: false
+ };
+
+ var _updateConfig = function () {
+ if (window.sessionStorage) {
+ window.sessionStorage.setItem("__wsc_devtools_config", JSON.stringify(_settings));
+ }
+ };
+
+ var Devtools = {
+ /**
+ * Prints the list of available commands.
+ */
+ help: function () {
+ window.console.log("");
+ window.console.log("%cAvailable commands:", "text-decoration: underline");
+
+ var cmds = [];
+ for (var cmd in Devtools) {
+ if (cmd !== '_internal_' && Devtools.hasOwnProperty(cmd)) {
+ cmds.push(cmd);
+ }
+ }
+ cmds.sort().forEach(function(cmd) {
+ window.console.log("\tDevtools." + cmd + "()");
+ });
+
+ window.console.log("");
+ },
+
+ /**
+ * Disables/re-enables the editor autosave feature.
+ *
+ * @param {boolean} forceDisable
+ */
+ toggleEditorAutosave: function(forceDisable) {
+ _settings.editorAutosave = (forceDisable === true) ? false : !_settings.editorAutosave;
+ _updateConfig();
+
+ window.console.log("%c\tEditor autosave " + (_settings.editorAutosave ? "enabled" : "disabled"), "font-style: italic");
+ },
+
+ /**
+ * Enables/disables logging for fired event listener events.
+ *
+ * @param {boolean} forceEnable
+ */
+ toggleEventLogging: function(forceEnable) {
+ _settings.eventLogging = (forceEnable === true) ? true : !_settings.eventLogging;
+ _updateConfig();
+
+ window.console.log("%c\tEvent logging " + (_settings.eventLogging ? "enabled" : "disabled"), "font-style: italic");
+ },
+
+ /**
+ * Internal methods not meant to be called directly.
+ */
+ _internal_: {
+ enable: function () {
+ window.Devtools = Devtools;
+
+ window.console.log("%cDevtools for WoltLab Suite loaded", "font-weight: bold");
+
+ if (window.sessionStorage) {
+ var settings = window.sessionStorage.getItem("__wsc_devtools_config");
+ try {
+ if (settings !== null) {
+ _settings = JSON.parse(settings);
+ }
+ }
+ catch (e) {}
+
+ if (!_settings.editorAutosave) Devtools.toggleEditorAutosave(true);
+ if (_settings.eventLogging) Devtools.toggleEventLogging(true);
+ }
+
+ window.console.log("Settings are saved per browser session, enter `Devtools.help()` to learn more.");
+ window.console.log("");
+ },
+
+ editorAutosave: function () {
+ return _settings.editorAutosave;
+ },
+
+ eventLog: function(identifier, action) {
+ if (_settings.eventLogging) {
+ window.console.log("[Devtools.EventLogging] Firing event: " + action + " @ " + identifier);
+ }
+ }
+ }
+ };
+
+ return Devtools;
+});
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @module WoltLabSuite/Core/Event/Handler
*/
-define(['Core', 'Dictionary'], function(Core, Dictionary) {
+define(['Core', 'Devtools', 'Dictionary'], function(Core, Devtools, Dictionary) {
"use strict";
var _listeners = new Dictionary();
* @param {object=} data event data
*/
fire: function(identifier, action, data) {
+ Devtools._internal_.eventLog(identifier, action);
+
data = data || {};
var actions = _listeners.get(identifier);
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @module WoltLabSuite/Core/Ui/Redactor/Autosave
*/
-define(['Core', 'EventHandler', 'Language', 'Dom/Traverse', './Metacode'], function(Core, EventHandler, Language, DomTraverse, UiRedactorMetacode) {
+define(['Core', 'Devtools', 'EventHandler', 'Language', 'Dom/Traverse', './Metacode'], function(Core, Devtools, EventHandler, Language, DomTraverse, UiRedactorMetacode) {
"use strict";
if (!COMPILER_TARGET_DEFAULT) {
* @return {string} message content
*/
getInitialValue: function() {
+ //noinspection JSUnresolvedVariable
+ if (window.ENABLE_DEVELOPER_TOOLS && Devtools._internal_.editorAutosave() === false) {
+ //noinspection JSUnresolvedVariable
+ return this._element.value;
+ }
+
var value = '';
try {
value = window.localStorage.getItem(this._key);
* @protected
*/
_saveToStorage: function() {
+ //noinspection JSUnresolvedVariable
+ if (window.ENABLE_DEVELOPER_TOOLS && Devtools._internal_.editorAutosave() === false) {
+ //noinspection JSUnresolvedVariable
+ return;
+ }
+
var content = this._editor.code.get();
if (this._editor.utils.isEmpty(content)) {
content = '';
'ColorUtil': 'WoltLabSuite/Core/ColorUtil',
'Core': 'WoltLabSuite/Core/Core',
'DateUtil': 'WoltLabSuite/Core/Date/Util',
+ 'Devtools': 'WoltLabSuite/Core/Devtools',
'Dictionary': 'WoltLabSuite/Core/Dictionary',
'Dom/ChangeListener': 'WoltLabSuite/Core/Dom/Change/Listener',
'Dom/Traverse': 'WoltLabSuite/Core/Dom/Traverse',