2306 |
22 May 06 |
jari |
/* $Id$ |
903 |
08 Jul 05 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2005 Nicklas Nordborg |
4889 |
06 Apr 09 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg |
903 |
08 Jul 05 |
nicklas |
5 |
|
2304 |
22 May 06 |
jari |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
Available at http://base.thep.lu.se/ |
903 |
08 Jul 05 |
nicklas |
8 |
|
903 |
08 Jul 05 |
nicklas |
BASE is free software; you can redistribute it and/or |
903 |
08 Jul 05 |
nicklas |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
as published by the Free Software Foundation; either version 3 |
903 |
08 Jul 05 |
nicklas |
of the License, or (at your option) any later version. |
903 |
08 Jul 05 |
nicklas |
13 |
|
903 |
08 Jul 05 |
nicklas |
BASE is distributed in the hope that it will be useful, |
903 |
08 Jul 05 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
903 |
08 Jul 05 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
903 |
08 Jul 05 |
nicklas |
GNU General Public License for more details. |
903 |
08 Jul 05 |
nicklas |
18 |
|
903 |
08 Jul 05 |
nicklas |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
903 |
08 Jul 05 |
nicklas |
21 |
------------------------------------------------------------------ |
903 |
08 Jul 05 |
nicklas |
22 |
|
903 |
08 Jul 05 |
nicklas |
JavaScript functions for the Annotations |
903 |
08 Jul 05 |
nicklas |
/common/annotations/* |
903 |
08 Jul 05 |
nicklas |
25 |
|
903 |
08 Jul 05 |
nicklas |
@author Nicklas |
903 |
08 Jul 05 |
nicklas |
@version 2.0 |
903 |
08 Jul 05 |
nicklas |
28 |
*/ |
7419 |
03 Nov 17 |
nicklas |
'use strict'; |
903 |
08 Jul 05 |
nicklas |
30 |
|
6246 |
25 Feb 13 |
nicklas |
var Annotations = function() |
903 |
08 Jul 05 |
nicklas |
32 |
{ |
6246 |
25 Feb 13 |
nicklas |
var annotations = {}; |
6246 |
25 Feb 13 |
nicklas |
var internal = {}; |
6246 |
25 Feb 13 |
nicklas |
35 |
|
6246 |
25 Feb 13 |
nicklas |
var lastProtocolId = null; |
6246 |
25 Feb 13 |
nicklas |
var editFrameLoaded = false; |
6246 |
25 Feb 13 |
nicklas |
38 |
|
6246 |
25 Feb 13 |
nicklas |
var lastParents = null; |
6246 |
25 Feb 13 |
nicklas |
var inheritFrameLoaded = false; |
6246 |
25 Feb 13 |
nicklas |
41 |
|
6246 |
25 Feb 13 |
nicklas |
42 |
/** |
6944 |
01 Sep 15 |
nicklas |
Event handler for switching to the annotations tab for |
6944 |
01 Sep 15 |
nicklas |
items not having a protocol and/or subtype. |
6944 |
01 Sep 15 |
nicklas |
45 |
*/ |
6944 |
01 Sep 15 |
nicklas |
annotations.onSwitchToAnnotationsTab = function(event) |
6944 |
01 Sep 15 |
nicklas |
47 |
{ |
6944 |
01 Sep 15 |
nicklas |
annotations.autoLoadEditFrame(); |
6944 |
01 Sep 15 |
nicklas |
49 |
} |
6944 |
01 Sep 15 |
nicklas |
50 |
|
6944 |
01 Sep 15 |
nicklas |
51 |
/** |
6246 |
25 Feb 13 |
nicklas |
Automatically load or reload the 'Edit annotations' frame. The |
6246 |
25 Feb 13 |
nicklas |
frame is loaded if it has not previously been loaded, or if |
6246 |
25 Feb 13 |
nicklas |
the protocolId parameter has changed since last time this method |
6944 |
01 Sep 15 |
nicklas |
was called. DO NOT USE AS AN EVENT HANDLER. |
6246 |
25 Feb 13 |
nicklas |
56 |
*/ |
6947 |
08 Sep 15 |
nicklas |
annotations.autoLoadEditFrame = function(protocolId, subtypeId, parents) |
6246 |
25 Feb 13 |
nicklas |
58 |
{ |
6947 |
08 Sep 15 |
nicklas |
if (editFrameLoaded) |
6947 |
08 Sep 15 |
nicklas |
60 |
{ |
6947 |
08 Sep 15 |
nicklas |
if (parents) |
6947 |
08 Sep 15 |
nicklas |
62 |
{ |
6947 |
08 Sep 15 |
nicklas |
frames['annotations'].Annotate.setParents(parents); |
6947 |
08 Sep 15 |
nicklas |
64 |
} |
6947 |
08 Sep 15 |
nicklas |
return; |
6947 |
08 Sep 15 |
nicklas |
66 |
} |
6246 |
25 Feb 13 |
nicklas |
editFrameLoaded = true; |
6246 |
25 Feb 13 |
nicklas |
68 |
|
6246 |
25 Feb 13 |
nicklas |
var url = App.getRoot() + 'common/annotations/annotate.jsp?ID='+App.getSessionId(); |
6246 |
25 Feb 13 |
nicklas |
url += '&item_type='+Data.get('annotate-data', 'item-type'); |
6246 |
25 Feb 13 |
nicklas |
url += '&item_id='+Data.get('annotate-data', 'item-id');; |
6246 |
25 Feb 13 |
nicklas |
if (protocolId) url += '&protocol_id='+protocolId; |
6246 |
25 Feb 13 |
nicklas |
if (subtypeId) url += '&subtype_id='+subtypeId; |
6947 |
08 Sep 15 |
nicklas |
if (parents && parents.length) |
6947 |
08 Sep 15 |
nicklas |
75 |
{ |
6947 |
08 Sep 15 |
nicklas |
for (var i = 0; i < parents.length; i++) |
6947 |
08 Sep 15 |
nicklas |
77 |
{ |
6947 |
08 Sep 15 |
nicklas |
url += '&parents='+parents[i]; |
6947 |
08 Sep 15 |
nicklas |
79 |
} |
6947 |
08 Sep 15 |
nicklas |
80 |
} |
6947 |
08 Sep 15 |
nicklas |
81 |
|
6246 |
25 Feb 13 |
nicklas |
frames['annotations'].location.replace(url); |
6246 |
25 Feb 13 |
nicklas |
83 |
} |
6246 |
25 Feb 13 |
nicklas |
84 |
|
6246 |
25 Feb 13 |
nicklas |
85 |
/** |
6246 |
25 Feb 13 |
nicklas |
Save all modified annotations to the given form. If |
6246 |
25 Feb 13 |
nicklas |
the 'Edit annotations' frame hasn't been loaded, this |
6246 |
25 Feb 13 |
nicklas |
call is ignored. |
6246 |
25 Feb 13 |
nicklas |
89 |
*/ |
6246 |
25 Feb 13 |
nicklas |
annotations.saveModifiedAnnotationsToForm = function(frm) |
6246 |
25 Feb 13 |
nicklas |
91 |
{ |
6246 |
25 Feb 13 |
nicklas |
if (!editFrameLoaded) return; |
6246 |
25 Feb 13 |
nicklas |
frames['annotations'].Annotate.saveModifiedAnnotationToForm(frm); |
6246 |
25 Feb 13 |
nicklas |
94 |
} |
6246 |
25 Feb 13 |
nicklas |
95 |
|
6246 |
25 Feb 13 |
nicklas |
96 |
|
6246 |
25 Feb 13 |
nicklas |
// Check if two arrays have the same elements |
6246 |
25 Feb 13 |
nicklas |
internal.equalArrays = function(a1, a2) |
6246 |
25 Feb 13 |
nicklas |
99 |
{ |
6246 |
25 Feb 13 |
nicklas |
if (a1.length != a2.length) return false; |
6246 |
25 Feb 13 |
nicklas |
101 |
|
6246 |
25 Feb 13 |
nicklas |
for (var i = 0; i < a1.length; i++) |
6246 |
25 Feb 13 |
nicklas |
103 |
{ |
6246 |
25 Feb 13 |
nicklas |
if (a1[i] != a2[i]) return false; |
6246 |
25 Feb 13 |
nicklas |
105 |
} |
6246 |
25 Feb 13 |
nicklas |
106 |
|
6246 |
25 Feb 13 |
nicklas |
return true; |
6246 |
25 Feb 13 |
nicklas |
108 |
} |
6246 |
25 Feb 13 |
nicklas |
109 |
|
6246 |
25 Feb 13 |
nicklas |
return annotations; |
6246 |
25 Feb 13 |
nicklas |
111 |
}(); |
6246 |
25 Feb 13 |
nicklas |
112 |
|