ICal Parser Fix V2

Updated the parser fix so it is a little more elegant.
This commit is contained in:
thegunslingers 2016-01-24 12:29:45 -05:00
parent bb1adbc4a6
commit 1ba6a59f8b

View File

@ -80,7 +80,6 @@ function ical_parser(feed_url, callback){
//Keep track of when we are activly parsing an event //Keep track of when we are activly parsing an event
var in_event = false; var in_event = false;
var summary_set = false;
//Use as a holder for the current event being proccessed. //Use as a holder for the current event being proccessed.
var cur_event = null; var cur_event = null;
for(var i=0;i<cal_array.length;i++){ for(var i=0;i<cal_array.length;i++){
@ -95,7 +94,6 @@ function ical_parser(feed_url, callback){
in_event = false; in_event = false;
this.events.push(cur_event); this.events.push(cur_event);
cur_event = null; cur_event = null;
summary_set = false;
} }
//If we are in an event //If we are in an event
else if(in_event){ else if(in_event){
@ -110,12 +108,9 @@ function ical_parser(feed_url, callback){
type = ln.substr(0,idx).replace(/^\s\s*/, '').replace(/\s\s*$/, '');//Trim type = ln.substr(0,idx).replace(/^\s\s*/, '').replace(/\s\s*$/, '');//Trim
val = ln.substr(idx+1).replace(/^\s\s*/, '').replace(/\s\s*$/, ''); val = ln.substr(idx+1).replace(/^\s\s*/, '').replace(/\s\s*$/, '');
//Ensure summary is not overwritten by VAlARM Summary if(typeof cur_event[type] !== 'undefined'){
if(type =='SUMMARY' && !summary_set){
summary_set = true;
}else if(type =='SUMMARY' && summary_set){
continue; continue;
} }
//If the type is a start date, proccess it and store details //If the type is a start date, proccess it and store details
if(type =='DTSTART'){ if(type =='DTSTART'){