Go Back   Google Chrome Forums > Google Chrome > Chrome Plugins


http://chromeplugins.org/frwrdicon.jpg
Top Tip : Click here to Boost Your PC & Chrome Browsing Speed
Reply
 
Thread Tools Display Modes
  #21  
Old 07-12-2009, 07:35 AM
Waha's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Oregon
Posts: 601
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
Libraries: bliplib
Tools: manifest syntax highlighting & snippits
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #22  
Old 07-12-2009, 01:08 PM
StevePaul's Avatar
Senior Member
 
Join Date: Mar 2009
Location: Birmingham, England
Posts: 1,415
Send a message via MSN to StevePaul
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..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #23  
Old 07-13-2009, 08:33 PM
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..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #24  
Old 07-13-2009, 09:53 PM
Waha's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Oregon
Posts: 601
Default

Cool, thanks. :] Maybe I'll keep it installed now. lol
__________________
~ Projects ~
Specialized: Carapass Auction Watcher
Libraries: bliplib
Tools: manifest syntax highlighting & snippits
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #25  
Old 07-13-2009, 10:02 PM
StevePaul's Avatar
Senior Member
 
Join Date: Mar 2009
Location: Birmingham, England
Posts: 1,415
Send a message via MSN to StevePaul
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #26  
Old 07-13-2009, 10:05 PM
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #27  
Old 07-13-2009, 10:34 PM
StevePaul's Avatar
Senior Member
 
Join Date: Mar 2009
Location: Birmingham, England
Posts: 1,415
Send a message via MSN to StevePaul
Default

@Kryptx

Just as a matter of interest what does the null parameter do ...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #28  
Old 07-13-2009, 10:45 PM
Waha's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Oregon
Posts: 601
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
Libraries: bliplib
Tools: manifest syntax highlighting & snippits
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #29  
Old 07-13-2009, 11:11 PM
StevePaul's Avatar
Senior Member
 
Join Date: Mar 2009
Location: Birmingham, England
Posts: 1,415
Send a message via MSN to StevePaul
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' ...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #30  
Old 07-14-2009, 12:34 AM
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chrome Officially Out of Beta Chrome Chrome Talk 1 12-16-2008 04:39 PM
Chrome To Come Out Of Beta Chrome Chrome Talk 0 12-10-2008 11:38 AM




Chrome Central - Chrome Talk - Chrome Tips and Tricks - Chrome Plugins - Chrome Themes - Chrome Tools - Bugs and Vulnerabilities - Chrome Tech - General Chat


All times are GMT. The time now is 01:03 AM.


Powered by vBulletin® Version 3.7.4 PL1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Google Chrome and Google™ is a Trademark of Google Inc
This site chromeplugins.org is not affiliated with or sponsored by Google Inc.
Thanks: Taree SEO Forum and John