Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <HTML>
- <HEAD>
- <META http-equiv="content-type" content="text/html; charset=utf-8" />
- <TITLE>Le jazz et le javascript</TITLE>
- <!--________________________MB/lincruste Technology 2014_(coucou psycho)____-->
- <SCRIPT language="Javascript">
- <!--
- function accordgen()
- {
- // Création d'un tableau de notes fondamentales
- var Note=["A", "B", "C", "D", "E", "F", "G"];
- // Création d'un tableau d'altérations
- var Alteration=["#", "b", ""];
- // Création d'un tableau de natures d'accords
- 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"];
- // Extraction du nombre de valeurs de chaque tableau
- var notelength = Note.length;
- var altlength = Alteration.length;
- var naturelength = Nature.length;
- // Choix aléatoire d'un nombre pour chaque tableau en fonction du nombre de valeurs
- var rand1 = Math.floor(Math.random() * notelength);
- var rand2 = Math.floor(Math.random() * altlength);
- var rand3 = Math.floor(Math.random() * naturelength);
- // Remplacer B#=C, Cb=B, E#=F, Fb=E
- if ((rand1==1)&&(rand2==0)) {
- var rand1 = 2;
- var rand2 = 2;
- } else if ((rand1==2)&&(rand2==1)) {
- var rand1 = 1;
- var rand2 = 2;
- } else if ((rand1==4)&&(rand2==0)) {
- var rand1 = 5;
- var rand2 = 2;
- } else if ((rand1==5)&&(rand2==1)) {
- var rand1 = 4;
- var rand2 = 2;
- } else {
- var accord = Note[rand1] + Alteration[rand2] + Nature[rand3];
- }
- return accord
- }
- //-->
- </SCRIPT>
- <!--___________________________________________________________________________________-->
- <SCRIPT language="Javascript">
- <!--
- function grille() {
- // Créer une référence pour le body
- var body = document.getElementsByTagName("body")[0];
- // Création d'éléments <table> et <tbody>
- var tbl = document.createElement("table");
- var tblBody = document.createElement("tbody");
- // Création des cellules
- for (var j = 0; j < 1; j++) {
- // Créer une rangée
- var row = document.createElement("tr");
- for (var i = 0; i < 4; i++) {
- // Créer un élément <td> et un text node, en faire
- // le contenu du <td> et le placer en fin de rangée
- var cell = document.createElement("td");
- var cellText = document.createTextNode(accordgen());
- cell.appendChild(cellText);
- row.appendChild(cell);
- }
- // Ajouter la rangée en fin de "table body"
- tblBody.appendChild(row);
- }
- // Mettre le <tbody> dans le <table>
- tbl.appendChild(tblBody);
- // Placer le <table> dans <body>
- body.appendChild(tbl);
- // Définir la valeur de border à 1
- tbl.setAttribute("border", "1");
- //Définir une largeur fixe
- tbl.appendChild(tblBody);
- body.appendChild(tbl);
- tbl.setAttribute("width", "450");
- tbl.appendChild(tblBody);
- body.appendChild(tbl);
- tbl.setAttribute("style", "table-layout:fixed");
- }
- //-->
- </SCRIPT>
- </HEAD>
- <!--___________________________________________________________________________________-->
- <BODY>
- <h5>Cliquez pour générer une grille d'accords aléatoires</h5>
- <h6> lincruste/<a href="http://www.jexpliquelesblagues.com/forum/index.php">JELB</a> 2014</h6>
- <input type="button" value="Let's OK gaijin" onclick="grille()">
- <input type="button" value="Remise à zéro" onclick="window.location.reload()">
- <hr>
- </BODY>
- </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement