if(!window.jQuery) { var script = document.createElement('script'); script.type = "text/javascript"; script.src = "https://code.jquery.com/jquery-3.5.1.min.js"; document.getElementsByTagName('head')[0].appendChild(script); } //LoadingDoc: '
', if(!window.iFrameResize) { var script = document.createElement('script'); script.type = "text/javascript"; script.src = "https://portal.myinvestmentoffice.com/js/iframeResizer.min.js"; document.getElementsByTagName('head')[0].appendChild(script); script.onload = function() { iFrameResize({ log: false,heightCalculationMethod: 'lowestElement' }, '.elements-widget'); } } var ElementsWidgets = { checker: null, checkIfDone: function() { if( $('.elements-widget').not('.loaded') == 0) { //we are done loading clearInterval(ElementsWidgets.checker); } }, supportsSRCDoc: (!!("srcdoc" in document.createElement("iframe"))), LoadingDoc: '
', FailedDoc: '

Uh Oh! There was an error while loading the widget. Click to Reload.

', attr2NVP: function(obj,filters) { var output = []; var a = {}; $.each($(obj)[0].attributes, function() { // this.attributes is not a plain object, but an array // of attribute nodes, which contain both the name and value if(this.name.indexOf('data-') == 0) { //output.push(this.name.replace('data-','') + '=' + escape(this.value)); a[ this.name.replace('data-','').toLowerCase() ] = escape(this.value); } }); if(filters) { for(i in filters) { a[i.toLowerCase()] = filters[i]; } } for(i in a) { output.push(i + '=' + a[i] ); } return output.join('&'); }, loadWidgets: function(ok,origin,filters) { if(origin) { //good } else { origin=location.host.split('.')[0]; } $('.elements-widget').not('.loaded').not('.loading').not('.failed').each(function() { var url = 'https://api.myinvestmentoffice.com/rest/v1/reporting/widgets/' + $(this).attr('data-type') + '?' + ElementsWidgets.attr2NVP( $(this) ,filters) + '&orign=' + origin + '&ok=' + ok; //+ '&Origin=' + origin; ///console.log(url); if(ElementsWidgets.supportsSRCDoc==false) { $(this).attr('src',url).addClass('loaded'); } else { $(this).attr('srcdoc', ElementsWidgets.LoadingDoc); $(this).addClass('loading'); jQuery.ajax({ url: url, dataType: 'html', method: 'GET', obj: $(this), timeout: 30000 }).done(function(data) { //console.log('widget data loaded'); $(this.obj).attr('srcdoc', data).addClass('loaded').removeClass('loading').removeClass('failed'); }).fail(function(a,b,c) { //console.log('failed'); if(window.top.ProcessError) { window.top.ProcessError(a,b,c) } $(this.obj).removeClass('loading').addClass('failed'); $(this.obj).attr('srcdoc',ElementsWidgets.FailedDoc); return false; if(a.status != 401 && a.status != 400) { $(this.obj).removeClass('loading').addClass('failed') } else { $(this.obj).replaceWith('Your login has expired, please re-login.'); } }); } }); if(!ElementsWidgets.checker) { ElementsWidgets.checker = setInterval(ElementsWidgets.loadWidgets,500,ok,origin) }; return true; }, widgetListener: function(event,data) { //alert('here'); if(event == 'RowSelected' && data.Source.FilterListener != '') { $('.elements-widget[data-filtergroup="' + data.Source.FilterListener + '"]').each(function() { ///console.log('filtering ' + $(this).attr('id')); $(this).attr( 'data-filterfieldname',data.Source.FilterListener).attr('data-FilterFieldValue',data.Record[data.Source.FilterListener.toLowerCase()]).removeClass('loaded').prop('srcdoc',ElementsWidgets.LoadingDoc); }); ElementsWidgets.loadWidgets(data.Source.ok,data.Source.EntityID); } } }