-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Js/fix eslint #413
Js/fix eslint #413
Changes from 6 commits
b61ae7b
bd5d98e
99b45b3
1797794
f59ebb4
01c9311
7502143
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,13 +16,6 @@ | |
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
// | ||
// Inspired from https://github.com/declandewet/common-tags/ lib | ||
function stripIndent(html) { | ||
// remove the shortest leading indentation from each line | ||
const indent = Math.min(...html[0].match(/^[ \t]*(?=\S)/gm).map(el => el.length)); | ||
return html[0].replace(new RegExp('^[ \\t]{' + indent + '}', 'gm'), ''); | ||
} | ||
|
||
function number_write(x) { | ||
const text_box = document.getElementById("number"); | ||
|
@@ -52,7 +45,7 @@ class NumPad { | |
|
||
const div = document.createElement('div'); | ||
div.setAttribute('class', 'panel panel-info'); | ||
div.innerHTML = stripIndent` | ||
div.innerHTML = ` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't know why I found that cool back in 2015... |
||
<div id="saisie" class="panel-heading input-group"> | ||
<input type="text" class="form-control" placeholder="Masse" id="number" name="num"> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -229,7 +229,9 @@ const fillItems = (div, types, push) => { | |
*/ | ||
function ticketUpdateUI(container, totalUI, bag, value) { | ||
// Constitution du panier | ||
const { _, nom, couleur, id_last_insert, ticket } = bag; | ||
const { | ||
_, nom, couleur, id_last_insert, ticket, | ||
} = bag; | ||
const li = document.createElement('li'); | ||
li.setAttribute('class', 'list-group-item'); | ||
const span = '<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>'; | ||
|
@@ -316,7 +318,7 @@ function recycleurReset() { | |
element.selected = false; | ||
}); | ||
Array.from(document.getElementById('list_evac').children) | ||
.forEach(btn => btn.setAttribute('style', 'display: none; visibility: hidden')); | ||
.forEach((btn) => btn.setAttribute('style', 'display: none; visibility: hidden')); | ||
} | ||
|
||
/** Fonction de remise à zéro de l'interface graphique et des tickets en cours. | ||
|
@@ -385,16 +387,16 @@ function login(onSuccess = undefined) { | |
const form = new FormData(document.getElementById('formLogin')); | ||
const username = form.get('mail'); | ||
const password = form.get('pass'); | ||
const fetchPromise = fetch('../moteur/login_post.php', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
fetch('../moteur/login_post.php', { | ||
method: 'POST', | ||
credidentials: 'include', | ||
headers: { | ||
'Accept': 'application/json', | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json; charset=utf-8', | ||
}, | ||
body: JSON.stringify({ username, password }), | ||
}).then(status) | ||
.then((json) => { | ||
.then((_) => { | ||
container.setAttribute('style', 'visibility: hidden; opacity: 0;'); | ||
if (onSuccess) { | ||
onSuccess(); | ||
|
@@ -459,7 +461,7 @@ function post_data(url, getData, onFinalise, onImpress = (_, a) => a) { | |
credentials: 'include', | ||
method: 'POST', | ||
headers: { | ||
'Accept': 'application/json', | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json; charset=utf-8', | ||
}, | ||
body: JSON.stringify(data), | ||
|
@@ -557,12 +559,12 @@ const dashBreak = '<p>-----------------------------------</p>'; | |
* - window.OressourceEnv.types_evac | ||
* - window.OressourceEnv.types_dechet | ||
*/ | ||
function showTickets(data, unit = 'kg') { | ||
function showTickets(data) { | ||
const item = (data.hasOwnProperty('items') && data.items.length > 0 | ||
? `<p>Ventes</p>${dashBreak}${showTicket(data.items, window.OressourceEnv.types_dechet, unit)}` | ||
? `<p>Ventes</p>${dashBreak}${showTicket(data.items, window.OressourceEnv.types_dechet)}` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
: ''); | ||
return item + (data.hasOwnProperty('evacs') && data.evacs.length > 0 | ||
? `<p>Matériaux</p>${dashBreak}${showTicket(data.evacs, window.OressourceEnv.types_evac, unit)}` | ||
? `<p>Matériaux</p>${dashBreak}${showTicket(data.evacs, window.OressourceEnv.types_evac)}` | ||
: ''); | ||
} | ||
|
||
|
@@ -593,9 +595,9 @@ function showTicket(data, types) { | |
* @param {number} moyenId moyenId represente un id valide de moyen de paiement. | ||
* @returns {string} Nom du moyen de paiement ou "Moyen de paiement inconnu!" | ||
*/ | ||
const showMoyen = (moyens, moyenId) => { | ||
return moyens.find(({id}) => id === moyenId).nom || "moyen de paiement inconnu!"; | ||
} | ||
const showMoyen = (moyens, moyenId) => ( | ||
moyens.find(({id}) => id === moyenId).nom || "moyen de paiement inconnu!" | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just little trick to remove |
||
|
||
/** | ||
* Represente un moyen de paiement comme une chaine de caractère. | ||
|
@@ -606,7 +608,7 @@ const showMoyen = (moyens, moyenId) => { | |
const showPaiement = (moyenId) => { | ||
const moyens = window.OressourceEnv.moyens_paiement || null; | ||
return (moyens ? `<p>Payé en ${showMoyen(moyens, moyenId)}</p>` : ''); | ||
} | ||
}; | ||
|
||
/** | ||
* Cette fonction construit une <IFrame/> et l'imprime et l'iframe est détruite | ||
|
@@ -620,7 +622,7 @@ const showPaiement = (moyenId) => { | |
* @globals window.OressourceEnv.adresse | ||
* @global moment bibliothèque d'internationnalisation des dates | ||
*/ | ||
function impressionTicket(data, response, unit = 'kg', tvaStuff = () => '', sumFunc = sumMasseTickets) { | ||
function impressionTicket(data, response, tvaStuff = () => '') { | ||
const title = classeToName(data.classe); | ||
// Hack affreux pour gérer les ventes car on utilise pas un objet si global dans leur gestion. | ||
const html = ` | ||
|
@@ -639,24 +641,22 @@ function impressionTicket(data, response, unit = 'kg', tvaStuff = () => '', sumF | |
${showPaiement(data.id_moyen)} | ||
<p>Ticket client à conserver.</p> | ||
<p>Date d'édition du ticket : ${moment().format('DD/MM/YYYY - HH:mm')}</p> | ||
${showTickets(data, unit)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was never read in |
||
${showTickets(data)} | ||
</body> | ||
</html>`; | ||
|
||
const iframe = document.createElement('iframe'); | ||
function closePrint() { | ||
document.body.removeChild(this.__container__); | ||
} | ||
|
||
function setPrint() { | ||
iframe.onload = function () { | ||
this.contentWindow.__container__ = this; | ||
this.contentWindow.onbeforeunload = closePrint; | ||
this.contentWindow.onafterprint = closePrint; | ||
this.contentWindow.focus(); | ||
this.contentWindow.print(); | ||
} | ||
|
||
const iframe = document.createElement('iframe'); | ||
iframe.onload = setPrint; | ||
}; | ||
iframe.style.visibility = 'hidden'; | ||
iframe.style.position = 'fixed'; | ||
iframe.style.right = 0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed it ended up eating CPU in the wild.