// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
/**
* Javascript helper function for SCORM module.
*
* @package mod-scorm
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
mod_scorm_launch_next_sco = null;
mod_scorm_launch_prev_sco = null;
mod_scorm_activate_item = null;
M.mod_scorm = {};
M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launch_sco, scoes_nav) {
var scorm_disable_toc = false;
var scorm_hide_nav = true;
var scorm_hide_toc = true;
if (hide_toc == 0) {
if (hide_nav != 1) {
scorm_hide_nav = false;
}
scorm_hide_toc = false;
} else if (hide_toc == 3) {
scorm_disable_toc = true;
}
scoes_nav = JSON.parse(scoes_nav);
var scorm_layout_widget;
var scorm_current_node;
var scorm_buttons = [];
var scorm_bloody_labelclick = false;
var scorm_nav_panel;
Y.use('yui2-resize', 'yui2-dragdrop', 'yui2-container', 'yui2-button', 'yui2-layout', 'yui2-treeview', 'yui2-json', 'yui2-event', function(Y) {
Y.YUI2.widget.TextNode.prototype.getContentHtml = function() {
var sb = [];
sb[sb.length] = this.href ? '';
sb[sb.length] = this.label;
sb[sb.length] = this.href?'':'';
return sb.join("");
};
var scorm_activate_item = function(node) {
if (!node) {
return;
}
scorm_current_node = node;
scorm_current_node.highlight();
// remove any reference to the old API
if (window.API) {
window.API = null;
}
if (window.API_1484_11) {
window.API_1484_11 = null;
}
var url_prefix = M.cfg.wwwroot + '/mod/scorm/loadSCO.php?';
var el_old_api = document.getElementById('scormapi123');
if (el_old_api) {
el_old_api.parentNode.removeChild(el_old_api);
}
if (node.title) {
var el_scorm_api = document.getElementById("external-scormapi");
el_scorm_api.parentNode.removeChild(el_scorm_api);
el_scorm_api = document.createElement('script');
el_scorm_api.setAttribute('id','external-scormapi');
el_scorm_api.setAttribute('type','text/javascript');
var pel_scorm_api = document.getElementById('scormapi-parent');
pel_scorm_api.appendChild(el_scorm_api);
var api_url = M.cfg.wwwroot + '/mod/scorm/loaddatamodel.php?' + node.title;
document.getElementById('external-scormapi').src = api_url;
}
var content = new Y.YUI2.util.Element('scorm_content');
try {
// first try IE way - it can not set name attribute later
// and also it has some restrictions on DOM access from object tag
if (window_name || node.title == null) {
var obj = document.createElement('