Browser problems with jQuery/JavaScript
Posted: Sat 06 Apr 2013 11:10 am
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? var lines=fdata.split("\n"); // defines that newline used to split daily observations in dayfile
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){
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;