0) {
tbls[i].removeAttribute(tbls[i].attributes[0].nodeName);
}
tbls[i].id = 'pageTbl';
tbls[i].className = 'pageTbl';
for (j = 0; j < tbls[i].rows[0].cells.length; j++) {
while (tbls[i].rows[0].cells[j].attributes && tbls[i].rows[0].cells[j].attributes.length > 0) {
tbls[i].rows[0].cells[j].removeAttribute(tbls[i].rows[0].cells[j].attributes[0].nodeName);
}
tbls[i].rows[0].cells[j].className = 'pageTblCell' + j.toString();
}
}
// List tables
if (tbls[i].getAttribute('width') == '80%' && tbls[i] && tbls[i].rows && tbls[i].rows[0].cells && tbls[i].rows[0].cells.length == 6) { // Potential list table
if (tbls[i].rows[0].cells[2].innerHTML.match(/Price /)) { // First list table
tbls[i].id = 'lstTbl0';
}
else if (tbls[i].rows[1] && tbls[i].rows[1].cells[2].innerHTML.match(/RM /)) { // Subsequent list tables
tblIdCount++;
tbls[i].id = 'lstTbl' + tblIdCount.toString();
}
}
// Advertisement table
if (tbls[i].className == 'bt bl br bb') { tbls[i].id = 'advertTbl_RCol'; }
}
// Remove advert elements
if (document.getElementById('advertTbl_RCol') != null) { document.getElementById('advertTbl_RCol').parentNode.removeChild(document.getElementById('advertTbl_RCol')); }
while (document.getElementsByTagName('iframe')[0] != null) {
document.getElementsByTagName('iframe')[0].parentNode.removeChild(document.getElementsByTagName('iframe')[0]);
}
if (document.getElementById('lstTbl0') != null) {
return true;
} else {
return false;
}
}
function ReadTables(data) {
var c0, c1, c2, c3, c4, c5;
var tbl, i = 0;
while (document.getElementById('lstTbl' + i.toString()) != null) {
tbl = document.getElementById('lstTbl' + i.toString());
for (j = 0; j < tbl.rows.length; j++) {
for (k = 0; k < 6; k++) {
eval('c' + k.toString() + ' = tbl.rows[j].cells[k].innerHTML;');
}
if ((c0 + c1 + c2 + c3 + c4 + c5).length != 0) {
if (i == 0 && j == 0) {
data[0] = [c0, c1, c2, c3, c4, c5, 'price', 'time'];
} else {
data.push([c0, c1, c2, c3, c4, c5, CalcPrice(c2), CalcTime(c5)]);
}
}
}
i++;
}
return true;
}
function ModifyTableData(data) {
if (data.length > 1) {
data[0][2] = ''+aD+''+aU+'' + data[0][2];
data[0][5] = ''+aD+''+aU+'' + data[0][5];
for (i = 1; i < data.length; i++) {
data[i][2] = data[i][2].replace(/font-weight: bold;">RM /,'">RM ');
data[i][2] += 'RM ' + FormatPrice(data[i][6]) + '
';
if (data[i][4].match(/ Bids/)) {
data[i][4] = '' + data[i][4] + '';
} else if (data[i][4].match(/\d{3,} Views/)) {
data[i][4] = '' + data[i][4] + '';
}
}
}
return;
}
function ShowTable(data, sorter) {
var titleRow, tbl, newRow, newCell;
var closedItemExists = false;
var i = 0;
if (sorter == null) {
sorter = GetSortCommand();
}
AppendSortCommandToLinks(sorter);
if (document.getElementById('qcksrch') && document.getElementById('qcksrch_sort') == null) {
var newInput = document.createElement('input');
newInput.id = 'qcksrch_sort';
newInput.type = 'hidden';
newInput.name = 'SortBy';
newInput.value = sorter;
document.getElementById('qcksrch').appendChild(newInput);
} else if (document.getElementById('qcksrch_sort')) {
document.getElementById('qcksrch_sort').value = sorter;
}
tbl = document.getElementById('lstTbl0');
if (tbl == null) { return; }
// Delete existing rows
while (tbl.rows[0] != null) {
tbl.deleteRow(0);
}
// Sort table data
titleRow = data.shift();
data = data.sort(eval(sorter));
data.unshift(titleRow);
// Add new rows with data
for (i = 0; i < data.length; i ++) {
newRow = tbl.insertRow(-1);
if (i == 0) { newRow.id = 'titleRow'; } // Title row.
if (i % 2 == 1) { newRow.style.backgroundColor = '#e8e8e8'; } // Alternate row background color.
for (j = 0; j < 6; j++) { // Insert cells
if (data[i][5].match(/Closed/) && hideClosed == true) {
} else {
newCell = newRow.insertCell(-1);
newCell.className = 'column' + j.toString();
newCell.innerHTML = data[i][j];
}
if (data[i][5].match(/Closed/)) { closedItemExists = true; } // Check if any item is 'Closed'
}
}
// Manage sorter arrows
document.getElementById(sorter).className += ' currentSort';
document.getElementById(sorter).setAttribute('onclick', '');
// Remove existing list tables
i = 1;
while ( document.getElementById( 'lstTbl' + i.toString() ) != null ) {
tbl.parentNode.removeChild( document.getElementById('lstTbl' + i.toString()) );
i++;
}
// Add 'Hide Closed Item' button
if (document.getElementById('pageTbl') != null && closedItemExists == true && hideClosed == false) {
var newTd = document.createElement('td');
newTd.className = 'hideClosedItemCell';
newTd.setAttribute('onclick', 'HideClosedItems()');
newTd.innerHTML = 'Hide
Closed
';
document.getElementById('pageTbl').rows[0].appendChild(newTd);
}
// Add top pagination table
if (document.getElementById('pageTblTop') == null && document.getElementById('pageTbl') != null) {
var newPageTbl = document.getElementById('pageTbl').cloneNode(true);
newPageTbl.id = 'pageTblTop';
document.getElementById('lstTbl0').parentNode.insertBefore(newPageTbl, document.getElementById('lstTbl0'));
}
return;
}
function HideClosedItems() {
while (document.getElementsByClassName('pageTblCell3 hideClosedItemCell')[0]) {
document.getElementsByClassName('pageTblCell3 hideClosedItemCell')[0].parentNode.removeChild(document.getElementsByClassName('pageTblCell3 hideClosedItemCell')[0]);
}
hideClosed = true;
ShowTable(tblData, null);
return;
}
function GetSortCommand() {
if (document.URL.match(/SortBy=priceAsc|SortBy=priceDesc|SortBy=timeAsc|SortBy=timeDesc/)) {
return document.URL.match(/priceAsc|priceDesc|timeAsc|timeDesc/)[0];
} else {
return 'priceAsc';
}
}
function AppendSortCommandToLinks(command) {
var i;
var links = document.getElementsByTagName('a');
for (i = 0; i < links.length; i++) {
if (links[i].href.match(/Auc\/List\/List.asp/) || links[i].href.match(/http:\/\/list\.lelong\.com\.my\/L\.asp/)) { // Listing page
if (links[i].href.match(/SortBy=priceAsc|SortBy=priceDesc|SortBy=timeAsc|SortBy=timeDesc/)) { // Link contains sort command parameters
links[i].href = links[i].href.replace(/SortBy=priceAsc|SortBy=priceDesc|SortBy=timeAsc|SortBy=timeDesc/, 'SortBy=' + command);
} else if (links[i].href.match(/\?/i)) { // Link already contains other parameters
links[i].href += '&SortBy=' + command;
} else { // Link does not contain any parameters
links[i].href += '?SortBy=' + command;
}
}
}
return;
}
function CalcPrice(data) {
var prices = data.match(/RM [\d,]{1,}\.\d\d/g);
if (prices != null && prices[0] != null) {
prices[0] = parseFloat(prices[0].replace(/RM/,'').replace(/,/,'').replace(/\s/g, ''));
if (prices[1] != null) {
prices[1] = parseFloat(prices[1].replace(/RM/,'').replace(/,/,'').replace(/\s/g, ''));
prices[0] = parseInt((prices[0] + prices[1]) * 100);
prices[0] = prices[0] / 100;
}
return prices[0].toString();
} else {
return '0';
}
}
function CalcTime(time) {
var d = 0;
var h = 0;
var m = 0;
if (time.match(/Closed/)) { return -1; }
time = time.replace(/ /g, '');
time = time.replace(/\s/g, '');
if (time.match(/\d{1,}d/) != null) { d = parseInt(time.match(/\d{1,}d/)); }
if (time.match(/\d{1,}h/) != null) { h = parseInt(time.match(/\d{1,}h/)); }
if (time.match(/\d{1,}m/) != null) { m = parseInt(time.match(/\d{1,}m/)); }
if (time.match(/\d{1,}min/) != null) { m = parseInt(time.match(/\d{1,}min/)); }
if (d != 0 && isFinite(d)) { d *= 1440; }
if (h != 0 && isFinite(h)) { h *= 60; }
return (d + h + m).toString();
}
function FormatPrice(price) {
var formattedPrice = price;
if (!formattedPrice.toString().match(/\./)) {
formattedPrice += '.00';
} else if (formattedPrice.toString().length - formattedPrice.toString().search(/\./) == 2) {
formattedPrice += '0';
}
if (formattedPrice.toString().length > 6) {
formattedPrice = formattedPrice.toString().substr(0, formattedPrice.toString().length - 6) + ',' + formattedPrice.toString().substr(-6);
}
return formattedPrice;
}
function priceAsc(a, b) {
var x = a[6];
var y = b[6];
return x-y;
}
function priceDesc(a, b) {
var x = a[6];
var y = b[6];
return y-x;
}
function timeAsc(a, b) {
var x = a[7];
var y = b[7];
return x-y;
}
function timeDesc(a, b) {
var x = a[7];
var y = b[7];
return y-x;
}]]>).toString()); // >>>>>>>>>> [End] AddJavascript
AddCSS((