Testlandia wrote:A tool may not execute restricted actions simultaneously, but must instead wait for the completion of each command--that is, a complete response from the NationStates server--before issuing the next one. A tool should not spawn background processes to enable multiple simultaneous server connections that each perform a restricted action.
In imperative programming, this aspect of things is relatively straightforward: do not have multiple threads of execution simultaneously making HTTP requests that perform restricted actions of nationstates.net, even in response to multiple user inputs. For example, in a GUI program like an android app, it's can be easier to follow this rule than not to.
In HTML/javascript, however, this can be tricky.
It is illegal to generate and use a page with multiple forms pointed at nationstates.net if you can submit the forms in parallel: that is to say, if you can click the next form without waiting for the last form's submission to be completed. It is also illegal to create a button which causes something to happen when clicked and can be clicked again before the result of the previous click is complete. It is also illegal to create a keybinding which causes something to happen when pressed (other than clicking an existing NS form or link) and does not prevent you from using it (or another one) before it finishes.
Legal solutions will involve submitting restricted actions using AJAX and not allowing a subsequent action until the AJAX callback is called. This might look somewhat like the following:
- Code: Select all
$('form#my_restricted_action_button_form').submit(function(event) {
disallow_next_click();
$.post("http://embed.nationstates.net/cgi-bin/restricted-action.cgi", data, function(){
allow_next_click();
});
event.preventDefault();
});
function disallow_next_click() {
$('form input[type="submit"], form button').attr("disabled", true).addClass("disabledForSimultaneity");
}
function allow_next_click() {
$('.disabledForSimultaneity').removeAttr("disabled").removeClass("disabledForSimultaneity");
}
This approach has the advantage of not re-enabling things that were meant to be disabled.
The only situation in which you don't have to proactively lock things down is when you turn user input into a "restricted action" is if you are submitting a form or clicking a link which is part of the HTML your browser received from nationstates.net.