bookmarket testing

Soldato
Joined
1 Apr 2009
Posts
9,952
javascript:(function()
{
var shoppingBasket = document.getElementById("shoppingBkt");

var tbdy = shoppingBasket.getElementsByTagName('tbody')[0];

var rows = tbdy.getElementsByTagName('tr');

var str = "[COLOR=\"Yellow\"]YOUR BASKET[/COLOR]\n";

var images = "";

for (var i=1; i < rows.length - 4; i++)
{
var row = rows;

var cells = row.getElementsByTagName('td');

if (row.className == "basket_option")
{
var inputs = row.getElementsByTagName('input');

/* a complete system with no option price or count */
if(inputs.length == 0)
{
var cell = cells[0];

for (var j=0; j < cell.childNodes.length; j ++)
{
var option = cell.childNodes[j];

if(option.nodeName == "#text")
{
var desc = "[COLOR=\"Wheat\"]" + option.data + "[/COLOR]\n";
str += desc;
}
}
}
// a fully configurable build.
else if(inputs.length == 1)
{
var desc = cells[0].childNodes[2].data;
var qty = cells[1].childNodes[0].value;
var price = cells[2].childNodes[0].innerText;
str += "[COLOR=\"Wheat\"]" + qty + " x " + desc + "[/COLOR] [COLOR=\"Yellow\"]" + price + "[/COLOR]\n";
}
}
else
{
var image = cells[0].childNodes[0].src;
var desc = cells[1].childNodes[0].textContent;
var link = cells[1].childNodes[0].href;
var qty = cells[2].childNodes[0].value;
var price = cells[3].childNodes[0].innerText;
var total = cells[4].childNodes[0].innerText;
images += "" + " ";

str += qty + " x " + "" + desc + " " + "[COLOR=\"Yellow\"]" + price + "[/COLOR]";

if(qty > 1)
{
str += " [COLOR=\"DarkOrange\"](" + total + ")[/COLOR]";
}
str += "\n";
}
}

/* shipping costs */
var shipping = rows[rows.length - 3];

var shippingCells = shipping.getElementsByTagName('td');

var shippingValue = shippingCells[2].textContent;

/* grand total */
var total = document.getElementById('orderTotal');

var totalCells = total.getElementsByTagName('td');

var totalValue = totalCells[2].textContent;

str += "Total : [COLOR=\"Yellow\"]" + totalValue + "[/COLOR] " + "(includes shipping : " + shippingValue + ").\n";

/* thumbnails*/
str += "\n" + images + "\n\n";

window.clipboardData.setData("Text",str);
};
)
();
 
Back
Top Bottom