function mpiq_widget_init(ind){ if(ind >= mp_files.length){ mpiq_load_widgets(); return false; } var file=mp_files[ind]; var flag=eval(mp_flags[ind]); if(flag){ var _doc = document.getElementsByTagName('head')[0]; var js = document.createElement('script'); js.setAttribute('type', 'text/javascript'); js.setAttribute('src', mpiq_get_url(file)); _doc.appendChild(js); if(-[1,]){//if not IE js.onload = function () { mpiq_widget_init(++ind); } } else { // IE6,IE7 support js.onreadystatechange js.onreadystatechange = function () { if ((js.readyState == 'loaded' || js.readyState == 'complete') && !js.loaded ){ mpiq_widget_init(++ind); } } } }else{ mpiq_widget_init(++ind); } return false; } var mp_files=new Array("/LTISystem/jsp/javascript/jquery-1.8.2.min.js","/LTISystem/jsp/javascript/jquery-ui-1.9.0.min.js","/LTISystem/jsp/portfolio/images/jquery.ajaxAutoComplete/jquery.suggest.js","/LTISystem/jsp/widgets/js/jquery.tipTip.js","/LTISystem/jsp/template/ed/js/jquery.colorbox.js","/LTISystem/jsp/javascript/mpiq/sunnytabs.js?version_1"); var mp_flags=new Array("typeof window.jQuery == \"undefined\"","typeof jQuery.ui == \"undefined\"","typeof jQuery.suggest == \"undefined\"","typeof jQuery.fn.tipTip == \"undefined\"","typeof jQuery.colorbox == \"undefined\"","typeof jQuery.fn.sunnytabs == \"undefined\""); function mpiq_load_data_from_server(data_url,fn){ window.jQuery.ajax({ type : "GET", url : data_url, dataType : "jsonp", jsonp: 'jsoncallback', success : function(data){ window.jQuery(".mpiq_loading_back").hide(); window.jQuery(".mpiq_loading").hide(); fn(data); }, error:function(){ window.jQuery(".mpiq_loading_back").hide(); window.jQuery(".mpiq_loading").hide(); } }); } function mpiq_post_data_to_server(data_url,data,fn){ window.jQuery(".mpiq_loading_back").show(); window.jQuery(".mpiq_loading").show(); window.jQuery.ajax({ type : "post", url : data_url, data : data, dataType : "jsonp", jsonp: 'jsoncallback', success : function(data){ window.jQuery(".mpiq_loading_back").hide(); window.jQuery(".mpiq_loading").hide(); fn(data); }, error:function(){ window.jQuery(".mpiq_loading_back").hide(); window.jQuery(".mpiq_loading").hide(); } }); } function mpiq_ajax_post_server(data_url,fn){ window.jQuery(".mpiq_loading_back").show(); window.jQuery(".mpiq_loading").show(); window.jQuery.ajax({ type : "GET", url : data_url, dataType : "jsonp", jsonp: 'jsoncallback', success : function(data){ window.jQuery(".mpiq_loading_back").hide(); window.jQuery(".mpiq_loading").hide(); fn(data); }, error:function(){ window.jQuery(".mpiq_loading_back").hide(); window.jQuery(".mpiq_loading").hide(); } }); } function mpiq_widget_ajax(url, data, isShow, fn, type){ var params = arguments; var json = { url: params[0] }; for(var i = 1; i<=params.length; i++){ if(typeof params[i] == "function"){ json.success = params[i]; if(params[i+1]){ json.dataType = params[i+1]; } if(i == 2){ if(typeof params[i-1] == "boolean"){ json.isShow = params[i-1]; }else{ json.data = params[i-1]; } }else if(i == 3){ json.isShow = params[i-1]; json.data = params[i-2]; } break; } } mpiq_widget_ajaxAll(json); } function mpiq_widget_ajaxAll(param){ var defaults = { url : "", data : "", dataType : "jsonp", success : function(){}, error : function(a, b, c){ console.log(a); console.log(b); console.log(c); }, isShow : true } var ops = window.jQuery.extend({}, defaults, param); if(ops.isShow){ window.jQuery(".mpiq_loading_back").show(); window.jQuery(".mpiq_loading").show(); } window.jQuery.ajax({ type : "GET", url : ops.url, data : ops.data, dataType : ops.dataType, jsonp: 'jsoncallback', success : function(data){ if(ops.isShow){ window.jQuery(".mpiq_loading_back").hide(); window.jQuery(".mpiq_loading").hide(); } ops.success(data); }, error:function(a,b,c){ ops.error(); if(ops.isShow){ window.jQuery(".mpiq_loading_back").hide(); window.jQuery(".mpiq_loading").hide(); } } }); } function mpiq_widget_comparewidget(){} function mpiq_compare_init(type, elem, opts){ var params, url, defaults; if(type == "all" || !type){ params = { "project" : "performance,img,flashChart,moreAnalytics", "performanceItem" : "isShowTitle,1WR,YTD,1YA,1YS,3YA,3YS,5YA,5YS,10YA,10YS", "imgItem" : "isShowTitle,3M,1Y,3Y,5Y,10Y", "isColorBox" : true, "isShowBtn" : true, "isGetPage" : true, "isSearchBox" : true } }else if(type == "img"){ params = { "project" : "img", "imgItem" : "3M,1Y,3Y,5Y,10Y", "isColorBox" : false, "isShowBtn" : false, "isGetPage" : false, "isSearchBox" : false } }else if(type == "performance"){ params = { "project" : "performance", "performanceItem" : "1WR,YTD,1YA,1YS,3YA,3YS,5YA,5YS,10YA,10YS", "isColorBox" : false, "isShowBtn" : false, "isGetPage" : false, "isSearchBox" : false } } defaults = { "portfolios" : "", "symbols" : "", "isReplaceHtml" : false, "isShowLink" : false, "isShowLoading" : false, "queryStrategy" : false,//show portfolio's strategy "compareParam" : "", "afterComplete" : function(){} } var o = window.jQuery.extend({}, defaults, params, opts); if(o.isShowBtn){ url = mpiq_get_url("/LTISystem/widgets/comparewidget/started.action?widgetName=comparewidget"); o.compareParam = Obj2str(o); }else{ url = mpiq_get_url("/LTISystem/widgets/comparewidget/compare.action?widgetName=comparewidget"); } var s = { Param : Obj2str(o) } if(o.queryStrategy){ s.queryStrategy = o.queryStrategy; } if(!o.isShowBtn){ s.portfolios = o.portfolios, s.symbols = o.symbols } try{ mpiq_widget_ajax(url, s, o.isShowLoading, function(msg){ if(o.isReplaceHtml){ window.jQuery(elem).css("position","relative").html(msg.html); }else{ window.jQuery(elem).css("position","relative").append(msg.html); } o.afterComplete(); }) }catch(e){ o.afterComplete(); } } function mpiq_load_widgets(){ window.jQuery(document).ready(function(){ mpiq_widget_comparewidget(); }) } /* * load css file */ function mpiq_load_css(href){ var cssHead = document.getElementsByTagName('head')[0]; for(var i = 0;i