MDL-22605 - Shift the debugger activation code, so that it gets access to the DOM.

This commit is contained in:
Piers Harding 2010-05-27 23:47:34 +00:00
parent 5a884a49a8
commit 33f54da3cc
2 changed files with 21 additions and 17 deletions

View File

@ -1,4 +1,4 @@
// hopefully fool ie IE proof way of getting DOM element
<!--// hopefully fool ie IE proof way of getting DOM element
function safeGetElement(doc, el) {
return doc.ids ? doc.ids[el] : doc.getElementById ? doc.getElementById(el) : doc.all[el];
}
@ -23,21 +23,6 @@ function getElementsByClassName( strClassName, obj ) {
}
}
// Add in a JS controlled link for toggling the Debug logging
var logButton = document.createElement('a');
logButton.id = 'mod-scorm-log-toggle';
logButton.name = 'logToggle';
logButton.href = 'javascript:toggleLog();';
if (getLoggingActive() == "A") {
logButton.innerHTML = '<?php print_string('scormloggingon','scorm') ?>';
} else {
logButton.innerHTML = '<?php print_string('scormloggingoff','scorm') ?>';
}
var content = safeGetElement(document, 'region-main');
content = getElementsByClassName( 'region-content', content );
content.appendChild(logButton);
// retrieve cookie data
function getCookie (cookie_name){
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
@ -67,7 +52,7 @@ function toggleLog () {
if (getLoggingActive() == "A") {
AppendToLog("Moodle Logging Deactivated", 0);
setLoggingActive('N');
logButton.innerHTML = '<?php print_string('scormloggingoff','scorm') ?>';
logButton.innerHTML = '--><?php print_string('scormloggingoff','scorm') ?>';
} else {
setLoggingActive('A');
AppendToLog("Moodle Logging Activated", 0);

View File

@ -299,7 +299,26 @@
<![if !IE]>
<object id="scoframe1" class="scoframe" type="text/html" data="<?php echo $fullurl; ?>"></object>
<![endif]>
<?php
if (scorm_debugging($scorm)) {
?>
<script>
// Add in a JS controlled link for toggling the Debug logging
var logButton = document.createElement('a');
logButton.id = 'mod-scorm-log-toggle';
logButton.name = 'logToggle';
logButton.href = 'javascript:toggleLog();';
if (getLoggingActive() == "A") {
logButton.innerHTML = '<?php print_string('scormloggingon','scorm') ?>';
} else {
logButton.innerHTML = '<?php print_string('scormloggingoff','scorm') ?>';
}
var content = safeGetElement(document, 'scormpage');
content.insertBefore(logButton, content.firstChild);
</script>
<?php
}
$PAGE->requires->js_function_call('scorm_resize');
} else {
// Clean the name for the window as IE is fussy