diff --git a/customize.dist/pages.js b/customize.dist/pages.js index 73e4daaf4..070788dc4 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -570,12 +570,12 @@ define([ }; var appToolbar = function () { - return h('div#toolbar.toolbar-container'); + return h('div#cp-toolbar.cp-toolbar-container'); }; Pages['/whiteboard/'] = Pages['/whiteboard/index.html'] = function () { return [ - h('div#cp-toolbar.cp-toolbar-container'), + appToolbar(), h('div#cp-app-whiteboard-canvas-area', h('canvas#cp-app-whiteboard-canvas', { width: 600, height: 600 @@ -680,8 +680,7 @@ define([ ]) ]) ]) - ]), - loadingScreen() + ]) ]; }; diff --git a/customize.dist/src/less2/include/fileupload.less b/customize.dist/src/less2/include/fileupload.less index bd90ab5d3..a07d365bd 100644 --- a/customize.dist/src/less2/include/fileupload.less +++ b/customize.dist/src/less2/include/fileupload.less @@ -28,6 +28,11 @@ td { padding: @upload_pad_h @upload_pad_v; } + .cp-fileupload-table-link { + .fa { + margin-right: 5px; + } + } .cp-fileupload-table-progress { width: 200px; position: relative; diff --git a/customize.dist/src/less2/include/toolbar.less b/customize.dist/src/less2/include/toolbar.less index 0ce8616e6..2d49da6b2 100644 --- a/customize.dist/src/less2/include/toolbar.less +++ b/customize.dist/src/less2/include/toolbar.less @@ -650,6 +650,14 @@ } } } + p.cp-toolbar-account { + &> span { + font-weight: bold; + span { + font-weight: normal; + } + } + } .cp-toolbar-backup { margin: 0; border-radius: 0; diff --git a/www/code/app-code.less b/www/code/app-code.less index 8772a2653..d625da0da 100644 --- a/www/code/app-code.less +++ b/www/code/app-code.less @@ -3,10 +3,12 @@ @import (once) "../../customize/src/less2/include/markdown.less"; @import (once) '../../customize/src/less2/include/fileupload.less'; @import (once) '../../customize/src/less2/include/alertify.less'; +@import (once) '../../customize/src/less2/include/tokenfield.less'; .toolbar_main(); .fileupload_main(); .alertify_main(); +.tokenfield_main(); // body &.cp-app-code { diff --git a/www/code/inner.js b/www/code/inner.js index 7146285b0..c4917e6fc 100644 --- a/www/code/inner.js +++ b/www/code/inner.js @@ -230,7 +230,7 @@ define([ if (data !== false) { $previewContainer.show(); APP.$previewButton.addClass('active'); - $codeMirror.removeClass('fullPage'); + $codeMirror.removeClass('cp-app-code-fullpage'); } }); return; @@ -238,7 +238,7 @@ define([ APP.$previewButton.hide(); $previewContainer.hide(); APP.$previewButton.removeClass('active'); - $codeMirror.addClass('fullPage'); + $codeMirror.addClass('cp-app-code-fullpage'); }; config.onInit = function (info) { @@ -374,6 +374,9 @@ define([ }; common.openFilePicker(pickerCfg); }).appendTo($rightside); + + var $tags = common.createButton('hashtag', true); + $rightside.append($tags); } }; @@ -604,7 +607,7 @@ define([ SFCommon.create(waitFor(function (c) { APP.common = common = c; })); }).nThen(function (/*waitFor*/) { CodeMirror = common.initCodeMirrorApp(null, CM); - $('.CodeMirror').addClass('fullPage'); + $('.CodeMirror').addClass('cp-app-code-fullpage'); editor = CodeMirror.editor; Cryptpad.onError(function (info) { if (info && info.type === "store") { diff --git a/www/common/LessLoader.js b/www/common/LessLoader.js index f7e4f6985..3275c88b5 100644 --- a/www/common/LessLoader.js +++ b/www/common/LessLoader.js @@ -9,18 +9,20 @@ define([ var module = { exports: {} }; var key = Config.requireConf.urlArgs; var localStorage = {}; - try { - localStorage = window.localStorage || {}; - if (localStorage['LESS_CACHE'] !== key) { - Object.keys(localStorage).forEach(function (k) { - if (k.indexOf('LESS_CACHE|') !== 0) { return; } - delete localStorage[k]; - }); - localStorage['LESS_CACHE'] = key; + if (!window.cryptpadCache) { + try { + localStorage = window.localStorage || {}; + if (localStorage['LESS_CACHE'] !== key) { + Object.keys(localStorage).forEach(function (k) { + if (k.indexOf('LESS_CACHE|') !== 0) { return; } + delete localStorage[k]; + }); + localStorage['LESS_CACHE'] = key; + } + } catch (e) { + console.error(e); + localStorage = {}; } - } catch (e) { - console.error(e); - localStorage = {}; } var cacheGet = function (k, cb) { diff --git a/www/common/common-interface.js b/www/common/common-interface.js index fc91a655b..f85aec474 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -135,6 +135,11 @@ define([ }); }; + var $root = $t.parent(); + $t.on('tokenfield:removetoken', function () { + $root.find('.token-input').focus(); + }); + t.preventDuplicates = function (cb) { $t.on('tokenfield:createtoken', function (ev) { var val; @@ -181,26 +186,29 @@ define([ UI.warn(Messages._getKey('tags_duplicate', [val])); }); - var close = Util.once(function () { - var $t = $(tagger).fadeOut(150, function () { $t.remove(); }); - }); - - var listener = listenForKeys(function () {}, function () { - close(); - stopListening(listener); + var listener; + var close = Util.once(function (result, ev) { + var $frame = $(tagger).fadeOut(150, function () { + stopListening(listener); + $frame.remove(); + cb(result, ev); + }); }); - var CB = Util.once(cb); - findOKButton(tagger).click(function () { + var $ok = findOKButton(tagger).click(function () { var tokens = field.getTokens(); - close(); - CB(tokens); + close(tokens); }); - findCancelButton(tagger).click(function () { - close(); - CB(null); + var $cancel = findCancelButton(tagger).click(function () { + close(null); + }); + listenForKeys(function () { + $ok.click(); + }, function () { + $cancel.click(); }); + document.body.appendChild(tagger); // :( setTimeout(function () { field.setTokens(tags); diff --git a/www/common/common-util.js b/www/common/common-util.js index f6ec8d4df..4015fbfe4 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -18,7 +18,8 @@ define([], function () { fire: function () { if (fired) { return; } fired = true; - handlers.forEach(function (h) { h(); }); + var args = Array.prototype.slice.call(arguments); + handlers.forEach(function (h) { h.apply(null, args); }); } }; }; diff --git a/www/common/mergeDrive.js b/www/common/mergeDrive.js index 596049475..1a5fb5f29 100644 --- a/www/common/mergeDrive.js +++ b/www/common/mergeDrive.js @@ -111,12 +111,14 @@ define([ var newFo = proxyData.fo; var oldRecentPads = parsed.drive[newFo.FILES_DATA]; var newRecentPads = proxy.drive[newFo.FILES_DATA]; - var newFiles = newFo.getFiles([newFo.FILES_DATA]); var oldFiles = oldFo.getFiles([newFo.FILES_DATA]); + var newHrefs = Object.keys(newRecentPads).map(function (id) { + return newRecentPads[id].href; + }); oldFiles.forEach(function (id) { var href = oldRecentPads[id].href; // Do not migrate a pad if we already have it, it would create a duplicate in the drive - if (newFiles.indexOf(id) !== -1) { return; } + if (newHrefs.indexOf(href) !== -1) { return; } // If we have a stronger version, do not add the current href if (Cryptpad.findStronger(href, newRecentPads)) { return; } // If we have a weaker version, replace the href by the new one diff --git a/www/common/sframe-chainpad-listmap.js b/www/common/sframe-chainpad-listmap.js index 8e0aa8810..22b7e6216 100644 --- a/www/common/sframe-chainpad-listmap.js +++ b/www/common/sframe-chainpad-listmap.js @@ -623,19 +623,6 @@ define([ throw new Error('unsupported datatype: '+ DeepProxy.type(cfg.data)); } - if (!cfg.crypto) { - // complain and stub - console.log("[chainpad-listmap] no crypto module provided. messages will not be encrypted"); - cfg.crypto = { - encrypt: function (msg) { - return msg; - }, - decrypt: function (msg) { - return msg; - } - }; - } - var realtimeOptions = { userName: cfg.userName, initialState: Sortify(cfg.data), diff --git a/www/common/sframe-chainpad-netflux-inner.js b/www/common/sframe-chainpad-netflux-inner.js index 787da1ca3..7e0eb2a57 100644 --- a/www/common/sframe-chainpad-netflux-inner.js +++ b/www/common/sframe-chainpad-netflux-inner.js @@ -46,7 +46,21 @@ define([ var metadataMgr = config.metadataMgr; config = undefined; - var chainpad; + var chainpad = ChainPad.create({ + userName: userName, + initialState: initialState, + transformFunction: transformFunction, + validateContent: validateContent, + avgSyncMilliseconds: avgSyncMilliseconds, + logLevel: logLevel + }); + chainpad.onMessage(function(message, cb) { + sframeChan.query('Q_RT_MESSAGE', message, cb); + }); + chainpad.onPatch(function () { + onRemote({ realtime: chainpad }); + }); + var myID; var isReady = false; var evConnected = Util.mkEvent(true); @@ -67,33 +81,20 @@ define([ sframeChan.on('EV_RT_DISCONNECT', function () { isReady = false; - if (chainpad) { chainpad.abort(); } + chainpad.abort(); onConnectionChange({ state: false }); }); sframeChan.on('EV_RT_CONNECT', function (content) { //content.members.forEach(userList.onJoin); - myID = content.myID; isReady = false; - if (chainpad) { + if (myID) { // it's a reconnect - if (chainpad) { chainpad.start(); } + myID = content.myID; + chainpad.start(); onConnectionChange({ state: true, myId: myID }); return; } - chainpad = ChainPad.create({ - userName: userName, - initialState: initialState, - transformFunction: transformFunction, - validateContent: validateContent, - avgSyncMilliseconds: avgSyncMilliseconds, - logLevel: logLevel - }); - chainpad.onMessage(function(message, cb) { - sframeChan.query('Q_RT_MESSAGE', message, cb); - }); - chainpad.onPatch(function () { - onRemote({ realtime: chainpad }); - }); + myID = content.myID; onInit({ myID: myID, realtime: chainpad, @@ -130,7 +131,8 @@ define([ getMyID: function () { return myID; }, metadataMgr: metadataMgr, whenRealtimeSyncs: whenRealtimeSyncs, - onInfiniteSpinner: evInfiniteSpinner.reg + onInfiniteSpinner: evInfiniteSpinner.reg, + chainpad: chainpad, }); }; return Object.freeze(module.exports); diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index c58b8db61..10bb8fbac 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -112,10 +112,13 @@ define([ }; onComplete = function (href) { + var mdMgr = common.getMetadataMgr(); + var origin = mdMgr.getPrivateData().origin; + $link.prepend($('', {'class': 'fa fa-external-link'})); $link.attr('href', href) .click(function (e) { e.preventDefault(); - window.open($link.attr('href'), '_blank'); + window.open(origin + $link.attr('href'), '_blank'); }); var title = metadata.name; Cryptpad.log(Messages._getKey('upload_success', [title])); diff --git a/www/common/sframe-common-interface.js b/www/common/sframe-common-interface.js index 89614da0f..7c8aa2b10 100644 --- a/www/common/sframe-common-interface.js +++ b/www/common/sframe-common-interface.js @@ -205,12 +205,11 @@ define([ .click(function () { sframeChan.query('Q_TAGS_GET', null, function (err, res) { if (err || res.error) { return void console.error(err || res.error); } - var dialog = Cryptpad.dialog.tagPrompt(res.data, function (tags) { + Cryptpad.dialog.tagPrompt(res.data, function (tags) { if (!Array.isArray(tags)) { return; } console.error(tags); sframeChan.event('EV_TAGS_SET', tags); }); - document.body.appendChild(dialog); }); }); break; @@ -418,7 +417,7 @@ define([ $userAdminContent.append($userName); options.push({ tag: 'p', - attributes: {'class': 'accountData'}, + attributes: {'class': 'cp-toolbar-account'}, content: $userAdminContent.html() }); } diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index f9f7d6fae..f50bc1de2 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -259,7 +259,7 @@ define([ if (msg) { msg = msg.replace(/^cp\|/, ''); var decryptedMsg = crypto.decrypt(msg, secret.keys.validateKey); - msgs.push(decryptedMsg) + msgs.push(decryptedMsg); } }; network.on('message', onMsg); diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index 335888256..3218f40f4 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -688,7 +688,7 @@ define([ }; var typing = -1; - var kickSpinner = function (toolbar, config, local) { + var kickSpinner = function (toolbar, config/*, local*/) { if (!toolbar.spinner) { return; } var $spin = toolbar.spinner; @@ -708,7 +708,7 @@ define([ window.clearInterval($spin.interval); typing = -1; $spin.text(Messages.saved); - }, local ? 0 : SPINNER_DISAPPEAR_TIME); + }, /*local ? 0 :*/ SPINNER_DISAPPEAR_TIME); }; config.sfCommon.whenRealtimeSyncs(onSynced); }; diff --git a/www/common/userObject.js b/www/common/userObject.js index 0150b1528..7825161e4 100644 --- a/www/common/userObject.js +++ b/www/common/userObject.js @@ -457,7 +457,7 @@ define([ }; exp.getRecentPads = function () { var allFiles = files[FILES_DATA]; - var sorted = Object.keys(allFiles) + var sorted = Object.keys(allFiles).filter(function (a) { return allFiles[a]; }) .sort(function (a,b) { return allFiles[a].atime < allFiles[b].atime; }) @@ -1041,20 +1041,6 @@ define([ } }); }; - var migrateAttributes = function (el, id, parsed) { - // Migrate old pad attributes - ['userid', 'previewMode'].forEach(function (attr) { - var key = parsed.hash + '.' + attr; - var key2 = parsed.hash.slice(0,-1) + '.' + attr;// old pads not ending with / - if (typeof(files[key]) !== "undefined" || typeof(files[key2]) !== "undefined") { - debug("Migrating pad attribute", attr, "for pad", id); - el[attr] = files[key] || files[key2]; - delete files[key]; - delete files[key2]; - } - }); - // Migration done - }; var fixFilesData = function () { if (typeof files[FILES_DATA] !== "object") { debug("OLD_FILES_DATA was not an object"); files[FILES_DATA] = {}; } var fd = files[FILES_DATA]; @@ -1081,8 +1067,6 @@ define([ continue; } - migrateAttributes(el, id, parsed); - if ((loggedIn || config.testMode) && rootFiles.indexOf(id) === -1) { debug("An element in filesData was not in ROOT, TEMPLATE or TRASH.", id, el); var newName = Cryptpad.createChannelId(); diff --git a/www/register/main.js b/www/register/main.js index 7de37e8bf..1b7103cac 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -85,6 +85,8 @@ define([ Cryptpad.whenRealtimeSyncs(result.realtime, function () { Cryptpad.login(result.userHash, result.userName, function () { registering = false; + /* + FIXME: migration and readme not working if not redirected to drive if (sessionStorage.redirectTo) { var h = sessionStorage.redirectTo; var parser = document.createElement('a'); @@ -95,6 +97,7 @@ define([ return; } } + */ window.location.href = '/drive/'; }); }); diff --git a/www/slide/app-slide.less b/www/slide/app-slide.less index 0d54fa710..f6ebf8cf0 100644 --- a/www/slide/app-slide.less +++ b/www/slide/app-slide.less @@ -4,11 +4,13 @@ @import (once) '../../customize/src/less2/include/fileupload.less'; @import (once) '../../customize/src/less2/include/alertify.less'; @import (once) "../../customize/src/less2/include/mediatag.less"; +@import (once) '../../customize/src/less2/include/tokenfield.less'; .mediatag_base(); .toolbar_main(); .fileupload_main(); .alertify_main(); +.tokenfield_main(); // body font-size: unset; diff --git a/www/slide/inner.js b/www/slide/inner.js index 91830b749..0efe35d1c 100644 --- a/www/slide/inner.js +++ b/www/slide/inner.js @@ -516,6 +516,9 @@ define([ }; common.openFilePicker(pickerCfg); }).appendTo($rightside); + + var $tags = common.createButton('hashtag', true); + $rightside.append($tags); } metadataMgr.onChange(function () {