From e3decf9f2ef3296bc71e271800ffb28195855094 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Tue, 25 Oct 2011 12:04:18 +0000
Subject: [PATCH] Adding helped function to load hosted configuration

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2949 44740490-163a-0410-bde0-09ae8108e29a
---
 .../www/discojuice/discojuice.hosted.js       | 62 +++++++++++--------
 1 file changed, 36 insertions(+), 26 deletions(-)

diff --git a/modules/discojuice/www/discojuice/discojuice.hosted.js b/modules/discojuice/www/discojuice/discojuice.hosted.js
index f426cd265..28184bd56 100644
--- a/modules/discojuice/www/discojuice/discojuice.hosted.js
+++ b/modules/discojuice/www/discojuice/discojuice.hosted.js
@@ -5,35 +5,45 @@
  */
 if (typeof DiscoJuice == "undefined") var DiscoJuice = {};
 
+function getConfig (target, title, spentityid, responseurl, feeds, redirectURL) {
+	var options, i;
+	
+	options = {
+		"title": "Sign in to <strong>" + title + "</strong>",
+		"subtitle": "Select your Provider",
+		"disco": {
+			"spentityid": spentityid,
+			"url": responseurl,
+			"stores": ["https://store.discojuice.org/"],
+			"writableStore": "https://store.discojuice.org/"
+		},
+		"cookie": true,
+		"country": true,
+		"location": true,
+		"countryAPI": "https://store.discojuice.org/country",
+		"discoPath": "https://static.discojuice.org/",
+		"callback": function (e, djc) {
+            var returnto = window.location.href;
+			window.location = redirectURL + escape(e.entityID);
+		},
+		"metadata": []
+	};
+	
+	for(i = 0; i < feeds.length; i++) {
+		options.metadata.push("https://static.discojuice.org/feeds/" + feeds[i]);
+	}
+	return options;
+}
+
+
 DiscoJuice.Hosted = {
 	
-	"setup": function (target, title, spentityid, responseurl, feeds, redirectURL) {
-		var options, i;
-		
-		options = {
-			"title": "Sign in to <strong>" + title + "</strong>",
-			"subtitle": "Select your Provider",
-			"disco": {
-				"spentityid": spentityid,
-				"url": responseurl,
-				"stores": ["https://store.discojuice.org/"],
-				"writableStore": "https://store.discojuice.org/"
-			},
-			"cookie": true,
-			"country": true,
-			"location": true,
-			"countryAPI": "https://store.discojuice.org/country",
-			"discoPath": "https://static.discojuice.org/",
-			"callback": function (e, djc) {
-                var returnto = window.location.href;
-				window.location = redirectURL + escape(e.entityID);
-			},
-			"metadata": []
-		};
+	"getConfig": getConfig,
 		
-		for(i = 0; i < feeds.length; i++) {
-			options.metadata.push("https://static.discojuice.org/feeds/" + feeds[i]);
-		}
+	"setup": function (target, title, spentityid, responseurl, feeds, redirectURL) {
+		var options;
+
+		options = getConfig(target, title, spentityid, responseurl, feeds, redirectURL);
 		
 		$(document).ready(function() {
 			$(target).DiscoJuice(options);
-- 
GitLab