From 5bdf7808eab142ea1fd2a6dff392d579293a4129 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Wed, 13 Apr 2011 08:26:44 +0000
Subject: [PATCH] Add necccessary hooks for supporting Browser Plugins to
 collaborate with DiscoJuice

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2813 44740490-163a-0410-bde0-09ae8108e29a
---
 .../www/discojuice/discojuice.control.js      | 34 ++++++++++++++-----
 .../www/discojuice/discojuice.ui.js           |  5 ++-
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/modules/discojuice/www/discojuice/discojuice.control.js b/modules/discojuice/www/discojuice/discojuice.control.js
index a3fe422ad..91cdb8319 100644
--- a/modules/discojuice/www/discojuice/discojuice.control.js
+++ b/modules/discojuice/www/discojuice/discojuice.control.js
@@ -24,6 +24,8 @@ DiscoJuice.Control = {
 
 	"maxhits": 25,
 	
+	"extensionResponse": null,
+	
 	/*
 	 * Fetching JSON Metadata using AJAX.
 	 * Callback postLoad is called when data is returned.
@@ -59,6 +61,7 @@ DiscoJuice.Control = {
 
 		
 		this.readCookie();
+		this.readExtensionResponse();
 		this.prepareData();
 		this.discoReadSetup();
 		this.discoSubReadSetup();
@@ -88,6 +91,22 @@ DiscoJuice.Control = {
 		}
 	},
 	
+	"readExtensionResponse": function() {
+	
+		if (!this.extensionResponse) return;
+		
+		if(!!this.extensionResponse.autologin) {
+			this.selectProvider(this.extensionResponse.entityID, this.extensionResponse.subID);
+		}
+
+		if(this.extensionResponse.selectedRelID) {
+			this.setWeight(-100, this.extensionResponse.entityID, this.extensionResponse.subID);
+		}
+		this.parent.Utils.log('DiscoJuice Extension readExtensionResponse ' + this.extensionResponse.entityID + ' ' + this.extensionResponse.subID);
+
+	},
+
+	
 	"discojuiceextension": function() {
 		
 // 		console.log('Listener activated...');
@@ -111,14 +130,13 @@ DiscoJuice.Control = {
 		
 		var autologin = $("meta#discojuice_autologin").attr('content');
 		
-		if(autologin == '1') {
-// 			console.log('DiscoJuice Extension: Select provider');
-			this.selectProvider(entityID, subID);
-		} else {
-// 			console.log('DiscoJuice Extension: Set weight and refresh');
-			this.setWeight(-100, entityID, subID);
-			this.prepareData();
-		}
+		this.extensionResponse = {
+			selectedRelID: selectedRelID,
+			entityID: entityID,
+			subID: subID,
+			autologin: autologin
+		};
+
 		
 	},
 	
diff --git a/modules/discojuice/www/discojuice/discojuice.ui.js b/modules/discojuice/www/discojuice/discojuice.ui.js
index efeb3cbea..fb6065528 100644
--- a/modules/discojuice/www/discojuice/discojuice.ui.js
+++ b/modules/discojuice/www/discojuice/discojuice.ui.js
@@ -225,9 +225,12 @@ DiscoJuice.UI = {
 				'<div style="clear: both" class="locatemeafter"></div>' +
 			'</div>' +
 			
+			'<div style="display: none">' + 
+				'<button id="discojuiceextesion_listener" />' +
+			'</div>' +
+			
 			'<div class="filters bottom">' +
 				'<p style="margin 0px; text-align: right; color: #ccc; font-size: 75%">DiscoJuice &copy; UNINETT</p>' +
-				'<button id="discojuiceextesion_listener" style="display:none">' +
 			'</div>' +
 	
 
-- 
GitLab