Gazelle/static/functions/user.js

170 lines
6.8 KiB
JavaScript
Raw Normal View History

2011-03-28 14:21:28 +00:00
function ChangeTo(to) {
2013-04-18 08:00:54 +00:00
if (to == "text") {
2011-03-28 14:21:28 +00:00
$('#admincommentlinks').hide();
$('#admincomment').show();
resize('admincomment');
var buttons = document.getElementsByName('admincommentbutton');
2013-04-30 18:18:07 +00:00
for (var i = 0; i < buttons.length; i++) {
2011-03-28 14:21:28 +00:00
buttons[i].setAttribute('onclick',"ChangeTo('links'); return false;");
}
2013-04-18 08:00:54 +00:00
} else if (to == "links") {
2013-05-04 08:00:48 +00:00
ajax.post("ajax.php?action=preview","form", function(response) {
2011-03-28 14:21:28 +00:00
$('#admincommentlinks').raw().innerHTML = response;
$('#admincomment').hide();
$('#admincommentlinks').show();
var buttons = document.getElementsByName('admincommentbutton');
2013-04-30 18:18:07 +00:00
for (var i = 0; i < buttons.length; i++) {
2011-03-28 14:21:28 +00:00
buttons[i].setAttribute('onclick',"ChangeTo('text'); return false;");
}
})
}
}
function UncheckIfDisabled(checkbox) {
if (checkbox.disabled) {
checkbox.checked = false;
}
}
function AlterParanoia() {
// Required Ratio is almost deducible from downloaded, the count of seeding and the count of snatched
// we will "warn" the user by automatically checking the required ratio box when they are
// revealing that information elsewhere
2013-04-18 08:00:54 +00:00
if (!$('input[name=p_ratio]').raw()) {
2011-03-28 14:21:28 +00:00
return;
}
var showDownload = $('input[name=p_downloaded]').raw().checked || ($('input[name=p_uploaded]').raw().checked && $('input[name=p_ratio]').raw().checked);
if (($('input[name=p_seeding_c]').raw().checked) && ($('input[name=p_snatched_c]').raw().checked) && showDownload) {
$('input[type=checkbox][name=p_requiredratio]').raw().checked = true;
$('input[type=checkbox][name=p_requiredratio]').raw().disabled = true;
} else {
$('input[type=checkbox][name=p_requiredratio]').raw().disabled = false;
}
$('input[name=p_torrentcomments_l]').raw().disabled = !$('input[name=p_torrentcomments_c]').raw().checked;
$('input[name=p_collagecontribs_l]').raw().disabled = !$('input[name=p_collagecontribs_c]').raw().checked;
$('input[name=p_requestsfilled_list]').raw().disabled = !($('input[name=p_requestsfilled_count]').raw().checked && $('input[name=p_requestsfilled_bounty]').raw().checked);
$('input[name=p_requestsvoted_list]').raw().disabled = !($('input[name=p_requestsvoted_count]').raw().checked && $('input[name=p_requestsvoted_bounty]').raw().checked);
$('input[name=p_uploads_l]').raw().disabled = !$('input[name=p_uploads_c]').raw().checked;
$('input[name=p_uniquegroups_l]').raw().disabled = !$('input[name=p_uniquegroups_c]').raw().checked;
$('input[name=p_perfectflacs_l]').raw().disabled = !$('input[name=p_perfectflacs_c]').raw().checked;
$('input[name=p_seeding_l]').raw().disabled = !$('input[name=p_seeding_c]').raw().checked;
$('input[name=p_leeching_l]').raw().disabled = !$('input[name=p_leeching_c]').raw().checked;
$('input[name=p_snatched_l]').raw().disabled = !$('input[name=p_snatched_c]').raw().checked;
UncheckIfDisabled($('input[name=p_torrentcomments_l]').raw());
UncheckIfDisabled($('input[name=p_collagecontribs_l]').raw());
UncheckIfDisabled($('input[name=p_requestsfilled_list]').raw());
UncheckIfDisabled($('input[name=p_requestsvoted_list]').raw());
UncheckIfDisabled($('input[name=p_uploads_l]').raw());
UncheckIfDisabled($('input[name=p_uniquegroups_l]').raw());
UncheckIfDisabled($('input[name=p_perfectflacs_l]').raw());
UncheckIfDisabled($('input[name=p_seeding_l]').raw());
UncheckIfDisabled($('input[name=p_leeching_l]').raw());
UncheckIfDisabled($('input[name=p_snatched_l]').raw());
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
// unique groups, "Perfect" FLACs and artists added are deducible from the list of uploads
if ($('input[name=p_uploads_l]').raw().checked) {
$('input[name=p_uniquegroups_c]').raw().checked = true;
$('input[name=p_uniquegroups_l]').raw().checked = true;
$('input[name=p_uniquegroups_c]').raw().disabled = true;
2013-02-22 08:00:24 +00:00
$('input[name=p_uniquegroups_l]').raw().disabled = true;
2011-03-28 14:21:28 +00:00
$('input[name=p_perfectflacs_c]').raw().checked = true;
$('input[name=p_perfectflacs_l]').raw().checked = true;
$('input[name=p_perfectflacs_c]').raw().disabled = true;
2013-02-22 08:00:24 +00:00
$('input[name=p_perfectflacs_l]').raw().disabled = true;
2011-03-28 14:21:28 +00:00
$('input[type=checkbox][name=p_artistsadded]').raw().checked = true;
$('input[type=checkbox][name=p_artistsadded]').raw().disabled = true;
} else {
$('input[name=p_uniquegroups_c]').raw().disabled = false;
$('input[name=p_uniquegroups_l]').raw().checked = false;
$('input[name=p_uniquegroups_l]').raw().disabled = true;
$('input[name=p_perfectflacs_c]').raw().disabled = false;
$('input[type=checkbox][name=p_artistsadded]').raw().disabled = false;
}
if ($('input[name=p_collagecontribs_l]').raw().checked) {
$('input[name=p_collages_c]').raw().disabled = true;
$('input[name=p_collages_l]').raw().disabled = true;
$('input[name=p_collages_c]').raw().checked = true;
$('input[name=p_collages_l]').raw().checked = true;
} else {
$('input[name=p_collages_c]').raw().disabled = false;
$('input[name=p_collages_l]').raw().disabled = !$('input[name=p_collages_c]').raw().checked;
UncheckIfDisabled($('input[name=p_collages_l]').raw());
}
}
function ParanoiaReset(checkbox, drops) {
var selects = $('select');
for (var i = 0; i < selects.results(); i++) {
if (selects.raw(i).name.match(/^p_/)) {
2013-04-18 08:00:54 +00:00
if (drops == 0) {
2011-03-28 14:21:28 +00:00
selects.raw(i).selectedIndex = 0;
2013-04-18 08:00:54 +00:00
} else if (drops == 1) {
2011-03-28 14:21:28 +00:00
selects.raw(i).selectedIndex = selects.raw(i).options.length - 2;
2013-04-18 08:00:54 +00:00
} else if (drops == 2) {
2011-03-28 14:21:28 +00:00
selects.raw(i).selectedIndex = selects.raw(i).options.length - 1;
}
AlterParanoia();
}
}
var checkboxes = $(':checkbox');
for (var i = 0; i < checkboxes.results(); i++) {
if (checkboxes.raw(i).name.match(/^p_/) && (checkboxes.raw(i).name != 'p_lastseen')) {
if (checkbox == 3) {
checkboxes.raw(i).checked = !(checkboxes.raw(i).name.match(/_list$/) || checkboxes.raw(i).name.match(/_l$/));
} else {
checkboxes.raw(i).checked = checkbox;
}
2013-02-22 08:00:24 +00:00
AlterParanoia();
2011-03-28 14:21:28 +00:00
}
}
}
function ParanoiaResetOff() {
ParanoiaReset(true, 0);
}
function ParanoiaResetStats() {
ParanoiaReset(3, 0);
$('input[name=p_collages_l]').raw().checked = false;
}
function ParanoiaResetOn() {
ParanoiaReset(false, 0);
$('input[name=p_collages_c]').raw().checked = false;
$('input[name=p_collages_l]').raw().checked = false;
}
addDOMLoadEvent(AlterParanoia);
2012-03-03 08:00:28 +00:00
function ToggleWarningAdjust(selector) {
if (selector.options[selector.selectedIndex].value == '---') {
$('#ReduceWarningTR').show();
$('#ReduceWarning').raw().disabled = false;
} else {
$('#ReduceWarningTR').hide();
$('#ReduceWarning').raw().disabled = true;
}
2012-11-01 08:00:21 +00:00
}
addDOMLoadEvent(ToggleIdenticons);
function ToggleIdenticons() {
2013-04-18 08:00:54 +00:00
var selected = $('#disableavatars').raw().selectedIndex;
if (selected == 2 || selected == 3) {
$('#identicons').show();
} else {
$('#identicons').hide();
}
}
2013-05-14 08:00:34 +00:00
function userform_submit() {
var userform = jQuery('#userform');
if (jQuery('#resetpasskey').is(':checked')) {
if (confirm('Are you sure you want to reset your passkey?')) {
userform.submit();
}
}
else {
userform.submit();
};
}