diff options
author | Phie <phie@phie.ovh> | 2020-10-17 00:27:09 +0300 |
---|---|---|
committer | Phie <phie@phie.ovh> | 2020-10-17 00:27:09 +0300 |
commit | 1d9d36f972cea2b62a0010043f206d8a2860007f (patch) | |
tree | fef7218e2349787057494ba8d9188905de89067d | |
parent | 793ea224733bcf0c865421ae57e63c26fb62f656 (diff) |
no need to call prepare on nextcloud
-rw-r--r-- | browsers/browser.js | 82 |
1 files changed, 44 insertions, 38 deletions
diff --git a/browsers/browser.js b/browsers/browser.js index 52eaf0d..6bb7e2d 100644 --- a/browsers/browser.js +++ b/browsers/browser.js @@ -73,48 +73,54 @@ String.prototype.replaceAll = function (search, replacement) { return target.replace(new RegExp(search, 'g'), replacement); }; -function openNote(notePath, action) { - isLoadCanceled = false; - currentNotePath = notePath - RequestBuilder.sRequestBuilder.get("/note/open/prepare", function (error, data) { - console.log("opening " + data) - if (error) - return; - if (writerFrame.src == "") { - if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1 && navigator.userAgent.toLowerCase().indexOf("android") > -1) {//open in new tab for firefox android - window.open("writer?path=" + encodeURIComponent(notePath) + (action != undefined ? "&action=" + action : ""), "_blank"); - } - else { - writerFrame.src = data + "?path=" + encodeURIComponent(notePath) + (action != undefined ? "&action=" + action : ""); - if (notePath !== undefined) { - $("#editor-container").show() - console.log("notePath " + notePath) - $(loadingView).fadeIn(function () { - - writerFrame.style.display = "inline-flex" +function onPrepared(error, data, notePath, action) { + if (error) + return; - }) - } - } - /*setTimeout(function () { - writerFrame.openDevTools() - }, 1000)*/ + if (writerFrame.src == "") { + if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1 && navigator.userAgent.toLowerCase().indexOf("android") > -1) {//open in new tab for firefox android + window.open("writer?path=" + encodeURIComponent(notePath) + (action != undefined ? "&action=" + action : ""), "_blank"); } else { - console.log("reuse old iframe"); - $("#editor-container").show() - $(loadingView).fadeIn(function () { - if (compatibility.isElectron) { - writerFrame.send('loadnote', notePath); - writerFrame.send('action', action); - } - else - writerFrame.contentWindow.loadPath(notePath, action); - writerFrame.style.display = "inline-flex" - - }) + writerFrame.src = data + (notePath != undefined ? ("?path=" + encodeURIComponent(notePath) + (action != undefined ? "&action=" + action : "")) : ""); + if (notePath !== undefined) { + $("#editor-container").show() + $(loadingView).fadeIn(function () { + writerFrame.style.display = "inline-flex" + }) + } } - }) + /*setTimeout(function () { + writerFrame.openDevTools() + }, 1000)*/ + } + else { + console.log("reuse old iframe"); + $("#editor-container").show() + $(loadingView).fadeIn(function () { + if (compatibility.isElectron) { + writerFrame.send('loadnote', notePath); + writerFrame.send('action', action); + } + else + writerFrame.contentWindow.loadPath(notePath, action); + writerFrame.style.display = "inline-flex" + + }) + } +} + +function openNote(notePath, action) { + isLoadCanceled = false; + currentNotePath = notePath + if (compatibility.isElectron) { + RequestBuilder.sRequestBuilder.get("/note/open/prepare", function (error, url) { + onPrepared(error, url, notePath, action) + }) + } + else {//no need to call, always the same on nextcloud + onPrepared(undefined, "./writer", notePath, action) + } } var displaySnack = function (data) { |