Mercurial Hosting > linkmystyle
view src/qr_code.html.luan @ 1:2776f06236b4
add source.html
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 11 Jul 2025 21:17:19 -0600 |
parents | 8f4df159f06b |
children |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local Utils = require "site:/lib/Utils.luan" local base_url = Utils.base_url or error() local Shared = require "site:/lib/Shared.luan" local head = Shared.head or error() local body_header = Shared.body_header or error() local footer = Shared.footer or error() local User = require "site:/lib/User.luan" return function() local user = User.current_required() if user==nil then return end local url = base_url().."/"..user.name Io.stdout = Http.response.text_writer() %> <!doctype html> <html lang="en"> <head> <% head() %> <title>Link My Style</title> <style> div[body] { text-align: center; } [qrcode] { display: inline-block; } a[download] { display: inline-block !important; width: 256px !important; } </style> <script type="text/javascript" src="qrcode.js"></script> </head> <body onload="setHref()"> <div full> <% body_header() %> <div body> <h1>QR Code</h1> <span qrcode></span> <p><a download="linkmystyle" button big>Download</a></p> </div> <% footer() %> </div> </body> <script> 'use strict'; let qrcode = new QRCode( document.querySelector('[qrcode]'), { text: '<%=url%>', width: 256, height: 256, } ); //console.log(qrcode); function setHref() { let a = document.querySelector('a[download]'); let img = document.querySelector('[qrcode] img'); //console.log(img.src); a.href = img.src; } </script> </html> <% end