Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/public/js/query.js
akuma06 e62ebb05ba Mass edit mod api JS (done) (#868)
* Mass Edit MOD api JS (WIP)

In continuity with the mass edit mod api, this is the javascript use of
it.
##What does it do?
* Delete of multiple torrents on index/search
* Category change of multiple torrents
* Change of owner of multiple torrents
* Lock & delete of multiple torrents

##How?
* New toolbar only visible for mods
* Checkboxes added only for mods
* Selection and click on the button in toolbar
* Nothing is submitted, you have to review the changes in a modal window
listing them.
* Then the ajax queries are initialized one at a time with a progression
bar
* You can always at any moment delete entries from the queuing list

* Improved progress bar

* Deleting part almost done

Improved modal design
All dom interactions should be done
Prepared Query for only one callback
Improved Modal to keep a link to the active modal

* Finished =D

Added some translation string

* Forgot the refreshing of the page

Just an option that can be disabled by making refreshTimeout to 0
2017-06-02 12:51:44 +10:00

42 lignes
Pas d'EOL
1,6 Kio
JavaScript

var Query = {
Failed:0,
MaxFail: 10,
Get: function(url, renderer, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function(e) {
if (this.status == 200) {
Query.Failed = 0;
renderer(this.response);
if (callback != undefined) callback(this.response);
} else {
console.log("Error when refresh")
Query.Failed++;
console.log("Attempt to refresh "+Query.Failed+"...");
if ((Query.MaxFail == -1) || (Query.Failed < Query.MaxFail)) Query.Get(url, renderer, callback);
else console.error("Too many attempts, stopping...")
}
};
xhr.send();
},
Post: function(url, postArgs, callback) {
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.responseType = 'json';
xhr.onload = function(e) {
if (this.status == 200) {
Query.Failed = 0;
if (callback != undefined) callback(this.response);
} else {
console.log("Error when refresh")
Query.Failed++;
console.log("Attempt to refresh "+Query.Failed+"...");
if ((Query.MaxFail == -1) || (Query.Failed < Query.MaxFail)) Query.Post(url, postArgs, callback);
else console.error("Too many attempts, stopping...")
}
};
xhr.send(postArgs);
}
};