Posts Tagged ‘javascript’
- Posted by Mon
- October 21st, 2009
Version in this article: jQuery 1.3.2 / CSV2Table 0.03-b-2.9
Lately I started to like CSV (Common Separated Values) more and more comparing to XML.XML is a pain to setup even as entering data, then grabbing the data requires Einstein’s brain plus 3 sleepless and hair-pulling days of coding… okay, I maybe exaggerated a bit, but that’s how I feel about XML. My first encounter with CSV was InDesign, in there, you can import a bunch of data and generates PDF like Word’s Mail Merge feature. Then one day, someone asked me if I can find a better and easier way to help the non web people to maintain a site. I started out with search terms like “jQuery read text files” or something like that, one of the results returned as using CSV and there is a plugin called CSV2Table in the jQuery Plugins website by Toshiro Takahashi written earlier this year. Testing… (more…)
- Posted by Mon
- August 31st, 2009
This was one of the old posts that got corrupted when I did a reinstall of WP 2.8.1. Since this script is pretty handy, so I’m re-posting it.
This scripts worked in Acrobat 8 & 9 Pro. Instead of of manually extracting all the pages, and then manually optimize them, this script can ease the process. To access the Batch Processing menu: Advanced -> Document Processing -> Batch Processing. The screen shot below shows where and how to add the script:

Then add the following script into the “Javascript Editor”:
var filename = this.documentFileName.replace(".pdf","");
try{ for(var i = 0; i<this.numPages; i++)
var num = i+1;
this.extractPages({ nStart: i; });
cPath: filename+"_"+num+".pdf"});
}cath (e){ console.println {"Aborted: " + e) }
Saves a lot of time if you have a lot of files to extract and need to optimized the files using custom settings.
- Posted by Mon
- August 14th, 2009
Quickie note, a very simple script to pick a random number between 1–5, instead of 0–4
var rand = Math.floor(Math.random()*5);
if(rand > 0){
rand = rand+1;
alert(rand);
} else {
rand = 1;
alert(rand);
}