7604 |
25 Feb 19 |
nicklas |
/* $Id $ |
7604 |
25 Feb 19 |
nicklas |
2 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
Copyright (C) 2012 Nicklas Nordborg |
7604 |
25 Feb 19 |
nicklas |
4 |
|
7604 |
25 Feb 19 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
7604 |
25 Feb 19 |
nicklas |
Available at http://base.thep.lu.se/ |
7604 |
25 Feb 19 |
nicklas |
7 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is free software; you can redistribute it and/or |
7604 |
25 Feb 19 |
nicklas |
modify it under the terms of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
as published by the Free Software Foundation; either version 3 |
7604 |
25 Feb 19 |
nicklas |
of the License, or (at your option) any later version. |
7604 |
25 Feb 19 |
nicklas |
12 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is distributed in the hope that it will be useful, |
7604 |
25 Feb 19 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7604 |
25 Feb 19 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7604 |
25 Feb 19 |
nicklas |
GNU General Public License for more details. |
7604 |
25 Feb 19 |
nicklas |
17 |
|
7604 |
25 Feb 19 |
nicklas |
You should have received a copy of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
7604 |
25 Feb 19 |
nicklas |
20 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
21 |
|
7604 |
25 Feb 19 |
nicklas |
@author Nicklas |
7604 |
25 Feb 19 |
nicklas |
23 |
*/ |
7604 |
25 Feb 19 |
nicklas |
'use strict'; |
7604 |
25 Feb 19 |
nicklas |
25 |
|
7604 |
25 Feb 19 |
nicklas |
var Footnote = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pAutoReload = 60; // seconds until automatic page reload |
7604 |
25 Feb 19 |
nicklas |
var footnote = {}; |
7604 |
25 Feb 19 |
nicklas |
30 |
|
7604 |
25 Feb 19 |
nicklas |
31 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the page. |
7604 |
25 Feb 19 |
nicklas |
33 |
*/ |
7604 |
25 Feb 19 |
nicklas |
footnote.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
35 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Broadcast message popup |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('broadcast', footnote.showBroadcastMessage); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('singleMessage', footnote.singleMessageOnClick) |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('multiMessages', footnote.showAllMessages); |
7604 |
25 Feb 19 |
nicklas |
40 |
|
7604 |
25 Feb 19 |
nicklas |
Footnote.loadMessages(); |
7604 |
25 Feb 19 |
nicklas |
42 |
} |
7604 |
25 Feb 19 |
nicklas |
43 |
|
7604 |
25 Feb 19 |
nicklas |
44 |
/** |
7604 |
25 Feb 19 |
nicklas |
Reload the footnote page. |
7604 |
25 Feb 19 |
nicklas |
46 |
*/ |
7604 |
25 Feb 19 |
nicklas |
footnote.loadMessages = function() |
7604 |
25 Feb 19 |
nicklas |
48 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = 'ajax.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=GetFootnoteMessages'; |
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7604 |
25 Feb 19 |
nicklas |
request.open("GET", url, true); |
7604 |
25 Feb 19 |
nicklas |
Ajax.setReadyStateHandler(request, footnote.messagesLoaded, footnote.messagesNotLoaded); |
7604 |
25 Feb 19 |
nicklas |
request.send(null); |
7604 |
25 Feb 19 |
nicklas |
55 |
} |
7604 |
25 Feb 19 |
nicklas |
56 |
|
7604 |
25 Feb 19 |
nicklas |
footnote.messagesLoaded = function(request) |
7604 |
25 Feb 19 |
nicklas |
58 |
{ |
7604 |
25 Feb 19 |
nicklas |
var messages = JSON.parse(request.responseText); |
7604 |
25 Feb 19 |
nicklas |
60 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.hide('broadcast'); |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('credit'); |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('singleMessage'); |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('multiMessages'); |
7604 |
25 Feb 19 |
nicklas |
if (messages.broadcast) |
7604 |
25 Feb 19 |
nicklas |
66 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.show('broadcast'); |
7604 |
25 Feb 19 |
nicklas |
Doc.element('broadcast-title').innerHTML = Strings.encodeTags(messages.broadcast); |
7604 |
25 Feb 19 |
nicklas |
69 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (messages.newMessages > 1) |
7604 |
25 Feb 19 |
nicklas |
71 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.show('multiMessages'); |
7604 |
25 Feb 19 |
nicklas |
Doc.element('num-messages').innerHTML = messages.newMessages; |
7604 |
25 Feb 19 |
nicklas |
74 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (messages.newMessages == 1) |
7604 |
25 Feb 19 |
nicklas |
76 |
{ |
7604 |
25 Feb 19 |
nicklas |
var msg = messages.message; |
7604 |
25 Feb 19 |
nicklas |
Doc.show('singleMessage'); |
7604 |
25 Feb 19 |
nicklas |
Data.set('singleMessage', 'message-id', msg.id); |
7604 |
25 Feb 19 |
nicklas |
Doc.element('message-name').innerHTML = Strings.encodeTags(msg.name); |
7604 |
25 Feb 19 |
nicklas |
Doc.element('message-from').innerHTML = Strings.encodeTags(msg.from); |
7604 |
25 Feb 19 |
nicklas |
82 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
84 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.show('credit'); |
7604 |
25 Feb 19 |
nicklas |
86 |
} |
7604 |
25 Feb 19 |
nicklas |
Footnote.startReloadTimer(pAutoReload); |
7604 |
25 Feb 19 |
nicklas |
88 |
} |
7604 |
25 Feb 19 |
nicklas |
89 |
|
7604 |
25 Feb 19 |
nicklas |
footnote.messagesNotLoaded = function(request) |
7604 |
25 Feb 19 |
nicklas |
91 |
{ |
7604 |
25 Feb 19 |
nicklas |
App.debug('Footnote not updated: ' + request.responseText); |
7604 |
25 Feb 19 |
nicklas |
Footnote.startReloadTimer(pAutoReload); |
7604 |
25 Feb 19 |
nicklas |
94 |
} |
7604 |
25 Feb 19 |
nicklas |
95 |
|
7604 |
25 Feb 19 |
nicklas |
96 |
/** |
7604 |
25 Feb 19 |
nicklas |
Show a popup with the broadcast message. |
7604 |
25 Feb 19 |
nicklas |
98 |
*/ |
7604 |
25 Feb 19 |
nicklas |
footnote.showBroadcastMessage = function() |
7604 |
25 Feb 19 |
nicklas |
100 |
{ |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(App.getRoot()+'info/broadcast.jsp', 'BroadcastMessage', 510, 340); |
7604 |
25 Feb 19 |
nicklas |
102 |
} |
7604 |
25 Feb 19 |
nicklas |
103 |
|
7604 |
25 Feb 19 |
nicklas |
104 |
/** |
7604 |
25 Feb 19 |
nicklas |
'click' handler for showing a single message in a popup |
7604 |
25 Feb 19 |
nicklas |
106 |
*/ |
7604 |
25 Feb 19 |
nicklas |
footnote.singleMessageOnClick = function(event) |
7604 |
25 Feb 19 |
nicklas |
108 |
{ |
7604 |
25 Feb 19 |
nicklas |
var messageId = Data.get(event.currentTarget, 'message-id'); |
7604 |
25 Feb 19 |
nicklas |
if (!messageId) return; |
7604 |
25 Feb 19 |
nicklas |
Items.viewItem('MESSAGE', messageId); |
7604 |
25 Feb 19 |
nicklas |
Footnote.startReloadTimer(1); |
7604 |
25 Feb 19 |
nicklas |
113 |
} |
7604 |
25 Feb 19 |
nicklas |
114 |
|
7604 |
25 Feb 19 |
nicklas |
footnote.startReloadTimer = function(timeoutInSeconds) |
7604 |
25 Feb 19 |
nicklas |
116 |
{ |
7604 |
25 Feb 19 |
nicklas |
setTimeout(footnote.loadMessages, timeoutInSeconds * 1000); |
7604 |
25 Feb 19 |
nicklas |
118 |
} |
7604 |
25 Feb 19 |
nicklas |
119 |
|
7604 |
25 Feb 19 |
nicklas |
120 |
/** |
7604 |
25 Feb 19 |
nicklas |
Show all messages in the main frame. |
7604 |
25 Feb 19 |
nicklas |
122 |
*/ |
7604 |
25 Feb 19 |
nicklas |
footnote.showAllMessages = function() |
7604 |
25 Feb 19 |
nicklas |
124 |
{ |
7604 |
25 Feb 19 |
nicklas |
window.top['main'].location.href = App.getRoot()+'my_base/messages/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
126 |
} |
7604 |
25 Feb 19 |
nicklas |
127 |
|
7604 |
25 Feb 19 |
nicklas |
return footnote; |
7604 |
25 Feb 19 |
nicklas |
129 |
}(); |
7604 |
25 Feb 19 |
nicklas |
130 |
|
6167 |
12 Oct 12 |
nicklas |
Doc.onLoad(Footnote.initPage); |