Skip to content

Instantly share code, notes, and snippets.

@b1rdex
Created May 15, 2012 08:06
Show Gist options
  • Save b1rdex/2699921 to your computer and use it in GitHub Desktop.
Save b1rdex/2699921 to your computer and use it in GitHub Desktop.
Print cart for ulmart.ru shop
//Dear Razrabs, please add this fucking feature to your site.
;(function() {
var artids = $('.artid'),
names = $('.clName a'),
counts = $('.clCount input'),
prices = $('.clPrice'),
costs = $('.clCost'),
r = []
;
artids.map(function(i) {
return r.push([
$(this).text().match(/\d+/)[0],
names.eq(i).text().trim(),
counts.eq(i).val(),
prices.eq(i).text().replace(' ', '').match(/\d+/)[0],
costs.eq(i).text().replace(' ', '').match(/\d+/)[0]
]);
});
var w = window.open(),
body = $(w.document.body),
table = $('<table></table>'),
header = '<tr><th>артикул</th><th>что</th><th>количество</th><th>цена</th><th>стоимость</th></tr>',
r2 = ''
;
$(r).map(function() {
return r2 = r2 + '<tr><td>' + this.join('</td><td>') + '</td></tr>';
});
table.append($(header + r2));
body.append(table);
})()
//for bookmarklet
javascript:void(function(){var artids = $('.artid'),names = $('.clName a'),counts = $('.clCount input'),prices = $('.clPrice'),costs = $('.clCost'),r = [];artids.map(function(i) {return r.push([$(this).text().match(/\d+/)[0],names.eq(i).text().trim(),counts.eq(i).val(),prices.eq(i).text().replace(' ', '').match(/\d+/)[0],costs.eq(i).text().replace(' ', '').match(/\d+/)[0]]);});var w = window.open(),body = $(w.document.body),table = $('<table></table>'),header = '<tr><th>артикул</th><th>что</th><th>количество</th><th>цена</th><th>стоимость</th></tr>',r2 = '';$(r).map(function() {return r2 = r2 + '<tr><td>' + this.join('</td><td>') + '</td></tr>';});table.append($(header + r2));body.append(table);}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment