From a0c420af8ec88f50023e26f3941ce6380ec0b824 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 4 May 2017 16:37:25 +0200 Subject: [PATCH] jshint compliance --- .jshintignore | 2 ++ www/code/main.js | 39 ++++++++++++++++----------------------- www/common/toolbar2.js | 20 +++++++++----------- 3 files changed, 27 insertions(+), 34 deletions(-) diff --git a/.jshintignore b/.jshintignore index 93e467aef..919395546 100644 --- a/.jshintignore +++ b/.jshintignore @@ -11,3 +11,5 @@ NetFluxWebsocketServer.js WebRTCSrv.js www/common/media-tag.js www/scratch + +www/common/toolbar.js diff --git a/www/code/main.js b/www/code/main.js index 50ff90aa1..8e709bc1b 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -37,7 +37,7 @@ define([ secret.keys = secret.key; } - var onConnectError = function (info) { + var onConnectError = function () { Cryptpad.errorLoadingScreen(Messages.websocketError); }; @@ -50,7 +50,6 @@ define([ var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox'); var parsedHash = Cryptpad.parsePadUrl(window.location.href); var defaultName = Cryptpad.getDefaultName(parsedHash); - var initialState = Messages.codeInitialState; var isHistoryMode = false; @@ -172,10 +171,10 @@ define([ } }; - var isDefaultTitle = function () { +/* var isDefaultTitle = function () { var parsed = Cryptpad.parsePadUrl(window.location.href); return Cryptpad.isDefaultName(parsed, document.title); - }; + };*/ var initializing = true; @@ -226,7 +225,7 @@ define([ uid: Cryptpad.getUid(), }; addToUserData(myData); - Cryptpad.setAttribute('username', myUserName, function (err, data) { + Cryptpad.setAttribute('username', myUserName, function (err) { if (err) { console.log("Couldn't set username"); console.error(err); @@ -378,7 +377,7 @@ define([ } }; - var onInit = config.onInit = function (info) { + config.onInit = function (info) { userList = info.userList; var configTb = { @@ -407,12 +406,9 @@ define([ toolbar = module.toolbar = Toolbar.create(configTb); var $rightside = $bar.find('.' + Toolbar.constants.rightside); - var $userBlock = $bar.find('.' + Toolbar.constants.username); - var $usernameButton = module.$userNameButton = $($bar.find('.' + Toolbar.constants.changeUsername)); + module.$userNameButton = $($bar.find('.' + Toolbar.constants.changeUsername)); var editHash; - var viewHash = Cryptpad.getViewHashFromKeys(info.channel, secret.keys); - if (!readOnly) { editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys); } @@ -475,7 +471,7 @@ define([ } /* add a forget button */ - var forgetCb = function (err, title) { + var forgetCb = function (err) { if (err) { return; } setEditable(false); }; @@ -502,9 +498,7 @@ define([ isSelect: true, }; var $block = module.$language = Cryptpad.createDropdown(dropdownConfig); - var $button = $block.find('.buttonTitle'); - - $block.find('a').click(function (e) { + $block.find('a').click(function () { setMode($(this).attr('data-value'), $block); onLocal(); }); @@ -537,11 +531,10 @@ define([ initialValue: lastTheme }; var $block = module.$theme = Cryptpad.createDropdown(dropdownConfig); - var $button = $block.find('.buttonTitle'); setTheme(lastTheme, $block); - $block.find('a').click(function (e) { + $block.find('a').click(function () { var theme = $(this).attr('data-value'); setTheme(theme, $block); localStorage.setItem(themeKey, theme); @@ -579,7 +572,7 @@ define([ } }; - var onReady = config.onReady = function (info) { + config.onReady = function (info) { module.users = info.userList.users; if (module.realtime !== info.realtime) { var realtime = module.realtime = info.realtime; @@ -693,7 +686,7 @@ define([ return cursor; }; - var onRemote = config.onRemote = function () { + config.onRemote = function () { if (initializing) { return; } if (isHistoryMode) { return; } var scroll = editor.getScrollInfo(); @@ -748,14 +741,14 @@ define([ } }; - var onAbort = config.onAbort = function (info) { + config.onAbort = function () { // inform of network disconnect setEditable(false); toolbar.failed(); Cryptpad.alert(Messages.common_connectionLost, undefined, true); }; - var onConnectionChange = config.onConnectionChange = function (info) { + config.onConnectionChange = function (info) { setEditable(info.state); toolbar.failed(); if (info.state) { @@ -767,9 +760,9 @@ define([ } }; - var onError = config.onError = onConnectError; + config.onError = onConnectError; - var realtime = module.realtime = Realtime.start(config); + module.realtime = Realtime.start(config); editor.on('change', onLocal); @@ -779,7 +772,7 @@ define([ var interval = 100; var second = function (CM) { - Cryptpad.ready(function (err, env) { + Cryptpad.ready(function () { andThen(CM); Cryptpad.reportAppUsage(); }); diff --git a/www/common/toolbar2.js b/www/common/toolbar2.js index 2a1ceaeba..b91e16793 100644 --- a/www/common/toolbar2.js +++ b/www/common/toolbar2.js @@ -370,7 +370,7 @@ define([ return "Loading share button"; }; - var createFileShare = function (toolbar, config) { + var createFileShare = function () { if (!window.location.hash) { throw new Error("Unable to display the share button: hash required in the URL"); } @@ -467,7 +467,7 @@ define([ return $titleContainer; }; - var createLinkToMain = function (toolbar, config) { + var createLinkToMain = function (toolbar) { var $linkContainer = $('', { 'class': "cryptpad-link" }).appendTo(toolbar.$top); @@ -605,13 +605,12 @@ define([ return $spin; }; - var createState = function (toolbar, config) { + var createState = function (toolbar) { return toolbar.$userAdmin.find('.'+STATE_CLS).text(Messages.synchronizing).show(); }; - var createLimit = function (toolbar, config) { + var createLimit = function (toolbar) { if (!Config.enablePinning) { return; } - var usage; var $limitIcon = $('', {'class': 'fa fa-exclamation-triangle'}); var $limit = toolbar.$userAdmin.find('.'+LIMIT_CLS).attr({ 'title': Messages.pinLimitReached @@ -628,7 +627,7 @@ define([ return $limit; }; - var createNewPad = function (toolbar, config) { + var createNewPad = function (toolbar) { var $newPad = toolbar.$userAdmin.find('.'+NEWPAD_CLS).show(); var pads_options = []; @@ -676,7 +675,6 @@ define([ Cryptpad.createUserAdminMenu(userMenuCfg); var $userButton = $userAdmin.find('a.' + USERBUTTON_CLS); - var renameAlertOpened; $userButton.click(function (e) { e.preventDefault(); e.stopPropagation(); @@ -688,7 +686,7 @@ define([ }); }); }); - Cryptpad.onDisplayNameChanged(function (newName) { + Cryptpad.onDisplayNameChanged(function () { Cryptpad.findCancelButton().click(); }); @@ -697,7 +695,7 @@ define([ // Events var initClickEvents = function (toolbar, config) { - var removeDropdowns = function (e) { + var removeDropdowns = function () { toolbar.$toolbar.find('.cryptpad-dropdown').hide(); }; var cancelEditTitle = function (e) { @@ -720,7 +718,7 @@ define([ // Click in iframes try { if (w.$ && w.$('iframe').length) { - var innerIfrw = config.ifrw.$('iframe').each(function (i, el) { + config.ifrw.$('iframe').each(function (i, el) { $(el.contentWindow).on('click', removeDropdowns); $(el.contentWindow).on('click', cancelEditTitle); }); @@ -821,7 +819,7 @@ define([ // Main - var create = Bar.create = function (cfg) { + Bar.create = function (cfg) { var config = cfg || {}; Cryptpad = config.common; Messages = Cryptpad.Messages;