WME GetNodeID

Gives NodeID of selected segments

16.05.2015 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name                WME GetNodeID
// @namespace           Fafa114
// @description         Gives NodeID of selected segments
// @include             https://www.waze.com/editor/*
// @include             https://www.waze.com/*/editor/*
// @version             0.2
// @grant               na
// ==/UserScript==

if ('undefined' == typeof __RTLM_PAGE_SCOPE_RUN__) {
	(function page_scope_runner() {
		var my_src = "(" + page_scope_runner.caller.toString() + ")();"; // If we're _not_ already running in the page, grab the full source of this script.

		// Create a script node holding this script, plus a marker that lets us know we are running in the page scope (not the Greasemonkey sandbox).
		// Note that we are intentionally *not* scope-wrapping here.
		var script = document.createElement('script');
		script.setAttribute("type", "text/javascript");
		script.textContent = "var __RTLM_PAGE_SCOPE_RUN__ = true;\n" + my_src;

		// Insert the script node into the page, so it will run, and immediately remove it to clean up.  Use setTimeout to force execution "outside" of the user script scope completely.
		setTimeout(function() {
			document.body.appendChild(script);
			document.body.removeChild(script);
		}, 0);
	})();
	return; // Stop running, because we know Greasemonkey actually runs us in an anonymous wrapper.
}

function bootstrap(){
	if (typeof(unsafeWindow) === "undefined"){
		unsafeWindow = ( function () {
			var dummyElem = document.createElement('p');
			dummyElem.setAttribute('onclick', 'return window;');
			return dummyElem.onclick();
		}) ();
	}
	/* begin running the code! */
	setTimeout(init, 700);
}

function NodesID() {
	var Nbr = Waze.selectionManager.selectedItems.length;
	var NbrSeg = 0;
	var Texte = "";
	var Mem = [];
	if (Nbr > 0) {
        for(i = 0; i<Nbr; i++){ 
        	if (Waze.selectionManager.selectedItems[i].model.type == "segment") { 
				var TrouveFrom = false;
				var TrouveTo = false;
				for(u = 0; u<Mem.length; u++){
					if (Waze.selectionManager.selectedItems[i].model.attributes.fromNodeID == Mem[u]){
						TrouveFrom = true;
					}
					if (Waze.selectionManager.selectedItems[i].model.attributes.toNodeID == Mem[u]){
						TrouveTo = true;
					}
				}
				if (TrouveFrom == false){
					Mem[Mem.length] = Waze.selectionManager.selectedItems[i].model.attributes.fromNodeID;
					if (i == 0){
						Texte = Waze.selectionManager.selectedItems[i].model.attributes.fromNodeID;
					}else{
						Texte = Texte + ', ' + Waze.selectionManager.selectedItems[i].model.attributes.fromNodeID;
					}
				}
				if (TrouveTo == false){
					Mem[Mem.length] = Waze.selectionManager.selectedItems[i].model.attributes.toNodeID;
					Texte = Texte + ', ' + Waze.selectionManager.selectedItems[i].model.attributes.toNodeID;
				}
				NbrSeg++;
			}
		}
        if (NbrSeg > 0) {
			segeditgen = document.getElementById("segment-edit-general");
			segextra = document.getElementById("segment-extra-details");
			if (!segextra) {
				segextra = document.createElement('div');
				segextra.id = 'segment-extra-details';
				segeditgen.appendChild(segextra);
			}

			segextra.innerHTML = '<div{width:20px;}><B>WME GetNodeID</B><br>Segment(s) sélectionné(s) : ' + NbrSeg + '<br><br>Liste des IDs de Noeuds:<br><wbr>' + Texte + '</wbr></div>';
			$("#sidebar").animate({ scrollTop: $("#sidebar").offset().top + 5000 }, 1); //5000 pour être sûr d'être tout en bas...
    	}
  	}
  	return true;
}

function init(){
	Waze = unsafeWindow.Waze;
	if(typeof(Waze) == 'undefined'){
		window.setTimeout(init, 700);
		return;
	}
	Waze.selectionManager.events.register("selectionchanged", null, NodesID);
	NodesID(); // exécution de la fonction dès le lancement du script pour fonctionnement avec un permalink
}

bootstrap();