277 lines
7.8 KiB
HTML
277 lines
7.8 KiB
HTML
<%#
|
|
Argon is a clean HTML5 theme for LuCI. It is based on luci-theme-bootstrap and MUI and Argon Template
|
|
|
|
luci-theme-argon
|
|
Copyright 2020 Jerryk <jerrykuku@gmail.com>
|
|
|
|
Have a bug? Please create an issue here on GitHub!
|
|
https://github.com/jerrykuku/luci-theme-argon/issues
|
|
|
|
luci-theme-bootstrap:
|
|
Copyright 2008 Steven Barth <steven@midlink.org>
|
|
Copyright 2008-2016 Jo-Philipp Wich <jow@openwrt.org>
|
|
Copyright 2012 David Menting <david@nut-bolt.nl>
|
|
|
|
MUI:
|
|
https://github.com/muicss/mui
|
|
|
|
Agron Theme
|
|
https://demos.creative-tim.com/argon-dashboard/index.html
|
|
|
|
Licensed to the public under the Apache License 2.0
|
|
-%>
|
|
|
|
<%+header_login%>
|
|
<%
|
|
local util = require "luci.util"
|
|
local uci = require "luci.model.uci".cursor()
|
|
logosize = uci:get("custom", "logo", "size")
|
|
if logosize == nil then
|
|
logosize = "small"
|
|
end
|
|
|
|
function file_exists(name)
|
|
local f=io.open(name,"r")
|
|
if f~=nil then io.close(f) return true else return false end
|
|
end
|
|
|
|
local boardinfo = util.ubus("system", "board")
|
|
if boardinfo.model == nil then
|
|
boardinfo.model = " "
|
|
end
|
|
if file_exists("/etc/custom") then
|
|
file = io.open("/etc/custom", "r")
|
|
board = file:read("*line")
|
|
model = file:read("*line")
|
|
hostname = file:read("*line")
|
|
file:close()
|
|
else
|
|
board = boardinfo.model
|
|
model = boardinfo.model
|
|
end
|
|
local headername = ""
|
|
local file = io.open("/etc/header_msg", "r")
|
|
if file ~= nil then
|
|
line = file:read("*line")
|
|
line = line:gsub("<model>", model)
|
|
headername = headername .. line
|
|
line = file:read("*line")
|
|
line = file:read("*line")
|
|
linex = file:read("*line")
|
|
if linex ~= nil then
|
|
img_name = resource .. linex
|
|
else
|
|
img_name = resource .. "/img/tomato.png"
|
|
end
|
|
file:close()
|
|
end
|
|
|
|
local fs = require "nixio.fs"
|
|
local nutil = require "nixio.util"
|
|
|
|
function glob(...)
|
|
local iter, code, msg = fs.glob(...)
|
|
if iter then
|
|
return nutil.consume(iter)
|
|
else
|
|
return nil, code, msg
|
|
end
|
|
end
|
|
|
|
function getExtension(str)
|
|
return str:match(".+%.(%w+)$")
|
|
end
|
|
|
|
local bgcount = 0
|
|
local currentBg = {}
|
|
local bgs,attr = {}
|
|
local theme_dir = "/luci-static/background/"
|
|
for i, f in ipairs(glob("/www" .. theme_dir .. "*")) do
|
|
attr = fs.stat(f)
|
|
if attr then
|
|
local ext = getExtension(fs.basename(f))
|
|
if ext == "jpg" or ext == "png" or ext == "gif" or ext == "mp4" then
|
|
local bg = {}
|
|
bg.type = ext
|
|
bg.url = theme_dir .. fs.basename(f)
|
|
table.insert(bgs,bg)
|
|
bgcount = bgcount + 1
|
|
end
|
|
end
|
|
end
|
|
|
|
if bgcount > 0 then
|
|
currentBg = bgs[math.random(1,bgcount)]
|
|
end
|
|
|
|
iframe = uci:get("iframe", "login", "logframe")
|
|
if iframe == nil then
|
|
iframe = "0"
|
|
end
|
|
if iframe == "1" then
|
|
os.execute("/usr/lib/iframe/update.sh")
|
|
ifloc = uci:get("iframe", "login", "logtype")
|
|
ifimg = "/luci-static/img/" .. uci:get("iframe", "login", "logimage")
|
|
ifr = true
|
|
else
|
|
ifr = false
|
|
end
|
|
|
|
%>
|
|
<style type="text/css">
|
|
body {
|
|
overflow: scroll; /* Show scrollbars */
|
|
|
|
html {
|
|
height: 110%;
|
|
margin-bottom: 0.01em;
|
|
font-size: 1.1vw;
|
|
}
|
|
}
|
|
</style>
|
|
<div class="login-page">
|
|
<% if (bgcount > 0 and currentBg.type == "mp4") then %>
|
|
<div class="video">
|
|
<video autoplay loop muted id="video">
|
|
<source src="<%=currentBg.url%>" type="video/mp4">
|
|
</video>
|
|
</div>
|
|
<div class="volume-control mute"></div>
|
|
<script>
|
|
$(".volume-control").click(function(){
|
|
if($(this).hasClass("mute")){
|
|
$(this).removeClass("mute")
|
|
$("#video").prop('muted', false);
|
|
}else{
|
|
$(this).addClass("mute")
|
|
$("#video").prop('muted', true);
|
|
}
|
|
})
|
|
</script>
|
|
<% else %>
|
|
<div class="main-bg" id="main-bg"
|
|
<%
|
|
if (bgcount == 0 ) then
|
|
local http = require "luci.sys"
|
|
local json = require "luci.jsonc"
|
|
local bg_url = media .. "/img/bg1.jpg"
|
|
local bing = http.httpget("http://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US")
|
|
if (bing and bing ~= '') then
|
|
local bingjson = json.parse(bing)
|
|
bg_url = "https://www.bing.com" .. bingjson.images[1].url
|
|
end
|
|
%>
|
|
style="background-image:url(<%=bg_url%>)"
|
|
<% elseif (bgcount > 0 and currentBg["type"] ~= "mp4") then %>
|
|
style="background-image:url(<%=currentBg.url%>)"
|
|
<% end %>
|
|
></div>
|
|
|
|
<% end %>
|
|
|
|
<div class="login-container">
|
|
<div class="login-form">
|
|
<%if logosize == "small" then%>
|
|
<a class="brand" href="/"><img src="/luci-static/img/open.png" class="icon"><span
|
|
class="brand-text"><%=striptags( (headername or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %></span></a>
|
|
<%else%>
|
|
<a class="brand" href="/"><img src="/luci-static/img/open.png" class="icon-lg"></a>
|
|
<a class="brandlg" ><span class="brand-textlg"><%=striptags( (headername or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %></span></a>
|
|
<% end %>
|
|
|
|
<form class="form-login" method="post" action="<%=pcdata(luci.http.getenv("REQUEST_URI"))%>">
|
|
|
|
<%- if fuser then %>
|
|
<div class="errorbox"><%:Invalid username and/or password! Please try again.%></div>
|
|
<% end -%>
|
|
|
|
<div class="input-container">
|
|
<div class="input-group user-icon">
|
|
<input class="cbi-input-user" id="cbi-input-user" type="text" name="luci_username" value="<%=duser%>" />
|
|
<label class="border" for="cbi-input-user"></label>
|
|
</div>
|
|
<div class="input-group pass-icon">
|
|
<input class="cbi-input-password" id="cbi-input-password" type="password" name="luci_password" />
|
|
<label class="border" for="cbi-input-password"></label>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<input type="submit" value="<%:Login%>" class="cbi-button cbi-button-apply" />
|
|
</div>
|
|
</form>
|
|
|
|
<%if ( ifr ) then%>
|
|
<%if ( ifloc == "3" ) then%>
|
|
<div class="login-iframe">
|
|
<div class="login-iform">
|
|
<a class="ifframe"><iframe src="/luci-static/display.html" id="Iframe" title="Iframe Example" width="100%" height="100%"</iframe></a>
|
|
</div>
|
|
</div>
|
|
<% else%>
|
|
<%if ( ifloc == "1" ) then%>
|
|
<div class="login-iframem">
|
|
<div class="login-iform">
|
|
<a class="ifframe"><iframe src="/luci-static/display.html" id="Iframe" title="Iframe Example" width="100%" height="100%"</iframe></a>
|
|
</div>
|
|
</div>
|
|
<% else%>
|
|
<a class="brandim" href="/"><img src="<%=ifimg%>" class="icon-im"></a>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<script type="text/javascript">//<![CDATA[
|
|
// Selecting the iframe element
|
|
var frame = document.getElementById("Iframe");
|
|
|
|
// Adjusting the iframe height onload event
|
|
frame.onload = function()
|
|
// function execute while load the iframe
|
|
{
|
|
// set the height of the iframe as
|
|
// the height of the iframe content
|
|
frame.style.height =
|
|
frame.contentWindow.document.body.scrollHeight + 'px';
|
|
|
|
|
|
// set the width of the iframe as the
|
|
// width of the iframe content
|
|
frame.style.width =
|
|
frame.contentWindow.document.body.scrollWidth+'px';
|
|
|
|
}
|
|
//]]></script>
|
|
|
|
<script type="text/javascript">//<![CDATA[
|
|
var input = document.getElementsByName('luci_password')[0];
|
|
if (input)
|
|
input.focus();
|
|
//]]></script>
|
|
<%
|
|
local uci = require "luci.model.uci".cursor()
|
|
local fs = require "nixio.fs"
|
|
local https_key = uci:get("uhttpd", "main", "key")
|
|
local https_port = uci:get("uhttpd", "main", "listen_https")
|
|
if type(https_port) == "table" then
|
|
https_port = https_port[1]
|
|
end
|
|
|
|
if https_port and fs.access(https_key) then
|
|
https_port = https_port:match("(%d+)$")
|
|
%>
|
|
|
|
<script type="text/javascript">//<![CDATA[
|
|
if (document.location.protocol != 'https:') {
|
|
var url = 'https://' + window.location.hostname + ':' + '<%=https_port%>' + window.location.pathname;
|
|
var img = new Image;
|
|
img.onload = function () { window.location = url };
|
|
img.src = 'https://' + window.location.hostname + ':' + '<%=https_port%>' + '<%=resource%>/cbi/up.gif?' + Math.random();;
|
|
setTimeout(function () {
|
|
img.src = ''
|
|
}, 5000);
|
|
}
|
|
//]]></script>
|
|
<% end %>
|
|
|
|
|