Skip to content

Instantly share code, notes, and snippets.

@jubo
Created June 6, 2016 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jubo/e38b0360719d4fb7960dc4cfa53ff7d4 to your computer and use it in GitHub Desktop.
Save jubo/e38b0360719d4fb7960dc4cfa53ff7d4 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<!--
Vous m'évaluez combien ça coûte, ce dev, "à la louche" ?
Auteur : https://twitter.com/juboo_
-->
<html>
<head>
<meta charset="UTF-8" />
<title>Louchotron. Parce que vous le valez bien !</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
crossorigin="anonymous">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<div style='margin:15px'>
<center style="width:900px;">
<h1>Louchotron JS </h1>
</center>
<em>
Petit script JS qui évalue le coût de ton projet... à la louche.
</em>
<div>
<div style="float:left;">
<img src="potion.png" style="width:120px;" />
</div>
<div style="float:left;">
<em>
<ul style="margin-top:60px;" ><li>Un whisky, ça vous irai ? </li>
<li>Oui, mais juste une louche alors ...</li>
<li>Vous ne voulez pas un whisky d'abord ?</li>
</ul>
</em>
</div>
</div>
<div style="clear:both"></div>
<div class="table-responsive">
<table class="table table-striped" style='width:900px;margin:10px' id="lecteurChiffrage">
<thead><th>Libellé</th><th>Estimation (j)</th></thead>
<tr>
<td><input value="Démarrage projet, architecture logicielle" style="width:100%"/></td>
<td></td>
</tr>
<tr>
<td><input value="Interface utilisateur " style="width:100%"/></td>
<td></td>
</tr>
<tr>
<td><input value="Documentation" style="width:100%"/></td>
<td></td>
</tr>
<tr style='font-weight:bold' ><td>Total</td><td></td></tr>
</table>
</div><br />
<input type="button" value="Ajouter un item" id="addItem" style="width:200px;" />
</div>
<script>
function update(override ){
$('table').each(function() {
var ci= this.cellIndex;
var total = 0;
$('td:last-child', $(this))
.each(function() {
if(!$(this).closest('tr').is(':last-child'))
{
var input_libelle = $('input', $(this).prev());
console.log(input_libelle.html());
var loucho_criter = input_libelle.val().length;
console.log("Le criter de la louche, c'est la longueur de l'item :" + loucho_criter);
var louche = $(this).html()*1;
if(!louche || override)
{
if(loucho_criter <= 20)
{
louche = 0.5;
}
else if(loucho_criter <= 100)
{
louche = 2.5;
}
else if(loucho_criter <= 120)
{
louche = 3;
}
else
{
louche = 5;
}
}
$(this).html(louche.toString());
total+= louche*1;
}
else
{
$(this).html(total)
}
});
console.log("Total table : " + $(this).attr("id") + " : " +
total);
});
}
$(document).ready(function()
{
update();
$('input').keyup(function(){ update(true); } );
$('#addItem').click(function()
{
var newrow = $('<tr><td><input style="width:100%" /></td><td></td></tr>');
$('input', newrow).keyup(function() { update(true); });
newrow.insertBefore($('tbody tr:last-child'));
}
);
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment