Utilisateur:Ellysor/vector.js
Aller à la navigation
Aller à la recherche
Note : après avoir publié vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
- Firefox / Safari : maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou appuyez sur Ctrl + F5 ou Ctrl + R (⌘ + R sur un Mac).
- Google Chrome : appuyez sur Ctrl + Maj + R (⌘ + Shift + R sur un Mac).
- Internet Explorer / Edge : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl + F5.
- Opera : appuyez sur Ctrl + F5.
function Géolocalisation2(){ // Contient la taille (en pixels) des images de [[Fichier:Plan-xxxx.jpg]] var zones = { "Bassin aurique (niveau supérieur)" : { width:2048, height:2816 }, "Bassin aurique (souterrains)" : { width:2048, height:2816 }, "Bassin aurique (surface)" : { width:2048, height:2816 }, "Champs de bataille éternels" : { width:3080, height:3072 }, "Champs de Gendarran" : { width:4224, height:2048 }, "Champs de Ruine" : { width:3072, height:3072 }, "Chutes de la Canopée" : { width:2304, height:3200 }, "Cimesèche" : { width:2096, height:1628 }, "Collines de Kessex" : { width:4096, height:2048 }, "Congères d'Antreneige" : { width:4096, height:2048 }, "Contreforts du Voyageur" : { width:1792, height:4608 }, "Côte de la marée sanglante" : { width:2432, height:3200 }, "Crique de Sud-Soleil" : { width:2688, height:1792 }, "Détroit de la Dévastation" : { width:3328, height:2816 }, "Détroit des gorges glacées" : { width:3072, height:3072 }, "Falaises de Hantedraguerre" : { width:2304, height:3200 }, "Forêt de Caledon" : { width:1920, height:3968 }, "Hinterlands Harathis" : { width:3200, height:2816 }, "Hoelbrak" : { width:2304, height:1664 }, "L'Arche du Lion" : { width:2434, height:1536 }, "La Citadelle noire" : { width:1538, height:2048 }, "La Vallée de la reine" : { width:3584, height:2432 }, "Le Bosquet" : { width:1408, height:2048 }, "Le Promontoire divin" : { width:1920, height:1792 }, "Les Contrées sauvages d'Argent" : { width:2306, height:1666 }, "Les Steppes de la Strie flamboyante" : { width:2048, height:4096 }, "Marais de fer" : { width:2048, height:4096 }, "Marais de Lumillule" : { width:2560, height:3328 }, "Mont Maelström" : { width:3840, height:2432 }, "Montée de Flambecoeur" : { width:3328, height:2816 }, "Orée d'émeraude (niveau supérieur)" : { width:3200, height:1536 }, "Orée d'émeraude (souterrains)" : { width:3200, height:1536 }, "Orée d'émeraude (surface)" : { width:3200, height:1536 }, "Passage de Lornar" : { width:1794, height:4864 }, "Plaines d'Ashford" : { width:4096, height:2048 }, "Plateau de Diessa" : { width:3584, height:2304 }, "Profondeurs verdoyantes (niveau supérieur)" : { width:3328, height:2304 }, "Profondeurs verdoyantes (souterrains)" : { width:3328, height:2304 }, "Profondeurs verdoyantes (surface)" : { width:3328, height:2304 }, "Province de Metrica" : { width:2176, height:3328 }, "Rata Sum" : { width:2560, height:2560 }, "Rivage maudit" : { width:2048, height:4096 }, "Saut de Malchor" : { width:4096, height:2048 }, "Terres sauvages de Brisban" : { width:3456, height:2688 }, "????" : { width:1000, height:1000 } }; $('.carte').each(function(){ // Actually only works for 1 map per page var mapObj = $(this).find('img'); if (mapObj.length === 0) { console.log("No image in div .carte"); return; } var height = mapObj.height(); var width = mapObj.width(); var iconSize = Math.max(Math.min(width/40, 32), 10); var zoneName = mapObj.attr("alt").substr(5, mapObj.attr("alt").length-9); console.log("Map:" + zoneName + " x:" + width+ " y:height iconSize:" + iconSize); if (zoneName in zones) { $(this).find('.carte-point').each(function() { var x = $(this).find('.carte-x').text(); var y = $(this).find('.carte-y').text(); if ((x != 0) && (y != 0)) { var nw_x = (x/zones[zoneName]["height"])*height - iconSize/2; var nw_y = (y/zones[zoneName]["width"])*width - iconSize/2; //var icone = $(this).find('.carte-icone').text(); // For local img var icone = $(this).find('.carte-icone').find('img').attr("src"); if (icone) { var elementToDisplay = '<img src="' + icone + '"' + ' height=' + iconSize + ' style="display:inline; position:absolute; left:' + nw_x + 'px; top:' + nw_y + 'px;"/>'; $(elementToDisplay).appendTo(".carte"); }else{ console.log("No icon for '" + $(this).attr("title") ); } } else { console.log("No coordinates for '" + $(this).attr("title") ); } }); } else { console.log("Zone " + zoneName + " is not listed in zones array" ); } }); } $(document).ready(function() { new Géolocalisation2(); });