Source:thumbfilter.js

(function () {
  'use strict';
  // Thumbnail Filter
  angular
    .module('mohistory')
    .filter('thumbFilter', thumbFilter);
  /**
   * Given an item object, determine the appropriate thumbnail path. Does
   * not return full path to thumbnail, this allows the caller to customize
   * the output.
   * @memberof mohistory
   * @name thumbFilter
   * @ngdoc filter
   */
  function thumbFilter() {
    var thumbType = '';
    return function (itemObj) {
      //This should take an item's metadata and return the thumbnail path it needs
      var guess = '';
      if (itemObj && itemObj.types && itemObj.types[0]) {
        for (var typeValue in itemObj.types) {
          thumbType = itemObj.types[typeValue]['label'];
          if (thumbType === 'Videocassette') {
            guess = 'img/collection-thumbnails/videocassette';
            break;
          } else if (itemObj.recordType == 'collection') {
            guess = 'img/collection-thumbnails/collection';
            break;
          } else if (/Collection/.test(thumbType)) {
            guess = 'img/collection-thumbnails/collection';
            break;
          } else if (/Series/.test(thumbType)) {
            guess = 'img/collection-thumbnails/collection';
            break;
          } else if (/Box/.test(thumbType)) {
            guess = 'img/collection-thumbnails/box';
            break;
          } else if (/Image/.test(thumbType)) {
            guess = 'img/collection-thumbnails/image';
            break;
          } else if (/Page/.test(thumbType)) {
            guess = 'img/collection-thumbnails/page';
            break;
          } else if (thumbType == 'Box') {
            guess = 'img/collection-thumbnails/box';
            break;
          } else if (/Folder/.test(thumbType)) {
            guess = 'img/collection-thumbnails/folder';
            break;
          } else if (itemObj.mimsyRecordType == 'A' && itemObj.recordType == 'document') {
            guess = 'img/collection-thumbnails/document';
            continue;
          } else if (itemObj.mimsyRecordType == 'M' && itemObj.recordType == 'item') {
            guess = 'img/collection-thumbnails/moving-images';
            continue;
          } else if (itemObj.mimsyRecordType == 'M' && itemObj.recordType == 'video') {
            guess = 'img/collection-thumbnails/moving-images';
            continue;
          } else if (itemObj.mimsyRecordType == 'O' && itemObj.recordType == 'collection') {
            guess = 'img/collection-thumbnails/collection';
            continue;
          } else if (itemObj.mimsyRecordType == 'O' && itemObj.recordType == 'item') {
            guess = 'img/collection-thumbnails/object';
            continue;
          } else if (itemObj.mimsyRecordType == 'P' && itemObj.recordType == 'collection') {
            guess = 'img/collection-thumbnails/collection';
            continue;
          } else if (itemObj.mimsyRecordType == 'L') {
            guess = 'img/collection-thumbnails/document';
            continue;
          } else {
            guess = 'img/collection-thumbnails/folder';
            continue;
          }
        }
      } else {
        guess = 'img/folder';
      }
      return guess;
    }
  }
})();