123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <strong>Fails / Requêtes :</strong> <span id="fail">0</span>/<span id="tries">0</span><br />
- Délai entre deux requêtes : <input type="text" id="ms" maxlength="4" style="width:40px" value="1" />ms <input type="submit" id="go" value="Go!" /><br />
- <p>Fail si :
- <ul>
- <li>Noms de catégories identiques</li>
- <li>Une (au moins) catégorie vide</li>
- <li>Pas assez de questions</li>
- <li>Pas assez de thèmes</li>
- </ul>
- </p>
-
- <script src="js/jquery-2.1.4.min.js"></script>
- <script>
- var tries = 0;
- var fail = 0;
- var goon = false;
- var delay = 1;
-
- function yolo() {
- tries++;
- $.ajax({
- async: false,
- url: './api/',
- dataType: 'json',
- success: function(json) {
- var questions = 0;
- var themes = json.cat1.themes.length + json.cat2.themes.length;
- json.cat1.themes.forEach(function(theme) {
- question += theme.questions.length;
- });
- json.cat2.themes.forEach(function(theme) {
- question += theme.questions.length;
- });
- if(json.cat1.nom_cat === json.cat2.nom_cat || json.cat1.nom_cat === "" || json.cat2.nom_cat === ""
- || questions < 2*2*3 || themes < 2*2) {
- fail++;
- }
- }
- })
-
- $("#fail").html(fail);
- $("#tries").html(tries);
- if(goon) window.setTimeout(yolo, delay);
- }
-
- $("#go").on("click", function() {
- if(!goon) $("#go").val("Stop!");
- if(goon) $("#go").val("Go!");
- delay = $("#ms").val()
- goon = !goon;
- yolo();
- });
-
- $(document).on("keypress", function(event) {
- if(event.which === 32) {
- if(!goon) $("#go").val("Stop!");
- if(goon) $("#go").val("Go!");
- delay = $("#ms").val()
- goon = !goon;
- yolo();
- }
- });
- </script>
|