const Handlebars = require('handlebars'); const { mediaKind, safeJsonForScript, getPlayerPageTemplate, getPlayerClientNameScript, getPlayerPageScript, getPlayerOnboardingLandingScript, getPlayerOnboardingFormScript } = require('./render-helpers'); function renderPage(template, options) { return template({ TITLE: options.title, BODY_CLASS: options.bodyClass || '', BODY: new Handlebars.SafeString(options.body || ''), SCRIPT_BLOCK: new Handlebars.SafeString(options.script || '') }); } function renderOnboardingLandingBody() { return [ '
', '
', '

Pulse Signage

', '

Onboard this player

', '

Choose an existing screen, name the client, and either scan the QR code or finish right here with a keyboard and mouse.

', '
', '
', '
', ' Onboarding QR code', '
', '
Preparing onboarding link...
', '
', '
', ' ', ' ', ' ', '
', '
', '
', '
', '
' ].join(''); } function renderOnboardingFormBody(deviceId) { return [ '
', '
', '

Pulse Signage

', '

Name this client

', '

Pick an existing screen and give this player a friendly name that will persist after refreshes.

', '
', ' ', ' ', ' ', ' ', '
', '
', '
', '
' ].join(''); } function renderOnboardingLandingScript() { return getPlayerOnboardingLandingScript()(); } function renderOnboardingFormScript(deviceId) { return getPlayerOnboardingFormScript()({ DEVICE_ID_JSON: new Handlebars.SafeString(JSON.stringify(deviceId || '')) }); } function renderPlayerPage(slug, initialData) { const onboardingScript = getPlayerClientNameScript()(); const template = getPlayerPageTemplate(); const script = getPlayerPageScript()({ SLUG_JSON: new Handlebars.SafeString(JSON.stringify(slug)), INITIAL_DATA_JSON: new Handlebars.SafeString(safeJsonForScript(initialData || null)) }); return renderPage(template, { title: 'Screen ' + slug, body: '
Loading screen...
', script: onboardingScript + script }); } function renderPlayerOnboardingLandingPage() { return renderPage(getPlayerPageTemplate(), { title: 'Onboard player', bodyClass: 'onboarding-page', body: renderOnboardingLandingBody(), script: renderOnboardingLandingScript() }); } function renderPlayerOnboardingFormPage(deviceId) { return renderPage(getPlayerPageTemplate(), { title: 'Onboard screen', bodyClass: 'onboarding-page', body: renderOnboardingFormBody(deviceId), script: renderOnboardingFormScript(deviceId) }); } module.exports = { mediaKind, renderPlayerPage, renderPlayerOnboardingLandingPage, renderPlayerOnboardingFormPage };