1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
function Vote(amount, requestid) {
if (typeof amount == 'undefined') {
amount = parseInt($('#amount').raw().value);
}
if (amount == 0) {
amount = 20 * 1024 * 1024;
}
var index;
var votecount;
if (!requestid) {
requestid = $('#requestid').raw().value;
votecount = $('#votecount').raw();
index = false;
} else {
votecount = $('#vote_count_' + requestid).raw();
bounty = $('#bounty_' + requestid).raw();
index = true;
}
if (amount > 20 * 1024 * 1024) {
upload = $('#current_uploaded').raw().value;
download = $('#current_downloaded').raw().value;
rr = $('#current_rr').raw().value;
if (amount > 0.3 * (upload - rr * download)) {
if (!confirm('This vote is more than 30% of your buffer. Please confirm that you wish to place this large of a vote.')) {
return false;
}
}
}
ajax.get('requests.php?action=takevote&id=' + requestid + '&auth=' + authkey + '&amount=' + amount, function (response) {
if (response == 'bankrupt') {
error_message("You do not have sufficient upload credit to add " + get_size(amount) + " to this request");
return;
} else if (response == 'dupesuccess') {
//No increment
} else if (response == 'success') {
votecount.innerHTML = (parseInt(votecount.innerHTML)) + 1;
}
if ($('#total_bounty').results() > 0) {
totalBounty = parseInt($('#total_bounty').raw().value);
totalBounty += (amount * (1 - $('#request_tax').raw().value));
$('#total_bounty').raw().value = totalBounty;
$('#formatted_bounty').raw().innerHTML = get_size(totalBounty);
save_message("Your vote of " + get_size(amount) + ", adding a " + get_size(amount * (1 - $('#request_tax').raw().value)) + " bounty, has been added");
$('#button').raw().disabled = true;
} else {
save_message("Your vote of " + get_size(amount) + " has been added");
}
}
);
}
function Calculate() {
var mul = (($('#unit').raw().options[$('#unit').raw().selectedIndex].value == 'mb') ? (1024*1024) : (1024*1024*1024));
var amt = Math.floor($('#amount_box').raw().value * mul);
if (amt > $('#current_uploaded').raw().value) {
$('#new_uploaded').raw().innerHTML = "You can't afford that request!";
$('#new_bounty').raw().innerHTML = "0.00 MB";
$('#bounty_after_tax').raw().innerHTML = "0.00 MB";
$('#button').raw().disabled = true;
} else if (isNaN($('#amount_box').raw().value)
|| (window.location.search.indexOf('action=new') != -1 && $('#amount_box').raw().value * mul < 100 * 1024 * 1024)
|| (window.location.search.indexOf('action=view') != -1 && $('#amount_box').raw().value * mul < 20 * 1024 * 1024)) {
$('#new_uploaded').raw().innerHTML = get_size(($('#current_uploaded').raw().value));
$('#new_bounty').raw().innerHTML = "0.00 MB";
$('#bounty_after_tax').raw().innerHTML = "0.00 MB";
$('#button').raw().disabled = true;
} else {
$('#button').raw().disabled = false;
$('#amount').raw().value = amt;
$('#new_uploaded').raw().innerHTML = get_size(($('#current_uploaded').raw().value) - amt);
$('#new_ratio').raw().innerHTML = ratio($('#current_uploaded').raw().value - amt, $('#current_downloaded').raw().value);
$('#new_bounty').raw().innerHTML = get_size(mul * $('#amount_box').raw().value);
$('#bounty_after_tax').raw().innerHTML = get_size(mul * 0.9 * $('#amount_box').raw().value);
}
}
function AddArtistField() {
var ArtistCount = document.getElementsByName("artists[]").length;
if (ArtistCount >= 200) {
return;
}
var ArtistField = document.createElement("input");
ArtistField.type = "text";
ArtistField.id = "artist";
ArtistField.name = "artists[]";
ArtistField.size = 45;
var ImportanceField = document.createElement("select");
ImportanceField.id = "importance";
ImportanceField.name = "importance[]";
ImportanceField.options[0] = new Option("Main", "1");
ImportanceField.options[1] = new Option("Guest", "2");
ImportanceField.options[2] = new Option("Composer", "4");
ImportanceField.options[3] = new Option("Conductor", "5");
ImportanceField.options[4] = new Option("DJ / Compiler", "6");
ImportanceField.options[5] = new Option("Remixer", "3");
ImportanceField.options[6] = new Option("Producer", "7");
var x = $('#artistfields').raw();
x.appendChild(document.createElement("br"));
x.appendChild(ArtistField);
x.appendChild(document.createTextNode('\n'));
x.appendChild(ImportanceField);
if ($("#artist").data("gazelle-autocomplete")) {
$(ArtistField).live('focus', function() {
$(ArtistField).autocomplete({
serviceUrl : 'artist.php?action=autocomplete'
});
});
}
ArtistCount++;
}
function RemoveArtistField() {
var ArtistCount = document.getElementsByName("artists[]").length;
if (ArtistCount == 1) {
return;
}
var x = $('#artistfields').raw();
while (x.lastChild.tagName != "INPUT") {
x.removeChild(x.lastChild);
}
x.removeChild(x.lastChild);
x.removeChild(x.lastChild); //Remove trailing new line.
ArtistCount--;
}
function Categories() {
var cat = $('#categories').raw().options[$('#categories').raw().selectedIndex].value;
if (cat == "Music") {
$('#artist_tr').gshow();
$('#releasetypes_tr').gshow();
$('#formats_tr').gshow();
$('#bitrates_tr').gshow();
$('#media_tr').gshow();
ToggleLogCue();
$('#year_tr').gshow();
$('#cataloguenumber_tr').gshow();
} else if (cat == "Audiobooks" || cat == "Comedy") {
$('#year_tr').gshow();
$('#artist_tr').ghide();
$('#releasetypes_tr').ghide();
$('#formats_tr').ghide();
$('#bitrates_tr').ghide();
$('#media_tr').ghide();
$('#logcue_tr').ghide();
$('#cataloguenumber_tr').ghide();
} else {
$('#artist_tr').ghide();
$('#releasetypes_tr').ghide();
$('#formats_tr').ghide();
$('#bitrates_tr').ghide();
$('#media_tr').ghide();
$('#logcue_tr').ghide();
$('#year_tr').ghide();
$('#cataloguenumber_tr').ghide();
}
}
function add_tag() {
if ($('#tags').raw().value == "") {
$('#tags').raw().value = $('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value;
} else if ($('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value == "---") {
} else {
$('#tags').raw().value = $('#tags').raw().value + ", " + $('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value;
}
}
function Toggle(id, disable) {
var arr = document.getElementsByName(id + '[]');
var master = $('#toggle_' + id).raw().checked;
for (var x in arr) {
arr[x].checked = master;
if (disable == 1) {
arr[x].disabled = master;
}
}
if (id == "formats") {
ToggleLogCue();
}
}
function ToggleLogCue() {
var formats = document.getElementsByName('formats[]');
var flac = false;
if (formats[1].checked) {
flac = true;
}
if (flac) {
$('#logcue_tr').gshow();
} else {
$('#logcue_tr').ghide();
}
ToggleLogScore();
}
function ToggleLogScore() {
if ($('#needlog').raw().checked) {
$('#minlogscore_span').gshow();
} else {
$('#minlogscore_span').ghide();
}
}
|