Plugin pour Papyrus v1.6.5

Comme le nom l'indique, ici ce sont les archives, où on met tous les vieux trucs :)

Moderators: shirlig, slicer, milkyway35, Forum moderators, France - Local Champs

Re: Plugin pour Papyrus

Postby Yoni33 » Mon Oct 24, 2011 11:19 am

bon boulot Alcolo47, je vais tester ça tout a l'heure.
Merci beaucoup...
CM level 5
Samsung Grand
Version: 3.9
AM sur le Grand-Bordeaux jusqu'au nord de la Gironde.
Image
Image
Yoni33
Country Manager
Country Manager
 
Posts: 386
Joined: Mon Oct 11, 2010 12:30 pm
Has thanked: 24 times
Been thanked: 1 time

Re: Plugin pour Papyrus

Postby Tim1987 » Thu Oct 06, 2011 4:58 pm

I've put up a new version on the international forum, here.
Hope you like it.
Tim1987
 
Posts: 55
Joined: Thu Mar 17, 2011 6:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Plugin pour Papyrus

Postby Tim1987 » Thu Oct 06, 2011 1:43 pm

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
Joined: Thu Mar 17, 2011 6:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Plugin pour Papyrus

Postby Tim1987 » Thu Oct 06, 2011 1:08 pm

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);
});
Last edited by Tim1987 on Thu Oct 06, 2011 1:39 pm, edited 1 time in total.
Tim1987
 
Posts: 55
Joined: Thu Mar 17, 2011 6:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Plugin pour Papyrus

Postby Tim1987 » Thu Oct 06, 2011 10:57 am

alcolo47 wrote:Version 1.2 toujours a la même URL:
http://waze-papyrus-extended-tools.googlecode.com/svn/trunk/waze.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
Joined: Thu Mar 17, 2011 6:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Plugin pour Papyrus

Postby Tim1987 » Wed Oct 05, 2011 10:56 pm

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
Joined: Thu Mar 17, 2011 6:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Plugin pour Papyrus v1.6.5

Postby tcm33 » Sun Nov 11, 2012 12:34 am

Super, bravo !
AM Aquitaine, CM France
UR : 11k
tcm33
Country Manager
Country Manager
 
Posts: 317
Joined: Mon Jun 18, 2012 10:49 pm
Location: Bordeaux, France
Has thanked: 21 times
Been thanked: 17 times

Re: Plugin pour Papyrus

Postby tcm33 » Fri Sep 21, 2012 12:08 pm

Hello,

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

Merci de nous faire gagner autant de temps.

--Timo
AM Aquitaine, CM France
UR : 11k
tcm33
Country Manager
Country Manager
 
Posts: 317
Joined: Mon Jun 18, 2012 10:49 pm
Location: Bordeaux, France
Has thanked: 21 times
Been thanked: 17 times

Re: Plugin pour Papyrus

Postby slicer » Wed Apr 18, 2012 8:15 am

Merci Alcolo, je viens de l'installer, je m'amuserai plus tard avec :)
Ghost
.....................................................................
S6 Edge+ - Android 6.0.1
slicer
 
Posts: 1792
Joined: Tue Mar 02, 2010 8:08 pm
Location: Lorraine
Has thanked: 33 times
Been thanked: 39 times

Re: Plugin pour Papyrus

Postby slicer » Mon Feb 20, 2012 8:34 pm

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 :)
Ghost
.....................................................................
S6 Edge+ - Android 6.0.1
slicer
 
Posts: 1792
Joined: Tue Mar 02, 2010 8:08 pm
Location: Lorraine
Has thanked: 33 times
Been thanked: 39 times

Next

Return to Archives

Who is online

Users browsing this forum: No registered users