js uglify example

master
Juan 3 years ago
parent b24e090421
commit db527a4ef4

@ -0,0 +1,13 @@
## source
https://www.npmjs.com/package/uglify-js
## installer uglify
npm install -g uglify-js
## compresser le js :
uglifyjs .\scripts-sources\main.js --compress -o .\scripts\main.js
## compresser avec source map
uglifyjs .\scripts-sources\main.js --compress --source-map -o .\scripts\main.js

@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<title>Réveil</title>
<link rel="stylesheet" href="style.css" />
<script type="text/javascript" src="scripts/main.js" async></script>
</head>
<body>
<main role="main">
<div>
Bonjour !
<div
id="loaded"
role="info"
aria-live="polite"
aria-hidden="true"
aria-label="état du document"></div>
réveillé à
<progress
id="pourcent-reveil"
aria-valuemin="0"
aria-valuemax="100"
aria-valuenow="10"
role="progressbar"
value="10" max="100"></progress>
<span id="finished" style="display:none;"> 100%</span>
</div>
<div
id="warning"
role="alert"
aria-live="assertive"
aria-hidden="true"
aria-label="état de la communication serveur"></div>
<ul>
<li lang="french">lien en français</li>
<li lang="en">In <span class="red blue white">English</span> please</li>
<li lang="français">lien en fran&ccedil;ais</li>
<li lang="zxx">Lorem Ipsum</li>
<li lang="fr-CA">Tabernacle!</li>
<li lang="es">Me llamo Juan</li>
<li lang="en-US">American English</li>
<li lang="de">Auf Deutsch</li>
<li lang="de"><span class="tankredi">Auf Deutsch</span></li>
<li lang="de"><span class="red">Auf Deutsch</span></li>
<li lang="de"><span class="red-blue">Auf Deutsch</span></li>
<li lang="de"><span class="redblue">Auf Deutsch</span></li>
</ul>
</div>
</main>
</body>
</html>

@ -0,0 +1,52 @@
console.log('scripts loaded');
document.onreadystatechange = function(event) {
if (document.readyState === "complete") {
if(document.getElementById('pourcent-reveil'))
{
console.log('has progress bar');
setcurrentprogress(document.getElementById('pourcent-reveil'),5);
updateprogress(document.getElementById('pourcent-reveil'),5);
}
if(oLoaded = document.getElementById('loaded'))
{
console.log('has live content');
oLoaded.setAttribute("class","shown");
oLoaded.removeAttribute("aria-hidden","true");
oLoaded.innerHTML="Document chargé!";
oLoaded.setAttribute("aria-live","off");
setTimeout(warning, 1500);
}
document.getElementById('doesnotexist').getAttribute('value');
}
}
function warning()
{
if(document.getElementById('warning'))
{
document.getElementById('warning').innerHTML="Erreur de communication avec le serveur!";
document.getElementById('warning').setAttribute("class","shown");
document.getElementById('warning').removeAttribute("aria-hidden");
}
}
function setcurrentprogress(obj,value)
{
obj.setAttribute("value",value);
obj.setAttribute("aria-valuenow",value);
}
function updateprogress(obj, step=5)
{
currentprogress = parseInt(obj.getAttribute("value")) + step;
if(currentprogress >= 100)
{
console.log("finished");
setcurrentprogress(obj,100);
document.getElementById("finished").setAttribute("style","");
return;
}
console.log("updateprogress to "+currentprogress);
setcurrentprogress(obj,currentprogress);
setTimeout(updateprogress, 500, obj);
}

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

@ -0,0 +1,287 @@
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
h4 {
font-size: 14px;
}
body, figure, img {
padding: 0;
border: none;
margin: 0;
}
#switch:checked ~ p {
background-color: green;
}
.img-wrap img {
width: calc(100% - (8px*2));
height: auto;
margin: 8px;
top: 50%;
transform: translateY(-25%);
}
picture {
position: relative;
display: block;
max-height: 40vh;
overflow: hidden;
}
#main-menu {
text-align: center;
}
#main-menu ul {
list-style: none;
}
#main-menu li {
text-align: left;
}
#main-menu li a,
#main-menu li span,
#main-menu li label {
color: black;
text-decoration: none;
font-size: 1.1rem;
}
#main-menu li span {
color: #666;
}
#main-menu .menu-label {
font-size: 1.5rem;
color: black;
text-decoration: none;
font-weight: bold;
display: inline-block;
line-height: 2rem;
}
.burger {
float: left;
margin: 3px 8px;
}
.burger b, .burger i {
display: block;
width: 20px;
}
.burger b {
height: 2px;
margin-bottom: 5px;
position: relative;
background: #000;
border-radius: 2px;
z-index: 1;
}
.burger b:first-of-type {
margin-top: 5px;
}
.burger i {
color: blue;
}
#main-menu ul {
display: none;
}
main, h1 {
margin: 1rem;
padding: 1rem;
}
#main-menu #switch:checked ~ ul {
display: block;
}
.contact-form-wrap {
display: none;
}
#show-contact:checked ~ .contact-form-wrap {
display: block;
}
.contact-form-wrap {
position: fixed;
background-color: rgba(0, 0, 0, 0.25);
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.contact-form-wrap .h3 {
color: white;
text-align: center;
margin-top: 120px;
}
.cf-form {
background-color: white;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 20px;
border-radius: 20px;
}
.cf-input, .cf-label {
min-height: 20px;
line-height: 20px;
box-sizing: border-box;
width: 100%;
min-width: 30vh;
}
.cf-input {
border: solid 1px #666;
border-radius: 4px;
padding: 4px;
}
.cf-label {
line-height: 30px;
box-sizing: border-box;
}
.cf-btn {
background-color: black;
color: white;
padding-left: 10px;
padding-right: 10px;
margin-top: 4px;
}
.cf-btn:hover {
background-color: white;
color: black;
transition: color 0.5s;
}
.cf-input-group:after {
content: "";
display: table;
clear: both;
overflow: auto;
}
.cf-close-wrap {
margin: -10px -10px 0 -20px;
}
.cf-close {
display: block;
position: relative;
box-sizing: border-box;
float: right;
clear: both;
font-size: 20px;
}
.icon-radio-checked {
display: none;
color: green;
}
.icon-radio-unchecked {
color: red;
}
#abonnement-oui:checked ~ .ct-radio .icon-radio-checked {
display: inline;
}
#abonnement-oui:checked ~ .ct-radio .icon-radio-unchecked {
display: none;
}
#abonnement-non:checked ~ .ct-radio .icon-radio-checked {
display: inline;
}
#abonnement-non:checked ~ .ct-radio .icon-radio-unchecked {
display: none;
}
.hidden,
*[aria-hidden] {
display: none !important;
}
.grand-L {
height: 16px;
}
main, aside {
box-sizing: border-box;
}
main {
width: calc(100% - 27vw);
}
.main-stat {
max-width: 73vw;
float: left;
margin: 10px 0 10px -2rem;
}
aside {
width: 25vw;
right: 0;
top: 75px;
position: fixed;
}
aside img {
max-width: 100%;
}
footer {
color: #a9a9a9;
border-top: solid 1px #000;
padding: 10px;
}
a[lang=fr]:after, a[target=_blank]:after {
color: blueviolet;
}
a[lang=fr]::after {
content: " [fr]";
}
a[target=_blank]::after {
content: " [^]";
}
#loaded {
background-color: #ccF;
border-left: solid 3px blue;
color: darkblue;
padding: 3px;
}
#warning {
background-color: #Fed;
border-left: solid 3px red;
color: darkred;
padding: 3px;
}
li[lang] {
color: #ccc;
}
li[lang=fr] {
color: darkblue;
}
li[lang^=fr] {
color: darkblue;
}
li[lang$=CA] {
color: blue;
}
li[lang*="-"] {
font-weight: bold;
}
span[class~=red] {
color: red;
}
span[class|=red] {
color: darkred;
}
/*# sourceMappingURL=style-main.css.map */
Loading…
Cancel
Save