Skip to content
This repository has been archived by the owner on Nov 3, 2018. It is now read-only.

Commit

Permalink
Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
chingc committed Apr 22, 2013
1 parent d21fbd9 commit 559ad9d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
## 1.3: 2013-04-22
- Code cleanup.


## 1.2: 2012-12-07
- Fixed: Purchase failure when using djmaxcrew.com instead of www.djmaxcrew.com.

<br />

## 1.1: 2012-11-04
- Fixed: Didn't work in Firefox.

<br />

## 1.0: 2012-11-03
- First public release.
36 changes: 18 additions & 18 deletions djbuy.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
javascript:(/* DJBuy, version 1.2, https://github.com/smwst/DJBuy */ function () {
javascript:(/* DJBuy, version 1.3, https://github.com/smwst/DJBuy */ function () {
'use strict';
var match = /djmaxcrew\.com\/maxshop\/shop_music_detail\.asp\?m=[01]&i=[a-zA-Z0-9]+/,
var to_int = function (str) {
return parseInt(str.replace(/,/g, ''), 10);
},
match = /djmaxcrew\.com\/maxshop\/shop_music_detail\.asp\?m=[01]&i=[a-zA-Z0-9]+/,
message,
points,
points_needed,
output,
si;
purchase_id;
if (match.test(location.hostname + location.pathname + location.search)) {
points = parseInt($('.login_maxpoint .point_blue').text().replace(/,/g, ''), 10);
points = to_int($('.login_maxpoint .point_blue').text());
points_needed = (function () {
var sum = 0;
$.map($.map($('.i_check:enabled').siblings('font'), function (element) {
return parseInt(element.innerHTML.replace(/,/g, ''), 10);
}), function (element) {
sum += element;
$('.i_check:enabled').siblings('font').each(function () {
sum += to_int(this.innerHTML);
});
return sum;
}());
output = 'Available Max Points: ' + points + '\nMax Points Needed: ' + points_needed + '\n\n';
si = [];
message = 'Available Max Points: ' + points + '\nMax Points Needed: ' + points_needed + '\n\n';
if (points_needed === 0) {
alert(output + 'Nothing to buy. Returning...');
alert(message + 'Nothing to buy. Returning...');
history.back();
} else if (points_needed > points) {
alert(output + 'Not enought Max Points to buy everything.');
alert(message + 'Not enought Max Points to buy everything.');
} else {
if (confirm(output + 'Proceed with purchase?')) {
$.map($('.i_check:enabled'), function (element) {
si.push(element.value, '|');
if (confirm(message + 'Proceed with purchase?')) {
purchase_id = [];
$('.i_check:enabled').each(function () {
purchase_id.push(this.value);
});
si.pop();
$.ajax({
url: 'http://' + location.hostname + '/maxshop/ProcShopMusic.asp?si=' + si.join('')
url: 'http://' + location.hostname + '/maxshop/ProcShopMusic.asp?si=' + purchase_id.join('|')
}).done(function () {
alert('Purchased! You have ' + (points - points_needed) + ' Max Points left.\n\nReturning...');
history.back();
Expand Down

0 comments on commit 559ad9d

Please sign in to comment.