From c341fa8e9409377824afbe7f28af40b880ae0563 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Tue, 18 Apr 2017 12:14:32 +0200 Subject: [PATCH] Pull jquery using require.js rather than as a script tag and fix require to pass jquery as a parameter --- customize.dist/about.html | 1 - customize.dist/contact.html | 1 - customize.dist/index.html | 1 - customize.dist/main.js | 8 +++----- customize.dist/messages.js | 6 ++---- customize.dist/privacy.html | 1 - customize.dist/share/frame.js | 8 ++------ customize.dist/share/test.js | 8 +++----- customize.dist/src/template.html | 1 - customize.dist/terms.html | 1 - www/assert/main.js | 6 ++---- www/assert/media/main.js | 6 +----- www/assert/pretty/main.js | 7 +++---- www/assert/translations/main.js | 5 ++--- www/code/main.js | 8 +++----- www/common/boot2.js | 11 +++++++++-- www/common/clipboard.js | 7 ++----- www/common/common-interface.js | 7 +++---- www/common/cryptget.js | 6 +++--- www/common/cryptpad-common.js | 7 +++---- www/common/fileObject.js | 5 ++--- www/common/fsStore.js | 5 ++--- www/common/login.js | 4 ++-- www/common/mergeDrive.js | 1 - www/common/toolbar.js | 7 +++---- www/common/userObject.js | 6 ++---- www/drive/main.js | 5 ++--- www/examples/board/board.js | 5 ++--- www/examples/board/main.js | 10 +++++----- www/examples/form/main.js | 10 ++++------ www/examples/hack/main.js | 9 ++++----- www/examples/json/main.js | 9 ++++----- www/examples/pin/main.js | 8 +++----- www/examples/read/main.js | 7 +++---- www/examples/render/main.js | 7 +++---- www/examples/style/main.js | 9 ++++----- www/examples/text/main.js | 9 ++++----- www/examples/upload/main.js | 13 ++++++------- www/login/index.html | 1 - www/login/main.js | 8 +++----- www/pad/main.js | 8 +++----- www/poll/main.js | 8 +++----- www/register/main.js | 7 +++---- www/settings/index.html | 1 - www/settings/main.js | 8 +++----- www/slide/main.js | 8 +++----- www/slide/slide.js | 7 +++---- www/whiteboard/main.js | 13 ++++--------- 48 files changed, 121 insertions(+), 183 deletions(-) diff --git a/customize.dist/about.html b/customize.dist/about.html index f3e87dd25..1cabfea02 100644 --- a/customize.dist/about.html +++ b/customize.dist/about.html @@ -8,7 +8,6 @@ - diff --git a/customize.dist/contact.html b/customize.dist/contact.html index fc98c6eba..b653529c4 100644 --- a/customize.dist/contact.html +++ b/customize.dist/contact.html @@ -8,7 +8,6 @@ - diff --git a/customize.dist/index.html b/customize.dist/index.html index 02a10078d..e05858e37 100644 --- a/customize.dist/index.html +++ b/customize.dist/index.html @@ -8,7 +8,6 @@ - diff --git a/customize.dist/main.js b/customize.dist/main.js index f4720afca..a02433b05 100644 --- a/customize.dist/main.js +++ b/customize.dist/main.js @@ -1,9 +1,8 @@ define([ + 'jquery', '/customize/application_config.js', - '/common/cryptpad-common.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Config, Cryptpad) { - var $ = window.$; + '/common/cryptpad-common.js' +], function ($, Config, Cryptpad) { var APP = window.APP = { Cryptpad: Cryptpad, @@ -191,4 +190,3 @@ define([ console.log("ready"); }); }); - diff --git a/customize.dist/messages.js b/customize.dist/messages.js index ba35f1d96..18d329d6d 100644 --- a/customize.dist/messages.js +++ b/customize.dist/messages.js @@ -23,12 +23,10 @@ var getLanguage = function () { }; var language = getLanguage(); -var req = ['/customize/translations/messages.js']; +var req = ['jquery', '/customize/translations/messages.js']; if (language && map[language]) { req.push('/customize/translations/messages.' + language + '.js'); } -req.push('/bower_components/jquery/dist/jquery.min.js'); -define(req, function(Default, Language) { - var $ = window.jQuery; +define(req, function($, Default, Language) { var externalMap = JSON.parse(JSON.stringify(map)); diff --git a/customize.dist/privacy.html b/customize.dist/privacy.html index dd1a7a686..203bb1008 100644 --- a/customize.dist/privacy.html +++ b/customize.dist/privacy.html @@ -8,7 +8,6 @@ - diff --git a/customize.dist/share/frame.js b/customize.dist/share/frame.js index 9f604af23..a07ff05ce 100644 --- a/customize.dist/share/frame.js +++ b/customize.dist/share/frame.js @@ -163,12 +163,8 @@ if (typeof(module) !== 'undefined' && module.exports) { module.exports = Frame; - } - else if ((typeof(define) !== 'undefined' && define !== null) && - (define.amd !== null)) { - define([ - '/bower_components/jquery/dist/jquery.min.js', - ], function () { + } else if (typeof(define) === 'function' && define.amd) { + define(['jquery'], function ($) { return Frame; }); } else { diff --git a/customize.dist/share/test.js b/customize.dist/share/test.js index c54d7ac79..efc9d81b4 100644 --- a/customize.dist/share/test.js +++ b/customize.dist/share/test.js @@ -1,8 +1,7 @@ define([ - '/customize/share/frame.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Frame) { - var $ = window.jQuery; + 'jquery', + '/customize/share/frame.js' +], function ($, Frame) { var domain = 'https://beta.cryptpad.fr'; @@ -123,4 +122,3 @@ define([ }].forEach(runTest); }); }); - diff --git a/customize.dist/src/template.html b/customize.dist/src/template.html index 069e23511..4615cce7f 100644 --- a/customize.dist/src/template.html +++ b/customize.dist/src/template.html @@ -8,7 +8,6 @@ - {{script}} diff --git a/customize.dist/terms.html b/customize.dist/terms.html index 28f0b62ac..391020c07 100644 --- a/customize.dist/terms.html +++ b/customize.dist/terms.html @@ -8,7 +8,6 @@ - diff --git a/www/assert/main.js b/www/assert/main.js index b6a1fbd45..eb9bb9157 100644 --- a/www/assert/main.js +++ b/www/assert/main.js @@ -1,12 +1,10 @@ -require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } }); define([ - '/bower_components/jquery/dist/jquery.min.js', + 'jquery', '/bower_components/hyperjson/hyperjson.js', '/bower_components/textpatcher/TextPatcher.amd.js', 'json.sortify', '/common/cryptpad-common.js', -], function (jQuery, Hyperjson, TextPatcher, Sortify, Cryptpad) { - var $ = window.jQuery; +], function ($, Hyperjson, TextPatcher, Sortify, Cryptpad) { window.Hyperjson = Hyperjson; window.TextPatcher = TextPatcher; window.Sortify = Sortify; diff --git a/www/assert/media/main.js b/www/assert/media/main.js index 31a496893..e60fa298b 100644 --- a/www/assert/media/main.js +++ b/www/assert/media/main.js @@ -1,8 +1,4 @@ -define([ - '/bower_components/jquery/dist/jquery.min.js', -], function () { - var $ = window.jQuery; - +define(['jquery'], function ($) { $('media').each(function () { window.alert("media tag selection works!"); }); diff --git a/www/assert/pretty/main.js b/www/assert/pretty/main.js index 1b8272884..825ad03ac 100644 --- a/www/assert/pretty/main.js +++ b/www/assert/pretty/main.js @@ -1,8 +1,7 @@ define([ - '/bower_components/hyperjson/hyperjson.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Hyperjson) { - var $ = window.jQuery; + 'jquery', + '/bower_components/hyperjson/hyperjson.js' +], function ($, Hyperjson) { var shjson = '["BODY",{"class":"cke_editable cke_editable_themed cke_contents_ltr cke_show_borders","spellcheck":"false"},[["P",{},["This is ",["STRONG",{},["CryptPad"]],", the zero knowledge realtime collaborative editor.",["BR",{},[]],"What you type here is encrypted so only people who have the link can access it.",["BR",{},[]],"Even the server cannot see what you type."]],["P",{},[["SMALL",{},[["I",{},["What you see here, what you hear here, when you leave here, let it stay here"]]]],["BR",{"type":"_moz"},[]]]]]]'; var hjson = JSON.parse(shjson); diff --git a/www/assert/translations/main.js b/www/assert/translations/main.js index e8825d422..9a5397c73 100644 --- a/www/assert/translations/main.js +++ b/www/assert/translations/main.js @@ -1,9 +1,8 @@ define([ - '/bower_components/jquery/dist/jquery.min.js', + 'jquery', '/common/cryptpad-common.js', '/customize/translations/messages.js', -], function (jQuery, Cryptpad, English) { - var $ = window.jQuery; +], function ($, Cryptpad, English) { var $body = $('body'); diff --git a/www/code/main.js b/www/code/main.js index 2b6553cf0..50bf06617 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -1,5 +1,5 @@ -require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } }); define([ + 'jquery', '/bower_components/chainpad-crypto/crypto.js', '/bower_components/chainpad-netflux/chainpad-netflux.js', '/bower_components/textpatcher/TextPatcher.js', @@ -12,10 +12,8 @@ define([ '/common/themes.js', '/common/visible.js', '/common/notify.js', - '/bower_components/file-saver/FileSaver.min.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad, Cryptget, Modes, Themes, Visible, Notify) { - var $ = window.jQuery; + '/bower_components/file-saver/FileSaver.min.js' +], function ($, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad, Cryptget, Modes, Themes, Visible, Notify) { var saveAs = window.saveAs; var Messages = Cryptpad.Messages; diff --git a/www/common/boot2.js b/www/common/boot2.js index 8a38fad2f..599875a93 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -1,7 +1,14 @@ // This is stage 1, it can be changed but you must bump the version of the project. define([], function () { // fix up locations so that relative urls work. - require.config({ baseUrl: window.location.pathname }); + require.config({ + baseUrl: window.location.pathname, + paths: { + // jquery declares itself as literally "jquery" so it cannot be pulled by path :( + "jquery": "/bower_components/jquery/dist/jquery.min", + // json.sortify same + "json.sortify": "/bower_components/json.sortify/dist/JSON.sortify" + } + }); require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]); }); - diff --git a/www/common/clipboard.js b/www/common/clipboard.js index 5e62f5a37..557c1a809 100644 --- a/www/common/clipboard.js +++ b/www/common/clipboard.js @@ -1,7 +1,4 @@ -define([ - '/bower_components/jquery/dist/jquery.min.js', -], function () { - var $ = window.jQuery; +define(['jquery'], function ($) { var Clipboard = {}; // copy arbitrary text to the clipboard @@ -13,7 +10,7 @@ define([ $('body').append($ta); - if (!($ta.length && $ta[0].select)) { + if (!($ta.length && $ta[0].select)) { // console.log("oops"); return; } diff --git a/www/common/common-interface.js b/www/common/common-interface.js index cc3f838f6..624bcfcf3 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -1,11 +1,10 @@ define([ + 'jquery', '/customize/messages.js', '/common/common-util.js', '/customize/application_config.js', - '/bower_components/alertifyjs/dist/js/alertify.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Messages, Util, AppConfig, Alertify) { - var $ = window.jQuery; + '/bower_components/alertifyjs/dist/js/alertify.js' +], function ($, Messages, Util, AppConfig, Alertify) { var UI = {}; diff --git a/www/common/cryptget.js b/www/common/cryptget.js index 0c73fa45b..e13b9b395 100644 --- a/www/common/cryptget.js +++ b/www/common/cryptget.js @@ -1,10 +1,10 @@ define([ + 'jquery', '/bower_components/chainpad-crypto/crypto.js', '/bower_components/chainpad-netflux/chainpad-netflux.js', '/common/cryptpad-common.js', - '/bower_components/textpatcher/TextPatcher.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Crypto, Realtime, Cryptpad, TextPatcher) { + '/bower_components/textpatcher/TextPatcher.js' +], function ($, Crypto, Realtime, Cryptpad, TextPatcher) { var Messages = Cryptpad.Messages; var noop = function () {}; var finish = function (S, err, doc) { diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index cf443fe5f..c5cbbfd96 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -1,4 +1,5 @@ define([ + 'jquery', '/api/config', '/customize/messages.js', '/common/fsStore.js', @@ -8,17 +9,15 @@ define([ '/common/clipboard.js', '/common/pinpad.js', - '/customize/application_config.js', + '/customize/application_config.js' +], function ($, Config, Messages, Store, Util, Hash, UI, Clipboard, Pinpad, AppConfig) { - '/bower_components/jquery/dist/jquery.min.js', -], function (Config, Messages, Store, Util, Hash, UI, Clipboard, Pinpad, AppConfig) { /* This file exposes functionality which is specific to Cryptpad, but not to any particular pad type. This includes functions for committing metadata about pads to your local storage for future use and improved usability. Additionally, there is some basic functionality for import/export. */ - var $ = window.jQuery; var common = window.Cryptpad = { Messages: Messages, diff --git a/www/common/fileObject.js b/www/common/fileObject.js index 202a67f4c..6f947dbe3 100644 --- a/www/common/fileObject.js +++ b/www/common/fileObject.js @@ -1,7 +1,6 @@ define([ - '/bower_components/jquery/dist/jquery.min.js', -], function () { - var $ = window.jQuery; + 'jquery', +], function ($) { var module = {}; var Messages = {}; diff --git a/www/common/fsStore.js b/www/common/fsStore.js index edab0e252..b02cccf16 100644 --- a/www/common/fsStore.js +++ b/www/common/fsStore.js @@ -1,10 +1,10 @@ define([ + 'jquery', '/bower_components/chainpad-listmap/chainpad-listmap.js', '/bower_components/chainpad-crypto/crypto.js?v=0.1.5', '/bower_components/textpatcher/TextPatcher.amd.js', '/common/userObject.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Listmap, Crypto, TextPatcher, FO) { +], function ($, Listmap, Crypto, TextPatcher, FO) { /* This module uses localStorage, which is synchronous, but exposes an asyncronous API. This is so that we can substitute other storage @@ -13,7 +13,6 @@ define([ To override these methods, create another file at: /customize/storage.js */ - var $ = window.jQuery; var Store = {}; var store; diff --git a/www/common/login.js b/www/common/login.js index 8e9067bc7..dff4a3be3 100644 --- a/www/common/login.js +++ b/www/common/login.js @@ -1,12 +1,12 @@ define([ + 'jquery', '/bower_components/chainpad-listmap/chainpad-listmap.js', '/bower_components/chainpad-crypto/crypto.js', '/common/cryptpad-common.js', '/common/credential.js', '/bower_components/tweetnacl/nacl-fast.min.js', '/bower_components/scrypt-async/scrypt-async.min.js', // better load speed - '/bower_components/jquery/dist/jquery.min.js', -], function (Listmap, Crypto, Cryptpad, Cred) { +], function ($, Listmap, Crypto, Cryptpad, Cred) { var Exports = { Cred: Cred, }; diff --git a/www/common/mergeDrive.js b/www/common/mergeDrive.js index 784817d1d..dfd891291 100644 --- a/www/common/mergeDrive.js +++ b/www/common/mergeDrive.js @@ -1,4 +1,3 @@ -require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } }); define([ '/common/cryptpad-common.js', '/common/cryptget.js', diff --git a/www/common/toolbar.js b/www/common/toolbar.js index 75a3e4b55..81dde3335 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -1,9 +1,8 @@ define([ + 'jquery', '/customize/application_config.js', - '/api/config', - '/bower_components/jquery/dist/jquery.min.js' -], function (Config, ApiConfig) { - var $ = window.jQuery; + '/api/config' +], function ($, Config, ApiConfig) { var Messages = {}; diff --git a/www/common/userObject.js b/www/common/userObject.js index c69be8de4..6a70a3622 100644 --- a/www/common/userObject.js +++ b/www/common/userObject.js @@ -1,7 +1,6 @@ define([ - '/bower_components/jquery/dist/jquery.min.js', -], function () { - var $ = window.jQuery; + 'jquery', +], function ($) { var module = {}; var ROOT = module.ROOT = "root"; @@ -897,4 +896,3 @@ define([ return module; }); - diff --git a/www/drive/main.js b/www/drive/main.js index 9b960fc92..f6e807031 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -1,5 +1,5 @@ -require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } }); define([ + 'jquery', '/bower_components/chainpad-listmap/chainpad-listmap.js', '/bower_components/chainpad-crypto/crypto.js', '/bower_components/textpatcher/TextPatcher.amd.js', @@ -10,11 +10,10 @@ define([ '/customize/application_config.js', '/common/cryptget.js', '/common/mergeDrive.js' -], function (Listmap, Crypto, TextPatcher, JSONSortify, Cryptpad, FO, Toolbar, AppConfig, Get, Merge) { +], function ($, Listmap, Crypto, TextPatcher, JSONSortify, Cryptpad, FO, Toolbar, AppConfig, Get, Merge) { var module = window.MODULE = {}; var Messages = Cryptpad.Messages; - var $ = window.jQuery; var saveAs = window.saveAs; // Use `$(function () {});` to make sure the html is loaded before doing anything else diff --git a/www/examples/board/board.js b/www/examples/board/board.js index 08f0b0dcd..26d695173 100644 --- a/www/examples/board/board.js +++ b/www/examples/board/board.js @@ -1,7 +1,6 @@ define([ - '/bower_components/jquery/dist/jquery.min.js', -],function () { - var $ = window.jQuery; + 'jquery' +],function ($) { var Board = {}; var proxy; diff --git a/www/examples/board/main.js b/www/examples/board/main.js index ca690bdc4..c5c664c49 100644 --- a/www/examples/board/main.js +++ b/www/examples/board/main.js @@ -1,5 +1,6 @@ define([ - '/api/config?cb=' + Math.random().toString(16).substring(2), + 'jquery', + '/api/config', '/customize/messages.js', 'board.js', '/bower_components/textpatcher/TextPatcher.js', @@ -8,10 +9,9 @@ define([ '/common/cryptpad-common.js', '/common/visible.js', '/common/notify.js', - '/bower_components/file-saver/FileSaver.min.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Config, Messages, Board, TextPatcher, Listmap, Crypto, Cryptpad, Visible, Notify) { - var $ = window.jQuery; + '/bower_components/file-saver/FileSaver.min.js' +], function ($, Config, Messages, Board, TextPatcher, Listmap, Crypto, Cryptpad, Visible, Notify) { + var saveAs = window.saveAs; Cryptpad.styleAlerts(); diff --git a/www/examples/form/main.js b/www/examples/form/main.js index bdb10065a..04a65e2c4 100644 --- a/www/examples/form/main.js +++ b/www/examples/form/main.js @@ -1,16 +1,14 @@ -require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } }); define([ - '/api/config?cb=' + Math.random().toString(16).substring(2), + 'jquery', + '/api/config', '/bower_components/chainpad-netflux/chainpad-netflux.js', '/bower_components/chainpad-crypto/crypto.js', '/bower_components/textpatcher/TextPatcher.amd.js', 'json.sortify', 'ula.js', '/bower_components/chainpad-json-validator/json-ot.js', - '/common/cryptpad-common.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Config, Realtime, Crypto, TextPatcher, Sortify, Formula, JsonOT, Cryptpad) { - var $ = window.jQuery; + '/common/cryptpad-common.js' +], function ($, Config, Realtime, Crypto, TextPatcher, Sortify, Formula, JsonOT, Cryptpad) { var secret = Cryptpad.getSecrets(); diff --git a/www/examples/hack/main.js b/www/examples/hack/main.js index 82a2b0f6e..c59460a60 100644 --- a/www/examples/hack/main.js +++ b/www/examples/hack/main.js @@ -1,12 +1,11 @@ define([ - '/api/config?cb=' + Math.random().toString(16).substring(2), + 'jquery', + '/api/config', '/bower_components/chainpad-netflux/chainpad-netflux.js', '/bower_components/chainpad-crypto/crypto.js', '/bower_components/textpatcher/TextPatcher.amd.js', - '/common/cryptpad-common.js', - '/bower_components/jquery/dist/jquery.min.js' -], function (Config, Realtime, Crypto, TextPatcher, Cryptpad) { - var $ = window.jQuery; + '/common/cryptpad-common.js' +], function ($, Config, Realtime, Crypto, TextPatcher, Cryptpad) { var secret = Cryptpad.getSecrets(); diff --git a/www/examples/json/main.js b/www/examples/json/main.js index 8b018ebd7..90654afa6 100644 --- a/www/examples/json/main.js +++ b/www/examples/json/main.js @@ -1,11 +1,10 @@ define([ - '/api/config?cb=' + Math.random().toString(16).substring(2), + 'jquery', + '/api/config', '/bower_components/chainpad-listmap/chainpad-listmap.js', '/bower_components/chainpad-crypto/crypto.js', - '/common/cryptpad-common.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Config, RtListMap, Crypto, Common) { - var $ = window.jQuery; + '/common/cryptpad-common.js' +], function ($, Config, RtListMap, Crypto, Common) { var secret = Common.getSecrets(); diff --git a/www/examples/pin/main.js b/www/examples/pin/main.js index 1853b9e4c..ad6905d7d 100644 --- a/www/examples/pin/main.js +++ b/www/examples/pin/main.js @@ -1,10 +1,8 @@ -require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } }); define([ + 'jquery', '/common/cryptpad-common.js', - '/common/pinpad.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Cryptpad, Pinpad) { - var $ = window.jQuery; + '/common/pinpad.js' +], function ($, Cryptpad, Pinpad) { var APP = window.APP = { Cryptpad: Cryptpad, }; diff --git a/www/examples/read/main.js b/www/examples/read/main.js index 9bce1ebe7..5692f9b6b 100644 --- a/www/examples/read/main.js +++ b/www/examples/read/main.js @@ -1,8 +1,7 @@ define([ - '/common/cryptget.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Crypt) { - var $ = window.jQuery; + 'jquery', + '/common/cryptget.js' +], function ($, Crypt) { var $target = $('#target'); var $dest = $('#dest'); diff --git a/www/examples/render/main.js b/www/examples/render/main.js index caf1f00c6..8f504c30c 100644 --- a/www/examples/render/main.js +++ b/www/examples/render/main.js @@ -1,14 +1,13 @@ define([ - '/api/config?cb=' + Math.random().toString(16).substring(2), + 'jquery', + '/api/config', '/bower_components/chainpad-netflux/chainpad-netflux.js', '/bower_components/chainpad-crypto/crypto.js', '/bower_components/marked/marked.min.js', '/bower_components/hyperjson/hyperjson.js', '/common/cryptpad-common.js', - '/bower_components/jquery/dist/jquery.min.js', '/bower_components/diff-dom/diffDOM.js', -], function (Config, Realtime, Crypto, Marked, Hyperjson, Cryptpad) { - var $ = window.jQuery; +], function ($, Config, Realtime, Crypto, Marked, Hyperjson, Cryptpad) { var DiffDom = window.diffDOM; var secret = Cryptpad.getSecrets(); diff --git a/www/examples/style/main.js b/www/examples/style/main.js index 1b41e8300..5b8c0f987 100644 --- a/www/examples/style/main.js +++ b/www/examples/style/main.js @@ -1,13 +1,12 @@ define([ - '/api/config?cb=' + Math.random().toString(16).substring(2), + 'jquery', + '/api/config', '/bower_components/chainpad-netflux/chainpad-netflux.js', '/bower_components/chainpad-crypto/crypto.js', '/bower_components/textpatcher/TextPatcher.amd.js', - '/common/cryptpad-common.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Config, Realtime, Crypto, TextPatcher, Cryptpad) { + '/common/cryptpad-common.js' +], function ($, Config, Realtime, Crypto, TextPatcher, Cryptpad) { // TODO consider adding support for less.js - var $ = window.jQuery; var $style = $('style').first(), $edit = $('#edit'); diff --git a/www/examples/text/main.js b/www/examples/text/main.js index 64b510383..20bdbc6a6 100644 --- a/www/examples/text/main.js +++ b/www/examples/text/main.js @@ -1,12 +1,11 @@ define([ - '/api/config?cb=' + Math.random().toString(16).substring(2), + 'jquery', + '/api/config', '/bower_components/chainpad-netflux/chainpad-netflux.js', '/bower_components/chainpad-crypto/crypto.js', '/bower_components/textpatcher/TextPatcher.amd.js', - '/common/cryptpad-common.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Config, Realtime, Crypto, TextPatcher, Cryptpad) { - var $ = window.jQuery; + '/common/cryptpad-common.js' +], function ($, Config, Realtime, Crypto, TextPatcher, Cryptpad) { var secret = Cryptpad.getSecrets(); diff --git a/www/examples/upload/main.js b/www/examples/upload/main.js index 1aa4ffb75..6aecafd76 100644 --- a/www/examples/upload/main.js +++ b/www/examples/upload/main.js @@ -1,9 +1,8 @@ define([ + 'jquery', '/common/cryptget.js', - '/bower_components/chainpad-crypto/crypto.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Crypt, Crypto) { - var $ = window.jQuery; + '/bower_components/chainpad-crypto/crypto.js' +], function ($, Crypt, Crypto) { var Nacl = window.nacl; var key = Nacl.randomBytes(32); @@ -49,14 +48,14 @@ define([ http://stackoverflow.com/questions/19959072/sending-binary-data-in-javascript-over-http - // Since we deal with Firefox and Chrome only + // Since we deal with Firefox and Chrome only var bytesToSend = [253, 0, 128, 1]; var bytesArray = new Uint8Array(bytesToSend); $.ajax({ url: '%your_service_url%', type: 'POST', - contentType: 'application/octet-stream', + contentType: 'application/octet-stream', data: bytesArray, processData: false }); @@ -65,7 +64,7 @@ http://stackoverflow.com/questions/19959072/sending-binary-data-in-javascript-ov }; var $file = $('input[type="file"]'); - $file.on('change', function (e) { + $file.on('change', function (e) { var file = e.target.files[0]; var reader = new FileReader(); reader.onload = function (e) { diff --git a/www/login/index.html b/www/login/index.html index e38950b75..cd39e6395 100644 --- a/www/login/index.html +++ b/www/login/index.html @@ -7,7 +7,6 @@ - diff --git a/www/login/main.js b/www/login/main.js index 706d5429a..9e93c7cb6 100644 --- a/www/login/main.js +++ b/www/login/main.js @@ -1,9 +1,8 @@ define([ + 'jquery', '/common/cryptpad-common.js', - '/common/login.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Cryptpad, Login) { - var $ = window.$; + '/common/login.js' +], function ($, Cryptpad, Login) { var APP = window.APP = { Cryptpad: Cryptpad, @@ -124,4 +123,3 @@ define([ }); }); }); - diff --git a/www/pad/main.js b/www/pad/main.js index 443463b1d..a9da8f4bd 100644 --- a/www/pad/main.js +++ b/www/pad/main.js @@ -1,5 +1,5 @@ -require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } }); define([ + 'jquery', '/bower_components/chainpad-crypto/crypto.js', '/bower_components/chainpad-netflux/chainpad-netflux.js', '/bower_components/hyperjson/hyperjson.js', @@ -15,12 +15,10 @@ define([ '/common/notify.js', '/pad/links.js', '/bower_components/file-saver/FileSaver.min.js', - '/bower_components/diff-dom/diffDOM.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Crypto, realtimeInput, Hyperjson, + '/bower_components/diff-dom/diffDOM.js' +], function ($, Crypto, realtimeInput, Hyperjson, Toolbar, Cursor, JsonOT, TypingTest, JSONSortify, TextPatcher, Cryptpad, Cryptget, Visible, Notify, Links) { - var $ = window.jQuery; var saveAs = window.saveAs; var Messages = Cryptpad.Messages; diff --git a/www/poll/main.js b/www/poll/main.js index acd4d0af2..5aa3e4ee2 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -1,4 +1,5 @@ define([ + 'jquery', '/bower_components/textpatcher/TextPatcher.js', '/bower_components/chainpad-listmap/chainpad-listmap.js', '/bower_components/chainpad-crypto/crypto.js', @@ -9,10 +10,8 @@ define([ '/common/toolbar.js', '/common/visible.js', '/common/notify.js', - '/bower_components/file-saver/FileSaver.min.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (TextPatcher, Listmap, Crypto, Cryptpad, Cryptget, Hyperjson, Renderer, Toolbar, Visible, Notify) { - var $ = window.jQuery; + '/bower_components/file-saver/FileSaver.min.js' +], function ($, TextPatcher, Listmap, Crypto, Cryptpad, Cryptget, Hyperjson, Renderer, Toolbar, Visible, Notify) { var Messages = Cryptpad.Messages; @@ -843,4 +842,3 @@ define([ }); }); - diff --git a/www/register/main.js b/www/register/main.js index 5455046b3..374118919 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -1,11 +1,10 @@ define([ + 'jquery', '/common/login.js', '/common/cryptpad-common.js', '/common/cryptget.js', - '/common/credential.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Login, Cryptpad, Crypt) { - var $ = window.jQuery; + '/common/credential.js' +], function ($, Login, Cryptpad, Crypt) { var APP = window.APP = { Login: Login, diff --git a/www/settings/index.html b/www/settings/index.html index 795ab825a..56d77905e 100644 --- a/www/settings/index.html +++ b/www/settings/index.html @@ -8,7 +8,6 @@ - diff --git a/www/settings/main.js b/www/settings/main.js index 250773556..8600dba4d 100644 --- a/www/settings/main.js +++ b/www/settings/main.js @@ -1,11 +1,10 @@ define([ + 'jquery', '/common/cryptpad-common.js', '/common/cryptget.js', '/common/mergeDrive.js', - '/bower_components/file-saver/FileSaver.min.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Cryptpad, Crypt, Merge) { - var $ = window.jQuery; + '/bower_components/file-saver/FileSaver.min.js' +], function ($, Cryptpad, Crypt, Merge) { var saveAs = window.saveAs; var USERNAME_KEY = 'cryptpad.username'; @@ -358,4 +357,3 @@ define([ } }); }); - diff --git a/www/slide/main.js b/www/slide/main.js index 5654f43ab..cf1b0c040 100644 --- a/www/slide/main.js +++ b/www/slide/main.js @@ -1,5 +1,5 @@ -require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } }); define([ + 'jquery', '/bower_components/chainpad-crypto/crypto.js', '/bower_components/chainpad-netflux/chainpad-netflux.js', '/bower_components/textpatcher/TextPatcher.js', @@ -13,10 +13,8 @@ define([ '/common/visible.js', '/common/notify.js', '/slide/slide.js', - '/bower_components/file-saver/FileSaver.min.js', - '/bower_components/jquery/dist/jquery.min.js', -], function (Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad, Cryptget, Modes, Themes, Visible, Notify, Slide) { - var $ = window.jQuery; + '/bower_components/file-saver/FileSaver.min.js' +], function ($, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad, Cryptget, Modes, Themes, Visible, Notify, Slide) { var saveAs = window.saveAs; var Messages = Cryptpad.Messages; diff --git a/www/slide/slide.js b/www/slide/slide.js index b4db44922..6c7b68fe8 100644 --- a/www/slide/slide.js +++ b/www/slide/slide.js @@ -1,9 +1,8 @@ define([ + 'jquery', '/bower_components/marked/marked.min.js', - '/bower_components/diff-dom/diffDOM.js', - '/bower_components/jquery/dist/jquery.min.js', -],function (Marked) { - var $ = window.jQuery; + '/bower_components/diff-dom/diffDOM.js' +],function ($, Marked) { var DiffDOM = window.diffDOM; var renderer = new Marked.Renderer(); diff --git a/www/whiteboard/main.js b/www/whiteboard/main.js index 938505d50..6cadfc487 100644 --- a/www/whiteboard/main.js +++ b/www/whiteboard/main.js @@ -1,9 +1,6 @@ -require.config({ paths: { - 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' -}}); - define([ - '/api/config?cb=' + Math.random().toString(16).substring(2), + 'jquery', + '/api/config', '/bower_components/chainpad-netflux/chainpad-netflux.js', '/bower_components/chainpad-crypto/crypto.js', '/common/toolbar.js', @@ -17,14 +14,12 @@ define([ '/common/notify.js', '/customize/application_config.js', '/bower_components/secure-fabric.js/dist/fabric.min.js', - '/bower_components/jquery/dist/jquery.min.js', '/bower_components/file-saver/FileSaver.min.js', -], function (Config, Realtime, Crypto, Toolbar, TextPatcher, JSONSortify, JsonOT, Cryptpad, Cryptget, Colors, Visible, Notify, AppConfig) { +], function ($, Config, Realtime, Crypto, Toolbar, TextPatcher, JSONSortify, JsonOT, Cryptpad, Cryptget, Colors, Visible, Notify, AppConfig) { var saveAs = window.saveAs; var Messages = Cryptpad.Messages; - var module = window.APP = { }; - var $ = module.$ = window.jQuery; + var module = window.APP = { $:$ }; var Fabric = module.Fabric = window.fabric; $(function () {