Page 1 of 1

Browser problems with jQuery/JavaScript

Posted: Sat 06 Apr 2013 11:10 am
by sfws
This is in connection with my routine at https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=8631 as I received an enquiry from another user. Whilst I no longer have any webspace, and am no longer doing any development work, I found to my surprise today that using local filespace, my script to insert the readings for a year ago works on Internet Explorer 9 and Safari 5, but not on latest versions of Chrome and Firefox based browsers. The same effect is seen with my routine at https://cumulus.hosiene.co.uk/viewtopic.php?f=18&t=8690.

Although I do not have time nor inclination to investigate properly, from a quick look using web developer tools in Firefox, it appears that the 'a year ago' script is probably failing at the 'split' instruction shown in context below. That split instruction was present in DAJ's original Annual data summary routine and apart from changing its context, I use it as the only way I know to separate out the rows, and subsequently date components and fields in dayfile.txt.

Can anyone explain why the browsers behave differently with the same script when using local filespace? I note that Firefox claim their latest release is complaint with a particular ECMA script standard. Is there a change in jQuery or a change in permitted function commands? I do have add-ons installed in my Firefox and Chrome, but I have tried this in SRWare Iron, Avant, IceDragon and Lunascape6 with the same result - it does seem to be linked to the browser engine differences. Can anybody suggest alternative coding that all script accepting browsers support?

Code: Select all

	// using jQuery  */
		$.get(dayfile,function(fdata){
var lines=fdata.split("\n"); // defines that newline used to split daily observations in dayfile

Code: Select all


			$.each(lines,function(n,elem){
					var wd_data=elem.split(field_delimiter); /* declare wd_data for each row,
	 as number of items varies between rows, since newer builds of Cumulus create more fields than older builds */
					var the_date=wd_data[0].split(date_delimiter); // first item is date in format something like dd/mm/yy
					// include observations only if for selected day  (the Cumulus date does not include century)
					if (('20'+the_date[2]==past_year)&& (the_date[1]==(1+(past_month)) // USA implementations swap month 
						&& (the_date[0]==past_day_of_month) // with day of month; this is written for UK arrangement
					)){ 	 
						for(var i=0; i<wd_data.length; i++){
							parameter_array[i,0]=label_items[i];
							parameter_array[i,1]="--";
							if ((wd_data[i])!==""){
									parameter_array[i,1]=wd_data[i]; // insert observations
							};  // end of numerical testing if
							switch(i){  // edit these cases to match your build of Cumulus, order does not matter
							case 1: $('#gust').prepend(parameter_array[i,1]);			break;
							case 3: $('#Tgust').append(parameter_array[i,1]);			break;
							case 4: $('#low_temp').prepend(parameter_array[i,1]);		break;

Re: Browser problems with jQuery/JavaScript

Posted: Sat 06 Apr 2013 11:56 am
by steve
Could you give a link to a page that's showing the problem?

Re: Browser problems with jQuery/JavaScript

Posted: Sat 06 Apr 2013 12:28 pm
by sfws
steve wrote:Could you give a link to a page that's showing the problem?
Sorry Steve - I gave up my webspace when I changed internet service provider. I thought I had already made that clear.
sfws wrote:Whilst I no longer have any webspace, and am no longer doing any development work, I found to my surprise today that using local filespace,
I have just looked at a dozen sites using the DAJ javascript Annual Summary, all of them display ok in Firefox including your own http://sanday.org.uk/weather/datasummary.html?year=2010. Even someone else's site using my daily summary code http://www.wareham-weather.co.uk/dailysummary.htm appears ok in Firefox 21, even though in local filespace my own implementation only works in IE and Safari. Equally a site using my 'a year ago' code works at http://www.christelow.co.uk/Development ... /today.htm, there have been a dozen downloads, and nobody commenting it did not work.

So perhaps it is somehow related to the differences in how script works between a web server and local filespace?

Maybe I was too hasty in posting and it is a problem unique to me - I sometimes find all technology stops working when I touch it, hence I prefer gardening and outdoor activities to sitting at my PC or having failures in operating machines like DVD players!

Re: Browser problems with jQuery/JavaScript

Posted: Sat 06 Apr 2013 12:40 pm
by steve
sfws wrote:I gave up my webspace when I changed internet service provider. I thought I had already made that clear.
Well, yes. But you also said that someone else had reported a problem, so I assumed that they had a page on the web showing the problem. Apparently not, so I'll leave this for someone else to puzzle over if they feel so inclined.