Welcome Guest   | Login   
  Search  
  Index |  Recent Threads |  Register | 


Quick Go »
Thread Status: Normal
Total posts in this thread: 9
[Change thread status] [Delete this Thread] [Move this Thread]
[Add To My Favorites] [Watch this Thread] [Post new Thread]
Author
Previous Thread This topic has been viewed 86 times and has 8 replies Next Thread
pscmedia
Newbie



Joined: Apr 3, 2015
Posts: 31
Status: Offline

Edit this Post   Embedding Challenge - need some assistance please Reply to this Post
Reply with Quote
[Delete this Thread]

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>
[Jul 10, 2015, 4:07:27 AM] [71.224.49.252] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
support
localendar Expert
Member's Avatar


Joined: Sep 15, 2004
Posts: 6061
Status: Offline
Edit this Post   Re: Embedding Challenge - need some assistance please Reply to this Post
Reply with Quote
[Delete this Post]

Thanks, we're committed to helping you too :)

Give me a few days to monkey/ask around about this. It may well be that we give you a different method for doing this (and we'll check in IE/FF/Chrome)

One thing I will mention is that testing from the local filesystem vs testing from a page being served by an actual webserver can yield different results. I assume you have tested the page from a server, but if not, it's something to try.
----------------------------------------
Marc Higgins
Support Associate, localendar.com
Follow us on Twitter! http://www.twitter.com/localendar_news
[Jul 11, 2015, 2:44:57 AM] [73.159.223.201] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
pscmedia
Newbie



Joined: Apr 3, 2015
Posts: 31
Status: Offline

Edit this Post   smile   Re: Embedding Challenge - need some assistance please Reply to this Post
Reply with Quote
[Delete this Post]

No need to spend any time.

I changed the code something far simpler and it seems to work in every browser including mobiles.

I'm posting the code so if anyone else wants to use it, they can.
They can also use my site as an example of how it works.

The code pasted below is a truncated example, limited to just a few categories.
There is a category for every swim and dive team and associated calendar events for each.

For future reference, the calendar to demonstrate it best is July 2015.

In summary, user can go to
http:///www.lbsl.org/calendar.html?CODE (whatever code they want to use).
This URL is what we publish to the users.

The CODE value is stripped from the URL and through a SWITCH command in JAVASCRIPT the equivalent LOCALENDAR script string is set and called to open within an HTML fragment on the page.

We can change the script string at any time to tailor it without having to have the user do anything different (they use the same URL).

*It is important to note that the variables p1,p2,s1,s2 must be used to break up the text or the browser tries to interpret it too soon and fails. Breaking it up list this allows the full string to be created before calling it.

*The default is there just in case someone goes to the page without a CODE set on the URL.

<script>
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);

var loc="";
var p1="<SCR";
var p2="IPT ";
var s1="></SCR";
var s2="IPT>";

switch (b)
{
case 'BAC' : loc="src='http://www.localendar.com/public/lbsl?categories=100%2C102%2C103%2C105%2C131%2C132%2C144%2C146%2C117&include=Y&dynamic=Y'"; window.alert("You are about to view: Bensalem Aquatic Club Dual Meets"); break;

case 'BDC' : loc="src='http://www.localendar.com/public/lbsl?categories=100%2C102%2C103%2C105%2C132%2C143%2C145%2C137&include=Y&dynamic=Y'"; window.alert("You are about to view: Brookside Dive Club Dual Meets"); break;

case 'PSC' : loc="src='http://www.localendar.com/public/lbsl?categories=100%2C102%2C103%2C105%2C131%2C132%2C144%2C146%2C111&include=Y&dynamic=Y'"; window.alert("You are about to view: PSC Highpoint Swim Team Dual Meets"); break;

case 'SWIM' : loc="src='http://www.localendar.com/public/lbsl?categories=100%2C102%2C103%2C105%2C131%2C132%2C144%2C146%2C147%2C&include=Y&dynamic=Y'"; window.alert("You are about to view: Swim Calendar Items (everything except dual meets) "); break;

case 'DIVE' : loc="src='http://www.localendar.com/public/lbsl?categories=100%2C103%2C105%2C132%2C143%2C145%2C148%2C&include=Y&dynamic=Y'"; window.alert("You are about to view: Dive Calendar Items (everything except dual meets) "); break;

case 'REDSWIM' : loc="src='http://www.localendar.com/public/lbsl?categories=100%2C102%2C103%2C105%2C131%2C132%2C144%2C146%2C106&include=Y&dynamic=Y'"; window.alert("You are about to view: All Swim Red Division Dual Meets"); break;

case 'WHITESWIM' : loc="src='http://www.localendar.com/public/lbsl?categories=100%2C102%2C103%2C105%2C131%2C132%2C144%2C146%2C107&include=Y&dynamic=Y'"; window.alert("You are about to view: All Swim White Division Dual Meets"); break;

case 'BLUESWIM' : loc="src='http://www.localendar.com/public/lbsl?categories=100%2C102%2C103%2C105%2C131%2C132%2C144%2C146%2C108&include=Y&dynamic=Y'"; window.alert("You are about to view: All Swim Blue Division Dual Meets"); break;

case 'REDDIVE' : loc="src='http://www.localendar.com/public/lbsl?categories=100%2C102%2C103%2C105%2C131%2C132%2C144%2C146%2C133&include=Y&dynamic=Y'"; window.alert("You are about to view: All Dive Red Division Dual Meets"); break;

case 'WHITEDIVE' : loc="src='http://www.localendar.com/public/lbsl?categories=100%2C102%2C103%2C105%2C131%2C132%2C144%2C146%2C134&include=Y&dynamic=Y'"; window.alert("You are about to view: All Dive White Division Dual Meets"); break;

default: window.alert("You must use a valid parameter on the URL");
}
all=p1+p2+loc+s1+s2;
document.write(all);
</script>
smile
[Jul 11, 2015, 4:50:42 AM] [71.224.49.252] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
pscmedia
Newbie



Joined: Apr 3, 2015
Posts: 31
Status: Offline

Edit this Post   Re: Embedding Challenge - need some assistance please Reply to this Post
Reply with Quote
[Delete this Post]

One addition would be to add this line after the assignment of b

b=b.substring(1);
b=b.toUpperCase();

This will accommodate the CODE no matter what case (upper or lower) they type it in.
[Jul 11, 2015, 5:21:54 AM] [71.224.49.252] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
support
localendar Expert
Member's Avatar


Joined: Sep 15, 2004
Posts: 6061
Status: Offline
Edit this Post   Re: Embedding Challenge - need some assistance please Reply to this Post
Reply with Quote
[Delete this Post]

Solved it yourself? Shared the solution besides? My favorite kind of member biggrin

Thanks!
----------------------------------------
Marc Higgins
Support Associate, localendar.com
Follow us on Twitter! http://www.twitter.com/localendar_news
[Jul 13, 2015, 2:21:28 PM] [24.190.224.252] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
OPwebmaster
localendar Expert



Joined: Jan 24, 2015
Posts: 286
Status: Offline

Edit this Post   Re: Embedding Challenge - need some assistance please Reply to this Post
Reply with Quote
[Delete this Post]

pscmedia:

>>For future reference, the calendar to demonstrate it best is July 2015.<<

What is the website of this calendar so other Localendar users can get a better understanding of what the code actually does, and where?


Harry
[Jul 14, 2015, 3:54:52 AM] [72.241.195.138] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
pscmedia
Newbie



Joined: Apr 3, 2015
Posts: 31
Status: Offline

Edit this Post   Re: Embedding Challenge - need some assistance please Reply to this Post
Reply with Quote
[Delete this Post]

Calendar Selection Example

The problem is, due to the bug which reared its head again, it no longer filters correctly by category.

:(

Once localendar fixes again, it will be up and running once more.
[Apr 19, 2016, 4:09:25 PM] [74.92.127.105] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
support
localendar Expert
Member's Avatar


Joined: Sep 15, 2004
Posts: 6061
Status: Offline
Edit this Post   Re: Embedding Challenge - need some assistance please Reply to this Post
Reply with Quote
[Delete this Post]

I hit the sample link, and got a lot of Javascript pop-up/debug messages (ie "Hello World" - are you working on this now, or would you like some hints ;)

No code has changed on our side in 3+ weeks (and even then, the last bit of code was related to weebly support), so I'm not sure what break/fix you are referring to.
----------------------------------------
Marc Higgins
Support Associate, localendar.com
Follow us on Twitter! http://www.twitter.com/localendar_news
[Apr 22, 2016, 2:30:58 AM] [65.113.88.17] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
lbsl
Newbie



Joined: Jun 4, 2015
Posts: 21
Status: Offline

Edit this Post   smile   Re: Embedding Challenge - need some assistance please Reply to this Post
Reply with Quote
[Delete this Post]

Support had suggested and I have tested and agreed, when embedding a month calendar in a site, do not use www in the URL for the localendar address.
This will allow the categories to be retained while scrolling through the months
[Apr 25, 2016, 2:17:53 PM] [74.92.127.105] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
[Show Thread Printable Version] [Post new Thread]

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