-
Notifications
You must be signed in to change notification settings - Fork 0
/
skillsoft.js
129 lines (113 loc) · 3.26 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
* @package mod-skillsoftmi
* @author $Author: [email protected] $
* @version SVN: $Header: https://moodle2-skillsoft-activity.googlecode.com/svn/branches/dev/skillsoft.js 158 2014-12-02 12:12:07Z [email protected] $
* @copyright 2009-2014 Martin Holden
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
var URL = '';
var NAME = '';
var OPTIONS = '';
var FULLSCREEN = false;
var AICCURL = '';
var SESSIONKEY = '';
function getVariable(variable) {
switch (variable) {
case "url":
return URL;
break;
case "name":
return NAME;
break;
case "options":
return OPTIONS;
break;
case "fullscreen":
return FULLSCREEN;
break;
case "aiccURL":
return AICCURL;
break;
case "sessionKey":
return SESSIONKEY;
break;
default:
return undefined;
}
}
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 view.php to open new window to the AICC URL */
function openAICCWindowOLSA(url,name,options,fullscreen,aiccURL,sessionKey) {
var startover = getStartOver();
if (startover != undefined) {
url = url + "%3fattempt=" + startover;
}
URL = url;
NAME = name;
OPTIONS = options;
FULLSCREEN = fullscreen;
AICCURL = aiccURL;
SESSIONKEY = sessionKey;
var trackingWin = window.open(aiccURL + "tracking.html", 'TrackingWindow',options);
trackingWin.resizeTo(500,300);
return trackingWin;
}
/* 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;
}
}