Created
September 29, 2020 08:36
-
-
Save PeteGCole/e5b6ed2782538b2598a48d47c66649a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// synchronous waitforspooling complete - unsupported, little tested. use at your own discretion. | |
// | |
function WaitForSpoolingComplete() { | |
var licenseGuid = "{09df1dc1-cba3-48a8-aebe-ef2f287b51cd}"; // replace with own | |
var serverApiUrl = MeadCo.makeApiEndPoint("http://127.0.0.1:41191", "v1/printHtml"); | |
var printApi = MeadCo.ScriptX.Print; | |
if (printApi.isSpooling) { | |
var jobs = printApi.queue; | |
for (var j = 0; j < jobs.length; j++) { | |
var jobId = jobs[j].jobIdentifier; | |
// console.log("job: " + j + ", id: " + jobId); | |
var status = 0; | |
do { | |
$.ajax(serverApiUrl + "/status/" + jobId, | |
{ | |
dataType: "json", | |
method: "GET", | |
cache: false, | |
async: false, | |
headers: { | |
"Authorization": "Basic " + btoa(licenseGuid + ":") | |
} | |
}).done(function (data) { | |
// console.log("status is: " + data.status); | |
status = data.status; | |
}) | |
.fail(function (jqXhr, textStatus, errorThrown) { | |
console.error("failed to get job status"); | |
status = -1; | |
}); | |
} while (status != 6 && status >= 0); | |
} | |
} | |
else { | |
console.warn("WaitForSpoolingComplete called when there are no jobs spooling"); | |
} | |
} | |
function print(printParameter) { | |
console.log("Simple print page starts"); | |
$.ajaxSetup({ async: false }); | |
factory.printing.Print(false); | |
WaitForSpoolingComplete(); | |
$.ajaxSetup({ async: true }); | |
console.log("The print completed"); | |
console.log("print exits"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment