// Hide object text box var queueOriginEl = document.getElementById('ao-ccss-queue' ); if (queueOriginEl) { queueOriginEl.style.display = 'none'; // Get queue object and call table renderer jQuery(document).ready(function() { // Instance and parse queue object var aoCssQueueRaw = document.getElementById('ao-ccss-queue').value; var aoCssQueue = aoCssQueueRaw.indexOf('{"') === 0 ? JSON.parse(aoCssQueueRaw) : ""; var aoCssQueueLog = aoCssQueue === "" ? "empty" : aoCssQueue; // hook up "remove all jobs" button to the JS action. jQuery("#removeAllJobs").click(function(){removeAllJobs();}); // Render queue table drawQueueTable(aoCssQueue); // Make queue table sortable if there are any elements var queueBodyEl = jQuery('#queue > tr').length; if (queueBodyEl > 0) { jQuery('#queue-tbl').tablesorter({ sortList: [[0,0]], headers: {6: {sorter: false}} }); } }); } // Render the queue in a table function drawQueueTable(queue) { jQuery('#queue').empty(); rowNumber=0; jQuery.each(queue, function(path, keys) { // Prepare commom job values ljid = keys.ljid; targetArr = keys.rtarget.split('|' ); target = targetArr[1]; type = keys.ptype; ctime = EpochToDate(keys.jctime); rbtn = false; dbtn = false; hbtn = false; // Prepare job statuses if (keys.jqstat === 'NEW') { // Status: NEW (N, sort order 1) status = '1N'; statusClass = 'new'; title = 'New (' + ljid + ')'; buttons = 'None'; } else if (keys.jqstat === 'JOB_QUEUED' || keys.jqstat === 'JOB_ONGOING') { // Status: PENDING (P, sort order 2) status = '2P'; statusClass = 'pending'; title = 'PENDING (' + ljid + ')'; buttons = 'None'; } else if (keys.jqstat === 'JOB_DONE' && keys.jrstat === 'GOOD' && (keys.jvstat === 'WARN' || keys.jvstat === 'BAD')) { // Status: REVIEW (R, sort order 5) status = '5R'; statusClass = 'review'; title = "REVIEW (" + ljid + ")\nInfo from criticalcss.com:\n- Job ID: " + keys.jid + "\n- Status: " + keys.jqstat + "\n- Result: " + keys.jrstat + "\n- Validation: " + keys.jvstat; buttons = ' '; dbtn = true; } else if (keys.jqstat === 'JOB_DONE') { // Status: DONE (D, sort order 6) status = '6D'; statusClass = 'done'; title = 'DONE (' + ljid + ')'; buttons = ' '; dbtn = true; } else if (keys.jqstat === 'JOB_FAILED' || keys.jqstat === 'STATUS_JOB_BAD' || keys.jqstat === 'INVALID_JWT_TOKEN' || keys.jqstat === 'NO_CSS' || keys.jqstat === 'NO_RESPONSE') { // Status: ERROR (E, sort order 4) status = '4E'; statusClass = 'error'; title = "ERROR (" + ljid + ")\nInfo from criticalcss.com:\n- Job ID: " + keys.jid + "\n- Status: " + keys.jqstat + "\n- Result: " + keys.jrstat + "\n- Validation: " + keys.jvstat; buttons = ' '; rbtn = true; dbtn = true; hbtn = true; } else { // Status: UNKNOWN (U, sort order 5) status = '5U'; statusClass = 'unknown'; title = "UNKNOWN (" + ljid + ")\nInfo from criticalcss.com:\n- Job ID: " + keys.jid + "\n- Status: " + keys.jqstat + "\n- Result: " + keys.jrstat + "\n- Validation: " + keys.jvstat; buttons = ' '; dbtn = true; hbtn = true; } // Prepare job finish time if (keys.jftime === null) { ftime = 'N/A'; } else { ftime = EpochToDate(keys.jftime); } // Append job entry jQuery("#queue").append("