From 0b8d67a8ebbd771e56ece04b78992419d717a27e Mon Sep 17 00:00:00 2001 From: Wim Brand Date: Tue, 4 Jun 2019 20:14:25 +0200 Subject: [PATCH] navigator.share --- init/conf/config.go | 4 ++-- res/static/script/Toolbar.js | 10 ++++++++++ res/static/script/Viewer.js | 7 ++++--- res/static/script/compiled/home.js | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/init/conf/config.go b/init/conf/config.go index 0040027..32fc7b7 100644 --- a/init/conf/config.go +++ b/init/conf/config.go @@ -11,8 +11,8 @@ type PixelWebConfig struct { const DefaultConfig = `# Pixeldrain Web UI server configuration -api_url_external = "https://sia.pixeldrain.com/api" # Used in the web browser, should be a full URL. Not ending with a slash -api_url_internal = "http://127.0.0.1:8080/api" # Used for internal API requests to the pixeldrain server, not visible to users +api_url_external = "/api" # Used in the web browser +api_url_internal = "http://127.0.0.1:8080" # Used for internal API requests to the pixeldrain server, not visible to users static_resource_dir = "res/static" template_dir = "res/template" debug_mode = false diff --git a/res/static/script/Toolbar.js b/res/static/script/Toolbar.js index 8d3f452..5aa290a 100644 --- a/res/static/script/Toolbar.js +++ b/res/static/script/Toolbar.js @@ -110,10 +110,20 @@ var Toolbar = { } }; + var Sharebar = { visible: false, toggle: function(){ + if (navigator.share) { + navigator.share({ + title: Viewer.title, + text: "Get this file from Pixeldrain!", + url: window.location.href + }); + return; + } + if (!Toolbar.visible){ Toolbar.toggle(); } diff --git a/res/static/script/Viewer.js b/res/static/script/Viewer.js index 10f7444..af96508 100644 --- a/res/static/script/Viewer.js +++ b/res/static/script/Viewer.js @@ -2,6 +2,7 @@ var Viewer = { currentFile: "", + title: "", // Contains either the file name or list title listId: "", isList: false, isFile: false, @@ -14,18 +15,18 @@ var Viewer = { // On small screens the toolbar takes too much space, so it collapses automatically if($("#filepreview").width() < 400 && Toolbar.visible){ - window.setTimeout(function(){ - Toolbar.toggle(); - }, 800); + Toolbar.toggle(); } if(type === "file"){ this.isFile = true; this.currentFile = data.id; + this.title = data.name; this.setFile(data); } else if (type === "list") { this.isList = true; this.listId = data.id; + this.title = data.title; ListNavigator.init(data.data); } diff --git a/res/static/script/compiled/home.js b/res/static/script/compiled/home.js index 776224f..9b939a5 100644 --- a/res/static/script/compiled/home.js +++ b/res/static/script/compiled/home.js @@ -314,7 +314,7 @@ var UploadWorker = /** @class */ (function () { }; UploadWorker.prototype.newFile = function () { var file = this.manager.grabFile(); - if (file === undefined) { // No more files in the queue. We're finished + if (file === undefined) { this.uploading = false; console.debug("No files left in queue"); return; // Stop the thread