Advertisement
lincruste

le jazz et le javascript

Dec 23rd, 2016
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    <HTML>
  2.     <HEAD>
  3.     <META http-equiv="content-type" content="text/html; charset=utf-8" />
  4.     <TITLE>Le jazz et le javascript</TITLE>
  5.    
  6. <!--________________________MB/lincruste Technology 2014_(coucou psycho)____-->
  7.  
  8.  
  9.     <SCRIPT language="Javascript">
  10. <!--
  11.  
  12. function accordgen()
  13. {
  14. // Création d'un tableau de notes fondamentales
  15.  
  16. var Note=["A", "B", "C", "D", "E", "F", "G"];
  17. // Création d'un tableau d'altérations
  18.  
  19. var Alteration=["#", "b", ""];
  20. // Création d'un tableau de natures d'accords
  21.  
  22. var Nature=["m", "-7", "-9", "-11", "-Maj7", "7sus4", "7sus4b9", "-6", "-b6", "-7b5", "o", "6", "M9", "Maj7", "Maj7#11", " ", "+", "7", "7b9", "7#11", "7#9", "7#9#11", "13", "13b9", "7add4", "7alt", "9", "Maj7sus4"];
  23.  
  24. // Extraction du nombre de valeurs de chaque tableau
  25.  
  26. var notelength = Note.length;
  27. var altlength = Alteration.length;
  28. var naturelength = Nature.length;
  29.  
  30. // Choix aléatoire d'un nombre pour chaque tableau en fonction du nombre de valeurs
  31.  
  32. var rand1 = Math.floor(Math.random() * notelength);
  33. var rand2 = Math.floor(Math.random() * altlength);
  34. var rand3 = Math.floor(Math.random() * naturelength);
  35.  
  36. // Remplacer B#=C, Cb=B, E#=F, Fb=E
  37. if ((rand1==1)&&(rand2==0)) {
  38.     var rand1 = 2;
  39.     var rand2 = 2;
  40. } else if ((rand1==2)&&(rand2==1)) {
  41.     var rand1 = 1;
  42.     var rand2 = 2;
  43. } else if ((rand1==4)&&(rand2==0)) {
  44.     var rand1 = 5;
  45.     var rand2 = 2;
  46. } else if ((rand1==5)&&(rand2==1)) {
  47.     var rand1 = 4;
  48.     var rand2 = 2;
  49. } else {
  50. var accord = Note[rand1] + Alteration[rand2] + Nature[rand3];
  51. }
  52. return accord
  53. }
  54. //-->
  55. </SCRIPT>
  56.  
  57.  
  58. <!--___________________________________________________________________________________-->
  59.  
  60.  
  61.     <SCRIPT language="Javascript">
  62.     <!--
  63.     function grille() {
  64.     // Créer une référence pour le body
  65.     var body = document.getElementsByTagName("body")[0];
  66.      
  67.     // Création d'éléments <table> et <tbody>
  68.     var tbl     = document.createElement("table");
  69.     var tblBody = document.createElement("tbody");
  70.      
  71.         // Création des cellules
  72.         for (var j = 0; j < 1; j++) {
  73.         // Créer une rangée
  74.         var row = document.createElement("tr");
  75.          
  76.         for (var i = 0; i < 4; i++) {
  77.  
  78.         // Créer un élément <td> et un text node, en faire
  79.         // le contenu du <td> et le placer en fin de rangée
  80.  
  81.  
  82.         var cell = document.createElement("td");
  83.         var cellText = document.createTextNode(accordgen());
  84.         cell.appendChild(cellText);
  85.         row.appendChild(cell);
  86.         }
  87.          
  88.         // Ajouter la rangée en fin de "table body"
  89.  
  90.         tblBody.appendChild(row);
  91.         }
  92.      
  93.     // Mettre le <tbody> dans le <table>
  94.  
  95.     tbl.appendChild(tblBody);
  96.     // Placer le <table> dans <body>
  97.  
  98.     body.appendChild(tbl);
  99.     // Définir la valeur de border à 1
  100.  
  101.     tbl.setAttribute("border", "1");
  102.  
  103.     //Définir une largeur fixe
  104.  
  105.     tbl.appendChild(tblBody);
  106.    
  107.     body.appendChild(tbl);
  108.  
  109.     tbl.setAttribute("width", "450");
  110.  
  111.  
  112.     tbl.appendChild(tblBody);
  113.    
  114.     body.appendChild(tbl);
  115.  
  116.     tbl.setAttribute("style", "table-layout:fixed");
  117.         }
  118.  
  119.     //-->
  120. </SCRIPT>
  121.  
  122.     </HEAD>
  123.  
  124. <!--___________________________________________________________________________________-->
  125.  
  126.     <BODY>
  127.    <h5>Cliquez pour générer une grille d'accords aléatoires</h5>
  128.   <h6> lincruste/<a href="http://www.jexpliquelesblagues.com/forum/index.php">JELB</a> 2014</h6>
  129.  
  130.   <input type="button" value="Let's OK gaijin" onclick="grille()">
  131.   <input type="button" value="Remise à zéro" onclick="window.location.reload()">
  132.   <hr>
  133.  
  134.    </BODY>
  135.    </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement