From 26c4bda4cda2bd5211beafe0a73b4bca075237af Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 25 Oct 2017 12:31:22 +0200 Subject: [PATCH 1/2] Fix file upload in code and slide --- www/common/common-file.js | 6 +++--- www/common/sframe-common-file.js | 2 ++ www/slide/inner.js | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/www/common/common-file.js b/www/common/common-file.js index 73a58cc50..dfe9bbe94 100644 --- a/www/common/common-file.js +++ b/www/common/common-file.js @@ -28,8 +28,8 @@ define([ var u8 = file.blob; // This is not a blob but a uint8array var metadata = file.metadata; - // if it exists, dropEvent contains the new pad location in the drive - var dropEvent = file.dropEvent; + // if it exists, path contains the new pad location in the drive + var path = file.path; var key = Nacl.randomBytes(32); var next = FileCrypto.encrypt(u8, metadata, key); @@ -76,7 +76,7 @@ define([ if (noStore) { return void onComplete(href); } - common.initialPath = dropEvent && dropEvent.path; + common.initialPath = path; common.renamePad(title || "", href, function (err) { if (err) { return void console.error(err); } onComplete(href); diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index 724c13349..7654b0ef3 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -93,6 +93,8 @@ define([ var metadata = file.metadata; var id = file.id; var dropEvent = file.dropEvent; + delete file.dropEvent; + if (dropEvent.path) { file.path = dropEvent.path; } if (queue.inProgress) { return; } queue.inProgress = true; diff --git a/www/slide/inner.js b/www/slide/inner.js index bcfdc60f0..2dd47105f 100644 --- a/www/slide/inner.js +++ b/www/slide/inner.js @@ -376,6 +376,8 @@ define([ var andThen2 = function (editor, CodeMirror, framework, isPresentMode) { + var common = framework._.sfCommon; + var $contentContainer = $('#cp-app-slide-editor'); var $modal = $('#cp-app-slide-modal'); var $content = $('#cp-app-slide-modal-content'); @@ -427,6 +429,22 @@ define([ framework._.sfCommon.setTabTitle('{title}' + slideNumber); }); Slide.update(editor.getValue()); + + var fmConfig = { + dropArea: $('.CodeMirror'), + body: $('body'), + onUploaded: function (ev, data) { + //var cursor = editor.getCursor(); + //var cleanName = data.name.replace(/[\[\]]/g, ''); + //var text = '!['+cleanName+']('+data.url+')'; + var parsed = Cryptpad.parsePadUrl(data.url); + var hexFileName = Cryptpad.base64ToHex(parsed.hashData.channel); + var src = '/blob/' + hexFileName.slice(0,2) + '/' + hexFileName; + var mt = ''; + editor.replaceSelection(mt); + } + }; + common.createFileManager(fmConfig); }); framework.onDefaultContentNeeded(function () { From 454fc8498c2c827428881f3ca8fd9eac0eea4dce Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 7 Nov 2017 13:50:07 +0100 Subject: [PATCH 2/2] remove old* apps --- www/olddrive/file.less | 821 ----- www/olddrive/index.html | 29 - www/olddrive/inner.html | 60 - www/olddrive/inner.js | 7 - www/olddrive/main.js | 3027 ----------------- www/oldfile/assets/image.png-encrypted | Bin 27455 -> 0 bytes www/oldfile/file-crypto.js | 271 -- www/oldfile/file.less | 130 - www/oldfile/index.html | 30 - www/oldfile/inner.html | 30 - www/oldfile/inner.js | 14 - www/oldfile/main.js | 269 -- www/oldfile/test/index.html | 16 - www/oldfile/test/main.js | 89 - www/oldpoll/index.html | 11 - www/oldpoll/main.js | 806 ----- www/oldpoll/poll.less | 479 --- www/oldpoll/render.js | 453 --- www/oldprofile/index.html | 20 - www/oldprofile/main.js | 532 --- www/oldprofile/main.less | 143 - .../example/assets/todomvc-app-css/index.css | 378 -- .../example/assets/todomvc-common/base.css | 141 - .../example/assets/todomvc-common/base.js | 249 -- www/oldtodo/example/index.html | 49 - www/oldtodo/example/js/app.js | 25 - www/oldtodo/example/js/controller.js | 270 -- www/oldtodo/example/js/helpers.js | 52 - www/oldtodo/example/js/model.js | 120 - www/oldtodo/example/js/store.js | 141 - www/oldtodo/example/js/template.js | 114 - www/oldtodo/example/js/view.js | 219 -- www/oldtodo/index.html | 30 - www/oldtodo/inner.html | 20 - www/oldtodo/inner.js | 15 - www/oldtodo/main.js | 229 -- www/oldtodo/todo.js | 83 - www/oldtodo/todo.less | 121 - www/oldwhiteboard/colors.js | 52 - www/oldwhiteboard/index.html | 9 - www/oldwhiteboard/main.js | 511 --- www/oldwhiteboard/whiteboard.less | 135 - 42 files changed, 10200 deletions(-) delete mode 100644 www/olddrive/file.less delete mode 100644 www/olddrive/index.html delete mode 100644 www/olddrive/inner.html delete mode 100644 www/olddrive/inner.js delete mode 100644 www/olddrive/main.js delete mode 100644 www/oldfile/assets/image.png-encrypted delete mode 100644 www/oldfile/file-crypto.js delete mode 100644 www/oldfile/file.less delete mode 100644 www/oldfile/index.html delete mode 100644 www/oldfile/inner.html delete mode 100644 www/oldfile/inner.js delete mode 100644 www/oldfile/main.js delete mode 100644 www/oldfile/test/index.html delete mode 100644 www/oldfile/test/main.js delete mode 100644 www/oldpoll/index.html delete mode 100644 www/oldpoll/main.js delete mode 100644 www/oldpoll/poll.less delete mode 100644 www/oldpoll/render.js delete mode 100644 www/oldprofile/index.html delete mode 100644 www/oldprofile/main.js delete mode 100644 www/oldprofile/main.less delete mode 100644 www/oldtodo/example/assets/todomvc-app-css/index.css delete mode 100644 www/oldtodo/example/assets/todomvc-common/base.css delete mode 100644 www/oldtodo/example/assets/todomvc-common/base.js delete mode 100644 www/oldtodo/example/index.html delete mode 100644 www/oldtodo/example/js/app.js delete mode 100644 www/oldtodo/example/js/controller.js delete mode 100644 www/oldtodo/example/js/helpers.js delete mode 100644 www/oldtodo/example/js/model.js delete mode 100644 www/oldtodo/example/js/store.js delete mode 100644 www/oldtodo/example/js/template.js delete mode 100644 www/oldtodo/example/js/view.js delete mode 100644 www/oldtodo/index.html delete mode 100644 www/oldtodo/inner.html delete mode 100644 www/oldtodo/inner.js delete mode 100644 www/oldtodo/main.js delete mode 100644 www/oldtodo/todo.js delete mode 100644 www/oldtodo/todo.less delete mode 100644 www/oldwhiteboard/colors.js delete mode 100644 www/oldwhiteboard/index.html delete mode 100644 www/oldwhiteboard/main.js delete mode 100644 www/oldwhiteboard/whiteboard.less diff --git a/www/olddrive/file.less b/www/olddrive/file.less deleted file mode 100644 index 729368af3..000000000 --- a/www/olddrive/file.less +++ /dev/null @@ -1,821 +0,0 @@ -@import "/customize/src/less/variables.less"; -@import "/customize/src/less/mixins.less"; -@import (once) "/customize/src/less2/include/tools.less"; - -@tree-bg: #eee; -@tree-fg: #000; -@tree-lines-col: #888; - -@drive-hover: #eee; -@drive-hover-light: lighten(@drive-hover, 20%); - -@content-bg: #fff; -@content-bg-ro: darken(@content-bg, 10%); -@content-fg: @tree-fg; -@info-box-bg: #d2e1f2; -@info-box-border: #bbb; -@table-header-fg: #555; -@table-header-bg: #e8e8e8; - -@toolbar-bg: #ddd; -@toolbar-fg: #555; -@toolbar-border-col: #ccc; -@toolbar-button-bg: #888; -@toolbar-button-border: #888; -@toolbar-button-bg-hover: #777; -@toolbar-button-fg: #eee; -@toolbar-path-bg: #fff; -@toolbar-path-border: #888; - -@size-mobile: 600px; - -/* PAGE */ - -html, body { - width: 100%; - height: 100%; - box-sizing: border-box; - padding: 0; - margin: 0; - position: relative; - font-size: @main-font-size; - overflow: auto; -} - -body { - display: flex; - flex-flow: column; -} -img.icon { - max-width: 20px; - max-height: 16px; -} - -.unselectable { - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -.app-container { - flex: 1; - overflow: auto; - width: 100%; - display: flex; - flex-flow: row; - @media screen and (max-width: @size-mobile) { - display: block; - #driveToolbar { - .path .element { - display: none; - } - } - #tree { - resize: none; - width: 100%; - max-width: unset; - max-height: unset; - border-bottom: 1px solid @toolbar-border-col; - .category { - margin-top: 0.5em; - } - } - } -} - -.padColor { color: @toolbar-pad-bg; } -.codeColor { color: @toolbar-code-bg; } -.slideColor { color: @toolbar-slide-bg; } -.pollColor { color: @toolbar-poll-bg; } -.fileColor { color: @toolbar-file-bg; } -.whiteboardColor { color: @toolbar-whiteboard-bg; } -.driveColor { color: @toolbar-drive-bg; } -.defaultColor { color: @toolbar-default-bg; } - -div:focus { - outline: none; -} - -.fa { - font-family: FontAwesome; -} - -ul { - list-style: none; - padding-left: 0px; // Remove the default padding -} - -li { - padding: 0px 5px; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -.contextMenu { - display: none; - position: absolute; - z-index: 500; - li { - padding: 0; - font-size: @main-font-size; - a { - cursor: pointer; - } - } -} - -.droppable { - background-color: #FE9A2E; - color: #222; -} - -.selected { - background: #666 !important; - color: #eee; - margin: -1px; - .fa-minus-square-o, .fa-plus-square-o { - color: @tree-fg; - } -} - -.selectedTmp { - border: 1px dotted #bbb; - background: #AAA; - color: #ddd; - margin: -1px; - .fa-minus-square-o, .fa-plus-square-o { - color: @tree-fg; - } -} - -span { - &.fa-folder, &.fa-folder-open { - //color: #FEDE8B; - //text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; - } -} - -/* TREE */ - - -#tree { - font-size: @main-font-size; - //border-right: 1px solid #ccc; - box-sizing: border-box; - background: @tree-bg; - overflow: auto; - resize: horizontal; - width: auto; - white-space: nowrap; - max-width: 500px; - min-width: 200px; - padding: 0px; - color: @tree-fg; - display: flex; - flex-flow: column; - max-height: 100%; - .categories-container { - flex: 1; - max-width: 500px; - overflow: auto; - } - img.icon { - margin-bottom: 3px; - margin-left: -2px; - } - .docTree { - margin-top: 20px; - //padding: 0 0 0 20px; - padding: 0; - cursor: auto; - &li, li { - padding: 0; - &.collapsed ul { - display: none; - } - input { - width: ~"calc(100% - 30px)"; - padding: 0 10px; - border: 0; - color: lighten(@tree-fg, 40%); - } - & > span.element-row { - overflow: hidden; - text-overflow: ellipsis; - //min-width: ~"calc(100% + 5px)"; - .leftsideCategory(); - width: ~"calc(100% + 5px)"; - margin: 0; - margin-bottom: -6px; - display: inline-block; - cursor: pointer; - margin-left: -5px; - padding-left: 5px; - } - & > span.element-row:not(.selected):not(.active):hover { - //background-color: @drive-hover; - } - } - } - span.element { - cursor: pointer; - } - /*.active { - &:not(.selected):not(.droppable) { - background-color: darken(@drive-hover, 15%); - } - }*/ - .category { - margin: 0; - margin-top: 15px; - .root { - &> .fa { - min-width: 30px; - cursor: pointer; - } - } - li { - padding: 0; - .element-row { - display: block; - padding-left: 20px; - .leftsideCategory(); - margin: 0; - .fa { - width: 25px; - } - } - } - } - .category:last-child { - margin-bottom: 20px; - } - #allfilesTree { - margin-top: 0; - } - .limit-container { - margin-top: 0; - } - #searchContainer { - text-align: center; - padding: 0; - position: relative; - input { - background: lighten(@toolbar-drive-bg, 8%); - color: @toolbar-drive-color; - .tools_placeholder-color(@toolbar-drive-color); - outline-width: 0px; - border-radius: 0; - width: 100%; - //border: 1px solid #ccc; - border: 0; - border-right: 1px solid lighten(@toolbar-drive-bg, 16%); - //border-right: 0; - height: @toolbar-line-height; - padding: 0 5px; - padding-left: 45px; - &:focus { - outline-width: 0px; - } - } - .searchIcon { - color: @toolbar-drive-color; - position: absolute; - left: 20px; // TODO align with drive categories - top: 8px; - } - } - .fa.expcol { - margin-left: -10px; - font-size: 14px; - position: absolute; - left: -20px; - top: 10px; - width: 11px !important; - height: 11px !important; - padding: 0; - margin: 0; - background: white; - z-index: 10; - cursor: default; - &:before { - position:relative; - top: -1px; - } - } - .docTree { - .root > .element-row > .expcol { - position: relative; - top:0; - left: -10px; - } - .root > .element-row > .folder { - margin-left: -5px; - } - .root { - &> .element-row { - padding-left: 20px; - } - &> ul { - padding-left: 30px; - } - } - } - - // Expand/collapse lines - .docTree ul { - margin: 0px 0px 0px 10px; - list-style: none; - padding-left: 10px; - li { - position: relative; - &:before { - position: absolute; - left: -15px; - top: -11px; - content: ''; - display: block; - border-left: 1px solid @tree-lines-col; - height: ~"calc(1em + 11px)"; - border-bottom: 1px solid @tree-lines-col; - width: 15px; - } - &:after { - position: absolute; - left: -15px; - bottom: -7px; - content: ''; - display: block; - border-left: 1px solid @tree-lines-col; - height: 100%; - } - &.root { - margin: 0px 0px 0px -10px; - &:before { - display: none; - } - &:after { - display: none; - } - } - &:last-child:after { - display: none; - } - } - } -} - -/* CONTENT */ -#rightCol { - display: flex; - flex-flow: column; - flex: 1; - // Needed to avoid the folder's path to overflows - // https://stackoverflow.com/questions/38223879/white-space-nowrap-breaks-flexbox-layout - min-width: 0; -} -#content { - box-sizing: border-box; - background: @content-bg; - color: @content-fg; - overflow: auto; - flex: 1; - display: flex; - flex-flow: column; - position: relative; - .selectBox { - display: none; - background-color: rgba(100, 100, 100, 0.7); - position: absolute; - z-index: 50; - } - &.readonly { - background: @content-bg-ro; - } - h1 { - padding-left: 10px; - margin-top: 10px; - } - .info-box { - line-height: 2em; - padding: 0.25em 0.75em; - margin: 1em; - background: @info-box-bg; - span { - cursor: pointer; - float: right; - margin-top: 0.5em; - } - &.noclose { - } - } - li { - cursor: default; - &:not(.header) { - *:not(input) { - /*pointer-events: none;*/ - } - &:hover { - &:not(.selected, .selectedTmp) { - background-color: @drive-hover; - } - .name { - /*text-decoration: underline;*/ - } - } - } - } - #folderContent { - li { - &.searchResult { - border-bottom: 1px solid @info-box-border; - display: block; - &:hover { - background-color: initial; - } - table { - width: 100%; - .label2 { - width: 150px; - font-size: 15px; - text-align: right; - padding-right: 15px; - } - .openDir { - a { - cursor: pointer; - color: #41b7d8; - &:hover { - color: #014c8c; - text-decoration: underline; - } - } - } - .path { - font-style: italic; - direction: rtl; - .element { - display: inline-block; - margin-right: 5px; - } - } - .title { - font-weight: bold; - cursor: pointer; - &:hover { - background-color: @drive-hover; - } - } - .col2 { - width: 250px; - } - td.icon { - width: 50px; - font-size: 40px; - } - } - } - } - } - .element { - .truncated { display: none; } - } - div.grid { - padding: 20px; - .fileIcon; - li { - &.element { - position: relative; - } - input { - width: 100%; - margin-top: 5px; - } - .state { - position: absolute; - top: 3px; - right: 3px; - .fa { - margin:0; - font-size: 18px; - } - } - } - .listElement { - display: none; - } - .addpad { - cursor: pointer; - opacity: 0.5; - padding: 0; - &:hover { - opacity: 0.7; - } - .fa { - cursor: pointer; - font-size: 90px; - margin-top: 5px; - margin-bottom: 0; - } - } - } - - .list { - .grid-element { - display: none; - } - // Make it act as a table! - padding-left: 20px; - ul { - display: table; - width: 100%; - padding: 0px 10px; - } - li { - display: table-row; - &> span { - padding: 0 5px; - display: table-cell; - } - &:not(.header) { - height: @toolbar-line-height; - line-height: @toolbar-line-height; - } - &.header { - cursor: default; - color: @table-header-fg; - span { - &:not(.fa) { - text-align: left; - } - &.sortasc, &.sortdesc { - float: right; - } - } - &> span { - padding: 15px 5px; - &.active { - font-weight: bold; - } - &.clickable { - cursor: pointer; - &:hover { - background: @table-header-bg; - } - } - } - } - } - .element { - span { - overflow: hidden; - white-space: nowrap; - box-sizing: border-box; - &.state { - .fa:not(:last-child) { - margin-right: 5px; - } - } - &.icon, &.state { - width: 30px; - } - &.type, &.atime, &.ctime { - width: 175px; - } - &.title { - width: 250px; - @media screen and (max-width: 1200px) { - display: none; - } - } - &.folders, &.files { - width: 150px; - } - } - } - } -} - -.parentFolder { - cursor: pointer; - margin-left: 10px; - &:hover { - text-decoration: underline; - } -} - -#folderContent { - padding-right: 10px; - flex: 1; -} - -#addPadDialog.cp-modal-container { - .fileIcon; - - li:not(.selected):hover { - border: 1px solid white; - } - .cp-modal { - display: flex; - flex-flow: column; - li, li .fa { - cursor: pointer; - } - &> p { - margin: 50px; - } - &> div { - display: flex; - flex-wrap: wrap; - justify-content: center; - align-content: center; - overflow-y: auto; - .uploadFile { - break-after: always; - page-break-after: always; - } - } - } - - @media screen and (max-height: @browser_media-not-big) { - .cp-modal { - & > p { - display: none; - } - & > div { - align-content: unset; - li { - height: 40px; - width: 90%; - display: flex; - align-items: center; - .fa { - font-size: 32px; - } - .name { - height: auto; - } - } - } - } - } -} - - -/* Toolbar */ - -#driveToolbar { - background: lighten(@toolbar-drive-bg, 8%); - color: @toolbar-drive-color; - //height: 30px; - //display: flex; - //flex-flow: row; - z-index: 100; - box-sizing: border-box; - height: @toolbar-line-height; - padding: 0; - display: flex; - flex-flow: row; - - * { - outline-width: 0; - &:focus { - outline-width: 0; - } - } - - .newPadContainer { - display: inline-block; - height: 100%; - } - - .history { - float: right; - } - - .rightside, .leftside { - display: inline-block; - margin: 0; - padding: 0; - .fa { - margin: 0; - } - button { - height: @toolbar-line-height; - padding: 0 10px; - border: none; - border-radius: 0; - box-sizing: border-box; - background: transparent; - font-size: @main-font-size; - color: @toolbar-drive-color; - transition: all 0.15s; - .drawer { - display: none; - } - .fa, span { - font-size: @main-font-size; - } - &:hover { - background: @toolbar-drive-bg; - } - &.active { - display: none; - } - } - } - .rightside { - float: right; - & > * { - float: right; - } - #contextButtonsContainer { - display: inline-block; - height: 100%; - } - padding-left: 10px; - } - .leftside { - & > span { - height: 100%; - margin: 0; - } - button { - padding: 0 10px; - .fa { - margin-right: 5px; - } - .cp-dropdown-button-title { - display: inline-flex; - height: @toolbar-line-height; - align-items: center; - span:not(.fa) { - line-height: 23px; - } - } - } - } - - button { - font: @toolbar-button-font; - span { - font: @toolbar-button-font; - } - .fa, &.fa { - font-family: FontAwesome; - } - } - /* The container
- needed to position the dropdown content */ - .cp-dropdown-container { - margin: 2px 2px; - line-height: 1em; - position: relative; - display: inline-block; - } - .cp-dropdown-content { - margin-right: 2px; - } - - .path { - flex: 1; - width: 100%; - height: @toolbar-line-height; - line-height: @toolbar-line-height; - cursor: default; - width: auto; - overflow: hidden; - white-space: nowrap; - direction: rtl; - max-width: 100%; - text-align: left; - .element { - display: inline-block; - height: @toolbar-line-height; - line-height: @toolbar-line-height; - font-size: @main-font-size; - padding: 0 5px; - border: 0; - background: darken(@toolbar-drive-bg, 10%); - color: @toolbar-drive-color; - box-sizing: border-box; - transition: all 0.15s; - &.separator { - color: #ccc; - } - &.clickable { - cursor: pointer; - &:hover { - background: darken(@toolbar-drive-bg, 15%); - } - } - } - } -} - - - diff --git a/www/olddrive/index.html b/www/olddrive/index.html deleted file mode 100644 index 02f92a5b3..000000000 --- a/www/olddrive/index.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - CryptDrive - - - - - - - diff --git a/www/olddrive/inner.html b/www/olddrive/inner.html deleted file mode 100644 index 0b26aa7a1..000000000 --- a/www/olddrive/inner.html +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - -
- - - - diff --git a/www/olddrive/inner.js b/www/olddrive/inner.js deleted file mode 100644 index e1779778b..000000000 --- a/www/olddrive/inner.js +++ /dev/null @@ -1,7 +0,0 @@ -define([ - 'less!/bower_components/components-font-awesome/css/font-awesome.min.css', - 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', - 'less!/drive/file.less', - 'less!/customize/src/less/cryptpad.less', - 'less!/customize/src/less/toolbar.less', -], function () {}); diff --git a/www/olddrive/main.js b/www/olddrive/main.js deleted file mode 100644 index d7766b75f..000000000 --- a/www/olddrive/main.js +++ /dev/null @@ -1,3027 +0,0 @@ -define([ - 'jquery', - '/bower_components/chainpad-listmap/chainpad-listmap.js', - '/bower_components/chainpad-crypto/crypto.js', - '/bower_components/textpatcher/TextPatcher.amd.js', - 'json.sortify', - '/common/cryptpad-common.js', - '/common/userObject.js', - '/common/toolbar2.js', - '/customize/application_config.js', - '/common/cryptget.js', - '/common/mergeDrive.js', - - 'less!/bower_components/components-font-awesome/css/font-awesome.min.css', - 'less!/customize/src/less/cryptpad.less', -], function ($, Listmap, Crypto, TextPatcher, JSONSortify, Cryptpad, FO, Toolbar, AppConfig, Get, Merge) { - var module = window.MODULE = {}; - - var Messages = Cryptpad.Messages; - //var saveAs = window.saveAs; - - // Use `$(function () {});` to make sure the html is loaded before doing anything else - $(function () { - var ifrw = $('#pad-iframe')[0].contentWindow; - - Cryptpad.addLoadingScreen(); - var onConnectError = function () { - Cryptpad.errorLoadingScreen(Messages.websocketError); - }; - - var APP = window.APP = { - editable: false, - Cryptpad: Cryptpad, - loggedIn: Cryptpad.isLoggedIn(), - mobile: function () { return $('body').width() <= 600; } // Menu and content area are not inline-block anymore for mobiles - }; - - var stringify = APP.stringify = function (obj) { - return JSONSortify(obj); - }; - - var E_OVER_LIMIT = 'E_OVER_LIMIT'; - - var SEARCH = "search"; - var SEARCH_NAME = Messages.fm_searchName; - var ROOT = "root"; - var ROOT_NAME = Messages.fm_rootName; - var FILES_DATA = Cryptpad.storageKey; - var FILES_DATA_NAME = Messages.fm_filesDataName; - var TEMPLATE = "template"; - var TEMPLATE_NAME = Messages.fm_templateName; - var TRASH = "trash"; - var TRASH_NAME = Messages.fm_trashName; - var RECENT = "recent"; - var RECENT_NAME = Messages.fm_recentPadsName; - - var LOCALSTORAGE_LAST = "cryptpad-file-lastOpened"; - var LOCALSTORAGE_OPENED = "cryptpad-file-openedFolders"; - var LOCALSTORAGE_VIEWMODE = "cryptpad-file-viewMode"; - var FOLDER_CONTENT_ID = "folderContent"; - - var config = {}; - var DEBUG = config.DEBUG = true; - var debug = config.debug = DEBUG ? function () { - console.log.apply(console, arguments); - } : function () { return; }; - var logError = config.logError = function () { - console.error.apply(console, arguments); - }; - var log = config.log = Cryptpad.log; - - var getLastOpenedFolder = function () { - var path; - try { - path = localStorage[LOCALSTORAGE_LAST] ? JSON.parse(localStorage[LOCALSTORAGE_LAST]) : [ROOT]; - } catch (e) { - path = [ROOT]; - } - return path; - }; - var setLastOpenedFolder = function (path) { - if (path[0] === SEARCH) { return; } - localStorage[LOCALSTORAGE_LAST] = JSON.stringify(path); - }; - - var initLocalStorage = function () { - try { - var store = JSON.parse(localStorage[LOCALSTORAGE_OPENED]); - if (!$.isArray(store)) { - localStorage[LOCALSTORAGE_OPENED] = '[]'; - } - } catch (e) { - localStorage[LOCALSTORAGE_OPENED] = '[]'; - } - }; - - var wasFolderOpened = function (path) { - var store = JSON.parse(localStorage[LOCALSTORAGE_OPENED]); - return store.indexOf(JSON.stringify(path)) !== -1; - }; - var setFolderOpened = function (path, opened) { - var s = JSON.stringify(path); - var store = JSON.parse(localStorage[LOCALSTORAGE_OPENED]); - if (opened && store.indexOf(s) === -1) { - store.push(s); - } - if (!opened) { - var idx = store.indexOf(s); - if (idx !== -1) { - store.splice(idx, 1); - } - } - localStorage[LOCALSTORAGE_OPENED] = JSON.stringify(store); - }; - - var getViewModeClass = function () { - var mode = localStorage[LOCALSTORAGE_VIEWMODE]; - if (mode === 'list') { return 'list'; } - return 'grid'; - }; - var getViewMode = function () { - return localStorage[LOCALSTORAGE_VIEWMODE] || 'grid'; - }; - var setViewMode = function (mode) { - if (typeof(mode) !== "string") { - logError("Incorrect view mode: ", mode); - return; - } - localStorage[LOCALSTORAGE_VIEWMODE] = mode; - }; - - var setSearchCursor = function () { - var $input = APP.$iframe.find('#searchInput'); - localStorage.searchCursor = $input[0].selectionStart; - }; - var getSearchCursor = function () { - return localStorage.searchCursor || 0; - }; - -/* var now = function () { - return new Date().getTime(); - }; */ - - var setEditable = function (state) { - APP.editable = state; - if (!state) { - APP.$iframe.find('#content').addClass('readonly'); - APP.$iframe.find('[draggable="true"]').attr('draggable', false); - } - else { - APP.$iframe.find('#content').removeClass('readonly'); - APP.$iframe.find('[draggable="false"]').attr('draggable', true); - } - }; - - // Icons - var $folderIcon = $('', {"class": "fa fa-folder folder icon"}); - //var $folderIcon = $('', {src: "/customize/images/icons/folder.svg", "class": "folder icon"}); - var $folderEmptyIcon = $folderIcon.clone(); - var $folderOpenedIcon = $('', {"class": "fa fa-folder-open folder"}); - //var $folderOpenedIcon = $('', {src: "/customize/images/icons/folderOpen.svg", "class": "folder icon"}); - var $folderOpenedEmptyIcon = $folderOpenedIcon.clone(); - //var $upIcon = $('', {"class": "fa fa-arrow-circle-up"}); - var $unsortedIcon = $('', {"class": "fa fa-files-o"}); - var $templateIcon = $('', {"class": "fa fa-cubes"}); - var $recentIcon = $('', {"class": "fa fa-clock-o"}); - var $trashIcon = $('', {"class": "fa fa-trash"}); - var $trashEmptyIcon = $('', {"class": "fa fa-trash-o"}); - //var $collapseIcon = $('', {"class": "fa fa-minus-square-o expcol"}); - var $expandIcon = $('', {"class": "fa fa-plus-square-o expcol"}); - var $emptyTrashIcon = $('