Last active
December 15, 2020 13:47
-
-
Save gartmeier/b0d03e0d705ab6516821caf45ca36efe to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(() => { | |
let file = null | |
let iframe = null | |
let version = 'v2' | |
window.initPersonalAdmin = () => { | |
file = window.serverJSON.files.find(f => f.vUrl == `zip/pitcher_personal_admin_${version}.zip`) | |
if (file) { | |
iframe = document.createElement('iframe') | |
iframe.onload = () => { | |
iframe.contentWindow.params = { | |
appID: serverJSON.appID | |
} | |
iframe.contentWindow.Ti = { | |
App: { | |
fireEvent: (name, params) => { | |
if (name == 'closeOpenModal') { | |
window.closePersonalAdmin() | |
} | |
if (params) { | |
params.source = 'homescreen' | |
for (const prop in params) { | |
const param = params[prop] | |
if (typeof param !== 'string') { | |
continue | |
} | |
try { | |
if (param.startsWith('cb')) { | |
window[param] = iframe.contentWindow[param] | |
} | |
} catch (e) { | |
console.warn(`[personal admin] unable to bind admin event ${prop}`) | |
} | |
} | |
} | |
Ti.App.fireEvent(name, params) | |
} | |
} | |
} | |
} | |
iframe.setAttribute('id', 'personal-admin') | |
iframe.setAttribute('src', `../zip/pitcher_personal_admin_${version}/index.html`) | |
iframe.style.border = '0' | |
iframe.style.display = 'none' | |
iframe.style.height = '100%' | |
iframe.style.left = '0px' | |
iframe.style.position = 'fixed' | |
iframe.style.top = '0px' | |
iframe.style.width = '100%' | |
iframe.style.zIndex = '10' | |
document.body.appendChild(iframe) | |
} | |
} | |
window.launchPersonalAdmin = () => { | |
if (!file) { | |
return Ti.App.fireEvent("showAlertBox", { | |
'title': 'File not found', | |
'message': 'Please contact Pitcher Support.' | |
}) | |
} | |
if (iframe) { | |
iframe.style.display = 'block' | |
} | |
} | |
window.closePersonalAdmin = () => { | |
if (iframe) { | |
iframe.style.display = 'none' | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment