Welcome guest, is this your first visit? Create Account now to join.
Page 3 of 9 FirstFirst 12345 ... LastLast
Results 21 to 30 of 88

This is a discussion on ChromeGestures beta 0.1 within the Chrome Plugins section, part of the Google Chrome category: Originally Posted by StevePaul @Waha Thanks loads for this, I'll go to bed a happy man now ;-) Everything worked ...


  1. #21
    Waha's Avatar
    Waha is offline Senior Member
    Join Date
    Apr 2009
    Location
    Oregon
    Posts
    788

    Default

    Quote Originally Posted by StevePaul View Post
    @Waha

    Thanks loads for this, I'll go to bed a happy man now ;-)

    Everything worked OK apart from Facebook, hides it OK but won't reinstate it ...
    Things like Facebook and other AJAX based websites might be a little trickier. I'm not entirely sure. I could try setting the body to hidden instead of replacing it with nothing. I'll see how that works out, but I don't really know that the body can have that style.
    ~ Projects ~
    Specialized: Carapass Auction Watcher, Kongregate Chat
    Libraries: bliplib
    Tools: manifest syntax highlighting & snippits
    ~ Happy to make extensions for pay too ;D ~
    Portfolio: Search and Share

  2. #22
    StevePaul's Avatar
    StevePaul is offline Senior Member
    Join Date
    Mar 2009
    Location
    Birmingham, England
    Posts
    1,522

    Default

    TBH It's not a problem for me, it was my son who spotted it (I don't use FB myself)... ;-)
    Last edited by StevePaul; 07-12-2009 at 10:40 PM.

  3. #23
    Kryptyx is offline Member
    Join Date
    Jul 2009
    Posts
    59

    Default

    First off, I must say that this a great extension. I have a small fix that will re-enable the rightclick context menu if you are not performing a gesture, if do perform a gesture, it will not show up.

    I'm using the modified JS file from Waha, also I changed the default blank tab to open google, this way its a little more user friendly.

    I'm fairly new to frontend coding, I typically do backend php/sql work but I figured I would mess with this a little.
    Code:
     /** READ THIS BEFORE EDITING **/
    //  Here you can create your own gestures. For the moment, how this works is that you create
    //  a Gesture and an Action. 
    //
    //         _____________
    //   _____/ Terminology |___________________________________________________________________________________________________________________________
    //  |                                                                                                                                               |
    //  |    Moves are either 'up', 'down', 'left' or 'right'.                                                                                          |
    //  |                                                                                                                                               |
    //  |    A Gesture is an array of Moves e.g.: myNewGesture = ["up","down","left"].                                                                  |
    //  |        - You should never have a Gesture that has two identical consecutive moves. e.g.: ["left","right","right"] is not a valid Gesture.     |
    //  |                                                                                                                                               |
    //  |    An Action is a function that takes no parameters and has no return value. e.g.: myNewAction = function(){ alert("OMG!") }                  |
    //  |                                                                                                                                               |
    //  |    You can then configure ChromeGesture by modifying the myGestures array.                                                                    |
    //  |    myGestures is an array where the index is your Gesture and the data is your Action. e.g.: myGestures[myNewGesture] = myNewAction;          |
    //  |       - Do not use the same Gesture for two Actions.                                                                                          |
    //  |                                                                                                                                               |
    //   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    //
    // In case of doubt, drop by the forums on chromeplugins.org and ask. We'll answer ;)
    
    // ============ BEGIN STUFF YOU CAN (AND SHOULD) EDIT ============
    var newTabGesture           = ["down","right"];
    var closeTabGesture         = ["down","left"];
    var historyBackGesture      = ["left"];
    var historyForwardGesture   = ["right"];
    var hidePageGesture   		= ["click","click"];
    
    // TODO: Support for Chrome API
    
    function  newTabAction() {
    	window.open("http://google.com/",null);
    }
    
    function closeTabAction() {
        window.close();
    }
    
    function historyBackAction() {
        history.back();
    }
    
    function historyForwardAction() {
        history.forward();
    }
    
    var ishiding = false;
    var page = "",backgroundimage="";
    function hidePageAction() {
    	if(ishiding){
    		document.body.innerHTML = page;
    		document.body.style.backgroundImage = backgroundimage;
    		ishiding = false;
    	} else {
    		page = document.body.innerHTML;
    		document.body.innerHTML = "";
    		backgroundimage = document.body.style.backgroundImage;
    		document.body.style.backgroundImage = "none";
    		ishiding = true;
    		console.log("Hiding?");
    	}
    }
    
    var myGestures = [];
    
    myGestures[newTabGesture]           = newTabAction;
    myGestures[closeTabGesture]         = closeTabAction;
    myGestures[historyBackGesture]      = historyBackAction;
    myGestures[historyForwardGesture]   = historyForwardAction;
    myGestures[hidePageGesture]   		= hidePageAction;
    
    // ============ UNLESS YOU KNOW WHAT YOU ARE DOING, DON'T EDIT PAST HERE :) ============
    
    // CONSTANTS
    
    var ChromeGesture = {
    
        // If you think the Gesture detection sensitity too low, make these higher.
        MINIMUM_DELTAY : 10,             // tweak this - Minimum Y distance that needs to be travelled between 2 captures for a move to be detected
        MINIMUM_DELTAX : 10,             // tweak this - Same for X
        DELAY_BETWEEN_CAPTURES : 10,     // tweak this - Time between captures
    
    
        LEFT_CLICK : 1,                 // Number associated with Left Click
        RIGHT_CLICK : 3,                 // Number associated with Right Click
    
    
        // Global variables
    
        pastX : 0,
        pastY : 0,
        currentGesture : [],
    
        pastTime : new Date(),
    
        // Functions
    
        captureGesture : function(event) {
            
            var currentTime = new Date();
            var diff = currentTime.getTime() - ChromeGesture.pastTime.getTime();
            
            var currentX = event.clientX;
            var currentY = event.clientY;
            
            ChromeGesture.printLine(currentX, currentY);
            
            if( diff < ChromeGesture.DELAY_BETWEEN_CAPTURES ){
                return;
            } else {
                console.debug("Capture!");
                
                var deltaX = currentX - ChromeGesture.pastX;
                var deltaY = currentY - ChromeGesture.pastY;
                
                console.log("Movement vector : (" + deltaX + ", " + deltaY + ")");
                
                ChromeGesture.pastX = currentX;
                ChromeGesture.pastY = currentY;
                
                var move = ChromeGesture.determineMove(deltaX, deltaY);
                
                if( move != null ){
                    if( move != ChromeGesture.currentGesture[ChromeGesture.currentGesture.length - 1]){
                        ChromeGesture.currentGesture.push(move);
                    }
                }
                
                console.warn("Moves : [" + ChromeGesture.currentGesture +"]");
                
                ChromeGesture.pastTime = currentTime;
            }
        },
    
        determineMove : function(deltaX, deltaY) {
    
            var absDeltaX = Math.abs(deltaX);
            var absDeltaY = Math.abs(deltaY);		
    
            if( absDeltaX < ChromeGesture.MINIMUM_DELTAX && absDeltaY < ChromeGesture.MINIMUM_DELTAY ) { 
    			return null;						
            }
    		else {
    			document.oncontextmenu = function(){return false;} // Gesture detected, hide the context menu
    		}
            
            if( absDeltaY > absDeltaX ) {
                if( deltaY < 0 ){
                    return "up"
                } else {
                    return "down"
                }
            } else {
                if( deltaX > 0 ){
                    return "right"
                } else {
                    return "left"
                }
            }
        },
    
        mouseButtonDown : function(event) {
            console.log("Mouse button down : " + event.which);
            if (event.which == ChromeGesture.RIGHT_CLICK){ 
            
            //TODO: Don't stop propagation if time between mouseup / mousedown is < CONSTANT
            
                document.oncontextmenu = function(){return true;} // Right-click detected, enable the context menu
            
                ChromeGesture.pastX = event.clientX;
                ChromeGesture.pastY = event.clientY;
                window.addEventListener("mousemove", ChromeGesture.captureGesture);			
            }
        },
    
        mouseButtonUp : function(event) { 
            console.log("Mouse button up : " + event.which);
            if(event.which == ChromeGesture.RIGHT_CLICK){
                
                event.preventDefault();
                event.stopPropagation();
            
                console.log("Removing event listener");
                window.removeEventListener("mousemove", ChromeGesture.captureGesture);
                
                if(myGestures[ChromeGesture.currentGesture]){
                    // TODO: Support passing of parameters based on the origin of the gesture and such.
                    myGestures[ChromeGesture.currentGesture]();
                }
                
                ChromeGesture.currentGesture = [];
            } else if (event.which == ChromeGesture.LEFT_CLICK){ 
    			ChromeGesture.currentGesture.push("click");
    		}
        },
        
        printLine : function() {
            // TODO: Print stuff next to cursor, track cursor position, append a div with text in document.
        }
    
    }
    // Initialization
    
    window.addEventListener("mousedown", ChromeGesture.mouseButtonDown, false);
    window.addEventListener("mouseup", ChromeGesture.mouseButtonUp, false);
    EDIT: I also wanted to mention that this might not be the cleanest or best way to do this but I found it as a workable solution.
    Last edited by Kryptyx; 07-13-2009 at 08:46 PM.

  4. #24
    Waha's Avatar
    Waha is offline Senior Member
    Join Date
    Apr 2009
    Location
    Oregon
    Posts
    788

    Default

    Cool, thanks. :] Maybe I'll keep it installed now. lol
    ~ Projects ~
    Specialized: Carapass Auction Watcher, Kongregate Chat
    Libraries: bliplib
    Tools: manifest syntax highlighting & snippits
    ~ Happy to make extensions for pay too ;D ~
    Portfolio: Search and Share

  5. #25
    StevePaul's Avatar
    StevePaul is offline Senior Member
    Join Date
    Mar 2009
    Location
    Birmingham, England
    Posts
    1,522

    Default

    @Kryptyx

    Great additions to Kyrax's original (and Waha's amendment) ...

    I took it a step further and changed the NewTab to show a page of my choice instead of the Google page you had put in (wasn't sure about the ,null at the end so left it in, it seems to work OK)...

    Works a treat ;-)

    Not missing CNT so much now ;-D

  6. #26
    Kryptyx is offline Member
    Join Date
    Jul 2009
    Posts
    59

    Default

    Quote Originally Posted by Waha View Post
    Cool, thanks. :] Maybe I'll keep it installed now. lol
    lol yeah same issue I had, I loved the concept and I think it was really well done but I still needed the context menu for obvious reasons.

  7. #27
    StevePaul's Avatar
    StevePaul is offline Senior Member
    Join Date
    Mar 2009
    Location
    Birmingham, England
    Posts
    1,522

    Default

    @Kryptx

    Just as a matter of interest what does the null parameter do ...

  8. #28
    Waha's Avatar
    Waha is offline Senior Member
    Join Date
    Apr 2009
    Location
    Oregon
    Posts
    788

    Default

    Quote Originally Posted by StevePaul View Post
    @Kryptx

    Just as a matter of interest what does the null parameter do ...
    That argument is for where the window should load, leaving it null makes it open in a new window in the default position, which I believe is "_blank".
    ~ Projects ~
    Specialized: Carapass Auction Watcher, Kongregate Chat
    Libraries: bliplib
    Tools: manifest syntax highlighting & snippits
    ~ Happy to make extensions for pay too ;D ~
    Portfolio: Search and Share

  9. #29
    StevePaul's Avatar
    StevePaul is offline Senior Member
    Join Date
    Mar 2009
    Location
    Birmingham, England
    Posts
    1,522

    Default

    Thanks for that Waha ...

    @Kyrax

    As your the author of this extension could you repackage it with the amended JS (additions by Waha & Kryptyx) ...

    The reason I ask is that I frequent the official Chrome Help forum and one of the questions that is still being constantly asked is about the NEWTab page and either customising it or making it blank ...

    Previously I have always recommended CNT, but as that isn't working currently this extension (with its new bits) is ideal to replace it....

    Just one thing I would ask is you put a note in the JS showing where to put your page of choice (rather than Google) ...

    If I remember rightly didn't you do that in the original version of CNT ...

    I think this is a really good extension and worthy of 'Flagshipping' this forum and the excellent work being done by all our 'developers' ...

  10. #30
    Kryptyx is offline Member
    Join Date
    Jul 2009
    Posts
    59

    Default

    I was thinking of re-releasing this project to maintain a stable development build. Ofcourse cediting the original author and waha for their work. I believe the author stated that he did not have time to maintain this addon...that is why I mentioned doing it. I have started to look at mouse trail abilities to fill in the authors "todo"s. Any suggestions? Also about the null... its not needed really I have some tweaked version that iu will release soon.

Page 3 of 9 FirstFirst 12345 ... LastLast

Similar Threads

  1. Chrome Officially Out of Beta
    By Chrome in forum Chrome Talk
    Replies: 1
    Last Post: 12-16-2008, 05:39 PM
  2. Chrome To Come Out Of Beta
    By Chrome in forum Chrome Talk
    Replies: 0
    Last Post: 12-10-2008, 12:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •