, so wait for the page body before building the widget. */ if (document.readyState === 'loading'){ document.addEventListener('DOMContentLoaded', init); } else { init(); } function init(){ var root = document.getElementById('raider-chat-root'); if (!root){ root = document.createElement('div'); root.id = 'raider-chat-root'; document.body.appendChild(root); } if (root.getAttribute('data-ready')) return; root.setAttribute('data-ready', '1'); /* ---------- Saved state (shared across *.rivier.edu, this browser) ---------- Two cookies, both scoped to .rivier.edu so www.rivier.edu and it.rivier.edu read the same values. Storage could not do this: sessionStorage and localStorage are scoped to one exact origin, and those two hosts are different origins. raiderChat - the conversation, shared by every tab on every Rivier site. raiderPrefs - launcher position, panel size, maximized or not, so a resize on www is still there on IT. Neither has a Max-Age, so both clear when the browser closes and the chat goes back to its designed size and spot next time. A cookie can only be scoped to the host you are on or one of its parents, so on a host that is not under rivier.edu (the WP Engine staging domain, say) we leave Domain off. Both still work there, just not across hosts. If a cookie is ever refused - over the ~4KB limit, or cookies blocked - that one falls back to sessionStorage on the current site rather than silently losing its value on every page load. */ var cookieDomain = /(^|\.)rivier\.edu$/i.test(location.hostname) ? '.rivier.edu' : null; var cookieOK = true, prefsOK = true; /* earlier versions kept position/size in localStorage, which outlived the browser closing; drop any leftover copy so returning visitors get the default size back */ try { localStorage.removeItem(PREFS_KEY); } catch(e){} function cookieRaw(name){ var m = document.cookie.match(new RegExp('(?:^|;\\s*)' + name + '=([^;]*)')); return m ? m[1] : null; } function cookieAttrs(){ /* no Max-Age: both cookies last only as long as the browser is open */ return '; Path=/' + (cookieDomain ? '; Domain=' + cookieDomain : '') + (location.protocol === 'https:' ? '; Secure' : '') + '; SameSite=Lax'; } /* writes the cookie and reads it straight back; false means it did not stick */ function writeCookie(name, json){ var enc = encodeURIComponent(json); try { document.cookie = name + '=' + enc + cookieAttrs(); } catch(e){} if (cookieRaw(name) === enc) return true; try { document.cookie = name + '=' + cookieAttrs() + '; Max-Age=0'; } catch(e){} /* drop any stale copy */ return false; } function readCookieJSON(name){ var raw = cookieRaw(name); if (raw){ try { return JSON.parse(decodeURIComponent(raw)); } catch(e){} } return null; } function loadState(){ if (cookieOK){ var c = readCookieJSON(COOKIE_NAME); if (c) return c; } try { return JSON.parse(sessionStorage.getItem(STATE_KEY)) || {}; } catch(e){ return {}; } } function saveState(patch){ var s = loadState(); for (var k in patch) s[k] = patch[k]; var json = JSON.stringify(s); if (cookieOK && !writeCookie(COOKIE_NAME, json)) cookieOK = false; if (!cookieOK){ try { sessionStorage.setItem(STATE_KEY, json); } catch(e){} } return s; } function clearConversation(){ saveState({ token:null, conversationId:null, tokenSavedAt:0 }); } function loadPrefs(){ if (prefsOK){ var c = readCookieJSON(PREFS_COOKIE); if (c) return c; } try { return JSON.parse(sessionStorage.getItem(PREFS_KEY)) || {}; } catch(e){ return {}; } } function savePrefs(){ var json = JSON.stringify(prefs); if (prefsOK && !writeCookie(PREFS_COOKIE, json)) prefsOK = false; if (!prefsOK){ try { sessionStorage.setItem(PREFS_KEY, json); } catch(e){} } } /* ---------- Web Chat look & feel ---------- */ var styleOptions = { primaryFont: '"Galaxie Polaris", "Noto Sans", "Segoe UI", Roboto, Arial, sans-serif', accent: '#004c97', backgroundColor: '#f3f5f8', subtle: '#5f6b7a', bubbleBackground: '#ffffff', bubbleTextColor: '#1f2328', bubbleBorderColor: '#c1c6c8', bubbleBorderWidth: 1, bubbleBorderRadius: 12, bubbleFromUserBackground: '#004c97', bubbleFromUserTextColor: '#ffffff', bubbleFromUserBorderColor: '#004c97', bubbleFromUserBorderRadius: 12, botAvatarImage: RAIDER_IMG, botAvatarBackgroundColor: '#ffffff', botAvatarInitials: 'R', avatarSize: 36, avatarBorderRadius: '50%', hideUploadButton: true, sendBoxBackground: '#ffffff', sendBoxTextColor: '#1f2328', sendBoxButtonColor: '#004c97', sendBoxButtonColorOnHover: '#13294b', sendBoxBorderTop: '1px solid #c1c6c8', suggestedActionBackgroundColor: '#ffffff', suggestedActionTextColor: '#004c97', suggestedActionBorderColor: '#004c97', suggestedActionBorderRadius: 18, suggestedActionBackgroundColorOnHover: '#e6eef7' }; /* ---------- Build the UI ---------- */ function el(tag, cls, html){ var e=document.createElement(tag); if(cls) e.className=cls; if(html!=null) e.innerHTML=html; return e; } var NAME_HTML = 'RAIder'; var btn = el('button','raider-launcher'); btn.type='button'; btn.setAttribute('aria-label','Chat with RAIder'); btn.setAttribute('aria-expanded','false'); btn.setAttribute('aria-controls','raider-panel'); var img = new Image(); img.src = RAIDER_IMG; img.alt = ''; img.draggable = false; btn.appendChild(img); var bubble = el('div','raider-bubble', "Hi, I'm " + NAME_HTML + ". How can I help you?"); bubble.setAttribute('role','status'); var bubbleClose = el('button','raider-bubble-close','✕'); bubbleClose.type='button'; bubbleClose.setAttribute('aria-label','Dismiss chat greeting'); var panel = el('div','raider-panel'); panel.id='raider-panel'; panel.setAttribute('role','dialog'); panel.setAttribute('aria-label','Chat with RAIder'); var header = el('div','raider-header'); var hImg = new Image(); hImg.src = RAIDER_IMG; hImg.alt = ''; var title = el('div','raider-title', NAME_HTML + '91影视 virtual assistant'); title.setAttribute('role','heading'); title.setAttribute('aria-level','2'); var close = el('button','raider-hbtn','✕'); close.type='button'; close.title='Close chat'; close.setAttribute('aria-label','Close chat'); var maxBtn = el('button','raider-hbtn maxbtn'); maxBtn.type='button'; /* More-options menu: Start a new chat, Download chat, Reset position & size */ var ICON_NEW = ''; var ICON_DL = ''; var ICON_HOME = ''; var ICON_MORE = ''; var moreBtn = el('button','raider-hbtn more', ICON_MORE); moreBtn.type='button'; moreBtn.title='More options'; moreBtn.setAttribute('aria-label','More options'); moreBtn.setAttribute('aria-haspopup','menu'); moreBtn.setAttribute('aria-expanded','false'); moreBtn.setAttribute('aria-controls','raider-menu'); var menu = el('div','raider-menu'); menu.id='raider-menu'; menu.setAttribute('role','menu'); menu.setAttribute('aria-label','More options'); menu.hidden = true; function mi(icon, text){ var b = el('button','raider-mi', icon + '' + text + ''); b.type='button'; b.setAttribute('role','menuitem'); return b; } var restart = mi(ICON_NEW, 'Start a new chat'); var download = mi(ICON_DL, 'Download chat'); /* saves the conversation as a .txt file; enabled once there are messages */ download.disabled = true; download.setAttribute('aria-disabled','true'); download.title = 'Nothing to download yet'; var home = mi(ICON_HOME, 'Reset position & size'); var msep = el('div','raider-msep'); msep.setAttribute('role','separator'); menu.appendChild(restart); menu.appendChild(download); menu.appendChild(msep); menu.appendChild(home); header.appendChild(hImg); header.appendChild(title); header.appendChild(moreBtn); header.appendChild(maxBtn); header.appendChild(close); var chatHost = el('div'); chatHost.id='raider-webchat'; var grip = el('div','raider-resize tl'); grip.title = 'Drag to resize'; grip.setAttribute('aria-hidden','true'); panel.appendChild(header); panel.appendChild(chatHost); panel.appendChild(grip); panel.appendChild(menu); btn.title = 'Chat with RAIder (drag to move)'; root.appendChild(panel); root.appendChild(btn); var state = loadState(); var hasConversation = !!(state.conversationId && state.token); /* Greeting shows on every page load (unless the chat is already open); the x hides it for this page only. */ /* ...except on the page a phone visitor just opened from a chat link, so it isn't covered */ if (state.quietBubble){ saveState({ quietBubble:false }); } else { root.appendChild(bubble); root.appendChild(bubbleClose); } function hideBubble(){ if (bubble.parentNode) bubble.parentNode.removeChild(bubble); if (bubbleClose.parentNode) bubbleClose.parentNode.removeChild(bubbleClose); } /* ---------- Position: movable launcher, resizable panel ---------- */ var MARGIN = 8, GAP = 12, LSIZE = 64, MIN_W = 300, MIN_H = 320; var prefs = loadPrefs(); function clamp(v, lo, hi){ return Math.max(lo, Math.min(hi, v)); } function launcherPos(){ var vw = document.documentElement.clientWidth || window.innerWidth, vh = window.innerHeight; var p = prefs.pos || defaultPos(vw); return { right: clamp(p.right, MARGIN, vw - LSIZE - MARGIN), bottom: clamp(p.bottom, MARGIN, vh - LSIZE - MARGIN), vw:vw, vh:vh }; } function defaultPos(vw){ /* bottom-right corner, shifted left of any element in AVOID_SELECTORS that sits in the same column */ var right = 24, els = document.querySelectorAll(AVOID_SELECTORS); for (var i = 0; i < els.length; i++){ var r = els[i].getBoundingClientRect(); if (r.width && r.right > vw - right - LSIZE - 12) right = Math.max(right, Math.round(vw - r.left + 12)); } return { right:right, bottom:96 }; } /* keep the greeting on one line; on narrow screens shrink the text a little, and wrap only as a last resort */ function fitBubble(avail, allowWrap){ bubble.style.whiteSpace = 'nowrap'; bubble.style.fontSize = ''; bubble.style.maxWidth = 'none'; var w = bubble.offsetWidth, fits = true; if (w > avail && w > 0){ var fs = parseFloat(getComputedStyle(bubble).fontSize), pad = 36; bubble.style.fontSize = Math.max(13, Math.floor(fs * (avail - pad) / (w - pad) * 10) / 10) + 'px'; if (bubble.offsetWidth > avail){ fits = false; if (allowWrap) bubble.style.whiteSpace = 'normal'; } } bubble.style.maxWidth = avail + 'px'; return fits; } /* ---------- Maximize (button between the menu and close; default on phones) ---------- */ /* "full screen" corner icons: corners point out to maximize, in to restore */ var ICON_MAX = ''; var ICON_RESTORE = ''; function isMobile(){ return (document.documentElement.clientWidth || window.innerWidth) <= 640; } function isMax(){ var k = isMobile() ? 'maxMobile' : 'max'; return prefs[k] === undefined ? isMobile() : !!prefs[k]; } function applyMax(){ var m = !!open && isMax(); panel.classList.toggle('max', m); root.classList.toggle('maxed', m); document.documentElement.style.overflow = m ? 'hidden' : ''; maxBtn.innerHTML = isMax() ? ICON_RESTORE : ICON_MAX; var lbl = isMax() ? 'Restore chat size' : 'Maximize chat'; maxBtn.title = lbl; maxBtn.setAttribute('aria-label', lbl); maxBtn.setAttribute('aria-pressed', isMax() ? 'true' : 'false'); } maxBtn.addEventListener('click', function(){ prefs[isMobile() ? 'maxMobile' : 'max'] = !isMax(); savePrefs(); layout(); }); var lay = { above:true, alignRight:true }; function layout(){ var L = launcherPos(); btn.style.right = L.right + 'px'; btn.style.bottom = L.bottom + 'px'; var lLeft = L.vw - L.right - LSIZE, lTop = L.vh - L.bottom - LSIZE; var onLeft = (lLeft + LSIZE/2) < L.vw/2; /* greeting bubble beside the launcher with the x above the launcher; if one line won't fit beside it (narrow phones), put the bubble above the launcher instead */ var sideRoom = (onLeft ? L.vw - lLeft : L.vw - L.right) - LSIZE - 16 - MARGIN; bubble.classList.toggle('flip', onLeft); bubble.classList.remove('up'); bubble.style.bottom = (L.bottom + 2) + 'px'; bubble.style.left = onLeft ? (lLeft + LSIZE + 16) + 'px' : 'auto'; bubble.style.right = onLeft ? 'auto' : (L.right + LSIZE + 16) + 'px'; bubbleClose.style.right = (L.right + 4) + 'px'; bubbleClose.style.bottom = (lTop < 50 ? L.bottom - 40 : L.bottom + LSIZE + 10) + 'px'; if (!fitBubble(sideRoom, false)){ if (lTop > 140){ bubble.classList.add('up'); fitBubble(L.vw - 2*MARGIN, true); var bw = bubble.offsetWidth, bh = bubble.offsetHeight; var bl = clamp(onLeft ? lLeft : lLeft + LSIZE - bw, MARGIN, L.vw - bw - MARGIN); bubble.style.left = bl + 'px'; bubble.style.right = 'auto'; bubble.style.setProperty('--tail', clamp(lLeft + LSIZE/2 - bl - 8, 12, bw - 28) + 'px'); bubble.style.bottom = (L.bottom + LSIZE + 14) + 'px'; bubbleClose.style.right = clamp(L.vw - bl - bw - 10, 0, L.vw - 30) + 'px'; bubbleClose.style.bottom = (L.bottom + LSIZE + 14 + bh - 16) + 'px'; } else { fitBubble(sideRoom, true); } } /* panel above or below the launcher (whichever has more room), lined up with it */ var mobile = L.vw <= 640, sz = prefs.size || { w:380, h:560 }; var w = mobile ? Math.round(L.vw * 0.95) : sz.w, h = mobile ? Math.round(L.vh * 0.70) : sz.h; w = clamp(w, Math.min(MIN_W, L.vw - 2*MARGIN), L.vw - 2*MARGIN); h = clamp(h, Math.min(MIN_H, L.vh - 2*MARGIN), L.vh - 2*MARGIN); var above = (lTop) >= (L.vh - lTop - LSIZE); var room = above ? lTop - GAP - MARGIN : L.vh - lTop - LSIZE - GAP - MARGIN; var top, left; if (room >= MIN_H || mobile){ if (!mobile) h = Math.min(h, room); top = above ? lTop - GAP - h : lTop + LSIZE + GAP; left = onLeft ? lLeft : lLeft + LSIZE - w; } else { /* not enough room above or below: open beside the launcher */ top = lTop + LSIZE - h; left = onLeft ? lLeft + LSIZE + GAP : lLeft - GAP - w; } panel.style.top = clamp(top, MARGIN, L.vh - h - MARGIN) + 'px'; panel.style.left = clamp(left, MARGIN, L.vw - w - MARGIN) + 'px'; panel.style.right = 'auto'; panel.style.bottom = 'auto'; panel.style.width = w + 'px'; panel.style.height = h + 'px'; lay = { above: above, alignRight: !onLeft }; grip.className = 'raider-resize ' + (above ? 't' : 'b') + (onLeft ? 'r' : 'l'); grip.hidden = mobile; applyMax(); } layout(); window.addEventListener('resize', layout); /* the video controls are added by the theme's script after load, so re-check the default spot a few times */ window.addEventListener('load', layout); setTimeout(layout, 1500); setTimeout(layout, 4000); /* drag the launcher anywhere on the page (a short click still opens the chat) */ var drag = null, suppressClick = false; btn.addEventListener('pointerdown', function(e){ if (e.button !== 0) return; e.preventDefault(); /* stop the browser's own image drag, which would cancel ours */ var L = launcherPos(); drag = { id:e.pointerId, sx:e.clientX, sy:e.clientY, right:L.right, bottom:L.bottom, moved:false }; try { btn.setPointerCapture(e.pointerId); } catch(err){} }); btn.addEventListener('pointermove', function(e){ if (!drag || e.pointerId !== drag.id) return; var dx = e.clientX - drag.sx, dy = e.clientY - drag.sy; if (!drag.moved && Math.abs(dx) + Math.abs(dy) < 6) return; if (!drag.moved){ drag.moved = true; btn.classList.add('dragging'); } prefs.pos = { right: drag.right - dx, bottom: drag.bottom - dy }; layout(); }); function endDrag(){ if (!drag) return; if (drag.moved){ suppressClick = true; btn.classList.remove('dragging'); var L = launcherPos(); prefs.pos = { right:L.right, bottom:L.bottom }; savePrefs(); } drag = null; } btn.addEventListener('pointerup', endDrag); btn.addEventListener('pointercancel', endDrag); btn.addEventListener('dragstart', function(e){ e.preventDefault(); }); /* keyboard: Shift + arrow keys move the launcher */ btn.addEventListener('keydown', function(e){ var k = { ArrowLeft:[20,0], ArrowRight:[-20,0], ArrowUp:[0,20], ArrowDown:[0,-20] }[e.key]; if (!k || !e.shiftKey) return; e.preventDefault(); var L = launcherPos(); prefs.pos = { right: L.right + k[0], bottom: L.bottom + k[1] }; layout(); savePrefs(); }); /* drag the corner grip to resize the panel */ grip.addEventListener('pointerdown', function(e){ if (e.button !== 0) return; e.preventDefault(); try { grip.setPointerCapture(e.pointerId); } catch(err){} var r = panel.getBoundingClientRect(), sx = e.clientX, sy = e.clientY, a = lay; panel.classList.add('resizing'); function move(ev){ var dx = ev.clientX - sx, dy = ev.clientY - sy; prefs.size = { w: Math.round(Math.max(MIN_W, r.width + (a.alignRight ? -dx : dx))), h: Math.round(Math.max(MIN_H, r.height + (a.above ? -dy : dy))) }; layout(); } function up(){ grip.removeEventListener('pointermove', move); grip.removeEventListener('pointerup', up); grip.removeEventListener('pointercancel', up); panel.classList.remove('resizing'); savePrefs(); } grip.addEventListener('pointermove', move); grip.addEventListener('pointerup', up); grip.addEventListener('pointercancel', up); }); /* ---------- Download chat (saves this conversation as a plain-text file) ---------- */ var chatStore = null, storeUnsub = null, canDownload = null; function chatMessages(){ var st = chatStore && chatStore.getState(); return ((st && st.activities) || []).filter(function(a){ return a.type === 'message' && (a.text || (a.attachments && a.attachments.length)); }); } function setDownloadEnabled(on){ if (on === canDownload) return; canDownload = on; download.disabled = !on; download.setAttribute('aria-disabled', on ? 'false' : 'true'); download.title = on ? 'Save this conversation as a text file' : 'Nothing to download yet'; } /* follow the current Web Chat store so the menu item turns on once there are messages */ function watchStore(store){ if (storeUnsub){ try { storeUnsub(); } catch(e){} storeUnsub = null; } chatStore = store; setDownloadEnabled(false); if (store) storeUnsub = store.subscribe(function(){ setDownloadEnabled(chatMessages().length > 0); }); } /* the agent's markdown as readable text: [text](url) -> text (url); citations [1]: url "title" -> [1] title - url */ function plainText(md){ return String(md || '') .replace(/^\[(\d+)\]:\s*(\S+)(?:\s+"([^"]*)")?\s*$/gm, function(m, n, u, t){ return '[' + n + '] ' + (t ? t + ' - ' : '') + u; }) .replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, function(m, t, u){ return t === u ? u : t + ' (' + u + ')'; }) .replace(/\*\*([^*]+)\*\*/g, '$1') .replace(/^#{1,6}\s+/gm, '') .trim(); } /* text from cards the agent sends (Adaptive Cards, hero/thumbnail cards) */ function cardText(att){ var c = att && att.content, out = []; if (!c || typeof c !== 'object') return att && att.contentUrl ? '[Attachment] ' + (att.name || att.contentUrl) : ''; if (/card\.(hero|thumbnail)/.test(att.contentType || '')){ [c.title, c.subtitle, c.text].forEach(function(s){ if (s) out.push(s); }); (c.buttons || []).forEach(function(b){ if (b.title) out.push('[' + b.title + ']' + (b.type === 'openUrl' && b.value ? ' ' + b.value : '')); }); } else { (function walk(n){ if (!n || typeof n !== 'object') return; if (Array.isArray(n)){ for (var i = 0; i < n.length; i++) walk(n[i]); return; } var t = n.type || ''; if ((t === 'TextBlock' || t === 'TextRun') && n.text) out.push(n.text); else if (t === 'FactSet' && n.facts) n.facts.forEach(function(f){ out.push(f.title + ': ' + f.value); }); else if (/^Action\./.test(t) && n.title) out.push('[' + n.title + ']' + (n.url ? ' ' + n.url : '')); for (var k in n) if (k !== 'facts' && n[k] && typeof n[k] === 'object') walk(n[k]); })(c); } return out.map(plainText).filter(Boolean).join('\n'); } function transcript(){ var lines = ['RAIder chat - 91影视 virtual assistant', 'Saved ' + new Date().toLocaleString() + ' from ' + location.href, '']; chatMessages().forEach(function(a){ var body = [plainText(a.text)].concat((a.attachments || []).map(cardText)).filter(Boolean).join('\n'); if (!body) return; var ts = a.timestamp || (a.channelData && a.channelData.clientTimestamp); var who = a.from && a.from.role === 'user' ? 'You' : 'RAIder'; lines.push(who + (ts ? ' (' + new Date(ts).toLocaleString() + ')' : '') + ':', body, ''); }); return lines.join('\n').replace(/\r?\n/g, '\r\n'); } function downloadChat(){ var d = new Date(), p = function(n){ return (n < 10 ? '0' : '') + n; }; var name = 'RAIder-chat-' + d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate()) + '-' + p(d.getHours()) + p(d.getMinutes()) + '.txt'; var url = URL.createObjectURL(new Blob(['\ufeff' + transcript()], { type:'text/plain;charset=utf-8' })); var a = document.createElement('a'); a.href = url; a.download = name; a.style.display = 'none'; document.body.appendChild(a); a.click(); document.body.removeChild(a); setTimeout(function(){ URL.revokeObjectURL(url); }, 1000); } /* ---------- Web Chat loading ---------- */ var directLine = null, started = false, tokenWatch = null; function loadScript(src){ return new Promise(function(resolve, reject){ if (window.WebChat) return resolve(); var s = document.createElement('script'); s.src = src; s.async = true; s.onload = resolve; s.onerror = function(){ reject(new Error('Could not load Web Chat')); }; document.head.appendChild(s); }); } function getJSON(url){ return fetch(url).then(function(r){ if(!r.ok) throw new Error('HTTP '+r.status); return r.json(); }); } var domainPromise = null; function getDomain(){ if (!domainPromise){ domainPromise = getJSON(REGION_ENDPOINT) .then(function(j){ return j.channelUrlsById.directline.replace(/\/$/,'') + '/v3/directline'; }) .catch(function(){ return undefined; }); } return domainPromise; } function showStatus(msg){ chatHost.innerHTML = ''; chatHost.appendChild(el('div','raider-status', msg)); } function startChat(forceNew){ started = true; watchStore(null); /* a new chat has nothing to download until messages arrive */ showStatus('Connecting to ' + NAME_HTML + '…'); if (tokenWatch){ clearInterval(tokenWatch); tokenWatch = null; } if (directLine){ try { directLine.end(); } catch(e){} directLine = null; } if (forceNew) clearConversation(); var s = loadState(); var resume = !forceNew && s.token && s.conversationId && (Date.now() - (s.tokenSavedAt||0) < TOKEN_LIFETIME); Promise.all([ loadScript(WEBCHAT_JS), getDomain(), resume ? Promise.resolve(null) : getJSON(TOKEN_ENDPOINT) ]) .then(function(r){ var domain = r[1], fresh = r[2]; var opts = { domain: domain }; if (resume){ opts.token = s.token; opts.conversationId = s.conversationId; opts.watermark = '0'; /* replay history */ } else { opts.token = fresh.token; saveState({ token: fresh.token, conversationId: fresh.conversationId, tokenSavedAt: Date.now() }); } if (!domain) delete opts.domain; directLine = window.WebChat.createDirectLine(opts); /* If a saved conversation can't be resumed (expired, etc.), start a new one. */ var sub = directLine.connectionStatus$.subscribe(function(st){ if (st === 2 && resume) { /* Online */ } if (st === 3 || st === 4){ /* ExpiredToken / FailedToConnect */ try { sub.unsubscribe(); } catch(e){} if (resume){ resume = false; startChat(true); } else showStatus('Sorry, ' + NAME_HTML + ' is unavailable right now. Please try again later.'); } }); /* Direct Line refreshes its token every ~15 min; keep the saved copy current. */ tokenWatch = setInterval(function(){ var cur = loadState(); if (directLine && directLine.token && directLine.token !== cur.token){ saveState({ token: directLine.token, tokenSavedAt: Date.now() }); } }, 30000); var isNew = !resume, greetingStyled = false; var store = window.WebChat.createStore({}, function(api){ return function(next){ return function(action){ if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED' && isNew){ isNew = false; /* Ask Copilot Studio to send its greeting (Conversation Start topic). */ api.dispatch({ type:'WEB_CHAT/SEND_EVENT', payload:{ name:'startConversation', type:'event', value:{} } }); } /* Bold the "AI" in RAIder in the first message from the bot (the welcome message). */ if (action.type === 'DIRECT_LINE/INCOMING_ACTIVITY' && !greetingStyled){ var act = action.payload && action.payload.activity; if (act && act.type === 'message' && act.from && act.from.role !== 'user'){ greetingStyled = true; if (typeof act.text === 'string' && /\bRAIder\b/.test(act.text)){ act = Object.assign({}, act, { text: act.text.replace(/\bRAIder\b/, 'R**AI**der') }); action = Object.assign({}, action, { payload: Object.assign({}, action.payload, { activity: act }) }); } } } return next(action); }; }; }); watchStore(store); /* render into a brand-new element each time, so the restart button mounts a fresh Web Chat */ chatHost.innerHTML = ''; var mount = document.createElement('div'); mount.style.height = '100%'; chatHost.appendChild(mount); window.WebChat.renderWebChat({ directLine: directLine, store: store, styleOptions: styleOptions, /* Buttons/cards that open a URL: keep Rivier pages in this tab too */ cardActionMiddleware: function(){ return function(next){ return function(args){ var ca = args.cardAction || {}; if (ca.type === 'openUrl' && goToSiteUrl(ca.value)) return; return next(args); }; }; }, locale: document.documentElement.lang || 'en-US' }, mount); }) .catch(function(){ started = false; showStatus('Sorry, ' + NAME_HTML + ' couldn’t connect. Please try again in a moment.'); }); } /* ---------- Open / close ---------- */ var open = false; function toggle(openState, restored){ open = (typeof openState === 'boolean') ? openState : !open; panel.setAttribute('data-restored', restored ? 'true' : 'false'); panel.setAttribute('data-open', open ? 'true' : 'false'); btn.setAttribute('aria-expanded', open ? 'true' : 'false'); saveState({ open: open }); applyMax(); if (!open) closeMenu(); if (open){ hideBubble(); layout(); if (!started) startChat(false); if (!restored) setTimeout(function(){ var box = chatHost.querySelector('input[type="text"], textarea'); if (box) box.focus(); }, 300); } } btn.addEventListener('click', function(e){ if (suppressClick){ suppressClick = false; e.preventDefault(); return; } toggle(); }); bubble.addEventListener('click', function(){ toggle(true); }); bubbleClose.addEventListener('click', function(){ hideBubble(); }); close.addEventListener('click', function(){ toggle(false); btn.focus(); }); restart.addEventListener('click', function(){ closeMenu(); startChat(true); }); download.addEventListener('click', function(){ closeMenu(true); downloadChat(); }); home.addEventListener('click', function(){ closeMenu(); delete prefs.pos; delete prefs.size; delete prefs.max; delete prefs.maxMobile; savePrefs(); layout(); }); /* More-options menu: open/close, click outside, keyboard */ function openMenu(){ menu.hidden = false; moreBtn.classList.add('on'); moreBtn.setAttribute('aria-expanded','true'); var first = menu.querySelector('.raider-mi:not(:disabled)'); if (first) first.focus(); } function closeMenu(focusBtn){ if (menu.hidden) return; menu.hidden = true; moreBtn.classList.remove('on'); moreBtn.setAttribute('aria-expanded','false'); if (focusBtn) moreBtn.focus(); } moreBtn.addEventListener('click', function(){ if (menu.hidden) openMenu(); else closeMenu(); }); document.addEventListener('pointerdown', function(e){ if (!menu.hidden && !menu.contains(e.target) && !moreBtn.contains(e.target)) closeMenu(); }, true); menu.addEventListener('keydown', function(e){ var items = [].slice.call(menu.querySelectorAll('.raider-mi:not(:disabled)')), i = items.indexOf(document.activeElement); if (e.key === 'ArrowDown'){ e.preventDefault(); items[(i + 1) % items.length].focus(); } else if (e.key === 'ArrowUp'){ e.preventDefault(); items[(i - 1 + items.length) % items.length].focus(); } else if (e.key === 'Tab'){ closeMenu(); } }); document.addEventListener('keydown', function(e){ if (e.key !== 'Escape') return; if (!menu.hidden){ closeMenu(true); return; } if (open) toggle(false); }); /* ---------- Links inside the chat ---------- */ function isSiteHost(h){ h = (h||'').toLowerCase(); return h === location.hostname.toLowerCase() || SITE_HOSTS.indexOf(h) !== -1; } /* Returns true if href is a Rivier page and we navigated there in this tab. Navigates to the link's OWN origin, so a www link clicked on it.rivier.edu goes to www.rivier.edu and not to a path that does not exist on this host. */ function goToSiteUrl(href){ var url; try { url = new URL(href, location.href); } catch(err){ return false; } if (!/^https?:$/.test(url.protocol) || !isSiteHost(url.hostname)) return false; /* external: new tab */ /* so the visitor can see the page the link opens: on desktop leave full screen but keep the chat open; on phones close the chat (the conversation is kept and reloads when the icon is tapped) */ var keepOpen = !isMobile(); if (keepOpen && isMax()){ prefs.max = false; savePrefs(); layout(); } saveState({ open: keepOpen, quietBubble: !keepOpen }); /* same origin AND same page: just an anchor. The origin test matters across Rivier hosts, or a www link whose path happens to match this page's would only move the hash. */ if (url.origin === location.origin && url.pathname === location.pathname && url.search === location.search && url.hash){ if (!keepOpen) toggle(false); location.hash = url.hash; /* anchor on this page */ } else { location.assign(url.origin + url.pathname + url.search + url.hash); } return true; } chatHost.addEventListener('click', function(e){ if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return; var a = e.target.closest ? e.target.closest('a[href]') : null; if (!a) return; if (goToSiteUrl(a.getAttribute('href'))){ e.preventDefault(); e.stopPropagation(); } }, true); /* ---------- Restore after navigation ---------- */ if (state.open && hasConversation) toggle(true, true); } /* end init */ })();

91影视

Find Your Program

  • Enhance your credentials and advance your career with an online Adult Gerontology 鈥� Acute Care Post-Master鈥檚 Certificate.

    Learn More
  • Applied Artificial Intelligence (AI)

    • M.S.
    • Graduate
    • On Campus
    • Computer Science

    Leverage the power of artificial intelligence and advance your career with a graduate degree from 91影视.

    Learn More
  • Applied Artificial Intelligence (AI) (Online)

    • M.S.
    • Graduate
    • Online
    • Computer Science

    Leverage the power of artificial intelligence and advance your career with a graduate degree from 91影视.

    Learn More
  • Applied Exercise Science

    • B.S.
    • Undergraduate
    • On Campus
    • Nursing & Health Professions

    The Applied Exercise Science program is designed for problem-solvers with a desire to change the lives of individuals in varying degrees of health and wellness.

    Learn More
  • Artificial Intelligence (AI)

    • B.S.
    • Undergraduate
    • On Campus
    • Computer Science

    Harness the power of artificial intelligence with a future-focused degree program at 91影视.

    Learn More
  • Artificial Intelligence (Three-Year)

    • Applied B.S.
    • Undergraduate
    • On Campus
    • Computer Science

    Prepare to shape the future of technology with a three-year (90 credit) Applied B.S. in Artificial Intelligence

    Learn More
  • Biology

    • B.S.
    • Undergraduate
    • On Campus
    • Science

    Prepare to work in exciting and emerging scientific fields with the hands-on research experiences and knowledge crucial for success in today's global environment.

    Learn More
  • Biotechnology

    • B.S.
    • Undergraduate
    • On Campus
    • Science

    Learn how to improve the quality of human life through impactful solutions to the legal, ethical, and social issues associated with biotechnology worldwide.

    Learn More
  • Business Management

    • B.S.
    • Undergraduate
    • On Campus
    • Business and Security Studies

    Prepare to be a leader in today's global business arena with a degree in Business Management from Rivier.

    Learn More
  • Business Management (Three-Year)

    • Applied B.S.
    • Undergraduate
    • On Campus
    • Business and Security Studies

    Launch your business career faster with a three-year (90 credit) Applied B.S. in Business Management.

    Learn More
  • Clinical Mental Health Counseling (Online)

    • M.A.
    • Graduate
    • Online
    • Counseling & Psychology

    In Rivier's Master in Clinical Mental Health Counseling online degree program, you'll learn to help those in need and prepare yourself to follow your passion in a wide variety of counseling jobs.

    Learn More
  • Computer Information Systems

    • M.S.
    • Graduate
    • On Campus
    • Computer Science

    Bridge the gap between information technology and business management. Learn to work and thrive in the competitive world of business IT with an M.S. in Computer Information Systems.

    Learn More
  • Computer Information Systems (Online)

    • M.S.
    • Graduate
    • Online
    • Computer Science

    In Rivier's online Master's in Computer Information Systems program, you will develop a unique combination of business expertise and technical competence to position you for leadership roles in almost any organization.

    Learn More
  • Computer Science

    • B.S.
    • Undergraduate
    • On Campus
    • Computer Science

    Prepare for a career in the fast-paced world of technology with a degree in Computer Science.

    Learn More
  • Computer Science

    • M.S.
    • Graduate
    • On Campus
    • Computer Science

    Prepare for a successful career in one of the economy鈥檚 fastest-growing industries鈥攂e a leader in today's high-tech world.

    Learn More
  • Criminal Justice

    • B.S.
    • Undergraduate
    • On Campus
    • Humanities & Social Sciences

    Your degree in Criminal Justice will open doors to an array of opportunities, from fieldwork, to lab work, to the courtroom, and beyond. You will be prepared for the impact of rapidly developing technology in the ever-changing world of law enforcement.

    Learn More
  • Criminal Justice (Three-Year)

    • Applied B.S.
    • Undergraduate
    • On Campus
    • Humanities & Social Sciences

    Prepare for a career in law enforcement with a three-year (90 credit) Applied B.S. in Criminal Justice.

    Learn More
  • Cybersecurity Management

    • B.S.
    • Undergraduate
    • On Campus
    • Business and Security Studies

    Learn how to identify, protect, and respond to cybersecurity attacks; innovate and create connections between technologies with this high-demand Bachelor of Science in Cybersecurity degree.

    Learn More
  • DNP: Doctor of Nursing Practice (Online)

    • DNP
    • Doctoral
    • Online
    • Nursing & Health Professions

    Advance your nursing career and expand your impact with a DNP from 91影视.

    Learn More
  • Ed.D.: Executive Doctorate in Leadership and Innovation

    • Ed.D.
    • Doctoral
    • On Campus
    • Education and Leadership

    91影视 offers the Executive Doctorate for leaders who want to transform organizations.

    Learn More
  • Ed.D.: Executive Doctorate in Leadership and Innovation (Online)

    • Ed.D.
    • Doctoral
    • Online
    • Education and Leadership

    91影视 offers the Executive Doctorate for leaders who want to transform organizations.

    Learn More
  • Education Studies鈥擟ounseling and School Psychology

    • M.Ed
    • Graduate
    • On Campus
    • Counseling & Psychology

    With an M.Ed. in Education Studies with a Concentration in Counseling and School Psychology, you can become a guide and advocate for students while building a rewarding career.

    Learn More
  • Educational Specialist in Counseling (Post-Master's)

    • Ed.S.
    • Graduate
    • On Campus
    • Counseling & Psychology

    Our Ed.S. in Counseling program is designed for professionals who hold a master鈥檚 degree in counseling, or a closely related field, and want to pursue further education and/or become certified school counselors.

    Learn More
  • Elementary Education

    • B.A.
    • Undergraduate
    • On Campus
    • Education and Leadership

    Play an important role in shaping future leaders. Our B.A. in Elementary Education will help you become a certified elementary and middle school teacher.

    Learn More
  • Elementary Education (Three-Year)

    • Applied B.A.
    • Undergraduate
    • On Campus
    • Education and Leadership

    Launch your teaching career faster with an Applied B.A. in Elementary Education.

    Learn More
  • Environmental Studies and Sustainability

    • B.A.
    • Undergraduate
    • On Campus
    • Humanities & Social Sciences

    Address environmental challenges with a well-rounded education in natural sciences, social sciences, and the humanities.

    Learn More
  • Family Nurse Practitioner鈥擣NP Post-Master's Certificate (Online)

    • Certificate
    • Graduate
    • Online
    • Nursing & Health Professions

    Enhance your credentials and advance your career with an online Post-Master's Family Nurse Practitioner Certificate.

    Learn More
  • Finance

    • B.S.
    • Undergraduate
    • On Campus
    • Business and Security Studies

    With the B.S. in Finance, you will be prepared for leadership roles in today's financial arena.

    Learn More
  • Forensic Science

    • B.S.
    • Undergraduate
    • On Campus
    • Science

    Apply scientific methods and modern technologies to solve crimes, serve justice, and make a real-world impact.

    Learn More
  • Health Science

    • B.S.
    • Undergraduate
    • On Campus
    • Nursing & Health Professions

    Improve the lives of others by providing greater access to health and wellness services.

    Learn More
  • Human Services

    • B.A.
    • Undergraduate
    • On Campus
    • Humanities & Social Sciences

    With a B.A. in Human Services from Rivier, you will gain the knowledge and skills necessary to advance as a human services professional.

    Learn More
  • Liberal Studies

    • A.A.
    • B.A.
    • Undergraduate
    • On Campus
    • Liberal Studies

    Position yourself for success in a multitude of industries with a degree in Liberal Studies.

    Learn More
  • Marketing

    • B.S.
    • Undergraduate
    • On Campus
    • Business and Security Studies

    Innovate, create, and bring new ideas to the marketplace. Earn your B.S. in Marketing and prepare for a dynamic career.

    Learn More
  • MBA in Cybersecurity Leadership

    • MBA
    • Graduate
    • On Campus
    • Business and Security Studies

    Take your career to the next level鈥攑repare for a leadership role in the protection of organizations鈥� data and digital assets.

    Learn More
  • MBA in Cybersecurity Leadership (Online)

    • MBA
    • Graduate
    • Online
    • Business and Security Studies

    Lead cybersecurity initiatives with an MBA built for the challenges facing today鈥檚 organizations.

    Learn More
  • MBA in Healthcare Administration (Online)

    • MBA
    • Graduate
    • Online
    • Business and Security Studies

    Become a leader in the healthcare industry with an online MBA in Healthcare Administration degree from 91影视. You will develop the skills and knowledge needed to enhance operations to better meet patients鈥� needs.

    Learn More
  • MBA in Information Technology Management

    • MBA
    • Graduate
    • On Campus
    • Business and Security Studies

    Take your career to the next level with Rivier鈥檚 MBA in Information Technology Management, a dual-discipline education that delivers real-world skills for personal and professional success.

    Learn More
  • MBA in Information Technology Management (Online)

    • MBA
    • Graduate
    • Online
    • Business and Security Studies

    Rivier's online MBA in Information Technology Management offers a strong foundation in business administration while providing a concentrated study of the strategies and approaches to managing information technology.

    Learn More
  • MBA in Management

    • MBA
    • Graduate
    • On Campus
    • Business and Security Studies

    Take your career to the next level and prepare for leadership roles through in-depth study of core business disciplines while mastering real-world skills.

    Learn More
  • MBA in Management (Online)

    • MBA
    • Graduate
    • Online
    • Business and Security Studies

    Rivier's online MBA in Management program will provide you with a broad education in the traditional areas of business, as well as in the cross-disciplinary skills of leadership, problem-solving, and strategic management.

    Learn More
  • MBA in Management with Concentration in Marketing (Online)

    • MBA
    • Graduate
    • Online
    • Business and Security Studies

    Prepare for a dynamic career in marketing with an online MBA with a concentration in Marketing from 91影视.

    Learn More
  • MBA in Management with Concentration in Public Administration (Online)

    • MBA
    • Graduate
    • Online
    • Business and Security Studies

    Rivier鈥檚 online MBA in Management with Concentration in Public Administration prepares students to lead across government agencies, nonprofit organizations, and public service sectors.

    Learn More
  • MSN: Adult Gerontology 鈥� Acute Care Nurse Practitioner (Online)

    • MSN
    • Graduate
    • Online
    • Nursing & Health Professions

    Turn your critical care nursing experience into advanced acute care expertise.

    Learn More
  • MSN: Advanced Practice RN Completion Program

    • MSN
    • Graduate
    • Online
    • Nursing & Health Professions

    Licensed and practicing Advanced Practice Registered Nurses (APRN) who have been in the profession for many years without a graduate degree can complete this program to receive their Master鈥檚 in Nursing.

    Learn More
  • MSN: Family Nurse Practitioner鈥擣NP (Online)

    • MSN
    • Graduate
    • Online
    • Nursing & Health Professions

    Turn your nursing experience into advanced practice expertise with Rivier鈥檚 online MSN Family Nurse Practitioner program.

    Learn More
  • MSN: Leadership in Health Systems Management (Online)

    • MSN
    • Graduate
    • Online
    • Nursing & Health Professions

    Advance your nursing career with an online MSN: Leadership in Health Systems Management degree. Get the skills and knowledge you need to enhance patient care and guide other nurses in a senior leadership role.

    Learn More
  • MSN: Nursing Education (Online)

    • MSN
    • Graduate
    • Online
    • Nursing & Health Professions

    Make a difference in the next generation of nurses with an online MSN: Nursing Education degree. As an experienced clinician and instructor, you can play a role in ensuring the quality of nursing education and future patient care.

    Learn More
  • MSN: Psychiatric Mental Health Nurse Practitioner (Online)

    • MSN
    • Graduate
    • Online
    • Nursing & Health Professions

    Become a leader in mental health care through Rivier's online Psychiatric Mental Health Nurse Practitioner (PMHNP) program.

    Learn More
  • Nursing Education鈥擯ost-Master's Certificate (Online)

    • Certificate
    • Graduate
    • Online
    • Nursing & Health Professions

    With a Nursing Education Post-Master's Certificate, you can expand or change your advanced nursing practice with a new area of specialization.

    Learn More
  • Nursing鈥擜ccelerated BSN

    • BSN
    • Professional Studies
    • Online
    • Nursing & Health Professions

    Transition into a rewarding nursing career with an Accelerated Bachelor of Science in Nursing degree from 91影视.

    Learn More
  • 狈耻谤蝉颈苍驳鈥擜厂狈

    • ASN
    • Professional Studies
    • On Campus
    • Nursing & Health Professions

    Through a focus on experiential learning and extensive hands-on clinical experience, Rivier's ASN program will prepare you for a rewarding career as a registered nurse.

    Learn More
  • 狈耻谤蝉颈苍驳鈥擝厂狈

    • BSN
    • Undergraduate
    • On Campus
    • Nursing & Health Professions

    Whether you dream of a future in pediatrics, obstetrics, geriatrics, oncology, surgery, or private care, Rivier鈥檚 Nursing top ranked program prepares you for a successful career in healthcare.

    Learn More
  • Nursing鈥擫PN to ASN

    • ASN
    • Professional Studies
    • On Campus
    • Nursing & Health Professions

    Fast track your nursing career with Rivier's LPN to ASN program.

    Learn More
  • Nursing鈥擱N to BSN (Online)

    • BSN
    • Professional Studies
    • Online
    • Nursing & Health Professions

    Advance your nursing career and impact the lives of others with an online, ACEN accredited B.S. in Nursing鈥擱N to BSN from Rivier, a recognized leader in the education of nursing and healthcare professionals.

    Learn More
  • Psy.D.: Doctor of Psychology in Counseling and School Psychology

    • Psy.D.
    • Doctoral
    • On Campus
    • Counseling & Psychology

    Prepare for licensure as a psychologist through our APA-accredited Psy.D. program, which integrates counseling and school psychology with extensive clinical training and supervised practice.

    Learn More
  • Psychiatric Mental Health Nurse Practitioner鈥擯ost-Master's Certificate (Online)

    • Certificate
    • Graduate
    • Online
    • Nursing & Health Professions

    The program of studies for our Post-Master鈥檚 Certificates vary depending upon the track desired鈥擣amily Nurse Practitioner (FNP), Psychiatric/Mental Health Nurse Practitioner (PMHNP), or Nursing Educator (NE)鈥攁nd the applicant鈥檚 prior Master鈥檚 in Nursing preparation.

    Learn More
  • Psychology

    • B.A.
    • Undergraduate
    • On Campus
    • Counseling & Psychology

    Prepare to shape the future of psychology through a career in healthcare, education, social services, business, government, or a variety of additional industries and professions.

    Learn More
  • Psychology (Online)

    • M.A.
    • Graduate
    • Online
    • Counseling & Psychology

    Prepare for a career in counseling, mental health, or social services through 91影视鈥檚 online M.A. in Psychology.

    Learn More
  • Psychology鈥擬ental Health & Addiction Studies Track

    • B.A.
    • Undergraduate
    • On Campus
    • Counseling & Psychology

    Prepare to shape the future of psychology through a career in healthcare, education, social services, business, government, or a variety of additional industries and professions.

    Learn More
  • School Counseling (Online)

    • M.Ed
    • Graduate
    • Online
    • Counseling & Psychology

    Prepare for a rewarding career of supporting students' educational and emotional growth and development with Rivier's online Master of Education in School Counseling degree.

    Learn More
  • Sport Management

    • B.S.
    • Undergraduate
    • On Campus
    • Business and Security Studies

    Combine your passion for athletics and business to prepare for a career in the dynamic sport management industry.

    Learn More