Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

David R. MacIver http://unenterprise.blogspot.com

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Chickenfoot shortcut script

Here's a little script to get Chickenfoot to add some keyboard shortcuts to firefox.

Add this to run as a trigger on window open and you'll be able to acquire focus on the current chickenfoot editor window by pressing 'alt-C' and to regain focus on the main tab (which is something I've often wanted to be able to do) with 'alt-D'

   1  
   2  // attach keyboard shortcut (Alt-C)
   3  chromeWindow.addEventListener("keypress",
   4     function(event) {
   5       if (event.altKey && event.charCode == 'c'.charCodeAt(0)) {
   6         event.preventDefault();
   7         var sidebar = Chickenfoot.getSidebarWindow(chromeWindow);
   8         if (sidebar) {
   9            sidebar.getSelectedBuffer().focus();
  10         }
  11       }
  12      },
  13      true);
  14  
  15  
  16  // attach keyboard shortcut (Alt-D)
  17  chromeWindow.addEventListener("keypress",
  18     function(event) {
  19       if (event.altKey && event.charCode == 'd'.charCodeAt(0)) {
  20         event.preventDefault();
  21  	   tab.focus();
  22         }
  23      },
  24      false);
  25  
  26  
  27  

Extracting the values of all forms on the page

This is a simple piece of javascript intended to be run from Firebug or as a bookmarklet which extracts all the name : value pairs from forms on the page and pops up a new window listing them.

It's not very well written, and doesn't yet handle any non input form elements, but it will do for now. :-)

   1  
   2  var displayWindow = window.open();
   3  
   4  function showFormValues(form ) { 
   5      displayWindow.document.write('Form:');
   6      displayWindow.document.write(form.name);
   7      displayWindow.document.write('<br>');
   8  
   9      var formElements = form.getElementsByTagName('input');
  10  
  11      for (var i = 0; i < formElements.length; i++){
  12          var element = formElements[i];
  13          
  14          displayWindow.document.write(element.name + ' :  ' + element.value + ' <br>');}} 
  15  
  16  Array.forEach(document.forms, showFormValues);
  17  

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS