Merge branch 'master' of fornaxian.com:Pixeldrain/pixeldrain-web
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
function DetailsWindow(viewer) {
|
||||
this.viewer = viewer
|
||||
this.visible = false
|
||||
this.fileID = ""
|
||||
this.file = null
|
||||
this.graph = 0
|
||||
|
||||
this.divPopup = document.getElementById("details_popup")
|
||||
@@ -32,16 +32,16 @@ DetailsWindow.prototype.toggle = function() {
|
||||
if (this.graph === 0) {
|
||||
this.renderGraph()
|
||||
}
|
||||
this.updateGraph(this.fileID)
|
||||
this.updateGraph(this.file)
|
||||
}
|
||||
}
|
||||
|
||||
DetailsWindow.prototype.setDetails = function(file) {
|
||||
DetailsWindow.prototype.setFile = function(file) {
|
||||
this.file = file
|
||||
let desc = ""
|
||||
if (this.viewer.isList) {
|
||||
desc = file.description
|
||||
}
|
||||
this.fileID = file.id
|
||||
this.divFileDetails.innerHTML = "<table>"
|
||||
+ "<tr><td>Name<td><td>" + escapeHTML(file.name) + "</td></tr>"
|
||||
+ "<tr><td>URL<td><td><a href=\""+file.link+"\">"+file.link+"</a></td></tr>"
|
||||
|
@@ -93,7 +93,7 @@ Toolbar.prototype.download = function() {
|
||||
return
|
||||
}
|
||||
|
||||
fetch(this.currentFile.file_availability_href).then(resp => {
|
||||
fetch(this.currentFile.availability_href).then(resp => {
|
||||
return resp.json()
|
||||
}).then(resp => {
|
||||
let popupDiv = document.getElementById("captcha_popup")
|
||||
|
@@ -54,8 +54,8 @@ function Viewer(type, viewToken, data) {
|
||||
this.setFile(fileFromSkyNet(data))
|
||||
}
|
||||
|
||||
this.renderSponsors()
|
||||
window.addEventListener("resize", e => { this.renderSponsors(e) })
|
||||
// this.renderSponsors()
|
||||
// window.addEventListener("resize", e => { this.renderSponsors(e) })
|
||||
|
||||
// Register keyboard shortcuts
|
||||
document.addEventListener("keydown", e => { this.keyboardEvent(e) })
|
||||
@@ -74,8 +74,8 @@ Viewer.prototype.setFile = function(file) {
|
||||
document.title = file.name + " ~ pixeldrain"
|
||||
}
|
||||
|
||||
// Update the file details
|
||||
this.detailsWindow.setDetails(file)
|
||||
// Relay the file change event to all components
|
||||
this.detailsWindow.setFile(file)
|
||||
this.toolbar.setFile(file)
|
||||
|
||||
// Register a new view. We don't care what this returns becasue we can't
|
||||
@@ -129,40 +129,40 @@ Viewer.prototype.setFile = function(file) {
|
||||
}
|
||||
}
|
||||
|
||||
Viewer.prototype.renderSponsors = function() {
|
||||
let scale = 1
|
||||
let scaleWidth = 1
|
||||
let scaleHeight = 1
|
||||
let minWidth = 728
|
||||
let minHeight = 800
|
||||
// Viewer.prototype.renderSponsors = function() {
|
||||
// let scale = 1
|
||||
// let scaleWidth = 1
|
||||
// let scaleHeight = 1
|
||||
// let minWidth = 728
|
||||
// let minHeight = 800
|
||||
|
||||
if (window.innerWidth < minWidth) {
|
||||
scaleWidth = window.innerWidth/minWidth
|
||||
}
|
||||
if (window.innerHeight < minHeight) {
|
||||
scaleHeight = window.innerHeight/minHeight
|
||||
}
|
||||
scale = scaleWidth < scaleHeight ? scaleWidth : scaleHeight
|
||||
// if (window.innerWidth < minWidth) {
|
||||
// scaleWidth = window.innerWidth/minWidth
|
||||
// }
|
||||
// if (window.innerHeight < minHeight) {
|
||||
// scaleHeight = window.innerHeight/minHeight
|
||||
// }
|
||||
// scale = scaleWidth < scaleHeight ? scaleWidth : scaleHeight
|
||||
|
||||
// Because of the scale transformation the automatic margins don't work
|
||||
// anymore. So we have to maunally calculate the margin. Where we take the
|
||||
// width of the viewport - the width of the ad to calculate the amount of
|
||||
// pixels around the ad. We multiply the ad size by the scale we calcualted
|
||||
// to account for the smaller size.
|
||||
let offset = (window.innerWidth - (minWidth*scale)) / 2
|
||||
if (offset < 0) {
|
||||
offset = 0
|
||||
}
|
||||
document.querySelector(".sponsors > iframe").style.marginLeft = offset+"px"
|
||||
// // Because of the scale transformation the automatic margins don't work
|
||||
// // anymore. So we have to maunally calculate the margin. Where we take the
|
||||
// // width of the viewport - the width of the ad to calculate the amount of
|
||||
// // pixels around the ad. We multiply the ad size by the scale we calcualted
|
||||
// // to account for the smaller size.
|
||||
// let offset = (window.innerWidth - (minWidth*scale)) / 2
|
||||
// if (offset < 0) {
|
||||
// offset = 0
|
||||
// }
|
||||
// document.querySelector(".sponsors > iframe").style.marginLeft = offset+"px"
|
||||
|
||||
if (scale == 1) {
|
||||
document.querySelector(".sponsors > iframe").style.transform = "none"
|
||||
document.querySelector(".sponsors").style.height = "90px"
|
||||
} else {
|
||||
document.querySelector(".sponsors > iframe").style.transform = "scale("+scale+")"
|
||||
document.querySelector(".sponsors").style.height = (scale*90)+"px"
|
||||
}
|
||||
}
|
||||
// if (scale == 1) {
|
||||
// document.querySelector(".sponsors > iframe").style.transform = "none"
|
||||
// document.querySelector(".sponsors").style.height = "90px"
|
||||
// } else {
|
||||
// document.querySelector(".sponsors > iframe").style.transform = "scale("+scale+")"
|
||||
// document.querySelector(".sponsors").style.height = (scale*90)+"px"
|
||||
// }
|
||||
// }
|
||||
|
||||
Viewer.prototype.keyboardEvent = function(evt) {
|
||||
if (evt.ctrlKey || evt.altKey) {
|
||||
@@ -243,8 +243,8 @@ function fileFromAPIResp(resp) {
|
||||
function fileFromSkyNet(resp) {
|
||||
let file = fileFromAPIResp(resp)
|
||||
file.icon_href = "/res/img/mime/empty.png"
|
||||
file.get_href = "https://siasky.net/"+resp.id
|
||||
file.download_href = "https://siasky.net/"+resp.id+"?attachment=1"
|
||||
file.get_href = "https://sky.pixeldrain.com/"+resp.id
|
||||
file.download_href = "https://sky.pixeldrain.com/"+resp.id+"?attachment=1"
|
||||
file.availability_href = ""
|
||||
file.view_href = ""
|
||||
file.timeseries_href = ""
|
||||
|
Reference in New Issue
Block a user