From cf686282ef69ba75ca4a9f9226fcbdd5a0698076 Mon Sep 17 00:00:00 2001 From: Luiza Pagliari Date: Thu, 11 May 2017 12:26:14 -0300 Subject: [PATCH] Do not use cookie for pad shortcuts Users still cannot choose which shortcuts they want to enable/disable, so it does not make sense (yet) to have a cookie with that preference. This can be reverted once we create an UI to change shortcuts, but PLEASE PLEASE PLEASE do not read the cookie every time handleKeyEvent is called!!! This is an adjustment to #2891. --- src/node/handler/PadMessageHandler.js | 1 + src/node/hooks/express/specialpages.js | 6 ----- src/static/js/ace2_inner.js | 33 +------------------------- 3 files changed, 2 insertions(+), 38 deletions(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 20b262f4e..b7ec7cb28 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1197,6 +1197,7 @@ function handleClientReady(client, message) "userColor": authorColorId, "padId": message.padId, "padOptions": settings.padOptions, + "padShortcutEnabled": settings.padShortcutEnabled, "initialTitle": "Pad: " + message.padId, "opts": {}, // tell the client the number of the latest chat-message, which will be diff --git a/src/node/hooks/express/specialpages.js b/src/node/hooks/express/specialpages.js index e933a05a4..2840f82ca 100644 --- a/src/node/hooks/express/specialpages.js +++ b/src/node/hooks/express/specialpages.js @@ -48,12 +48,6 @@ exports.expressCreateServer = function (hook_name, args, cb) { res.cookie('language', settings.padOptions.lang); } - // Enable the pad shortcut keys from settings.json - if (settings.padShortcutEnabled !== undefined) - { - res.cookie('padShortcutEnabled', JSON.stringify(settings.padShortcutEnabled)); - } - // The below might break for pads being rewritten var isReadOnly = req.url.indexOf("/p/r.") === 0; diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index b6d4bd253..3b103988e 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -61,7 +61,6 @@ function Ace2Inner(){ var SkipList = require('./skiplist'); var undoModule = require('./undomodule').undoModule; var AttributeManager = require('./AttributeManager'); - var readCookie = require('./pad_utils').readCookie; var DEBUG = false; //$$ build script replaces the string "var DEBUG=true;//$$" with "var DEBUG=false;" // changed to false @@ -3641,37 +3640,6 @@ function Ace2Inner(){ function handleKeyEvent(evt) { - // Get the enabled shortcut keys - // If it can't find the cookie, use default values - // Cookie should normally be set - // See settings.json - var padShortcutEnabled = JSON.parse(decodeURIComponent(readCookie('padShortcutEnabled'))); - if (!padShortcutEnabled) - { - padShortcutEnabled = { - "altF9" : true, - "altC" : true, - "cmdShift2" : true, - "delete" : true, - "return" : true, - "cmdS" : true, - "tab" : true, - "cmdZ" : true, - "cmdY" : true, - "cmdI" : true, - "cmdB" : true, - "cmdU" : true, - "cmd5" : true, - "cmdShiftL" : true, - "cmdShiftN" : true, - "cmdShiftC" : true, - "cmdH" : true, - "ctrlHome" : true, - "pageUp" : true, - "pageDown" : true, - } - } - // if (DEBUG && window.DONT_INCORP) return; if (!isEditable) return; var type = evt.type; @@ -3755,6 +3723,7 @@ function Ace2Inner(){ specialHandled = _.contains(specialHandledInHook, true); } + var padShortcutEnabled = parent.parent.clientVars.padShortcutEnabled; if ((!specialHandled) && altKey && isTypeForSpecialKey && keyCode == 120 && padShortcutEnabled.altF9){ // Alt F9 focuses on the File Menu and/or editbar. // Note that while most editors use Alt F10 this is not desirable