marty.net 1001 Postcards Love Love Love Meep Meep ZenZodiac DailyQuotation

YOU ARE HERE:
Handy Checkbox Tool For CP Shopkeeper

HOME

CPSHOP|

|

|

EMAIL MARTY
  marty.net message board
  « Handy Checkbox Tool For CP Shopkeeper »
Welcome, Guest. Please Login or Register.
12/18/17 at 01:12:38
Home Help Search Login Register
   marty.net message board
   General
   General Stuff
   Handy Checkbox Tool For CP Shopkeeper
(Moderator: Marty)
Pages: 1 Reply Notify of replies Send the topic Print 
   Author  Topic: Handy Checkbox Tool For CP Shopkeeper  (Read 785 times)
Jason
Gold Dragon
****

Posts: 54




   

Handy Checkbox Tool For CP Shopkeeper
« on: 01/22/08 at 15:28:37 »
Reply with quote Modify message

If you've been using CafePress very long you've probably noticed that the UI can be a bit tedious to work with. I'm in the process of exploring tools that can help with this. If you use Firefox install Greasemonkey and give this script a try. If you don't use Firefox, get your head checked.

This tool is great because it allows you to bulk toggle checkboxes. It's a time saver for bulk changing prices, images, descriptions, etc for a select subset of products. Finally, you don't have to click 22 of those little boxes by hand ) Just click one while holding down shift, click the last one of the group you want.

Disclaimer: I didn't write it, just found it...

Greasemonkey:
https://addons.mozilla.org/en-US/firefox/addon/748

The script:
/ Author: Csaba Gabor
// ==UserScript==
// @name          Checkbox clicker
// @namespace    
// @description   clicks all checkboxes between two given ones
// @include       http://*cafepress.com/*
// ==/UserScript==

window.setTimeout (function() {
 var fn=function(evt) {  // called when a checkbox is clicked
   if (!evt.screenX && !evt.screenY) return;  // don't parse simulated clicks
   if (evt.ctlKey || evt.altKey) return;  // if non shift => exit
   var former = arguments.callee.prior;   // prior pressed checkbox
   var shiftP = evt.shiftKey && former;   // shift key pressed AND prior checkbox click
   if (shiftP) {
     if (former==this) return;
     var check = arguments.callee.prior.checked;  // state of prior checkbox

     var bubble = function(elem) { // return an array of ancestors
       for (var L=0, aV = [elem]; aV[L++]!=document.body; aV[L] = aV[L-1].parentNode);
       return aV; }
     var aPar1 = bubble (former), L1 = aPar1.length;   // ancestors of former
     var aPar2 = bubble (this),   L2 = aPar2.length;   // ancestors of this
     // Percolate backwards to find a common ancestor (to minimize extra results)
     for (var pos=0; aPar1[L1-pos]==aPar2[L2-pos]; ++pos);
     var common=aPar1[aPar1.length-pos+1];
     var aCh = common.getElementsByTagName("INPUT");   // get all checkboxes

     // Now set the checkboxes
     var setCheck = function(elem, bState) {
       elem.checked = !bState;
       elem.click(); }   // so any other click handler fires (eg. highlighting)
     for (var i=0,phase=0;i<aCh.length;++i) {
       if (aCh[i].type!="checkbox") continue;
       if (!phase) {  // we don't know which comes first
         if (aCh[i]==this) { phase=former; setCheck(this, check); }
         else if (aCh[i]==former) phase=this; }
       else {
         setCheck (aCh[i], check);
         if (aCh[i]==phase) break; } } }

     // else set the checkbox just clicked as anchor
     if (!evt.shiftKey || !shiftP) arguments.callee.prior = this;
   }

 // assign the same event handler to all checkboxes
 var aCh=document.body.getElementsByTagName("INPUT");
 for (var cb,idx=0;idx<aCh.length;++idx)
   if (aCh[idx].type=="checkbox")
     aCh[idx].addEventListener("click", fn, false);

 }, 20);

// END FILE
« Last Edit: 01/22/08 at 15:30:40 by Jason » Logged

www.viadesigns.com
Jason
Gold Dragon
****

Posts: 54




   

Re: Handy Checkbox Tool For CP Shopkeeper
« Reply #1 on: 01/22/08 at 15:37:28 »
Reply with quote Modify message

Even better...someone has shared their lib of Greasemonkey scripts
http://forums.cafepress.com/eve/forums/a/tpc/f/594104/m/183108041
Logged

www.viadesigns.com
flippinsweetgear
Gold Dragon
****

Posts: 171



Go Scots!
   

WWW
Re: Handy Checkbox Tool For CP Shopkeeper
« Reply #2 on: 01/24/08 at 20:20:44 »
Reply with quote Modify message

These look awesome!!  Thanks.
Logged

Flippin Sweet Gear | Kids T-shirts | Big Lebowski Shirts
Pages: 1 Reply Notify of replies Send the topic Print 
Jump to:


marty.net message board (http://www.marty.net/cgi/marty/board/messageboard)

Powered by YaBB 1 Gold - Release (Yet Another Bulletin Board)
Copyright 2000-2001, X-Null. All Rights Reserved.