Get a sneak peek at whats next for Permanent Hazards on our April 7th Office Hours!
Comme le nom l'indique, ici ce sont les archives, où on met tous les vieux trucs :)
Post by slicer
Le select in landmark sous chrome ne fonctionne pas bien. Une petite astuce, lorsque tu sélectionnes, laisse ton doigt sur CTRL et sélectionne un autre segment. Puis déselectionne le (tjrs avec la touche CTRL enfoncée), ca devrait être bon :)
slicer
Emeritus Local Champ
Emeritus Local Champ
Posts: 1794
Has thanked: 11 times
Been thanked: 11 times
Send a message
Ghost
.....................................................................
Android User

Post by slicer
alcolo47 wrote:Pour le Open in > clipboard je ne sais pas si c'est possible. En javascript, il est impossible d'utiliser le presse papier (raison de sécurité), il faut passer par du flash (Et là, on ce demande pourquoi il nous em*de en js si on peut qd même contourné!!)). Incorporer du flash dans mon plugin, je le sens pas (c'est pas perdu, je sentais pas chrome a une époque et je m'y suis mis) ...
Et en passant par un <input type=text> ? on fait juste le ctrl + v :)
slicer
Emeritus Local Champ
Emeritus Local Champ
Posts: 1794
Has thanked: 11 times
Been thanked: 11 times
Send a message
Ghost
.....................................................................
Android User

Post by slicer
Merci Alcolo, je viens de l'installer, je m'amuserai plus tard avec :)
slicer
Emeritus Local Champ
Emeritus Local Champ
Posts: 1794
Has thanked: 11 times
Been thanked: 11 times
Send a message
Ghost
.....................................................................
Android User

Post by tcm33
Hello,

Je viens d'installer la dernière version, et je dirai juste : BRAVO à alcolo47.

Merci de nous faire gagner autant de temps.

--Timo
tcm33
Emeritus Local Champ
Emeritus Local Champ
Posts: 317
Has thanked: 14 times
Been thanked: 16 times
Send a message
AM Aquitaine, CM France
UR : 11k

Post by tcm33
Super, bravo !
tcm33
Emeritus Local Champ
Emeritus Local Champ
Posts: 317
Has thanked: 14 times
Been thanked: 16 times
Send a message
AM Aquitaine, CM France
UR : 11k

Post by Tim1987
Since us non-french folks aren't very good at your beautiful language, I hope either someone can translate or everyone of you understands english pretty good. :)
We took the liberty of adjusting this great script. Now it works in Chrome and shows state (for the US people).

Take a look at what we've got so far.

If it's up to me, all the credit still goes to Alcolo47. So thank you, it's great :)
Tim1987
Posts: 55
Send a message

Post by Tim1987
alcolo47 wrote:Version 1.2 toujours a la même URL:
http://waze-papyrus-extended-tools.goog ... ze.user.js

Adding chrome support (not tested)
Adding State column and http://www.waze.com support
Adding scrolling

J'ai intégré le code de tim1987 et ajouté le scrolling du tableau.
Alcolo,

Thanks for using the fix that I found and mentioning me (no need to really ;))
However, it doesn't work in Chrome right now. The newly added function GM_setValue and GM_getValue aren't supported in Chrome(/Chromium). See here.
Tim1987
Posts: 55
Send a message

Post by Tim1987
Made a small change so that the State column will only appear when on the www server.
Hope you don't mind me talking English here? (Or should I buzz off to the Papyrus forum? :))

Code: Select all

// ==UserScript==
// @name           Waze
// @namespace      https://waze-papyrus-extended-tools.googlecode.com/svn/trunk/
// @include        https://world.waze.com/cartouche/*
// @include        https://www.waze.com/cartouche/*
// @match          https://world.waze.com/cartouche/*
// @match          https://www.waze.com/cartouche/*
// ==/UserScript==



var version = "1.2.2";

// Compatibility with google chrome web browser
// Thanks to bgodette and Tim1987
if(window.navigator.vendor.match(/Google/)) {
  console.log("Patching google chrome environment");

  unsafeWindow = (function() {
    var el = document.createElement('p');
    el.setAttribute('onclick', 'return window;');
    return el.onclick();
  })();

  GM_deleteValue = function(name) {
    localStorage.removeItem(name);
  };

  GM_getValue = function(name, defaultValue) {
    var value = localStorage.getItem(name);
    if (!value) return defaultValue;
    var type = value[0];
    value = value.substring(1);
    switch (type) {
      case 'b': return value == 'true';
      case 'n': return Number(value);
      default: return value;
    }
  };

  GM_setValue = function(name, value) {
    localStorage.setItem(name, (typeof value)[0] + value);
  };
};

var $   = unsafeWindow.$;
var doc = unsafeWindow.document;
var wm  = unsafeWindow.wazeModel;
Array = unsafeWindow.Array; // Because unsafeWindow.Array have some extra prototype (like first())

function createElement(p, type, className) {
  var e = doc.createElement(type);
  if(p) p.appendChild(e);
  if (className != undefined) e.className = className;
  return e;
}

function createTextNode(p, txt) {
  p.appendChild(doc.createTextNode(txt));
  return p;
}



function getStreet(seg) {
  var sid = seg.attributes.primaryStreetID;
  if(sid) return wm.streets.objects[sid];
}

function getCity(str) {
  var cityId = str.cityID;
  if(cityId) return wm.cities.objects[cityId];
}

function getState(city) {
  var stateId = city.stateID;
  if (stateId) return wm.states.objects[stateId];
}

function getCountry(city) {
  var countryId = city.countryID;
  if(countryId) return wm.countries.objects[countryId];
}

function computeDicCountry() {
  var dicCountry = {};
  
  for(var segId in wm.segments.objects) {
    var seg = wm.segments.objects[segId];
    if(seg) {
      var str = getStreet(seg);
      var countryName = "";
      var stateName = "";
      var cityName = "";
      var strName = "";
      if(str) {
        if(str.name) strName = str.name;
        var city = getCity(str);
        if(city) {
          if(city.name) cityName = city.name;
          var country = getCountry(city);
          if(country && country.name) countryName = country.name;
          var state = getState(city);
          if (state && state.name) stateName = state.name;
        }
      }

      if(countryName == "Belgium") countryName = "BE";
      if(countryName == "Canada") countryName = "CAN";
      if(countryName == "France") countryName = "F";
      if(countryName == "Germany") countryName = "DE";
      if(countryName == "Mexico") countryName = "MEX";
      if(countryName == "Netherlands") countryName = "NL";
      if(countryName == "United States") countryName = "USA";
      
      
      var dicState = dicCountry[countryName];
      if (dicState == null) { dicState = {}; dicCountry[countryName] = dicState; }
      var dicCity = dicState[stateName];
      if(dicCity == null) { dicCity = {}; dicState[stateName] = dicCity; }
      var dicStr = dicCity[cityName];
      if(dicStr == null) { dicStr = {}; dicCity[cityName] = dicStr; }
      var lSeg = dicStr[strName];
      if(lSeg == null) { lSeg = new Array(); dicStr[strName] = lSeg; }
      lSeg.push(seg);
    }
  }  
  return dicCountry;
}

function refreshTable(tab, tbody) {
  console.log("Refresh");
  wm  = unsafeWindow.wazeModel;
  var dicCountry  = computeDicCountry();
  $(tbody).empty();
  for(var countryName in dicCountry) {
    var dicState = dicCountry[countryName];
    for(var stateName in dicState) {
      var dicCity = dicState[stateName];
      for(var cityName in dicCity) {
        var dicStr = dicCity[cityName];
        for(var strName in dicStr) {
          var lSeg = dicStr[strName]; 
          var tr = createElement(tbody, "TR");
          var td = createElement(tr, "TD");
          createTextNode(td, countryName);
          var td = createElement(tr, "TD");
		  if(location.hostname == "www.waze.com") {
            createTextNode(td, stateName);
            var td = createElement(tr, "TD");
		  }
          createTextNode(td, cityName);
          var td = createElement(tr, "TD");
          createTextNode(td, strName);
          var td = createElement(tr, "TD");
          
          var but = createElement(td, "INPUT");
          but.type = "button";
          but.value = lSeg.length;
          but.addEventListener("click", (function(lSeg) {
            return function(e) {
              unsafeWindow.selectionManager.select(lSeg);
            }; })(lSeg));
        }
      }
    }
  }
  $(tab).find("TD").css({borderWidth: "1px", borderStyle: "solid", padding: "2px"});
}

$(doc).ready(function() {
  console.log("Ready");
  window.setTimeout(function() {
    console.log("Timeout");
    $("#map-problems-explanation").remove();
    
    var user = $("#user-details");
    var para = createElement(null, "P");
    user.append(para);
    
    var divver = createElement(para, "DIV");
    $(divver).css( { fontSize: "10px", textAlign: "right" } );
    createTextNode(divver, "Extended tools V" + version);
    
    var but = createElement(para, "INPUT");
    but.type = "button";
    but.value = "Refresh table";
    but.addEventListener("click", function(e) { refreshTable(tab, tbody); });
    
    var log = createElement(para, "SPAN");
    $(log).css("font-size", "10px");
    
    var scrol = createElement(para, "DIV");
    $(scrol).css({ height: "670px", overflow: "auto" });
    
    var tab = createElement(scrol, "TABLE");
    $(tab).css("font-size", "10px");
    
    var thead = createElement(tab, "THEAD");
    $(thead).css( { fontSize: "12px", fontWeight: "bold" } );
    var td = createElement(thead, "TD");
    createTextNode(td, "Ctry");
    if(location.hostname == "www.waze.com") {
	  var td = createElement(thead, "TD");
      createTextNode(td, "State");
	}
    var td = createElement(thead, "TD");
    createTextNode(td, "City");
    var td = createElement(thead, "TD");
    createTextNode(td, "Street");
    var td = createElement(thead, "TD");
    createTextNode(td, "Select");
    
    
    var tbody = createElement(tab, "TBODY");
    
    refreshTable(tab, tbody);
    
  }, 5000);
});
Tim1987
Posts: 55
Send a message
Last edited by Tim1987 on Thu Oct 06, 2011 1:39 pm, edited 1 time in total.

Post by Tim1987
slicer wrote: Non that's cool :) Lots of us can translate :)
But I think we should discuss first because everybody's doing something on his own, and that's making a lot of different ways. We should create a topic on the papyrus's dedicated forum no, with one link to download ?

Must see with Alcolo, Alan, you and others who wants to take part of this little project :)
That would be a good idea, yes. And just now I see that Alcolo actually has a google code project for this script. That's the best way to work together of course.
I would like to contribute, but I'm sure I can help much with the actual code. (I haven't coded JS for a long time)

By the way, I edited the code above just a little, but it's not worthy of a new version number ;) Just added a few countries and sorted them alphabetically.
Tim1987
Posts: 55
Send a message

Post by Tim1987
I've put up a new version on the international forum, here.
Hope you like it.
Tim1987
Posts: 55
Send a message