// sanitise str_to_sanitize function sanitize_text(str_to_sanitize) { return $("").text(str_to_sanitize).html() } // REQUIRE var url_obj_description function show_obj_tooltip(container, obj_gid) { container = $(container); if (container.data('bs.popover')) { container.popover('show'); } else { let pop_header = "
" + sanitize_text(obj_gid) + "/div>"; let spinner = "
Loading...
"; container.popover({ title: pop_header, content: spinner, html: true, container: container, }) container.popover('show'); let popoverInstance = container.data('bs.popover'); $.getJSON(url_obj_description + obj_gid, function (data) { let desc = "
" Object.keys(data).forEach(function(key) { if (key=="status") { desc = desc + "
status
UP" } else { desc = desc + "fa-times-circle\">DOWN" } desc = desc + "
" } else if (key!=="tags" && key!=="id" && key!=="img" && key!=="svg_icon" && key!=="icon" && key!=="link" && key!=="type") { if (data[key]) { if ((key==="first_seen" || key==="last_seen") && data[key].length===8) { let date = sanitize_text(data[key]) desc = desc + "
" + sanitize_text(key) + "
" + date.slice(0, 4) + "-" + date.slice(4, 6) + "-" + date.slice(6, 8) + "
" } else { desc = desc + "
" + sanitize_text(key) + "
" + sanitize_text(data[key]) + "
" } } } }); desc = desc + "
" if (data["tags"]) { data["tags"].forEach(function(tag) { desc = desc + ""+ sanitize_text(tag) +""; }); } /*if (data["img"]) { if (data["tags_safe"]) { if (data["type"] === "screenshot") { desc = desc + ""; } else { desc = desc + ""; } }*/ desc = desc + "
" //div.html(desc) // .style("left", (d3_pageX) + "px") // .style("top", (d3_pageY - 28) + "px"); //d.popover = desc if (data["img"]) { blur_tooltip(); } popoverInstance.config.content = desc; popoverInstance.setContent(); popoverInstance.update(); //let popoverid = container.attr('aria-describedby'); //$('#' + popoverid).find('.popover-header').html(newTitle); //$('#' + popoverid).find('.popover-body').html('newContesssnt'); }).fail(function(error) { let desc = "
"+ error.statusText +"
" popoverInstance.config.content = desc; popoverInstance.setContent(); popoverInstance.update(); }); container.popover('hide'); container.popover('show'); } } function hide_obj_tooltip(container) { container = $(container); container.popover('hide') } function blur_tooltip(){ var image = $('#tooltip_screenshot_correlation')[0]; if (image) { let blurValue = $('#blur-slider-correlation').val(); blurValue = 15 - blurValue; image.style.filter = "blur(" + blurValue + "px)"; } }