NEOS Javascript API

Add NEOS To Web Page

To begin using the NEOS javascript API add the following html to the webpage:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://neos-server.org/neos/js/neos.js"></script>

JQuery Plugin Functions

NEOSResults

Description: Get job results using a form that contains the job number and password.
Arguments:

  • callback: A function were its argument is the JSON data returned from NEOS.

Example:

<script>
    $(function () {
        // when form is submitted
        $('form#example').submit(function () {
            // prevent the form from submitting
            event.preventDefault();
            // ask NEOS for results
            $(this).NEOSResults(function (results) {
                // write results to console
                console.log(results)
            })
        });
    });
</script>
<form id="example">
    <label>Job Number:
        <input name="job_number">
    </label>
<label>Password:
<input name="password">
</label>
<input type="submit">
</form>

NEOSSubmit

Description: Submit a job to NEOS using an HTML form.
Arguments:

  • callback: A function were its argument is the JSON data returned from NEOS.

URL Example:

<script>
$(function () {
$('form#example').submit(function () {
// prevent form submission
event.preventDefault();
// submit xml file to neos
$(this).NEOSSubmit(function (submit) {
// get back json containing job number and password
console.log(submit)
})
});
});
</script>

<form id="example">
<label>URL:
<input name="url">
</label>
<input type="submit">
</form>

String Example:

<script>
$(function () {
$('form#example').submit(function () {
// prevent form submission
event.preventDefault();
// submit xml string to neos
$(this).NEOSSubmit(function (submit) {
// get back json containing job number and password
console.log(submit)
})
});
});
</script>

<form id="example">
<label>String:
<input name="string">
</label>
<input type="submit">
</form>

NEOSSubmitAndWait

Description: Submit and wait for results. This will write the current status of the job to HTML element ‘status’. Each time NEOSResults is called, the callback function will be called.
Arguments:

  • status: HTML element intended to have the current status of the job written to it.
  • callback: A function were its argument is the JSON data returned from NEOS.

Example:

<script>
$(function () {
$('form#example').submit(function () {
event.preventDefault();
$(this).NEOSSubmitAndWait($('#status'), function (data) {
console.log(data);
})
})
});
</script>


<form id="example">
<label>URL:
<input name="url">
</label>
<input type="submit">
</form>

<div id="status"></div>

Javascript Functions

NEOSResults

Description: Get results of a NEOS job. This can be used when there’s no form to parse job number and password from.
Arguments:

  • job_number: NEOS job number
  • password: NEOS job password
  • callback: A function were its argument is the JSON data returned from NEOS.

Example:

<script>
$(function () {
NEOSResults(job_number, password, function (data) {
console.log(data);
})
});
</script>

NEOSSubmitUrl

Description: Submit a job to NEOS using an xml from an URL.
Arguments:

  • url: URL where job XML is located.
  • callback: A function were its argument is the JSON data returned from NEOS.

Example:

<script>
$(function () {
NEOSSubmitUrl(url, function (data) {
console.log(data);
})
});
</script>

NEOSSubmitString

Description: Submit a job to NEOS using an xml stored in a string.
Arguments:

  • string: Contains job XML in a string.
  • callback: A function were its argument is the JSON data returned from NEOS.

Example:

<script>
$(function () {
NEOSSubmitString(xml_str, function (data) {
console.log(data);
})
});
</script>