Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (err) {
return cba("Document xml is not valid: " + err)
}
if (!doc || !doc.document) return cba("document not valid or has no pages")
if (!doc.document.page || doc.document.page.length==0) return cba("document must have at least one page")
if (page>=doc.document.page.length) {
return cba('\r\n\r\nPresentation has ended (total '+doc.document.page.length+' pages). Press CTRL+C to exit.\r\n\r\n')
}
req.connection.on('close',function(){
screen = null
});
var screen = contrib.createScreen(req, res)
if (screen==null) return
viewer = new Viewer(doc.document, screen)
var err = viewer.renderPage(page, msg)
if (err!==null) {
clean(screen)
return cba(err)
}
//note the setTimeout is necessary even if delay is 0
setTimeout(function() {
//restore cursor
res.end('\033[?25h')
clean(screen)
return cba()
}, auto?5000:0)