// Arguments `p1`, `p2` - pointers in data array function news( p1, p2 ) { var value_ = ""; var nCer = 0; var nCom = 1; value_ = "Communications règlementées, "; // if($("#nCom").is(':checked')){var nCom = 1; value_ = "Communications règlementées, ";}else{var nCom = 0;} // if($("#nCer").is(':checked')){var nCer = 1; value_ += "cercle finance, ";} else{var nCer = 0;} j = 1; //count steps var nb_value = value_.length-2 if(nCom == 1 || nCer == 1){ $.ajax({ method: "GET", url: "cookie.php", data: { news_sel: value_.substr(0,nb_value) } }) createCookie("news_sel",value_.substr(0,nb_value),1) }else{ $.ajax({ method: "GET", url: "cookie.php", data: { news_sel: ""} }) eraseCookie("news_sel"); } var points_qty = p2 - p1; coefStepY_news = (SymexChartGlobals.max_[0] - SymexChartGlobals.min_[0]) / SymexChartGlobals.chart_height; var listThemes = ""; if ( document.location.search.search("themes") > -1 ) { var regex = new RegExp(",", "g"); listThemes = "_" + document.location.search.split("themes=")[1].split("&")[0].replace(regex, "_"); } for( var i = eval(p1); i < eval(p2); i++ ) { var val_key_ = [] ; if ( data_news[i] ) //if we have news in current date { // Create
element Object.keys(data_news[i]).forEach(function(cle){ val_key_.push(cle); }); for(var t = 0;t < val_key_.length;t++){ var val_key = val_key_[t]; if((data_news[i][val_key][6] == "Cercle Finance" && nCer == 1) || (data_news[i][val_key][6] == "Publeg" && nCom == 1)){ var new_div = document.createElement("div"); var triangleColor = "#000000"; // Set class (css) if ( listThemes != "" ) { triangleColor = listThemes.search("_" + data_news[i][val_key][5]) >= 0 ? "#CC0000" : "#000000"; } else { switch ( data_news[i][val_key][2] ) { case "publeg": triangleColor = SymexChartSettings.settings[4] || "#000000"; break; case "pubfi": triangleColor = SymexChartSettings.settings[5] || "#000000"; break; case "news": triangleColor = SymexChartSettings.settings[6] || "#C8C8C8"; break; case "conseils": triangleColor = SymexChartSettings.settings[7] || "#CC0000"; break; case "actus": triangleColor = SymexChartSettings.settings[8] || "#CC0000"; break; } } $( new_div ).css({ position: "absolute", width: 0, height: 0, overflow: "hidden", cursor: "pointer", zIndex: 903, borderLeft: "5px solid transparent", borderRight: "5px solid transparent", borderTop: "10px solid " + triangleColor }); // Add in document (or in a element) document.getElementById('priceGraph').appendChild(new_div); // Close value is needed because of `Y` position var tmp_close = 0; for (var i2 = i; i2 >= p1; i2--) { if(SymexChartGlobals.type_curve == "C"){ if ( data_close_0[i2] ) { tmp_close = data_close_0[i2]; break; } }else if(SymexChartGlobals.type_curve == "K"){ if ( data_close_0[i2] ) { tmp_close = data_close_0[i2]; break; } }else{ if ( data_high_0[i2] ) { tmp_close = data_high_0[i2]; break; } } } // Set position var pos = SymexChartGlobals.stepX * j - SymexChartGlobals.stepX -5 ; //5 => half of triangle image stepY_news = (SymexChartGlobals.max_[0] - tmp_close) / coefStepY_news -30;//10px above the point if(stepY_news < 0){ stepY_news = (SymexChartGlobals.max_[0] - data_low_0[i2]) / coefStepY_news;//10px above the point } new_div.style.left = pos.toFixed(0) + 'px'; new_div.style.top = stepY_news + 'px'; // Add left position in class new_div.className = " left_" + parseInt(pos); new_div.className += " triangle"; //set id => equal to pos in data_news array !!! new_div.id = i; // Append functions new_div.onclick = function() { // Note only when communication we have 5th cell in array - filename // For other types - it will be undefined go_news( this.id , data_news[ this.id ][val_key][2], data_news[ this.id ][val_key][4],data_news[ this.id ][val_key][3],data_news[ this.id ][val_key][6]); }; new_div.onmouseover = function() { val_key2_ = []; Object.keys(data_news[this.id]).forEach(function(cle){ val_key2_.push(cle); }); val_key = val_key2_[0]; if(val_key != "Cercle Finance" ){ var href; href = "P4"; href = href.replace( "P1", this.id ); href = href.replace( "P2", data_news[ this.id ][val_key][2] ); href = href.replace( "P3", data_news[ this.id ][val_key][4] ); href = href.replace( "P4", SymexChartSettings.lang_array[22] ); href = href.replace( "P5", data_news[ this.id ][val_key][3] ); href = href.replace( "P6", data_news[ this.id ][val_key][6] ); href = "  " + href; // Take in mind space for pointer (triangle img) and date (12px) // 7.5 - theorical width of a letter var headlineSize = parseInt( SymexChartGlobals.chart_width / 7.5 - 12 ); var pointerColor = "#000000"; if ( listThemes != "" ) { pointerColor = listThemes.search( "_" + data_news[this.id][val_key][5] ) >= 0 ? "#CC0000" : "#000000"; } else { switch ( data_news[this.id][val_key][2] ) { case "publeg": pointerColor = SymexChartSettings.settings[4] || "#000000"; break; case "pubfi": pointerColor = SymexChartSettings.settings[5] || "#000000"; break; case "news": pointerColor = SymexChartSettings.settings[6] || "#C8C8C8"; break; case "conseils": pointerColor = SymexChartSettings.settings[7] || "#CC0000"; break; case "actus": pointerColor = SymexChartSettings.settings[8] || "#CC0000"; break; } } var headlinePointer = $( "
" ).css({ position: "absolute", width: 0, height: 0, overflow: "hidden", cursor: "pointer", zIndex: 903, borderTop: "5px solid transparent", borderBottom: "5px solid transparent", borderLeft: "10px solid " + pointerColor }); var headline = headlinePointer.prop( "outerHTML" ) + "   "; headline += date_eu( data_news[this.id][val_key][3] ) + ": "; headline += short_headline( data_news[this.id][val_key][0], headlineSize ); headline += href; $("#news-info").css("left",($("#period_chart").width()+10)); document.getElementById( "news-info" ).innerHTML = headline; } }; new_div.onmouseout = function() { document.getElementById( "news-info" ).innerHTML = " "; }; } } } j++; } } /* This function must be customize according to the project! */ function go_news( newsID, newsType, fileName,dateNews,source ) { // Type `communication` = `publeg` || `pubfi` //if ( source == "Cercle Finance" ) { if(typeof(data_news[newsID][source][5]) != "undefined" && data_news[newsID][source][5] !== null && data_news[newsID][source][5] != "") { $("#popupBasic").css("visibility","visible"); $("#popupBasic").html("
" + data_news[newsID][source][5].replace(/(\r\n|\n\r|\r|\\n)/g, "
") + "
"); jQuery("#shut_btn_pop").bind("click touchstart",function(){ $("#popupBasic").html(""); jQuery("#popupBasic").css("visibility","hidden"); }); return; }else{ var pdfUrl = fileName; if(SymexChartSettings.settings[1] == 1){ window.open( pdfUrl ); }else{ $("#popupBasic").css("visibility","visible"); $("#popupBasic").html("
"); jQuery("#shut_btn_pop").bind("click touchstart",function(){ $("#popupBasic").html(""); jQuery("#popupBasic").css("visibility","hidden"); }); return; } } } function short_headline(str, len) { if (str.length > len) { str = str.substring(0, len); var a = str.split(' '); if (a.length > 1) a.pop(); return a.join(' ') + '...'; } else { return str; } } function array_prev_dot($arr, $p1, $p2, $curr) { for (var i = $p2; i > $p1; i--) { if ($arr[i]) return $arr[i]; } } function getCookie(name){ if(document.cookie.length == 0) return null; var regSepCookie = new RegExp('(; )', 'g'); var cookies = document.cookie.split(regSepCookie); for(var i = 0; i < cookies.length; i++){ var regInfo = new RegExp('=', 'g'); var infos = cookies[i].split(regInfo); if(infos[0] == name){ return unescape(infos[1]); } } return null; }