refactor(plg): converted iframe shadowbox launchpad to web component

This commit is contained in:
Zack Spear
2020-09-27 18:32:14 -07:00
parent 277b69c01b
commit 8745c54d1b

View File

@@ -825,27 +825,10 @@ response_complete($httpcode, '{}');
#sb-info {display:none}
</style>
<script markdown="0">
function showRegWizard() {
<? $license_state = strtoupper(empty($var['regCheck']) ? $var['regTy'] : $var['regCheck']); ?>
Shadowbox.open({
content:'https://registration.unraid.net/?ts=<?=time()?>&guid=<?=$var['flashGUID']?>&state=<?=$license_state?>&keyfile=<?=str_replace(['+','/','='], ['-','_',''], trim(base64_encode(@file_get_contents($var['regFILE']))))?>&reggen=<?=$var['regGen']?>&flashproduct=<?=$var['flashProduct']?>&flashvendor=<?=$var['flashVendor']?>&registered=<?=empty($remote['apikey'])||empty($var['regFILE'])?0:1?>&servername=<?=$var['NAME']?>&serverip=<?=$_SERVER['SERVER_ADDR']?>&internalip=<?=$_SERVER['SERVER_ADDR']?>&internalport=<?=$_SERVER['SERVER_PORT']?>&protocol=<?=$_SERVER['REQUEST_SCHEME']?>&site='+location.origin+'&email=<?=$remote['email']?>',
player: 'iframe',
options: {modal: true, animate: false, displayNav: false, overlayOpacity: 0.8, viewportPadding: 0, showMovieControls: false}
});
}
function hideRegWizard(cb) {
Shadowbox.close();
$.post('/update.php', {'#file': 'dynamix/dynamix.cfg', '#section': 'wizard', hideWizard: '1'}, cb);
}
function handleMessage(e) {
//if (e.origin != "http://child.com") { return; }
if (e.data.length == 0) { return; }
if (e.data == "CLOSE_SHADOWBOX") {
hideRegWizard();
return;
}
const SAFE_JSON_PARSE = (str) => {
try {
return [null, JSON.parse(str)];
@@ -934,17 +917,15 @@ function handleMessage(e) {
return window.location.reload();
case "REDIRECT_MAIN":
return window.location.href = '/Main';
case "STOP_SENDING_SESSION":
console.log('pop-up received session');
break;
default:
console.error('Unhandled event \'' + data.event + '\' fired. data:', data);
break;
}
}
window.addEventListener('message', handleMessage, false);
<? if (empty($wizard['hideWizard'])) { ?>
$(function() {
setTimeout(function() { showRegWizard(); }, 100);
});
<? } ?>
</script>
]]>
</INLINE>
@@ -1089,6 +1070,9 @@ unraid-user-profile {
<INLINE>
<![CDATA[
<!-- user profile component -->
<?if(empty($wizard['hideWizard'])):?>
<unraid-launchpad openOnLoad="<? echo empty($wizard['hideWizard']) ?>"></unraid-launchpad>
<?endif?>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<?
$upc_dev = 0;
@@ -1171,7 +1155,7 @@ cp -f /usr/local/emhttp/plugins/dynamix/Registration.page /usr/local/emhttp/plug
cat <<EOF >> /usr/local/emhttp/plugins/dynamix/Registration.page
&nbsp;
: <input type="button" value="Open Registration Wizard" onclick="showRegWizard();">
: <unraid-open-launchpad></unraid-open-launchpad>
EOF
]]>
</INLINE>