diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/openbis.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/openbis.js index 1742c800677d63cc19402288231fad4110aa7df2..1ad57eda3851a4d9d18355727740a7f277c65af0 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/openbis.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/openbis.js @@ -870,7 +870,66 @@ define([ 'jquery', 'util/Json' ], function(jquery, stjsUtil) { } }); } + + /** + * ======================= + * OpenBIS webapp context + * ======================= + * + * Provides a context information for webapps that are embedded inside the OpenBIS UI. + * + * @class + * + */ + var openbisWebAppContext = function() { + this.getWebAppParameter = function(parameterName){ + var match = location.search.match(RegExp("[?|&]"+parameterName+'=(.+?)(&|$)')); + if(match && match[1]){ + return decodeURIComponent(match[1].replace(/\+/g,' ')); + }else{ + return null; + } + } + + this.webappCode = this.getWebAppParameter("webapp-code"); + this.sessionId = this.getWebAppParameter("session-id"); + this.entityKind = this.getWebAppParameter("entity-kind"); + this.entityType = this.getWebAppParameter("entity-type"); + this.entityIdentifier = this.getWebAppParameter("entity-identifier"); + this.entityPermId = this.getWebAppParameter("entity-perm-id"); + + this.getWebappCode = function() { + return this.webappCode; + } + + this.getSessionId = function() { + return this.sessionId; + } + + this.getEntityKind = function() { + return this.entityKind; + } + + this.getEntityType = function() { + return this.entityType; + } + + this.getEntityIdentifier = function() { + return this.entityIdentifier; + } + + this.getEntityPermId = function() { + return this.entityPermId; + } + this.getParameter = function(parameterName) { + return this.getParameter(parameterName); + } + } + + this.getWebAppContext = function() { + return new openbisWebAppContext(); + } } return facade;