Skip to content

Commit

Permalink
Update page_modpack.js
Browse files Browse the repository at this point in the history
set_public and setting recommended now shows/hides other recommended buttons.
  • Loading branch information
cowpod committed Oct 31, 2024
1 parent c9763b2 commit ffea599
Showing 1 changed file with 43 additions and 4 deletions.
47 changes: 43 additions & 4 deletions resources/js/page_modpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@ function remove_box(id,name) {
$("#build-text").text(name);
$("#remove-button").attr("onclick","remove("+id+")");
}
function set_public(id) {
$("#cog-"+id).show();
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
response = JSON.parse(this.response);
$("#cog-"+id).hide();
if (response['status']=="succ") {
// if (response['latest']==id) {
// }
$("#pub-"+id).hide();
if (response['recommended']==id) {
$("#recd-"+id).show();
} else {
$("#rec-"+id).show();
}
} else {
console.log(response);
}
}
};
request.open("GET", "./functions/set-public-build.php?id="+id+"&ispublic=1");
request.send();

}
function remove(id) {
$("#cog-"+id).show();
var request = new XMLHttpRequest();
Expand Down Expand Up @@ -84,14 +109,28 @@ function set_recommended(id) {
request.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
response = JSON.parse(this.response);

$("[id^='recd-']").each(function() {
let otherid = $(this).attr("id").substring(5);
if (otherid==id) {
return;
} else {
// hide all recd
$(this).hide();
// show all rec
$("#rec-"+otherid).show();
}
});
$("#recd-"+id).show(); // recommended
$("#rec-"+id).hide(); // reccommend
$("#rec-v-li").show();
$("#rec-mc-li").show();
$("#cog-"+id).hide();
$("#rec-"+id).attr('disabled', true);
// $("#rec-"+id).attr('disabled', true);
var bid = $("#rec-disabled").attr('bid');
$("#rec-disabled").attr('disabled', false);
$("#rec-disabled").attr('id', 'rec-'+bid);
$("#rec-"+id).attr('id', 'rec-disabled');
// $("#rec-disabled").attr('disabled', false);
// $("#rec-disabled").attr('id', 'rec-'+bid);
// $("#rec-"+id).attr('id', 'rec-disabled');
$("#rec-name").text(response['name']);
$("#rec-mc").text(response['mc']);
$("#table-builds tr").attr('rec','false');
Expand Down

0 comments on commit ffea599

Please sign in to comment.