Minify css and js files

This commit is contained in:
Martin Boehm 2023-01-25 23:54:58 +01:00 committed by Martin
parent 184b6b762f
commit 250a788d20
8 changed files with 34 additions and 27 deletions

View File

@ -343,6 +343,9 @@ func (s *PublicServer) newTemplateData(r *http.Request) *TemplateData {
InternalExplorer: s.internalExplorer && !s.is.InitialSync, InternalExplorer: s.internalExplorer && !s.is.InitialSync,
TOSLink: api.Text.TOSLink, TOSLink: api.Text.TOSLink,
} }
if !s.debug {
t.Minified = ".min.1"
}
if s.is.HasFiatRates { if s.is.HasFiatRates {
// get the secondary coin and if it should be shown either from query parameters "secondary" and "use_secondary" // get the secondary coin and if it should be shown either from query parameters "secondary" and "use_secondary"
// or from the cookie "secondary_coin" in the format secondary=use_secondary, for example EUR=true // or from the cookie "secondary_coin" in the format secondary=use_secondary, for example EUR=true
@ -496,6 +499,7 @@ type TemplateData struct {
NextPage int NextPage int
PagingRange []int PagingRange []int
PageParams template.URL PageParams template.URL
Minified string
TOSLink string TOSLink string
SendTxHex string SendTxHex string
Status string Status string

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,8 @@
@import "TTHoves/TTHoves.css"; @import "TTHoves/TTHoves.css";
* { * {
margin: 0px; margin: 0;
padding: 0px; padding: 0;
outline: none; outline: none;
font-family: "TT Hoves", -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif; font-family: "TT Hoves", -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
} }
@ -253,7 +253,7 @@ span.btn-paging:hover {
.data-table { .data-table {
table-layout: fixed; table-layout: fixed;
overflow-wrap: break-word; overflow-wrap: anywhere;
margin-left: 8px; margin-left: 8px;
margin-top: 2rem; margin-top: 2rem;
margin-bottom: 2rem; margin-bottom: 2rem;

File diff suppressed because one or more lines are too long

1
static/js/main.min.1.js Normal file
View File

@ -0,0 +1 @@
function syntaxHighlight(t){return(t=(t=JSON.stringify(t,void 0,2)).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")).replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,t=>{let e="number";return/^"/.test(t)?e=/:$/.test(t)?"key":"string":/true|false/.test(t)?e="boolean":/null/.test(t)&&(e="null"),`<span class="${e}">${t}</span>`})}function getCoinCookie(){return document.cookie.split("; ").find(t=>t.startsWith("secondary_coin="))?.split("=")}function changeCSSStyle(t,e,l){let a=document.all?"rules":"cssRules";for(i=0,len=document.styleSheets[1][a].length;i<len;i++)if(document.styleSheets[1][a][i].selectorText===t){document.styleSheets[1][a][i].style[e]=l;return}}function amountTooltip(){let t=this.querySelector(".prim-amt"),e=this.querySelector(".sec-amt"),l=this.querySelector(".csec-amt"),a=this.querySelector(".base-amt"),r=this.querySelector(".cbase-amt"),s=`${t.outerHTML}<br>`;if(a){let n=a.getAttribute("tm");n||(n="now"),s+=`<span class="amt-time">${n}</span>${a.outerHTML}<br>`}if(r&&(s+=`<span class="amt-time">now</span>${r.outerHTML}<br>`),e){let o=e.getAttribute("tm");o||(o="now"),s+=`<span class="amt-time">${o}</span>${e.outerHTML}<br>`}return l&&(s+=`<span class="amt-time">now</span>${l.outerHTML}<br>`),`<span class="l-tooltip">${s}</span>`}function addressAliasTooltip(){let t=this.getAttribute("alias-type"),e=this.getAttribute("cc");return`<span class="l-tooltip">${t}<br>${e}</span>`}window.addEventListener("DOMContentLoaded",()=>{let t=getCoinCookie();t?.length===3&&("true"===t[2]&&(changeCSSStyle(".prim-amt","display","none"),changeCSSStyle(".sec-amt","display","initial")),document.querySelectorAll(".amt").forEach(t=>new bootstrap.Tooltip(t,{title:amountTooltip,html:!0}))),document.querySelectorAll("[alias-type]").forEach(t=>new bootstrap.Tooltip(t,{title:addressAliasTooltip,html:!0})),document.querySelectorAll("[tt]").forEach(t=>new bootstrap.Tooltip(t,{title:t.getAttribute("tt")})),document.querySelectorAll("#header .bb-group>.btn-check").forEach(t=>t.addEventListener("click",t=>{let e=getCoinCookie(),l="secondary-coin"===t.target.id;e?.length===3&&"true"===e[2]!==l&&(document.cookie=`${e[0]}=${e[1]}=${l}; Path=/`,changeCSSStyle(".prim-amt","display",l?"none":"initial"),changeCSSStyle(".sec-amt","display",l?"initial":"none"))})),document.querySelectorAll(".copyable").forEach(t=>t.addEventListener("click",t=>{if(t.clientX<t.target.getBoundingClientRect().x){let e=t.target.getAttribute("cc");e||(e=t.target.innerText),navigator.clipboard.writeText(e),t.target.className=t.target.className.replace("copyable","copied"),setTimeout(()=>t.target.className=t.target.className.replace("copied","copyable"),1e3),t.preventDefault()}}))});

View File

@ -5,9 +5,9 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,shrink-to-fit=no"> <meta name="viewport" content="width=device-width,initial-scale=1.0,shrink-to-fit=no">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<link rel="stylesheet" href="/static/css/main.css"> <link rel="stylesheet" href="/static/css/main{{.Minified}}.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
<script src="/static/js/main.js"></script> <script src="/static/js/main{{.Minified}}.js"></script>
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="Trezor {{.CoinLabel}} Explorer"> <meta name="description" content="Trezor {{.CoinLabel}} Explorer">
<title>Trezor {{.CoinLabel}} Explorer</title> <title>Trezor {{.CoinLabel}} Explorer</title>

View File

@ -142,6 +142,7 @@
</table> </table>
</div> </div>
</div> </div>
<span class="text-muted">{{$bb.About}}</span> <span class="text-muted">{{$bb.About}}
{{if .SecondaryCoin}}<span class="text-muted">Exchange rates provided by Coingecko.</span>{{end}} {{if .SecondaryCoin}}<br>Exchange rates provided by Coingecko.{{end}}
</span>
{{end}} {{end}}