Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2114 connectés 

 


Dernière réponse
Sujet : Mouse Gesture for Mozilla [simple normalement]
youdontcare :)

Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
youdontcare :)
sisicaivrai oua merci, ca marche  
mea culpa, j'avais pas fermé le quicklaunch de mozilla
 [:cupra]  
 
par contre avec ton truc pour avoir les 'alert', du coup j'en avais une a chaque fonction gesture  :p  
 
C super, vraiment MERCI  :hello: d'avoir passé du temps là dessus  :jap:
youdontcare ...
 
la fin du fichier mozgest.properties doit ressembler à :
 
g.halveImageSize=Halve Image Size
g.hideImage=Hide Image
g.w3cValidate=Validate this document
g.linksInWindows=Open Links in Windows
g.linksInTabs=Open Links in Tabs
g.openLink=Ouvre un lien
 
le fichier gestimp.js doit ressembler à :
 
addGesture("D", bundle.getString("g.openNewDocument" ), "openNewDocument();" );
addGesture("DU", bundle.getString("g.duplicateWindow" ), "duplicateWindow()" );
addGesture("ULU", bundle.getString("g.upDir" ), "upDir();" );
addGesture("ULD", bundle.getString("g.openLink" ), "g_openLink();" );
 
puis à la fin du fichier :
 
function g_openLink()
{
 linkInTab("http://forum.hardware.fr" );  
}
 
si tout ça ne marche pas, tu rajoutes un alert() de debug dans gestures.js :
 
function addGesture(gestCode, descString, evalCode){
 alert(gestCode + ' ' + descString + ' ' + evalCode);
  gesturesTable[gestCode]=new Array(descString, evalCode);
}
 
histoire de voir à partir de où ça plante.
 
et avant de tester ces modifs, tu dois fermer mozilla puis le rouvrir.
sisicaivrai en plus ils ne parlent meme pas de ce fichier properties sur leur site...
 
Bon là j'ai appliqué à la lettre tes instructions pour mon probleme, mais ca ne marchait pas alors j'ai essayé ton truc avec la date, meme resultat :/
je dois etre trop manche :/
youdontcare

sisicaivrai a écrit a écrit :

j'aurais du préciser que je ne connais RIEN en javascript


effectivement.  
 
ça m'aurait évité d'avoir envie de t'étrangler :D

sisicaivrai

youdontcare a écrit a écrit :

j'ai installé la bestiole histoire de tester ...
 
DONC :
 
addGesture prend trois paramètres :  
 
1. le code de la gesture
2. sa description
3. le code js qui s'éxécute lorsqu'elle est activée
 
un truc que tu aurais pu trouver en debuggant un minimum, c'est que la string de description vient d'un fichier appellé mozgest.properties . tu peux voir par exemple g.viewSiteCookies qui correspond à "View Cookies". (le fichier doit permettre la traduction).
 
en debuggant à nouveau, tu t'aperçois que ton addGesture plante si mozilla ne trouve pas de string de description. il faut donc la définir (au même endroit que les autres).
 
donc un petit exemple simple : lors d'un ULD, on affiche la date.
 
1/ on définit une nouvelle fonction dans gestimp.js :
 
function g_showDate()
{
  alert(new Date);
}  
 
2/ on définit sa description dans le fichier mozgest.properties à la suite des autres :
 
g.showDate=Affiche la date
 
3/ on définit le addGesture dans le fichier gestimp.js à la suite des autres :
 
addGesture("ULD", bundle.getString("g.showDate" ), "g_showDate();" );
 
et ça marche. (après un reload du browser). pour ton histoire de tab, tu suis la même démarche sauf qu'au lieu de new Date() tu appelles linkInTab("http://debuggeunpeulaprochainefois.merci" );.  




 
merci  :jap:  
j'aurais du préciser que je ne connais RIEN en javascript, car a voir le ton de ta réponse (complete je t'en remercie) tu as l'air de considérer que j'aurais pu m'en sortir seul
ben non, sinon je n'aurais pas posté de question
ca sert a ca un forum
 :jap: donc

youdontcare j'ai installé la bestiole histoire de tester ...
 
DONC :
 
addGesture prend trois paramètres :  
 
1. le code de la gesture
2. sa description
3. le code js qui s'éxécute lorsqu'elle est activée
 
un truc que tu aurais pu trouver en debuggant un minimum, c'est que la string de description vient d'un fichier appellé mozgest.properties . tu peux voir par exemple g.viewSiteCookies qui correspond à "View Cookies". (le fichier doit permettre la traduction).
 
en debuggant à nouveau, tu t'aperçois que ton addGesture plante si mozilla ne trouve pas de string de description. il faut donc la définir (au même endroit que les autres).
 
donc un petit exemple simple : lors d'un ULD, on affiche la date.
 
1/ on définit une nouvelle fonction dans gestimp.js :
 
function g_showDate()
{
  alert(new Date);
}  
 
2/ on définit sa description dans le fichier mozgest.properties à la suite des autres :
 
g.showDate=Affiche la date
 
3/ on définit le addGesture dans le fichier gestimp.js à la suite des autres :
 
addGesture("ULD", bundle.getString("g.showDate" ), "g_showDate();" );
 
et ça marche. (après un reload du browser). pour ton histoire de tab, tu suis la même démarche sauf qu'au lieu de new Date() tu appelles linkInTab("http://debuggeunpeulaprochainefois.merci" );.
sisicaivrai

youdontcare a écrit a écrit :

vas-tu nous donner des détails cette fois-ci ? qu'est censé faire le code, quelle partie as-tu écrite, quelle partie marche et quelle partie plante, etc. ?
 
et mieux encore, plutôt que de filer un pavé, filer un lien vers une page avec le code ?  




mais ce n'est pas mon code, c'est bien ca le probleme, c'est le code de mozgest,plugin pour mozilla, donc je n'en ai rien ecrit :/
toute la partie 'code' marche très bien, seulement avec ce qui est donné comme 'exemple' ben je ne sais pas faire ce que je veux
 
ce plugin serta avoir des raccourcis souris :U = up, D = down, L = left, R = right
 
donc par exemple, en faisant UD, ca reload
moi ce que je veux c ouvrir une nouvelle fenetre dans la tab avec par exemple DRU

youdontcare vas-tu nous donner des détails cette fois-ci ? qu'est censé faire le code, quelle partie as-tu écrite, quelle partie marche et quelle partie plante, etc. ?
 
et mieux encore, plutôt que de filer un pavé, filer un lien vers une page avec le code ?
sisicaivrai [:prosper youplaboum]
sisicaivrai :sweat:
sisicaivrai je ne m'étonnes pas de faire un bide ;)
:jap: de te pencher sur le probleme, mais ca ne marche pas :/
youdontcare

sisicaivrai a écrit a écrit :

[code]addGesture("DRU", bundle.getString("g.ULB" ), "linkInTab("http://xyz");" );


mets-toi à la place de l'interpréteur de code. comment savoir où finit la string qui commence par "linkInTab... ?
 
il va chopper une string :
 
"linkInTab("
 
une erreur :
 
http://xyz
 
une deuxième string :
" );"
 
donc
 
addGesture("DRU", bundle.getString("g.ULB" ), "linkInTab(\"http://xyz\" );" );  
 
ou
 
addGesture("DRU", bundle.getString("g.ULB" ), "linkInTab('http://xyz');" );  
 
et si tu t'étonnes de faire un bide en balançant des centaines de ligne de code ... :D

sisicaivrai kel bide :-/
sisicaivrai up !
sisicaivrai

Code :
  1. var prefRoot = Components.classes["@mozilla.org/preferences-serv
  2. ice;1"].getService(Components.interfaces.nsIPrefS
  3. ervice).getBranch("" );
  4. function initGestureTable() {
  5.   // *** navigational gestures (& related) ***
  6.   addGesture("L", bundle.getString("g.BrowserBack" ), "BrowserBack();" );
  7.   addGesture("R", bundle.getString("g.BrowserForward" ), "BrowserForward();" );
  8.   addGesture("UD", bundle.getString("g.BrowserReload" ), "BrowserReload();" );
  9.   addGesture("UDU", bundle.getString("g.BrowserReloadSkipCache" ), "BrowserReloadSkipCache();" );
  10.   addGesture("DURD", bundle.getString("g.BrowserHome" ), "BrowserHome();" );
  11.   addGesture("RDU", bundle.getString("g.scrollDown" ), "window._content.scrollBy(0,200);" );
  12.   addGesture("RU", bundle.getString("g.scrollUp" ), "window._content.scrollBy(0,-200);" );
  13.   addGesture("D", bundle.getString("g.openNewDocument" ), "openNewDocument();" );
  14.   addGesture("DU", bundle.getString("g.duplicateWindow" ), "duplicateWindow()" );
  15.   addGesture("ULU", bundle.getString("g.upDir" ), "upDir();" );
  16.   // *** tab gestures ***
  17.   addGesture("DULR", bundle.getString("g.BrowserOpenTab" ), "BrowserOpenTab();" ); //Contributed by Exotrip
  18.   addGesture("DUD", bundle.getString("g.duplicateTab" ), "linkInTab(window._content.document.location);" );
  19.   addGesture("DUR", bundle.getString("g.nextTab" ), "nextTab();" );
  20.   addGesture("DUL", bundle.getString("g.previousTab" ), "previousTab();" );
  21.   // *** window manipulation (minimize etc.)
  22.   addGesture("UR", bundle.getString("g.restMaxWin" ), "restMaxWin();" );
  23.   addGesture("DL", bundle.getString("g.minWin" ), "minWin();" );
  24.   addGesture("RLR", bundle.getString("g.closeDoc" ), "closeDoc();" );
  25.   addGesture("DR", bundle.getString("g.closeDoc" ), "closeDoc();" );
  26.   // *** misc ***  
  27.   addGesture("URD", bundle.getString("g.viewFrameSource" ), "viewFrameSource();" );
  28.   addGesture("LDRDL", bundle.getString("g.viewFrameSource" ), "viewFrameSource();" ); //Squarish "S"
  29.   addGesture("LDR", bundle.getString("g.viewSiteCookies" ), "viewSiteCookies();" );
  30.   addGesture("URDURD", bundle.getString("g.metaInfo" ), "metaInfo();" );
  31.   addGesture("RLDUR", bundle.getString("g.explodeBackground" ), "explodeBackground();" );
  32.   addGesture("DRDLU", bundle.getString("g.addBookmark" ), "addBookmark();" );
  33.   // *** link drag over gestures ***
  34.   addGesture("UL", bundle.getString("g.doubleStackWin" ), "doubleStackWin();" );
  35.   addGesture("U", bundle.getString("g.linkInTab" ), "if(globalOnLink) linkInTab(globalOnLink[0]);" );
  36.   // Diagonals stuff
  37.   addGesture("3", bundle.getString("g.doubleImageSize" ), "doubleImageSize();" );
  38.   addGesture("7", bundle.getString("g.halveImageSize" ), "halveImageSize();" );
  39.   addGesture("1", bundle.getString("g.hideImage" ), "hideImage();" );
  40.   addGesture("39", bundle.getString("g.w3cValidate" ), "w3cValidate();" );
  41.   // globalOnLink stuff
  42.   addGesture("+RU", bundle.getString("g.linksInWindows" ), "linksInWindows();" );
  43.   addGesture("+RUL", bundle.getString("g.linksInTabs" ), "linksInTabs();" );
  44. }
  45. function doubleImageSize(){
  46.   if(globalOnImage) {
  47.     globalOnImage.width = globalOnImage.width * 2;
  48.     globalOnImage.height = globalOnImage.height * 2;
  49.   }
  50. }
  51. function halveImageSize(){
  52.   if(globalOnImage) {
  53.     globalOnImage.width = globalOnImage.width * .5;
  54.     globalOnImage.height = globalOnImage.height * .5;
  55.   }
  56. }
  57. function hideImage(){
  58.   if(globalOnImage) {
  59.     globalOnImage.width = 0;
  60.     globalOnImage.height = 0;
  61.   }
  62. }
  63. function linkInTab(url){
  64.   var browser = getBrowser();
  65.   var tab = browser.addTab(url, getReferrer(document));
  66.   if (!prefRoot.getBoolPref("browser.tabs.loadInBackground" ))
  67.     browser.selectedTab = tab;
  68. }
  69. function linksInTabs(){
  70.   var browser = getBrowser();
  71.   for(i = 0; i < globalOnLink.length; i++) {
  72.     tab = browser.addTab(globalOnLink[i], getReferrer(document));
  73.   }
  74. }
  75. function linksInWindows(){
  76.   for(i = 0; i < globalOnLink.length; i++) {
  77.     tempW = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no",
  78.               globalOnLink[i], null, true, getReferrer(document) );
  79.   }
  80. }
  81. function openNewDocument(){
  82.   var tempW;
  83.     if(globalOnImage) {     // Open image in new window
  84.       tempW = window.open(globalOnImage);
  85.     } 
  86.     else {
  87.       if(!globalOnLink) { // open new browser window   
  88.         var uriToLoad = "";
  89.         if (prefRoot.getIntPref("browser.startup.page" ) == 1)
  90.           uriToLoad = getHomePage();
  91.         tempW = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no",
  92.                   uriToLoad, null, true, getReferrer(document) );
  93.       }
  94.       else { // open link in new window  
  95.         tempW = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no",
  96.                   globalOnLink[0], null, true, getReferrer(document) );}
  97.     }
  98. }
  99. function duplicateWindow(){
  100. openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no",
  101.            window._content.document.location, null, true, getReferrer(document));
  102. }
  103. function upDir(){ //from bookmarklets.com
  104.   var aUrl = window._content.document.location.href;
  105.   if (window._content.document.location.protocol != "about:" )
  106.     aUrl = aUrl.substring(0, aUrl.substring(0, aUrl.length-1).lastIndexOf('/')+1);
  107.     window._content.document.location.href = aUrl;
  108. }
  109. function nextTab(){ //Contributed by Scurrie
  110.   var tab, curTab, curTabNum, nextTab, l, i;
  111.   if (getBrowser().mTabContainer.childNodes.length > 1){
  112.     l = getBrowser().mTabContainer.childNodes.length;
  113.     curTab = getBrowser().selectedTab;
  114.     for (i = 0; i < l; i++){
  115.       tab = getBrowser().mTabContainer.childNodes[i];
  116.       if (tab == curTab) {curTabNum = i;}
  117.     }
  118.     if (curTabNum == getBrowser().mTabContainer.childNodes.length-1){
  119.       nextTab = getBrowser().mTabContainer.childNodes[0];
  120.     }
  121.     else {
  122.       nextTab = getBrowser().mTabContainer.childNodes[curTabNum+1];
  123.     }
  124.     getBrowser().selectedTab = nextTab;
  125.   }
  126. }
  127. function previousTab(){ //Contributed by Scurrie
  128.   var tab, curTab, curTabNum, nextTab, l, i;
  129.   if (getBrowser().mTabContainer.childNodes.length > 1){
  130.     l = getBrowser().mTabContainer.childNodes.length;
  131.     curTab = getBrowser().selectedTab;
  132.     for (i = 0; i < l; i++){
  133.       tab = getBrowser().mTabContainer.childNodes[i];
  134.       if (tab == curTab) {curTabNum = i;}
  135.     }
  136.     if (curTabNum == 0){
  137.       curTabNum = getBrowser().mTabContainer.childNodes.length -1;
  138.       nextTab = getBrowser().mTabContainer.childNodes[curTabNum];
  139.     }
  140.     else {
  141.       nextTab = getBrowser().mTabContainer.childNodes[curTabNum-1];}
  142.       getBrowser().selectedTab = nextTab;
  143.     }
  144. }
  145. function restMaxWin(){
  146.   if(window.maximize != 'undefined') {
  147.    if (window.windowState == STATE_MAXIMIZED)
  148.      window.restore();
  149.    else window.maximize();
  150.   }
  151. }
  152. function minWin(){
  153.   if(window.minimize != 'undefined') {
  154.     window.minimize();
  155.   }
  156. }
  157. function closeDoc(){
  158.   if (getBrowser().mTabContainer.childNodes.length > 1)
  159.     getBrowser().removeCurrentTab();
  160.   else window.setTimeout("window.close()", 10);
  161. }
  162. function viewSiteCookies(){ //Contributed by Squarefree.com
  163.   if (window._content.document.cookie)
  164.     alert(bundle.getString("cookies" ) + "\n\n"
  165.       + window._content.document.cookie.replace(/; /g,"\n" ));
  166.   else alert(bundle.getString("noCookies" ));
  167. }
  168. function metaInfo(){
  169.   var metas = window._content.document.getElementsByTagName("meta" );
  170.   if (metas.length != 0){
  171.     var metastr = bundle.getString("meta" ) + "\n\n";
  172.     for(var ameta = 0; ameta < metas.length; ameta++) {
  173.       var mymeta = metas.item(ameta);
  174.       metastr += "<META ";
  175.       if (mymeta.name) metastr += "name=\"" + mymeta.name + "\" ";
  176.       if (mymeta.httpEquiv) metastr+= "http-equiv=\"" + mymeta.httpEquiv + "\" ";
  177.       if (mymeta.content) metastr += "content=\"" + mymeta.content + "\" ";
  178.       if (mymeta.scheme) metastr += "scheme=\"" + mymeta.scheme + "\" ";
  179.       metastr += '>\n';
  180.     }
  181.     alert(metastr);
  182.   }
  183.   else alert(bundle.getString("noMeta" ));
  184. }
  185. function addBookmark(){
  186.   var browsers = getBrowser().browsers;
  187.   if (browsers.length > 1)
  188.     BookmarksUtils.addBookmarkForTabBrowser(gBrowser);
  189.   else
  190.     BookmarksUtils.addBookmarkForBrowser(gBrowser.webNavigation, true);
  191. }
  192. function explodeBackground(){
  193.   myBod = window._content.document.body;
  194.     myBod.background='http://www.surfmind.com/images/explode.gif';
  195.     myBod.setAttribute("style", "background:url(http://www.surfmind.com/images/explode.gif)" );
  196. }
  197. function doubleStackWin(){
  198.   var tempW;
  199.   if(globalOnLink) {
  200.     window.moveTo(0,0);
  201.     window.resizeTo(screen.availWidth/2, screen.availHeight);
  202.     tempW = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no",
  203.               globalOnLink[0], null, true, getReferrer(document) );
  204.     tempW.moveTo(screen.availWidth/2 + 1, 0);
  205.     tempW.resizeTo(screen.availWidth/2,screen.availHeight);
  206.   }
  207. }
  208. function w3cValidate() {
  209. window._content.document.location='http://validator.w3.org/check?uri='+window._content.document.location;
  210. }
  211. function viewFrameSource() {
  212.   try {
  213.     BrowserViewSourceOfDocument(globalSrcEvent.target.ownerDocument);
  214.   }
  215.   catch (ex) {
  216.   window.openDialog("chrome://navigator/content/viewSource.xul",
  217.                     "_blank",
  218.                     "scrollbars,resizable,chrome,dialog=no",
  219.                     globalSrcEvent.target.ownerDocument.location.href,
  220.                     "charset=" + globalSrcEvent.target.ownerDocument.characterSet);
  221.   }
  222. }


 
et j'aimerais avoir un raccourci pour ouvrir une url particulière dans la tab, donc g recopié :
addGesture("DUD", bundle.getString("g.duplicateTab" ), "linkInTab(window._content.document.location);" );
 
en :
 
addGesture("DRU", bundle.getString("g.ULB" ), "linkInTab("http://xyz" );" );
 
mais ca ne marche pas :/
des idées ?
 :hello:


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)