<commit_before>
// CalSourceType ist das Grund-Object. Es ist pro Quell-System einmal zu vererben.
// Innerhalb des Objektes werden dann die Events gehalten separiert nach Kategorie
function CalSourceType() {
  var t=this;
  // H�lt die Daten nach category_id auf
  t.data = new Object();
  // Timer zum Laden der Daten. Erst werden alle Categorien als "needData" markiert und dann l�dt er
  t.timer=null;
}

CalSourceType.prototype.prepareCategory = function(category_id, refresh) {
  var t=this;
  if (refresh==null) refresh=false;
  if ((refresh) || (t.data[category_id]==null)) {
    if ((t.data[category_id]!=null) && (t.data[category_id].current_CalEvents!=null))
      send2Calendar("removeEventSource", t.data[category_id].current_CalEvents);
    t.data[category_id]=new Object();
    t.data[category_id].hide=false;
    t.data[category_id].status="new";
    t.data[category_id].events=new Object();
  }
};

CalSourceType.prototype.needData = function(category_id, refresh) {
  var t=this;
  if (refresh==null) refresh=false;
  t.prepareCategory(category_id, refresh);
  if (t.data[category_id].status!="loaded" && t.data[category_id].status!="loadData") {
    t.data[category_id].status="needData";
    t.data[category_id].name=t.getName(category_id);
    t.triggerCollectTimer();
  }
  else if (t.data[category_id].hide && t.data[category_id].status=="loaded") {
    t.data[category_id].hide=false;
    t.showEventsOnCal(category_id);
  }
};

CalSourceType.prototype.getName = function(category_id) {
  return "Unknown["+category_id+"]";
};

CalSourceType.prototype.triggerCollectTimer = function() {
  var t=this;
  if (t.timer!=null)
    window.clearTimeout(t.timer);
  t.timer=window.setTimeout(function() {
    t.collectData();
    t.timer=null;
  }, 100);
};

CalSourceType.prototype.hideData = function(category_id) {
  var t=this;
  t.prepareCategory(category_id);
  t.data[category_id].hide=true;
  if (t.data[category_id].current_CalEvents!=null)
    send2Calendar("removeEventSource", t.data[category_id].current_CalEvents);
};

/**
 *
 * @param category_id entweder eine konkrete oder null, dann werden all refreshed
 * @param needRefresh default=false;
 */
CalSourceType.prototype.refreshView = function(category_id, needRefresh) {
  var t=this;
  if (needRefresh==null) needRefresh=false;
  if (category_id!=null) {
    this.hideData(category_id);
    this.needData(category_id, needRefresh);
  }
  else {
    each(t.data, function(k,a) {
      if (a.status=="loaded") {
        t.hideData(k);
        t.needData(k, needRefresh);
      }
    });
  }
};

CalSourceType.prototype.collectData = function() {
  var t=this;
  var ids=new Array();
  each(t.data, function(k,a) {
    if (a.status=="needData") {
      ids.push(k);
      t.data[k].status="loadData";
    }
  });
  if (ids.length>0) {
    t.jsonCall(ids);
  }
};

CalSourceType.prototype.jsonCall = function(ids) {
  throw new Exception("Not implemented!");
};
CalSourceType.prototype.showEventsOnCal = function(category_id) {
};

function _getEventsFromDate(cs_events, start, end) {
  var go = start.format(DATEFORMAT_EN).toDateEn(false);
  var e = new Date();
  if (end==null) {
    e=new Date(); e.addDays(1000);
  }
  else e = end.format(DATEFORMAT_EN).toDateEn(false);
  var arr = new Array();
  while (go.getTime()<=e.getTime()) {
    if (cs_events!=null && cs_events[go.getFullYear()]!=null &&
        cs_events[go.getFullYear()][go.getMonth()+1]!=null &&
        cs_events[go.getFullYear()][go.getMonth()+1][go.getDate()]!=null)
      arr=arr.concat(cs_events[go.getFullYear()][go.getMonth()+1][go.getDate()]);
    go.addDays(1);
  }
  return arr;
}

function _addEventsToDateIndex(cs_events, o) {
  var year=cs_events[o.start.getFullYear()];
  if (year==null) year=new Array();

  var month=year[o.start.getMonth()+1];
  if (month==null) month=new Array();

  var day=month[o.start.getDate()];
  if (day==null) day=new Array();

  day.push(o);
  month[o.start.getDate()]=day;
  year[o.start.getMonth()+1]=month;
  cs_events[o.start.getFullYear()]=year;
}

// ---------------------------------------------------------------------------------------------------------
// Der CalCC-Type l�dt die Daten aus der CC_CAL-Tabelle
//---------------------------------------------------------------------------------------------------------
function CalCCType() {<commit_msg>(Cal) Fix problem with long dates not always displayed correctly<commit_after>
// CalSourceType ist das Grund-Object. Es ist pro Quell-System einmal zu vererben.
// Innerhalb des Objektes werden dann die Events gehalten separiert nach Kategorie
function CalSourceType() {
  var t=this;
  // H�lt die Daten nach category_id auf
  t.data = new Object();
  // Timer zum Laden der Daten. Erst werden alle Categorien als "needData" markiert und dann l�dt er
  t.timer=null;
}

CalSourceType.prototype.prepareCategory = function(category_id, refresh) {
  var t=this;
  if (refresh==null) refresh=false;
  if ((refresh) || (t.data[category_id]==null)) {
    if ((t.data[category_id]!=null) && (t.data[category_id].current_CalEvents!=null))
      send2Calendar("removeEventSource", t.data[category_id].current_CalEvents);
    t.data[category_id]=new Object();
    t.data[category_id].hide=false;
    t.data[category_id].status="new";
    t.data[category_id].events=new Object();
  }
};

CalSourceType.prototype.needData = function(category_id, refresh) {
  var t=this;
  if (refresh==null) refresh=false;
  t.prepareCategory(category_id, refresh);
  if (t.data[category_id].status!="loaded" && t.data[category_id].status!="loadData") {
    t.data[category_id].status="needData";
    t.data[category_id].name=t.getName(category_id);
    t.triggerCollectTimer();
  }
  else if (t.data[category_id].hide && t.data[category_id].status=="loaded") {
    t.data[category_id].hide=false;
    t.showEventsOnCal(category_id);
  }
};

CalSourceType.prototype.getName = function(category_id) {
  return "Unknown["+category_id+"]";
};

CalSourceType.prototype.triggerCollectTimer = function() {
  var t=this;
  if (t.timer!=null)
    window.clearTimeout(t.timer);
  t.timer=window.setTimeout(function() {
    t.collectData();
    t.timer=null;
  }, 100);
};

CalSourceType.prototype.hideData = function(category_id) {
  var t=this;
  t.prepareCategory(category_id);
  t.data[category_id].hide=true;
  if (t.data[category_id].current_CalEvents!=null)
    send2Calendar("removeEventSource", t.data[category_id].current_CalEvents);
};

/**
 *
 * @param category_id entweder eine konkrete oder null, dann werden all refreshed
 * @param needRefresh default=false;
 */
CalSourceType.prototype.refreshView = function(category_id, needRefresh) {
  var t=this;
  if (needRefresh==null) needRefresh=false;
  if (category_id!=null) {
    this.hideData(category_id);
    this.needData(category_id, needRefresh);
  }
  else {
    each(t.data, function(k,a) {
      if (a.status=="loaded") {
        t.hideData(k);
        t.needData(k, needRefresh);
      }
    });
  }
};

CalSourceType.prototype.collectData = function() {
  var t=this;
  var ids=new Array();
  each(t.data, function(k,a) {
    if (a.status=="needData") {
      ids.push(k);
      t.data[k].status="loadData";
    }
  });
  if (ids.length>0) {
    t.jsonCall(ids);
  }
};

CalSourceType.prototype.jsonCall = function(ids) {
  throw new Exception("Not implemented!");
};
CalSourceType.prototype.showEventsOnCal = function(category_id) {
};

function _getEventsFromDate(cs_events, start, end) {
  var go = start.format(DATEFORMAT_EN).toDateEn(false);
  var e = new Date();
  if (end==null) {
    e=new Date(); e.addDays(1000);
  }
  else e = end.format(DATEFORMAT_EN).toDateEn(false);
  var arr = new Array();
  while (go.getTime()<=e.getTime()) {
    if (cs_events!=null && cs_events[go.getFullYear()]!=null &&
        cs_events[go.getFullYear()][go.getMonth()+1]!=null &&
        cs_events[go.getFullYear()][go.getMonth()+1][go.getDate()]!=null)
      arr=arr.concat(cs_events[go.getFullYear()][go.getMonth()+1][go.getDate()]);
    go.addDays(1);
  }
  // Delete items which are over one day, cause they are more than one time in it
  var ids = new Object();
  var newArr = new Array();
  each(arr, function(k, a) {
    if (ids[a.id]==null) {
      ids[a.id]=true;
      newArr.push(a);
    }    
  });
  return newArr;
}

/**
 * Uses a runningDate to get all days to the index
 * @param cs_events
 * @param o
 */
function _addEventsToDateIndex(cs_events, o) {
  if (o.runningDate==null) o.runningDate = new Date(o.start.getTime());
  var year=cs_events[o.runningDate.getFullYear()];
  if (year==null) year=new Array();

  var month=year[o.runningDate.getMonth()+1];
  if (month==null) month=new Array();

  var day=month[o.runningDate.getDate()];
  if (day==null) day=new Array();

  day.push(o);
  month[o.runningDate.getDate()]=day;
  year[o.runningDate.getMonth()+1]=month;
  cs_events[o.runningDate.getFullYear()]=year;
    
  o.runningDate.addDays(1);
  if (o.runningDate.getTime() < o.end.getTime()) {
   _addEventsToDateIndex(cs_events, o);
  }
}

// ---------------------------------------------------------------------------------------------------------
// Der CalCC-Type l�dt die Daten aus der CC_CAL-Tabelle
//---------------------------------------------------------------------------------------------------------
function CalCCType() {
{'fraction_non_alphanumeric': 0.2013063497162437, 'fraction_numerical': 0.0035335689045936395, 'mean_word_length': 3.4539818788745826, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7566169', 'n_tokens_mistral': 3212, 'n_tokens_neox': 3198, 'n_words': 565}