Add QR code to file viewer
This commit is contained in:
35
res/include/script/file_viewer/QRCodeWindow.js
Normal file
35
res/include/script/file_viewer/QRCodeWindow.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
function QRCodeWindow(viewer) {
|
||||||
|
this.viewer = viewer
|
||||||
|
this.visible = false
|
||||||
|
this.modal = new Modal(
|
||||||
|
document.getElementById("file_viewer"),
|
||||||
|
() => { this.toggle() },
|
||||||
|
"QR code", "500px", "auto",
|
||||||
|
)
|
||||||
|
|
||||||
|
this.img = document.createElement("img")
|
||||||
|
this.img.style.display = "block"
|
||||||
|
this.img.style.width = "100%"
|
||||||
|
this.modal.setBody(this.img)
|
||||||
|
|
||||||
|
this.btnQRCode = document.getElementById("btn_qr_code")
|
||||||
|
this.btnQRCode.addEventListener("click", () => { this.toggle() })
|
||||||
|
|
||||||
|
this.setFile()
|
||||||
|
}
|
||||||
|
|
||||||
|
QRCodeWindow.prototype.toggle = function () {
|
||||||
|
if (this.visible) {
|
||||||
|
this.modal.close()
|
||||||
|
this.btnQRCode.classList.remove("button_highlight")
|
||||||
|
this.visible = false
|
||||||
|
} else {
|
||||||
|
this.modal.open()
|
||||||
|
this.btnQRCode.classList.add("button_highlight")
|
||||||
|
this.visible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QRCodeWindow.prototype.setFile = function () {
|
||||||
|
this.img.src = "/api/misc/qr?text=" + encodeURIComponent(window.location.href)
|
||||||
|
}
|
@@ -17,6 +17,7 @@ function Viewer(type, viewToken, data) {
|
|||||||
this.toolbar = new Toolbar(this)
|
this.toolbar = new Toolbar(this)
|
||||||
this.detailsWindow = new DetailsWindow(this)
|
this.detailsWindow = new DetailsWindow(this)
|
||||||
this.editWindow = new EditWindow()
|
this.editWindow = new EditWindow()
|
||||||
|
this.qrCodeWindow = new QRCodeWindow(this)
|
||||||
|
|
||||||
this.divFilepreview = document.getElementById("filepreview")
|
this.divFilepreview = document.getElementById("filepreview")
|
||||||
|
|
||||||
@@ -117,6 +118,7 @@ Viewer.prototype.setFile = function (file) {
|
|||||||
this.detailsWindow.setFile(file)
|
this.detailsWindow.setFile(file)
|
||||||
this.editWindow.setFile(file)
|
this.editWindow.setFile(file)
|
||||||
this.toolbar.setFile(file)
|
this.toolbar.setFile(file)
|
||||||
|
this.qrCodeWindow.setFile()
|
||||||
|
|
||||||
// Register a new view. We don't care what this returns becasue we can't
|
// Register a new view. We don't care what this returns becasue we can't
|
||||||
// do anything about it anyway
|
// do anything about it anyway
|
||||||
|
@@ -69,6 +69,10 @@
|
|||||||
<i class="icon">share</i>
|
<i class="icon">share</i>
|
||||||
<span>Share</span>
|
<span>Share</span>
|
||||||
</button>
|
</button>
|
||||||
|
<button id="btn_qr_code" class="toolbar_button button_full_width">
|
||||||
|
<i class="icon">qr_code</i>
|
||||||
|
<span>QR code</span>
|
||||||
|
</button>
|
||||||
<button id="btn_shuffle" class="toolbar_button button_full_width" style="display: none;" title="Randomize the order of the files in this list">
|
<button id="btn_shuffle" class="toolbar_button button_full_width" style="display: none;" title="Randomize the order of the files in this list">
|
||||||
<i class="icon">shuffle</i>
|
<i class="icon">shuffle</i>
|
||||||
<span>Shuffle ☐</span>
|
<span>Shuffle ☐</span>
|
||||||
@@ -334,6 +338,7 @@
|
|||||||
{{template `Toolbar.js`}}
|
{{template `Toolbar.js`}}
|
||||||
{{template `EditWindow.js`}}
|
{{template `EditWindow.js`}}
|
||||||
{{template `EmbedWindow.js`}}
|
{{template `EmbedWindow.js`}}
|
||||||
|
{{template `QRCodeWindow.js`}}
|
||||||
{{template `DetailsWindow.js`}}
|
{{template `DetailsWindow.js`}}
|
||||||
{{template `AbuseReportWindow.js`}}
|
{{template `AbuseReportWindow.js`}}
|
||||||
{{template `ListNavigator.js`}}
|
{{template `ListNavigator.js`}}
|
||||||
|
Reference in New Issue
Block a user