/*
* INIT OBJECT
*****************************/
var TODSwitcherExclude = ['HARVESTEDDOCUMENT', 'OAIDOCUMENT', 'PHYSICALDOCUMENT_DEF'];
var IDSwitcher = new Object();
var TODSwitcher = new Object(); TODSwitcher =
{"Event":[["test1","#","/in/rest/annotationSVC/Attachment/attach_upload_abb8cedb-7d9a-455e-a35f-ddca47a0e14b?fileName=none.png"],["test2","#","/in/rest/annotationSVC/Attachment/attach_upload_abb8cedb-7d9a-455e-a35f-ddca47a0e14b?fileName=none.png"],["Les Événements","details.xhtml?id=75b8eaef-c8d5-4109-b0f9-57e0be0c234b","/in/rest/annotationSVC/Attachment/attach_upload_abb8cedb-7d9a-455e-a35f-ddca47a0e14b?fileName=none.png"]]}
; delete TODSwitcher['REMOVE ME'];
/*
* INIT CONFIG
* DEFAULT VALUE
***************/
var BreadTrailConfig = [["REPLACEDEFAULTTRAIL","false"],["RACINE","Skin_nav"],["REPLACEBYTYPE","true"],["REPLACEBYID","true"],["ACTIVEICON","true"],["ACTIVESPACER","true"],["CREATEHOME","true"],["AUTOCREATESELFNODE","true"],["EXCLUDEMENU","true"],["EXCLUDECREATEHOME","true"]];
var HOMEPAGE = ['Retour à la page d\'accueil','homeInBook.xhtml','/in/rest/annotationSVC/Attachment/attach_upload_8a6bc57c-c254-4438-a7e4-73d19c0c6a9e?fileName=homepage.png'];
var ACTIVEICON = 'true', //|BOOL |--> do we show icon ?
ACTIVESPACER = 'true', //|BOOL |--> do we show spacer ?
AUTOCREATESELFNODE = 'true', //|BOOL |--> do we auto end the breadtrail with self ?
BROWSEMENU = 'true', //|BOOL |--> do we create a browse menu ?
CREATEHOME = 'true', //|BOOL |--> do we autocreate home in breadtrail ?
EXCLUDECREATEHOME = 'true', //|BOOL |--> do we autocreate home in the exclude menu ?
EXCLUDEMENU = 'true', //|BOOL |--> do we create a menu on exclude document ?
RACINE = 'Skin_nav', //|STRING|--> node of navigation menu
REPLACEBYID = 'true', //|BOOL |--> do we replace by id ?
REPLACEBYTYPE = 'true', //|BOOL |--> do we replace by type ?
REPLACEDEFAULTTRAIL = 'true'; //|BOOL |--> replace default trail ?
/*
* OVERRIDE WITH CONFIG SHEETS
*****************************/
function parseBool(string){return (string.toUpperCase() === 'TRUE' || parseInt(string) === 1);}
$.each(BreadTrailConfig, function(cfgKey, cfgValue){
switch(cfgValue[0]){
case 'ACTIVEICON': {ACTIVEICON = parseBool(cfgValue[1])}; break;
case 'ACTIVESPACER': {ACTIVESPACER = parseBool(cfgValue[1])}; break;
case 'AUTOCREATESELFNODE': {AUTOCREATESELFNODE = parseBool(cfgValue[1])}; break;
case 'BROWSEMENU': {BROWSEMENU = parseBool(cfgValue[1])}; break;
case 'CREATEHOME': {CREATEHOME = parseBool(cfgValue[1])}; break;
case 'EXCLUDECREATEHOME': {EXCLUDECREATEHOME = parseBool(cfgValue[1])}; break;
case 'EXCLUDEMENU': {EXCLUDEMENU = parseBool(cfgValue[1])}; break;
case 'RACINE': {RACINE = cfgValue[1]}; break;
case 'REPLACEBYID': {REPLACEBYID = parseBool(cfgValue[1])}; break;
case 'REPLACEBYTYPE': {REPLACEBYTYPE = parseBool(cfgValue[1])}; break;
case 'REPLACEDEFAULTTRAIL': {REPLACEDEFAULTTRAIL = parseBool(cfgValue[1])}; break;
}
})
/*
* REPLACE CRUMBSTRAIL BY BREADTRAIL
***********************************/
if(REPLACEDEFAULTTRAIL){
$(document).ready(function(){
/*
* EVERY WHERE BUT NOT ON BROWSE AND HOME
****************************************/
if (document.URL.indexOf("homeInBook.xhtml") == -1 && document.URL.indexOf("browse.xhtml") == -1){
callRestToJson('restService_CustomBreadTrail', {'racine': RACINE});
var docID = '', query = '';
window.location.search.substring(1).split('&').forEach(function(kvBundle){
keyValue = kvBundle.split('=');
if(keyValue[0] == 'id' || keyValue[0] == 'profile' || keyValue[0] == 'profil'){
docID=keyValue[1];
query = [
'/in/rest/searchSVC/jsonp/geoquery?pageSize=1&lang=fr_ca',
'&query=InterviewId:"'+docID+'"',
'%20OR%20',
'id:"'+docID+'"',
].join('');
}
});
$.ajax({
type: 'GET', async: false,
url: query,
contentType: "application/json", dataType: 'jsonp',
success: function(data){
if(data.numHits > 0){
//console.log('TITLE', title);
//console.log('DATA', data.results[0]);
var typeOfDocument = data.results[0].TypeOfDocumentFacet.value.replace(' ', ''),
title = data.results[0].Title.value.toUpperCase();
var pageInfo = {'type': typeOfDocument, 'title': title, 'id': docID};
genBreadTrailModel($('#crumbtrail'), pageInfo);
}
},
});
};
/*
* Create a browse.xhtml menu
****************************************/
if(BROWSEMENU && document.URL.indexOf("browse.xhtml") >= 0){
// NOT IMPLEMENTED YET
}
}); // $(document).ready END
function genBreadTrailModel(racine, info){
var BreadTrailContainer = genBreadTrailDynamic($('#crumbtrail'));
$(racine).after(BreadTrailContainer);
/* Build BreadTrail by ID
* If config = yes to replaceById and the doc type is not in exclude
*******************************************************************/
var IDArray = [], spacerContainer= '';
if(ACTIVESPACER){spacerContainer=''};
if(REPLACEBYID && TODSwitcherExclude.indexOf(info['type']) == -1 && !TODSwitcher.hasOwnProperty(info['type'])){
$.each(IDSwitcher[info['id']], function(index, values){
IDArray.push(values[3]);
var iconContainer = '';
if(ACTIVEICON){ iconContainer=''; };
$('#BreadTrail').append('
');
});
}
/* Build BreadTrail by type
* If config = yes to replaceById and the doc type is not in exclude
*******************************************************************/
if(REPLACEBYTYPE && TODSwitcherExclude.indexOf(info['type']) == -1 && TODSwitcher.hasOwnProperty(info['type'])){
$.each(TODSwitcher[info['type']], function(index, values){
var iconContainer = '';
if(ACTIVEICON){ iconContainer=''; };
$('#BreadTrail').append('