localendar Forums Homepage


Print at Sep 22, 2025, 10:31:21 AM

Posted by pscmedia at Jul 10, 2015, 4:07:27 AM
Embedding Challenge - need some assistance please
So, I'm fully committed to localendar for multiple accounts.

I've uploaded probably hundreds of events now.

Now I have to serve them up to our consumers.

I have some localendar scripts embedded in our website pages and that works fine.

We have 27 teams and each has their own category for their specific events.

I also have created and included other common categories for their convenience such as meetings which are common across all teams.

I want them to be able to have their own link for just their meets and common events using a category combination.

...but I don't want to give them the std. localendar.com/public/lbsl?categories=100%2C101...etc. because once I provide that URL, users will save it as a favorite. I'm still not done fine tuning the categories, so I want to be able to make changes to what categories are included for them down the road.

What I've come up with with pointing them to a std. webpage with a unique parameter on the end such as www.lbsl.org/xyz.html?Brookside_Swim_Team

I've embedded javascript in the webpage which parses the URL and pulls out the parameter. Brookside_Swim_Team

Then using a Switch command, it conditionally provides/translates it to the localendar URL with the categories I want for them and sends them to that calendar..... which is embedded inside of the LBSL.org site.

They are never on just a localendar page....always an LBSL page.

This way, unless they look at the source code, they will never actually see the localendar URL which means I can change the lbsl.org script it down the road to adjust categories. Its all a matter of redirection which I control. All they need to know is their swim club name (on the end of the lbsl.org URL).

The problem is, the calendar won't load in anything other than Firefox and even then its kind of strange in that I need to have a window.alert message present.

I saw you helped others with calendar script embedding problems before, and I was hoping you could look at this one and provide a tip.

I'm included the sourcecode which can be run locally.

To test it, save it as test.html and open it with either the parameter

D:/test.html?Brookside_Swim_Club
or
D:/test.html?Bensalem_Aquatic_Club

Again, it only seems to work in Firefox. Can you help?

Here is the actual contents of the test.html file:

<script>

addEvent = function(elm, evType, fn, useCapture)
{
//Credit: Function written by Scott Andrews
//(slightly modified)
var ret = 0;
if (elm.addEventListener) {
ret = elm.addEventListener(evType, fn, useCapture);
} else if (elm.attachEvent) {
ret = elm.attachEvent('on' + evType, fn);
} else {
elm['on' + evType] = fn;
}
return ret;
};
var left_to_load = 0;
function init()
{
--left_to_load;
if (left_to_load > 0) {
return;
}
// all scripts are loaded now
// proceed with your logic
}
// load js file and call function when done
function load_javascript(src, callback) {
var a = document.createElement('script');
a.type = 'text/javascript';
a.src = src;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(a, s);
++left_to_load;
addEvent(a, 'load', callback, false);
}


var newURL = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname;
var pathArray = window.location.pathname.split( '/' );

var a = window.location.pathname;
var b = window.location.search;
b=b.substring(1);
switch (b) {
case "Bensalem_Aquatic_Club":
load_javascript("http://www.localendar.com/public/lbsl?categories=100%2C102%2C105%2C131%2C132%2C144%2C117&include=Y&dynamic=Y", init);
window.alert("Press Enter or Click to continue to Bensalem...");
break;

case "Brookside_Swim_Club":
load_javascript("http://www.localendar.com/public/lbsl?categories=100%2C102%2C105%2C131%2C132%2C144%2C112&include=Y&dynamic=Y", init);
window.alert("Press Enter or Click to continue to Brookside...");
break;
}



</script>

Help! | Cobranding | Legal | Privacy Policy | About localendar.com | Contact Us