// -*- coding: utf-8 -*-
// ===================================================================
// Class for formatting Parol info
//

function ParolFormatter(aModel)
{
  try {
    this._Model = aModel;
  }
  catch (e) {
    alert("ParolFormatter: " + e);
  }
}

ParolFormatter.prototype.toString = function()
{
  return "ParolFormatter";
}

// getInfo(aParol)
// returns [id, imgName, titleString, suffix]
// id =
//     0: new parol
//     1: in collection (= first parol)
//     2: second parol (= associated with any Parol in the collection)
//   250: deprecated parol
//   100: the rest
// suffix = the suffix if parolQual has a suffix behind underscore, otherwise empty string,
//   e.g. "I" from "Gn1v2-3_I"
ParolFormatter.prototype.getInfo = function(aParol)
{
  var parolQual = aParol.getID();
  var Match = parolQual.match(/_([A-Za-z0-9]+)/);
  var suffix = Match ? Match[1] : "";

  var state = aParol.getCategory("State");
  switch (state) {
  case   0: 
    return [  0, "parolNew.png", "neuer Bibelspruch", suffix];
    break;

  default:
  case 100: 
    if (this._Model.getParolInCollection(parolQual)) {
      return [1, "parolFirst.png", "Erstspruch", suffix];
    }
    if (this._Model.getPairSet().hasFirstForSecond(parolQual)) {
      return [2, "parolSecond.png", "Zweitspruch", suffix];
    }
    return [100, "parol.png", "Bibelspruch", suffix];

  case 250: 
    return [250, "parolDelete.png", "zurückgezogener Bibelspruch", suffix];
    break;
  }

}


