Skip to content

Commit

Permalink
Merge pull request #8 from ONLYOFFICE/develop
Browse files Browse the repository at this point in the history
Release/11.0
  • Loading branch information
LinneyS committed Apr 28, 2022
2 parents b60acdd + 00d4c55 commit 725af45
Show file tree
Hide file tree
Showing 47 changed files with 93 additions and 106 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 11.0
## Changed
- manifest v3
- change logout route for personal as appserver

## 10.1
## Changed
- removed unnecessary permission
Expand Down
Binary file removed Screan/1400x560.jpg
Binary file not shown.
Binary file added Screan/1400x560.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Screan/440x280.jpg
Binary file not shown.
Binary file added Screan/440x280.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Screan/920x680.jpg
Binary file not shown.
Binary file added Screan/920x680.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Screan/de/1280x800.jpg
Binary file not shown.
Binary file removed Screan/de/document.png
Binary file not shown.
Binary file added Screan/de/documents.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screan/de/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Screan/de/presentation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Screan/de/spreadsheet.png
Binary file not shown.
Binary file added Screan/de/spreadsheets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Screan/en/1280x800.jpg
Binary file not shown.
Binary file removed Screan/en/document.png
Binary file not shown.
Binary file added Screan/en/documents.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screan/en/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Screan/en/presentation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Screan/en/spreadsheet.png
Binary file not shown.
Binary file added Screan/en/spreadsheets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Screan/es/1280x800.jpg
Binary file not shown.
Binary file removed Screan/es/document.png
Binary file not shown.
Binary file removed Screan/es/presentation.png
Binary file not shown.
Binary file removed Screan/es/spreadsheet.png
Binary file not shown.
Binary file removed Screan/fr/1280x800.jpg
Binary file not shown.
Binary file removed Screan/fr/document.png
Diff not rendered.
Binary file added Screan/fr/documents.png
Binary file added Screan/fr/main.png
Binary file modified Screan/fr/presentation.png
Binary file removed Screan/fr/spreadsheet.png
Diff not rendered.
Binary file added Screan/fr/spreadsheets.png
Binary file removed Screan/ru/1280x800.jpg
Diff not rendered.
Binary file removed Screan/ru/document.png
Diff not rendered.
Binary file added Screan/ru/documents.png
Binary file added Screan/ru/main.png
Binary file modified Screan/ru/presentation.png
Binary file removed Screan/ru/spreadsheet.png
Diff not rendered.
Binary file added Screan/ru/spreadsheets.png
73 changes: 0 additions & 73 deletions Source/_locales/es/messages.json

This file was deleted.

16 changes: 11 additions & 5 deletions Source/js/background.js → Source/background.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
importScripts('js/constants.js', 'js/files.js');

chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if (request.recent && request.recent[0] == "[") {
try {
Expand All @@ -8,7 +10,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
}
});

chrome.extension.onConnect.addListener(function (port) {
chrome.runtime.onConnect.addListener(function (port) {
let isConnected = true;
port.onMessage.addListener(function (msg) {
if (msg.function && msg.args) {
Expand All @@ -30,9 +32,6 @@ chrome.extension.onConnect.addListener(function (port) {

var settings = null;

var platformOS;
chrome.runtime.getPlatformInfo((p) => { platformOS = p; });

function getSettings(callback) {
callback(settings);
}
Expand Down Expand Up @@ -61,7 +60,14 @@ chrome.storage.sync.get(["settings"], (result) => {
var recent = null;

function getRecent(callback) {
callback(recent);
let promise = getRecentFiles(settings.protocol + ":https://" + settings.domain);
promise
.then((json) => {
callback(json.files);
})
.catch(() => {
callback(recent);
});
}

var currentUpload = null;
Expand Down
2 changes: 1 addition & 1 deletion Source/js/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function checkAuth(host) {

function logOut(host) {
return new Promise((res, rej) => {
fetch(host + "/auth.aspx?t=logout")
fetch(host + "/api/2.0/authentication/logout", {method: "POST"})
.then((json) => {
res(true);
})
Expand Down
4 changes: 4 additions & 0 deletions Source/js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ var uploadableFiles = {
"odp": "application/vnd.oasis.opendocument.presentation"
};

var documentExts = ["doc", "docx", "docm", "dot", "dotx", "dotm", "odt", "fodt", "ott", "rtf", "txt", "html", "htm", "mht", "xml", "pdf", "djvu", "fb2", "epub", "xps", "oxps"];
var slideExts = ["pps", "ppsx", "ppsm", "ppt", "pptx", "pptm", "pot", "potx", "potm", "odp", "fodp", "otp"];
var cellExts = ["xls", "xlsx", "xlsm", "xlt", "xltx", "xltm", "ods", "fods", "ots", "csv"];

function timeoutPromise(ms, promise) {
return new Promise((res, rej) => {
setTimeout(() => {
Expand Down
31 changes: 27 additions & 4 deletions Source/js/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ function createFile(host, title) {
});
}

function uploadFile(host, file) {
var formData = new FormData();
formData.append("file", file, file.name);
function uploadFile(host, fileInfo) {
let array = [];
for (let bit in fileInfo.file) array.push(fileInfo.file[bit]);
let formData = new FormData();

let buffer = new Uint8Array(array);
let blob = new Blob([buffer], {type: fileInfo.fileType});
formData.append("file", blob, fileInfo.fileName);

return new Promise((res, rej) => {
fetch(host + "/api/2.0/files/@my/upload", {
Expand All @@ -44,4 +49,22 @@ function uploadFile(host, file) {
rej(err);
});
});
}
}

function getRecentFiles(host) {
return new Promise((res, rej) => {
fetch(host + `/api/2.0/files/@recent?filterType=FilesOnly`, {
method: "get"
})
.then((response) => {
if (!response.ok) rej(response.statusText);
return response.json();
})
.then((json) => {
res(json.response);
})
.catch((err) => {
rej(err);
});
})
}
4 changes: 0 additions & 4 deletions Source/js/inject.js
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
(function () {
var recent = localStorage.getItem("TeamLabRecentDocuments");
chrome.runtime.sendMessage({ recent: recent });
})();
50 changes: 38 additions & 12 deletions Source/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ window.onload = function () {
onGetSettings: onGetSettings
};

let background = chrome.extension.connect();
let background = chrome.runtime.connect();
background.onMessage.addListener(function (msg) {
if (msg.function) {
callbacks[msg.function].apply(this, msg.args);
}
});

if (chrome.extension.getBackgroundPage().platformOS.os == chrome.runtime.PlatformOs.LINUX) {
uploadCont.classList.add(displayNoneClass);
}
chrome.runtime.getPlatformInfo((p) => {
if (p.os == chrome.runtime.PlatformOs.LINUX) {
uploadCont.classList.add(displayNoneClass);
}
});

function fillHtml() {
background.postMessage({
Expand Down Expand Up @@ -85,7 +87,11 @@ window.onload = function () {
}

function handleFile(file) {
chrome.extension.getBackgroundPage().startUpload(file, uploadingProgress);
background.postMessage({
function: "startUpload",
callback: "uploadingProgress",
args: [file]
});
}

function uploadingProgress(obj) {
Expand Down Expand Up @@ -147,7 +153,7 @@ window.onload = function () {
switcher.onclick = switcherFunc;
overlay.onclick = switcherFunc;

uploadInput.onchange = (e) => {
uploadInput.onchange = async (e) => {
if (e.target.files.length != 1) {
ShowError(chrome.i18n.getMessage("errorFilesCount"));
e.target.value = "";
Expand All @@ -170,8 +176,16 @@ window.onload = function () {
return;
}

handleFile(file);
e.target.value = "";
let buffer = await file.arrayBuffer();
let uintArray = new Uint8Array(buffer);
let obj = {
fileType: file.type,
fileName: file.name,
file: uintArray

};
handleFile(obj);
if (e.target !== null) e.target.value = "";

uploadBtn.classList.add(displayNoneClass);
uploadProgress.classList.remove(displayNoneClass);
Expand Down Expand Up @@ -203,6 +217,18 @@ window.onload = function () {
return 0 <= posExt ? filename.substring(posExt + 1).trim().toLowerCase() : "";
}

function getIconByExt(ext) {
if (documentExts.includes(ext)) {
return "text";
}
else if (cellExts.includes(ext)) {
return "spreadsheet";
}
else if (slideExts.includes(ext)) {
return "presentation";
}
}

function onGetRecent(result) {
recentFiles = result || [];

Expand All @@ -212,19 +238,19 @@ window.onload = function () {

for (let i = 0; i < count; i++) {
let file = recentFiles[i];
if (!file.title || !file.url) continue;
if (!file.title || !file.webUrl) continue;

let a = document.createElement("a");
a.innerText = file.title;
let ext = file.fileType || getExt(file.title);
let ext = getExt(file.title);
if (ext) {
let span = document.createElement("span");
span.className = "ext-img " + ext;
span.className = "ext-img " + getIconByExt(ext);
a.prepend(span);
}

a.onclick = () => {
chrome.tabs.create({ url: file.url });
chrome.tabs.create({ url: file.webUrl });
}

recentFilesMenu.append(a);
Expand Down
14 changes: 7 additions & 7 deletions Source/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"manifest_version": 3,
"name": "__MSG_appName__",
"version": "10.1",
"version": "11.0",
"description": "__MSG_appDesc__",
"default_locale": "en",
"short_name": "ONLYOFFICE",
Expand All @@ -10,7 +10,7 @@
"48": "icon_48.png",
"128": "icon_128.png"
},
"browser_action": {
"action": {
"default_icon": {
"16": "icon_16.png",
"24": "icon_24.png",
Expand All @@ -20,18 +20,18 @@
"default_title": "__MSG_appName__"
},
"background": {
"scripts": [ "js/constants.js", "js/files.js", "js/background.js" ]
"service_worker": "background.js"
},
"content_scripts": [{
"matches": [ "https://*/favicon.ico", "https://*/favicon.ico" ],
"all_frames": true,
"js": [ "js/inject.js" ]
}],
"permissions": [
"storage",
"https://personal.onlyoffice.com/"
"storage"
],
"optional_permissions": [
"host_permissions": [
"https://personal.onlyoffice.com/",
"https://*/",
"https://*/"
]
Expand Down

0 comments on commit 725af45

Please sign in to comment.