Les scripts
Sam 16 Sep - 20:31
LES SCRIPTS
Késako ?! Un script est un morceau de code qui sert à améliorer l'expérience utilisateur d'un programme ou d'un site.
Pour pouvoir utiliser un script sur Fractal, il faudra d'abord installer un add-on (ou extension) qui permet l'utilisation des scripts sur un site internet défini.
Les 2 poids lourds du secteur sont "Greasemonkey" (Firefox) et "Tampermonkey" (Chome). Pour Edge, ne m'demandez pas, j'en sais rien, j'l'ai jamais ouvert !
Perso, j'utilise Chrome, donc Tampermonkey.
Comment l'installer :
1 - Sur Google Chrome, ouvrir le lien suivant : https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=fr
2 - Dans le coin supérieur droit du pop-up, cliquer sur "Ajouter à Chrome".
3 - Une fois l'add-on installé, vous aurez une petite icône (un carré noir avec deux cercles dans sa partie inférieure). Cliquez dessus et faites "Ajouter un nouveau script...".
4- Collez le script suivant pour avoir les résumés d'un groupe :
- Script Résumé Groupe:
- // ==UserScript==
// @name Fractal Resume : Groupe
// @namespace GroupeResume
// @include https://www.fract.org/monde/g_mbr.php
// @include https://fract.org/monde/g_mbr.php
// @require https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @version 1
// @grant none
// ==/UserScript==
//dernière mise à jour 06-05-2016
var i=0;
var j=0;
var k=0;
var nrt=0;
var eau=0;
var med=0;
var taille=0;
var pers=new Array();
var combat=new Array();
combat[0]=0;
var combattot='';
var transport=0;
var degat=0;
var nem=new Array();
var marchandises=new Array();for (i = 0; i < 51; i++) { marchandises[i] = new Array(); }
var marchtext='';
var tab=new Array();for (i = 0; i < 51; i++) { tab = new Array(); }
marchandises= [
['acier',0,'aci'],
['Betterave',0,'bet'],
['Bière blonde',0,'bbl'],
['Bière brune',0,'bbr'],
['Blé',0,'ble'],
['Bois',0,'boi'],
['Canabis',0,'cnb'],
['Charbon',0,'cha'],
['Cocaine',0,'coc'],
['Coke',0,'cok'],
['Cuivre',0,'cui'],
['Diesel',0,'dsl'],
['Eau',0,'eau'],
['Essence',0,'ess'],
['Fer',0,'fer'],
['Feuilles de coca',0,'fca'],
['Materiel',0,'mat'],
['Médicament',0,'med'],
['Munitions .22LR',0,'mu1'],
['Munitions .45ACP',0,'mu2'],
['Munitions .38 special',0,'mu3'],
['Munitions calibre 12',0,'mu4'],
['Munitions 9x19mm',0,'mu5'],
['Munitions 5.56x45mm',0,'mu6'],
['Munitions 7.62x5mm',0,'mu7'],
['Munitions 7.62x39mm',0,'mu8'],
['Munitions 7.62x54R mm',0,'mu9'],
['Munitions 7.65x17mm',0,'mu10'],
['Nourriture',0,'nrt'],
['Opium',0,'opm'],
['Pétrole',0,'pet'],
['Philtre en poudre',0,'php'],
['Pièce de fusils automatiques',0,'fua'],
["Pièces d'arme à poudre",0,'mou'],
["Pièces d'arme blanche",0,'arm'],
['Pièces de bateau à moteur',0,'vm2'],
['Pièces de camion',0,'vt3'],
['Pièces de fusils',0,'fus'],
['Pièces de moto',0,'vt1'],
['Pièces de véhicules vapeur',0,'vva'],
['Pièces de voilier',0,'vm1'],
['Pièces de voiture',0,'vt2'],
['Pierre',0,'pie'],
['Pomme de terre',0,'pdt'],
['Poudre de cire',0,'cir'],
['Poudre noire',0,'pou'],
['Rhum',0,'rhm'],
['Souffre',0,'sou'],
['TNT',0,'tnt'],
['Vodka',0,'vdk'],
['Whisky',0,'whk'],
];
var texte_a_afficher = '';
var text = '';
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
addGlobalStyle('.classresume a {color:black;}.classresume a:hover {color:white;} t{} rouge{color:red;} orange{color:orange;} petit{font-size:14px;font-family:calibri;}');
//Récupération du code du tableau des membres du groupe------------------
var total = document.getElementById("pcontenu").innerHTML;
//Répartition des différents membres du groupe dans un array-------------
//Nombre de persos dans le array : perso.length - 1
var perso = new Array();
perso = total.split('<div class="ttitre">');
var nbPersos = perso.length - 1;
texte_a_afficher = '<div class="classresume" style="margin-left:50px;width:810px" ><div class="tableau"><div class="ttitre">Résumé - Nombre de persos : '+nbPersos+'</div><br><div style="margin-left:50px;"><table style="border-collapse:collapse;">';
//Récupération des données de chaque perso ------------------------------
//var dataperso = new Array();
for (i = 0; i < nbPersos; i++)
{
j=1+i;
texte_a_afficher += "<tr><td>";
//Combat
pers=perso[j].split('<td width="80"><b>');
pers=pers[1].split('</b></td>');
combat[j]=pers[0].split(',');
pers=perso[j].split('(x');
if(pers[1]){
pers=pers[1].split(')');
pers=pers[0].split('d');
combat[j]=combat[j]*Number(pers[0]);
degat+=Number(pers[1]);
}
else{
degat+=1;
}
combat[0]+=Number(combat[j]);
combattot='<div style="width:40; display:inline;"><img src="https://www.fract.org/pix/caracteristique/cbt.png" alt="Combat"> x'+Math.round(combat[0]*100)/100+'d'+degat+'</div>';
//nom perso + jeton
pers=perso[j].split('<h2>');
pers=pers[1].split('</h2>');
pers=pers[0].split('<img src="../pix/geo.png" title="');
taille=pers.length - 1;
pers=pers[0].split('#" onclick="window.open(\'./popup');
texte_a_afficher += pers[0]+'./msg_ecrire';
pers=pers[1].split("&caztyp=1','popup','width=550,height=600,scrollbars=1');");
texte_a_afficher += pers[0]+pers[1]+'<img src="https://marthusfractal.free.fr/DevV7/pix/geo'+taille+'.png" alt="geo : '+taille+'"></td><td style="text-align:right;"> ';
//PV/PVM
pers=perso[j].split('<td>');
pers=pers[2].split('</td>');
pers=pers[0].split('/');
nombre = Number(pers[1])-Number(pers[0]);
if(nombre == 0){ texte_a_afficher += pers[0]+'</td><td>/</td><td>'+pers[1]+' </td>';}
else if(nombre > 0 && 1 > nombre){ texte_a_afficher += '<orange>' +pers[0]+'</orange></td><td>/</td><td>'+pers[1]+' </td>';}
else if(1 <= nombre){ texte_a_afficher += '<rouge>' +pers[0]+'</rouge></td><td>/</td><td>'+pers[1]+' </td>';}
//NEM
pers=perso[j].split('alt="');
taille=pers.length-2;
for (k = 10; k < taille; k++)
{
tab=pers[k].split('"');
for (l = 0; l < 51; l++)
{
if(tab[0]==marchandises[l][0])
{
tab[0]=tab[5].split('<br>');
tab[0]=tab[0][1].split('</div>');
tab[0]=tab[0][0].split(',');
marchandises[l][1]+=Number(tab[0]);
if(l==28){nem[0]=Number(tab[0]);}
if(l==12){nem[1]=Number(tab[0]);}
if(l==17){nem[2]=Number(tab[0]);}
}
}
}
if(nem[0]==undefined){nem[0]=0;}
if(nem[1]==undefined){nem[1]=0;}
if(nem[2]==undefined){nem[2]=0;}
texte_a_afficher +='<td width="40" style="background-color:#bebebe;"> <img src="https://www.fract.org/pix/caracteristique/nrt.png" alt="Nrt"></td><td style="background-color:#bebebe;"> '+nem[0]+' </td><td width="40"> <img src="https://www.fract.org/pix/caracteristique/eau.png" alt="Eau"></td><td> '+nem[1]+' </td><td width="40" style="background-color:#bebebe;"> <img src="https://www.fract.org/pix/caracteristique/med.png" alt="Med"></td><td style="background-color:#bebebe;"> '+nem[2]+' </td>';
nem[0]=0;
nem[1]=0;
nem[2]=0;
//Transport libre
pers=perso[j].split('Poids transportable: ');
pers=pers[1].split('</td>');
texte_a_afficher +='<td> Libre : '+pers[0]+'</td>';
pers=pers[0].split('<font color="red">');
if (pers[1]){pers=pers[1].split(' kg');transport+=Number(pers[0]);}
else{pers=pers[0].split(' kg');transport+=Number(pers[0]);}
texte_a_afficher += "</tr>";
}
//Autres marchandises
for (l = 0; l < 51; l++)
{
if(marchandises[l][1]!=0)
{
if(l!=28 && l!=12 && l!=17){marchtext+='<t title="'+marchandises[l][0]+'">'+marchandises[l][2]+'='+Math.round(marchandises[l][1]*100)/100+'</t> ';}
}
}
texte_a_afficher += '<tr style="background-color:#bebebe;"><td style="height:2px;"> </td><td></td><td></td><td></td><td style="background-color:#f0ede8;"><td style="background-color:#f0ede8;"></td><td></td><td></td><td style="background-color:#f0ede8;"></td><td style="background-color:#f0ede8;"></td><td></td></tr><tr><td>'+combattot+'</td><td></td><td></td><td></td><td width="40" style="background-color:#bebebe;"> <img src="https://www.fract.org/pix/caracteristique/nrt.png" alt="Nrt"></td><td style="background-color:#bebebe;"> '+Math.round(marchandises[28][1]*100)/100+' </td><td width="40"> <img src="https://www.fract.org/pix/caracteristique/eau.png" alt="Eau"></td><td> '+Math.round(marchandises[12][1]*100)/100+' </td><td width="40" style="background-color:#bebebe;"> <img src="https://www.fract.org/pix/caracteristique/med.png" alt="Meds"></td><td style="background-color:#bebebe;"> '+Math.round(marchandises[17][1]*100)/100+' </td><td> Libre : '+Math.round(transport*100)/100+' kg</td></tr></table></div><div style="width:750px; margin-left:30px"><br> Autres marchandises : <br> '+marchtext+'<br></div><br></div></div>';
var sp1 = document.createElement("span"); // on crée une balise span
sp1.setAttribute("id", "Affichage"); // on y ajoute un id
var sp1_content = document.createTextNode('');
sp1.appendChild(sp1_content);
var sp2 = document.getElementById('pcontenu') ; // Lieu où on veut afficher (A remplacer par ce que vous voulez
var parentDiv = sp2.parentNode;
parentDiv.insertBefore(sp1, sp2.nextSibling);
var tableau = document.createElement("span");
tableau.innerHTML = texte_a_afficher; // Ce qu'on veut afficher
document.getElementById('Affichage').insertBefore(tableau, document.getElementById('Affichage').firstChild); // Affichage
5 - Refaites la manipulation pour "Ajouter un nouveau script..." et collez le script suivant pour avoir le résumé pour la Communauté, cette fois :
- Script Résumé Communauté:
- // ==UserScript==
// @name Fractal Resume : Com
// @namespace ComResume
// @include https://www.fract.org/monde/c_mbr.php
// @include https://fract.org/monde/c_mbr.php
// @require https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @version 1
// @grant none
// ==/UserScript==
//Dernière modif 07/04/2016
var i=0;
var j=0;
var k=0;
var ancien='';
var nrt=0;
var eau=0;
var med=0;
var nombre=0;
var taille=0;
var pers=new Array();
var combat=new Array();
combat[0]=0;
var combattot='';
var transport=0;
var degat=0;
var objets='';
var nem=new Array();
var marchandises=new Array();for (i = 0; i < 51; i++) { marchandises[i] = new Array(); }
var marchtext='';
var tab=new Array();for (i = 0; i < 51; i++) { tab = new Array(); }
var prodnrt=0;
var prodeau=0;
var prodmed=0;
var prodmat=0;
var prodexp=0;
var prodart=0;
marchandises[0][0]='acier';marchandises[0][1]=0;marchandises[0][2]='aci';
marchandises[1][0]='Betterave';marchandises[1][1]=0;marchandises[1][2]='bet';
marchandises[2][0]='Bière blonde';marchandises[2][1]=0;marchandises[2][2]='bbl';
marchandises[3][0]='Bière brune';marchandises[3][1]=0;marchandises[3][2]='bbr';
marchandises[4][0]='Blé';marchandises[4][1]=0;marchandises[4][2]='ble';
marchandises[5][0]='Bois';marchandises[5][1]=0;marchandises[5][2]='boi';
marchandises[6][0]='Canabis';marchandises[6][1]=0;marchandises[6][2]='cnb';
marchandises[7][0]='Charbon';marchandises[7][1]=0;marchandises[7][2]='cha';
marchandises[8][0]='Cocaine';marchandises[8][1]=0;marchandises[8][2]='coc';
marchandises[9][0]='Coke';marchandises[9][1]=0;marchandises[9][2]='cok';
marchandises[10][0]='Cuivre';marchandises[10][1]=0;marchandises[10][2]='cui';
marchandises[11][0]='Diesel';marchandises[11][1]=0;marchandises[11][2]='dsl';
marchandises[12][0]='Eau';marchandises[12][1]=0;marchandises[12][2]='eau';
marchandises[13][0]='Essence';marchandises[13][1]=0;marchandises[13][2]='ess';
marchandises[14][0]='Fer';marchandises[14][1]=0;marchandises[14][2]='fer';
marchandises[15][0]='Feuilles de coca';marchandises[15][1]=0;marchandises[15][2]='fca';
marchandises[16][0]='Materiel';marchandises[16][1]=0;marchandises[16][2]='mat';
marchandises[17][0]='Médicament';marchandises[17][1]=0;marchandises[17][2]='med';
marchandises[18][0]='Munitions .22LR';marchandises[18][1]=0;marchandises[18][2]='mu1';
marchandises[19][0]='Munitions .45ACP';marchandises[19][1]=0;marchandises[19][2]='mu2';
marchandises[20][0]='Munitions .38 special';marchandises[20][1]=0;marchandises[20][2]='mu3';
marchandises[21][0]='Munitions calibre 12';marchandises[21][1]=0;marchandises[21][2]='mu4';
marchandises[22][0]='Munitions 9x19mm';marchandises[22][1]=0;marchandises[22][2]='mu5';
marchandises[23][0]='Munitions 5.56x45mm';marchandises[23][1]=0;marchandises[23][2]='mu6';
marchandises[24][0]='Munitions 7.62x5mm';marchandises[24][1]=0;marchandises[24][2]='mu7';
marchandises[25][0]='Munitions 7.62x39mm';marchandises[25][1]=0;marchandises[25][2]='mu8';
marchandises[26][0]='Munitions 7.62x54R mm';marchandises[26][1]=0;marchandises[26][2]='mu9';
marchandises[27][0]='Munitions 7.65x17mm';marchandises[27][1]=0;marchandises[27][2]='mu10';
marchandises[28][0]='Nourriture';marchandises[28][1]=0;marchandises[28][2]='nrt';
marchandises[29][0]='Opium';marchandises[29][1]=0;marchandises[29][2]='opm';
marchandises[30][0]='Pétrole';marchandises[30][1]=0;marchandises[30][2]='pet';
marchandises[31][0]='Philtre en poudre';marchandises[31][1]=0;marchandises[31][2]='php';
marchandises[32][0]='Pièce de fusils automatiques';marchandises[32][1]=0;marchandises[32][2]='fua';
marchandises[33][0]="Pièces d'arme à poudre";marchandises[33][1]=0;marchandises[33][2]='mou';
marchandises[34][0]="Pièces d'arme blanche";marchandises[34][1]=0;marchandises[34][2]='arm';
marchandises[35][0]='Pièces de bateau à moteur';marchandises[35][1]=0;marchandises[35][2]='vm2';
marchandises[36][0]='Pièces de camion';marchandises[36][1]=0;marchandises[36][2]='vt3';
marchandises[37][0]='Pièces de fusils';marchandises[37][1]=0;marchandises[37][2]='fus';
marchandises[38][0]='Pièces de moto';marchandises[38][1]=0;marchandises[38][2]='vt1';
marchandises[39][0]='Pièces de véhicules vapeur';marchandises[39][1]=0;marchandises[39][2]='vva';
marchandises[40][0]='Pièces de voilier';marchandises[40][1]=0;marchandises[40][2]='vm1';
marchandises[41][0]='Pièces de voiture';marchandises[41][1]=0;marchandises[41][2]='vt2';
marchandises[42][0]='Pierre';marchandises[42][1]=0;marchandises[42][2]='pie';
marchandises[43][0]='Pomme de terre';marchandises[43][1]=0;marchandises[43][2]='pdt';
marchandises[44][0]='Poudre de cire';marchandises[44][1]=0;marchandises[44][2]='cir';
marchandises[45][0]='Poudre noire';marchandises[45][1]=0;marchandises[45][2]='pou';
marchandises[46][0]='Rhum';marchandises[46][1]=0;marchandises[46][2]='rhm';
marchandises[47][0]='Souffre';marchandises[47][1]=0;marchandises[47][2]='sou';
marchandises[48][0]='TNT';marchandises[48][1]=0;marchandises[48][2]='tnt';
marchandises[49][0]='Vodka';marchandises[49][1]=0;marchandises[49][2]='vdk';
marchandises[50][0]='Whisky';marchandises[50][1]=0;marchandises[50][2]='whk';
var texte_a_afficher = '';
var text = '';
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
addGlobalStyle('.classresume a {color:black;}.classresume a:hover {color:white;} t{} rouge{color:red;} orange{color:orange;} petit{font-size:14px;font-family:calibri;} petitgris{font-size:14px;font-family:calibri;color:#9a9a9a;} #DivObjets {display:none;} #ClicObjets:hover ~ #DivObjets {display:block;} #DivObjets:hover {display:block;}');
//Récupération du code du tableau des membres du groupe------------------
var total = document.getElementById("pcontenu").innerHTML;
//Découpe en sous parties
var perso = new Array();
perso = total.split('<div class="ttitre">');
//Entête
pers=perso[1].split('Nbr de membres de la commuanuté : ');
pers=pers[1].split('<br>');
var nbPersos = pers[0];
pers=perso[1].split('Nbr de non-membres dans la commuanuté : ');
pers=pers[1].split('</div>');
var nbSquatteurs = pers[0];
texte_a_afficher = '<div class="classresume" style="margin-left:50px;width:810px" ><div class="tableau"><div class="ttitre">Resumé - Habitants/Squatteurs : '+nbPersos+'/'+nbSquatteurs+'</div><br><div style="margin-left:50px;"><table style="border-collapse:collapse;"><tr><td>Persos</td><td colspan="3" align="center">PV</td><td colspan="6" align="center">NEM</td><td><img src="https://www.fract.org/pix/caracteristique/nrt.png" alt="Production de nourriture"></td><td><img src="https://www.fract.org/pix/caracteristique/eau.png" alt="Production de d\'eau"></td><td><img src="https://www.fract.org/pix/caracteristique/med.png" alt="Production de de médicaments"></td><td><img src="https://www.fract.org/pix/caracteristique/mat.png" alt="Production de materiel"></td><td><img src="https://www.fract.org/pix/caracteristique/exp.png" alt="Exploitation"></td><td><img src="https://www.fract.org/pix/caracteristique/art.png" alt="Artisanat"></td></tr>';
//Récupération des données de chaque perso ------------------------------
pers = total.split('Comptable');
perso = pers[1].split('<div class="ttitre">');
nbPersos = perso.length - 1;
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
//Affichage des données
for (i = 0; i < nbPersos; i++)
{
j=1+i;
//test nouveau groupe
pers=perso[j].split('</div>');
if(pers[0]!==ancien){
ancien=pers[0];
pers=pers[0].split('Membres du groupe');
if(!pers[1]){pers[1]="Sans groupe";}
texte_a_afficher += '<tr><td colspan="10" style="height:14px;"><petitgris>'+pers[1]+'</petitgris></td><td align="center"><img src="https://www.fract.org/pix/caracteristique/nrt.png" alt="Production de nourriture" width="15px" height="15px"></td align="center"><td align="center"><img src="https://www.fract.org/pix/caracteristique/eau.png" alt="Production de d\'eau" width="15px" height="15px"></td align="center"><td align="center"><img src="https://www.fract.org/pix/caracteristique/med.png" alt="Production de de médicaments" width="15px" height="15px"></td><td align="center"><img src="https://www.fract.org/pix/caracteristique/mat.png" alt="Production de materiel" width="15px" height="15px"></td><td align="center"><img src="https://www.fract.org/pix/caracteristique/exp.png" alt="Exploitation" width="15px" height="15px"></td><td align="center"><img src="https://www.fract.org/pix/caracteristique/art.png" alt="Artisanat" width="15px" height="15px"></td></tr>';
}
texte_a_afficher += "<tr><td>";
//nom perso + jeton
pers=perso[j].split('<h2>');
pers=pers[1].split('</h2>');
texte_a_afficher += pers[0]+'</td><td style="text-align:right;"> ';
//PV/PVM
pers=perso[j].split('</h2>');
pers=pers[1].split('<td>');
pers=pers[1].split('</td>');
pers=pers[0].split('/');
nombre = Number(pers[1])-Number(pers[0]);
if(nombre === 0){ texte_a_afficher += pers[0]+'</td><td>/</td><td>'+pers[1]+' </td>';}
else if(nombre > 0 && 1 > nombre){ texte_a_afficher += '<orange>' +pers[0]+'</orange></td><td>/</td><td>'+pers[1]+' </td>';}
else if(1 <= nombre){ texte_a_afficher += '<rouge>' +pers[0]+'</rouge></td><td>/</td><td>'+pers[1]+' </td>';}
//NEM
pers=perso[j].split('"Artisanat"');
pers=pers[1].split('alt="Contacter"');
pers=pers[0].split('alt="');
for (k = 0; k < pers.length; k++)
{
tab=pers[k].split('"');
for (l = 0; l < 51; l++)
{
if(tab[0]==marchandises[l][2])
{
tab[0]=tab[3].split('<br>');
tab[0]=tab[0][1].split('</div>');
tab[0]=tab[0][0].split(',');
marchandises[l][1]+=Number(tab[0]);
if(l==28){nem[0]=Number(tab[0]);}
if(l==12){nem[1]=Number(tab[0]);}
if(l==17){nem[2]=Number(tab[0]);}
}
}
}
if(nem[0]===undefined){nem[0]=0;}
if(nem[1]===undefined){nem[1]=0;}
if(nem[2]===undefined){nem[2]=0;}
texte_a_afficher +='<td width="40" style="background-color:#bebebe;"> <img src="https://www.fract.org/pix/caracteristique/nrt.png" alt="Nrt"></td><td style="background-color:#bebebe;"> '+nem[0]+' </td><td width="40"> <img src="https://www.fract.org/pix/caracteristique/eau.png" alt="Eau"></td><td> '+nem[1]+' </td><td width="40" style="background-color:#bebebe;"> <img src="https://www.fract.org/pix/caracteristique/med.png" alt="Med"></td><td style="background-color:#bebebe;"> '+nem[2]+' </td>';
nem[0]=0;
nem[1]=0;
nem[2]=0;
//Prod
pers=perso[j].split('Production de nourriture');
pers=pers[1].split('<td width="80">');
pers=pers[1].split('</td>');
texte_a_afficher +='<td align="center"><petit>'+pers[0]+'</petit></td>';
prodnrt += Number(pers[0]);
pers=perso[j].split("Production de d'eau");
pers=pers[1].split('<td width="80">');
pers=pers[1].split('</td>');
texte_a_afficher +='<td align="center"><petit>'+pers[0]+'</petit></td>';
prodeau += Number(pers[0]);
pers=perso[j].split('Production de de médicaments');
pers=pers[1].split('<td width="80">');
pers=pers[1].split('</td>');
texte_a_afficher +='<td align="center"><petit>'+pers[0]+'</petit></td>';
prodmed+=Number(pers[0]);
pers=perso[j].split("Production de materiel");
pers=pers[1].split('<td width="80">');
pers=pers[1].split('</td>');
texte_a_afficher +='<td align="center"><petit>'+pers[0]+'</petit></td>';
prodmat+=Number(pers[0]);
pers=perso[j].split('Exploitation');
pers=pers[1].split('<td width="80">');
pers=pers[1].split('</td>');
texte_a_afficher +='<td align="center"><petit>'+pers[0]+'</petit></td>';
prodexp+=Number(pers[0]);
pers=perso[j].split("Artisanat");
pers=pers[1].split('<td width="80">');
pers=pers[1].split('</td>');
texte_a_afficher +='<td align="center"><petit>'+pers[0]+'</petit></td>';
prodart+=Number(pers[0]);
//Objets
pers=perso[j].split('<hr>');
pers=pers[2].split('<a href="msg_ecrire.php');
pers=pers[0].split('<a href="');
for (l = 1; l < pers.length; l++)
{
tab=pers[l].split('"');
objets+='<img src="'+tab[0]+'" alt="objet">';
}
texte_a_afficher += "</tr>";
}
//Autres marchandises
for (l = 0; l < 51; l++)
{
if(marchandises[l][1]!==0)
{
if(l!=28 && l!=12 && l!=17){marchtext+='<t title="'+marchandises[l][0]+'">'+marchandises[l][2]+'='+Math.round(marchandises[l][1]*100)/100+'</t> ';}
}
}
texte_a_afficher += '<tr style="background-color:#bebebe;"><td style="height:2px;"> </td><td></td><td></td><td></td><td style="background-color:#f0ede8;"><td style="background-color:#f0ede8;"></td><td></td><td></td><td style="background-color:#f0ede8;"></td><td style="background-color:#f0ede8;"></td><td colspan="6" style="background-color:#bebebe;"></td></tr><tr><td></td><td></td><td></td><td></td><td width="40" style="background-color:#bebebe;"> <img src="https://www.fract.org/pix/caracteristique/nrt.png" alt="Nrt"></td><td style="background-color:#bebebe;"> '+Math.round(marchandises[28][1]*100)/100+' </td><td width="40"> <img src="https://www.fract.org/pix/caracteristique/eau.png" alt="Eau"></td><td> '+Math.round(marchandises[12][1]*100)/100+' </td><td width="40" style="background-color:#bebebe;"> <img src="https://www.fract.org/pix/caracteristique/med.png" alt="Meds"></td><td style="background-color:#bebebe;">'+Math.round(marchandises[17][1]*100)/100+' </td><td align="center"><petit>'+Math.round(prodnrt)+'</petit></td><td align="center"><petit>'+Math.round(prodeau)+'</petit></td><td align="center"><petit>'+Math.round(prodmed)+'</petit></td><td align="center"><petit>'+Math.round(prodmat)+'</petit></td><td align="center"><petit>'+Math.round(prodexp)+'</petit></td><td align="center"><petit>'+Math.round(prodart)+'</petit></td></tr></table></div><div style="width:750px; margin-left:30px"><br> Autres marchandises : <br> '+marchtext+'<br><br> <div id="ClicObjets"> Survoler pour afficher les objets</div><br> <div id="DivObjets">'+objets+'</div><br></div><br></div></div>';
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
var sp1 = document.createElement("span"); // on crée une balise span
sp1.setAttribute("id", "Affichage"); // on y ajoute un id
var sp1_content = document.createTextNode('');
sp1.appendChild(sp1_content);
var sp2 = document.getElementById('pcontenu') ; // Lieu où on veut afficher (A remplacer par ce que vous voulez
var parentDiv = sp2.parentNode;
parentDiv.insertBefore(sp1, sp2.nextSibling);
var tableau = document.createElement("span");
tableau.innerHTML = texte_a_afficher; // Ce qu'on veut afficher
document.getElementById('Affichage').insertBefore(tableau, document.getElementById('Affichage').firstChild); // Affichage
Voilà, si vous avez d'autres scripts vous pouvez me les communiquer en MP et je me ferais un plaisir de les ajouter. J'ajoute que ces deux scripts ont été fait par Marthus, je n'y suis pour rien ^^
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum
|
|