forked from catalyst/moodle-mod_skillsoft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skillsoft.js
77 lines (66 loc) · 2.33 KB
/
skillsoft.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* @package mod-skillsoft
* @author [email protected]
* @copyright 2009-2014 Martin Holden
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function getStartOver() {
var containerdiv = document.getElementById('restart');
var startover = document.getElementById('startover');
var attempt = document.getElementById('attempt');
if(startover != undefined) {
if (startover.checked) {
attempt.value = startover.value;
//Remove the "restart" message
containerdiv.innerHTML="";
}
}
return attempt.value;
//return;
}
/* Used by view.php to open new window to the AICC URL */
function openAICCWindow(url,name,options,fullscreen) {
var startover = getStartOver();
if (startover != undefined) {
url = url + "%3fattempt=" + startover;
}
var aiccWin = window.open('',name,options);
if (fullscreen) {
aiccWin.moveTo(0,0);
aiccWin.resizeTo(screen.availWidth,screen.availHeight);
}
aiccWin.focus();
aiccWin.location = url;
return aiccWin;
}
/* Used by getolsadata to set values in mod_form abstraction of setting data in textareas
* Needs md5.js
*/
function setTextArea( thewindow, name, value) {
var _window = thewindow.window;
var _textarea = _window.document.getElementById('id_'+name);
var _htmlarea = eval('_window.'+'editor_'+hex_md5(name));
var _attoeditor = _window.document.getElementById('id_'+name+'editable');
var _htmlareaexists = !(typeof _htmlarea == "undefined");
var _textareaexists = !(typeof _textarea == "undefined") && _textarea.type == 'textarea';
var _tinymceexists = !(typeof tinyMCE== "undefined");
var _attoexists = !(typeof _attoeditor == "undefined");
if (_htmlareaexists) {
//Set the value for HTMLArea
_htmlarea.setHTML(value);
return;
} else if(_tinymceexists) {
//10-SEPT-2014 - Set the underlying textarea so Moodle validation works
_textarea.value = value;
tinyMCE.get('id_'+name).setContent(value);
return;
} else if(_attoexists) {
//10-OCT-2014 - Support Atto Editor
_attoeditor.innerHTML = value;
_textarea.value = value;
return;
} else if(_textareaexists) {
_textarea.value = value;
return;
}
}