navigator.share

This commit is contained in:
2019-06-04 20:14:25 +02:00
parent 1261563f31
commit 0b8d67a8eb
4 changed files with 17 additions and 6 deletions

View File

@@ -11,8 +11,8 @@ type PixelWebConfig struct {
const DefaultConfig = `# Pixeldrain Web UI server configuration 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_external = "/api" # Used in the web browser
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_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" static_resource_dir = "res/static"
template_dir = "res/template" template_dir = "res/template"
debug_mode = false debug_mode = false

View File

@@ -110,10 +110,20 @@ var Toolbar = {
} }
}; };
var Sharebar = { var Sharebar = {
visible: false, visible: false,
toggle: function(){ toggle: function(){
if (navigator.share) {
navigator.share({
title: Viewer.title,
text: "Get this file from Pixeldrain!",
url: window.location.href
});
return;
}
if (!Toolbar.visible){ if (!Toolbar.visible){
Toolbar.toggle(); Toolbar.toggle();
} }

View File

@@ -2,6 +2,7 @@
var Viewer = { var Viewer = {
currentFile: "", currentFile: "",
title: "", // Contains either the file name or list title
listId: "", listId: "",
isList: false, isList: false,
isFile: false, isFile: false,
@@ -14,18 +15,18 @@ var Viewer = {
// On small screens the toolbar takes too much space, so it collapses automatically // On small screens the toolbar takes too much space, so it collapses automatically
if($("#filepreview").width() < 400 && Toolbar.visible){ if($("#filepreview").width() < 400 && Toolbar.visible){
window.setTimeout(function(){
Toolbar.toggle(); Toolbar.toggle();
}, 800);
} }
if(type === "file"){ if(type === "file"){
this.isFile = true; this.isFile = true;
this.currentFile = data.id; this.currentFile = data.id;
this.title = data.name;
this.setFile(data); this.setFile(data);
} else if (type === "list") { } else if (type === "list") {
this.isList = true; this.isList = true;
this.listId = data.id; this.listId = data.id;
this.title = data.title;
ListNavigator.init(data.data); ListNavigator.init(data.data);
} }

View File

@@ -314,7 +314,7 @@ var UploadWorker = /** @class */ (function () {
}; };
UploadWorker.prototype.newFile = function () { UploadWorker.prototype.newFile = function () {
var file = this.manager.grabFile(); var file = this.manager.grabFile();
if (file === undefined) { // No more files in the queue. We're finished if (file === undefined) {
this.uploading = false; this.uploading = false;
console.debug("No files left in queue"); console.debug("No files left in queue");
return; // Stop the thread return; // Stop the thread