You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by do...@apache.org on 2008/09/24 00:54:14 UTC
svn commit: r698387 - in
/incubator/shindig/trunk/javascript/samplecontainer: samplecontainer.html
samplecontainer.js
Author: doll
Date: Tue Sep 23 15:54:14 2008
New Revision: 698387
URL: http://svn.apache.org/viewvc?rev=698387&view=rev
Log:
SHINDIG-618
Patch from Arne Roomann-Kurrik. Adds support to the samplecontainer for url and cache params.
Modified:
incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html
incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.js
Modified: incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html?rev=698387&r1=698386&r2=698387&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html (original)
+++ incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html Tue Sep 23 15:54:14 2008
@@ -40,7 +40,8 @@
<script type="text/javascript" src="samplecontainer.js"></script>
</head>
-<body onLoad="shindig.samplecontainer.unpackFormState(); shindig.samplecontainer.initGadget();">
+<body onLoad="shindig.samplecontainer.initSampleContainer();
+ shindig.samplecontainer.unpackFormState(); shindig.samplecontainer.initGadget();">
<div id="headerDiv">
<div style="float:left">Gadget testing container</div>
<div class="subTitle">
Modified: incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.js?rev=698387&r1=698386&r2=698387&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.js (original)
+++ incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.js Tue Sep 23 15:54:14 2008
@@ -43,7 +43,11 @@
var socialDataPath = document.location.protocol + "//" + document.location.host
+ "/social/rest/samplecontainer/";
- var gadgetUrl = baseUrl + 'examples/SocialHelloWorld.xml';
+ var gadgetUrlMatches = /[?&]url=((?:[^#&]+|&)+)/.exec(parentUrl);
+ var gadgetUrl = (gadgetUrlMatches)
+ ? gadgetUrlMatches[1]
+ : baseUrl + 'examples/SocialHelloWorld.xml';
+
var gadgetUrlCookie = 'sampleContainerGadgetUrl';
var stateFileUrl = baseUrl + '../sampledata/canonicaldb.json';
@@ -120,7 +124,7 @@
"POST_DATA" : opt_postParams};
if (!opt_excludeSecurityToken) {
- url = socialDataPath + url + "?st=" + gadget.secureToken;
+ url = socialDataPath + url + "?st=" + gadget.secureToken;
}
gadgets.io.makeNonProxiedRequest(url,
@@ -135,7 +139,7 @@
};
function generateGadgets(metadata) {
- // TODO: The gadget.js file should really have a clearGadgets method
+ // TODO: The gadget.js file should really have a clearGadgets method
gadgets.container.gadgets_ = {};
for (var i = 0; i < metadata.gadgets.length; i++) {
gadget = gadgets.container.createGadget(
@@ -152,7 +156,7 @@
};
function refreshGadgets(metadata) {
- // TODO: The gadget.js file should really have a getGadgets method
+ // TODO: The gadget.js file should really have a getGadgets method
for (var gadget in gadgets.container.gadgets_) {
var newtitle = metadata.gadgets[0].title;
var specUrl = metadata.gadgets[0].url;
@@ -178,14 +182,22 @@
}]
};
- sendRequestToServer("/gadgets/metadata", "POST",
+ sendRequestToServer("/gadgets/metadata", "POST",
gadgets.json.stringify(request), opt_callback, true);
}
/**
* Public Functions
*/
-
+ shindig.samplecontainer.initSampleContainer = function() {
+ // Upon initial load, check for the cache query parameter (we don't want
+ // to overwrite when clicking "refresh all")
+ var cacheUrlMatches = /[?&]cache=([01])/.exec(parentUrl);
+ if (cacheUrlMatches && cacheUrlMatches[1] == "0") {
+ document.getElementById("useCacheCheckbox").checked = false;
+ }
+ }
+
shindig.samplecontainer.initGadget = function() {
// Fetch cookies
var cookieGadgetUrl = decodeURIComponent(shindig.cookies.get(gadgetUrlCookie));