-
Notifications
You must be signed in to change notification settings - Fork 3
/
sna_bookmarklet.js
141 lines (134 loc) · 5.38 KB
/
sna_bookmarklet.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
130
131
132
133
134
135
136
137
138
139
140
141
var serverPath = "http://www.snappvis.org/SNAPP2/";
var foundLMSForum = "No";
var foundLMSForumExpanded = "No";
var LMS ="";
function attachScript(html_doc, script)
{
script.setAttribute("type", "text/javascript");
script.setAttribute("src", serverPath + "loadsna.js?uniqueCache=" + (new Date()).getTime() + "&serverPath=" + serverPath + "&LMS=" + LMS);
html_doc.appendChild(script);
}
function traverse(w)
{
try
{
if (w.frames.length == 0) {
// Forum page from Moodle found - Moodle does not use frames
var docLocation = document.location.href;
var html_doc = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
if ((docLocation.indexOf("mod/forum/discuss.php") != -1) || (docLocation.indexOf("mod/forum/view.php") != -1))
{
//alert("Moodle");
// Moodle Individual Thread View && Moodle Forum View with links to Multiple Threads
foundLMSForum = "Yes"; foundLMSForumExpanded = "Yes"; LMS = "moodle";
attachScript(html_doc, script);
}
else if (docLocation.indexOf("discussions/admin/forum_topics_list.d2l") != -1)
{
// D2L Multi Forum Thread - For D2L Version 9
foundLMSForum = "Yes"; foundLMSForumExpanded = "Yes"; LMS = "d2l";
//alert("D2L Multiple Forum Found D2L 9");
attachScript(html_doc, script);
}
}
else {
for (var i = 0; i < w.frames.length; i++) {
var docLocation = w.frames[i].document.location.href;
var html_doc = w.frames[i].document.getElementsByTagName('head')[0];
var script = w.frames[i].document.createElement('script');
if (((docLocation.indexOf("webct/newMessageThread.dowebct") != -1)|| (docLocation.indexOf("/discussionHomepageView.dowebct") != -1) || (docLocation.indexOf("serve_bulletin") != -1))) // ACTION=DESIGN_LIST or LIST for older version of Web CT
{
//alert("sna_bookmarklet: WebCT");
foundLMSForum = "Yes"; foundLMSForumExpanded = "Yes"; LMS = "webct";
//alert("LMS: " + LMS);
if (typeof w.frames[i].getSNAPPVersion == 'function')
{
//re-run snapp
w.frames[i].resetSNAPP();
}
else
{
attachScript(html_doc, script);
}
}
else if ((docLocation.indexOf("do/message?action=list_messages") != -1) || (docLocation.indexOf("do/forum?action=list_threads") != -1) || (docLocation.indexOf("discussionboard/do/conference") != -1) || (docLocation.indexOf("discussionboard/do/message") != -1))
{
foundLMSForum = "Yes"; foundLMSForumExpanded = "Yes"; LMS = "blackboard";
// embed SNA Analysis script in this window
// either individual thread or multiple threads from list_forum
if (typeof w.frames[i].getSNAPPVersion == 'function') {
//re-run snapp
w.frames[i].resetSNAPP();
}
else {
attachScript(html_doc, script);
}
}
else if ((docLocation.indexOf("Objects/DiscussionForums/Threads2.aspx") != -1))
{
foundLMSForum = "Yes"; foundLMSForumExpanded = "Yes"; LMS = "angel";
//alert("ANGEL!");
// embed SNA Analysis script in this window
// either individual thread or multiple threads from list_forum
if (typeof w.frames[i].getSNAPPVersion == 'function') {
//re-run snapp
w.frames[i].resetSNAPP();
}
else {
attachScript(html_doc, script);
}
}
else if ((docLocation.indexOf("newMessageThread.dowebct") != -1)) {
// forum displayed but not expanded
foundLMSForum = "Yes"; foundLMSForumExpanded = "No"; LMS = "webct";
}
else if ((docLocation.indexOf("do/forum?action=list_threads") != -1)) {
// forum displayed but not expanded
foundLMSForum = "Yes"; foundLMSForumExpanded = "No"; LMS = "blackboard";
}
else if ((docLocation.indexOf("discussions/messageLists/message_list_gridstyle.d2l") != -1)||(docLocation.indexOf("discussions/admin/forum_topics_list.d2l") != -1)||(docLocation.indexOf("discussions/messageLists/message_list_readingstyle.d2l") != -1))
{
// D2L Forum Thread
foundLMSForum = "Yes"; foundLMSForumExpanded = "Yes"; LMS = "d2l";
//alert("D2L Forum Found NOW");
// embed SNA Analysis script in this window
// either individual thread or multiple threads from list_forum
if (typeof w.frames[i].getSNAPPVersion == 'function') {
//re-run snapp
w.frames[i].resetSNAPP();
}
else {
// inject sna extraction
attachScript(html_doc, script);
}
}
traverse(w.frames[i]);
}
}
}
catch(e)
{
/* Maybe access violation from cross frame scripting - Don't need to do anything as this will not be the embedded forum! */
//alert("An exception occurred in the SNA Script. Error name: " + e.name + ". Error message: " + e.message);
}
}
traverse(window);
if (foundLMSForum=="No")
{
alert("SNAPP is either unable to determine the LMS you are using or you are trying to analyse a page that does not contain a forum. SNAPP works with WebCT Vista, WebCT CE, Blackboard (versions 7, 8 and 9) and Moodle.");
}
else
{
if (foundLMSForumExpanded=="No")
{
if (LMS=="webct")
{
alert("You are trying to analyse a forum that has not been expanded. The SNA Analysis tool requires that the Expand All button be clicked, before the SNA data can be extracted.");
}
else if (LMS=="blackboard")
{
alert("The SNA Analysis tool requires that you view the forum thread, before the SNA data can be extracted in Blackboard.");
}
}
}