Issue #29 - Fixed javascript redirection.

This commit is contained in:
Daniel Thee Roperto
2016-09-14 13:41:45 +10:00
parent 8648fc5d49
commit 5e873d766c
3 changed files with 12 additions and 10 deletions

View File

@@ -17,13 +17,15 @@ If you need to make changes here, remember to update your settings inside Moodle
width: 100%;
z-index: 9999;
}
#auth_outage_warningbar_box.imminent {
background: purple;
}
.auth_outage_warningbar_center {
margin-top: -45px;
position: relative;
top: 50%;
margin-top: -45px;
}
#auth_outage_warningbar_countdown {

View File

@@ -2,9 +2,10 @@ var auth_outage_countdown = {
timer: null,
clienttime: Date.now(),
siteadmin: false,
init: function (countdown, siteadmin) {
init: function (countdown, siteadmin, redirectto) {
this.countdown = countdown;
this.siteadmin = siteadmin;
this.redirectto = redirectto;
this.divtext = document.getElementById('auth_outage_warningbar_countdown');
this.divblock = document.getElementById('auth_outage_warningbar_box');
this.text = this.divtext.innerHTML;
@@ -25,7 +26,7 @@ var auth_outage_countdown = {
missing = 0;
clearInterval(this.timer);
if (!this.siteadmin) {
location = '/auth/outage/info.php';
window.location = this.redirectto;
}
}
this.divtext.innerHTML = this.text.replace('{{countdown}}', this.seconds2hms(missing));

View File

@@ -27,6 +27,8 @@ if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
}
$infolink = new moodle_url('/auth/outage/info.php', ['id' => $outage->id]);
echo html_writer::tag('style', get_config('auth_outage', 'css'));
?>
@@ -34,11 +36,7 @@ echo html_writer::tag('style', get_config('auth_outage', 'css'));
<div class="auth_outage_warningbar_center">
<div id="auth_outage_warningbar_countdown"><?php echo $countdown; ?></div>
<div class="auth_outage_warningbar_box_message">
<?php echo html_writer::link(
new moodle_url('/auth/outage/info.php', ['id' => $outage->id]),
$outage->get_title(),
['target' => 'outage']
); ?>
<?php echo html_writer::link($infolink, $outage->get_title(), ['target' => '_blank']); ?>
</div>
</div>
</div>
@@ -47,8 +45,9 @@ echo html_writer::tag('style', get_config('auth_outage', 'css'));
<script>
<?php require($CFG->dirroot . '/auth/outage/views/warningbar.js'); ?>
auth_outage_countdown.init(
<?php echo ($outage->starttime - $time); ?>,
<?php echo (is_siteadmin() ? 'true' : 'false'); ?>
<?php echo($outage->starttime - $time); ?>,
<?php echo(is_siteadmin() ? 'true' : 'false'); ?>,
'<?php echo $infolink; ?>'
);
</script>
<?php endif; ?>