//iTop Form field ; $(function() { // the widget definition, where 'itop' is the namespace, // 'breadcrumb' the widget name $.widget( 'itop.breadcrumb', { // default options options: { itop_instance_id: '', new_entry: null, }, // the constructor _create: function() { var me = this; this.element .addClass('breadcrumb'); if(typeof(Storage) !== "undefined") { var sBreadCrumbStorageKey = this.options.itop_instance_id + 'breadcrumb-v1'; var aBreadCrumb = []; var sBreadCrumbData = sessionStorage.getItem(sBreadCrumbStorageKey); if (sBreadCrumbData !== null) { aBreadCrumb = JSON.parse(sBreadCrumbData); } var iDisplayableItems = aBreadCrumb.length; if (this.options.new_entry !== null) { var sUrl = this.options.new_entry.url; if (sUrl.length == 0) { sUrl = window.location.href; } // Eliminate items having the same id, before appending the new item var aBreadCrumb = $.grep(aBreadCrumb, function(item, ipos){ if (item.id == me.options.new_entry.id) return false; else return true; }); aBreadCrumb.push({ id: this.options.new_entry.id, label: this.options.new_entry.label, description: this.options.new_entry.description, icon: this.options.new_entry.icon, url: sUrl }); // Keep only the last N items aBreadCrumb = aBreadCrumb.slice(-8); // Do not show the last = current item iDisplayableItems = aBreadCrumb.length - 1; } sBreadCrumbData = JSON.stringify(aBreadCrumb); sessionStorage.setItem(sBreadCrumbStorageKey, sBreadCrumbData); var sBreadCrumbHtml = '