Last active
November 17, 2020 16:32
-
-
Save natea/e4a2a1378897974f4d4193ceeba06dab to your computer and use it in GitHub Desktop.
This file contains 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
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> | |
<div id="wharf"> | |
<iframe src="https://staging-avl.appsembler.com/isc/newdeploy/" style="visibility: hidden" width="0" height="0"></iframe> | |
<p>When you click the button below, a new REPLACE-THIS-WITH-PROJECT-FRIENDLY-NAME site will be started for you.</p> | |
<input type="button" value="Launch REPLACE-THIS-WITH-PROJECT-FRIENDLY-NAME site" style="margin-bottom: 20px;"> </div> | |
<script> | |
(function() { | |
var $wharf = $('#wharf'), | |
$launch_button = $wharf.find('input'); | |
$launch_button.click(function() { | |
$launch_button.attr('disabled', 'disabled').val('Launching...'); | |
var user_id = $('div.logininfo a').attr('href').split('id=')[1]; | |
$wharf.find('iframe')[0].contentWindow.postMessage({ | |
owner_email: user_id + "@moodle_id.appsembler", | |
project: "REPLACE-THIS-WITH-YOUR-PROJECTS-NAME", | |
token: "REPLACE-THIS-WITH-YOUR-PROJECTS-TOKEN" | |
}, "https://staging\u002Davl.appsembler.com"); | |
return false; | |
}); | |
window.addEventListener("message", function(event) { | |
if (event.origin !== 'https://staging\u002Davl.appsembler.com') return; | |
if (event.data.status === 'siteDeployed') { | |
$wharf.html(event.data.html_content); | |
} else if (event.data.status === 'deploymentError') { | |
$wharf.text(event.data.error_message); | |
} | |
}, false); | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment