/* */
/* Copyright 2003-2017 */
/* copyright@slipt.net|copyright@dccollc.com */
/* DCCO LLC., The Media Trust Company */
/* */
/* This is proprietary software. Any unauthorized distribution or */
/* modification is strictly forbidden and will be prosecuted to the */
/* fullest extent of the law. */
/* */
/* Front-End Development Team Version 7 */
/* */
function ScanLine() {}
ScanLine.prototype.init = function()
{
var scan_line = this;
$(document)
//General scan line
.off("click", ".add_to_cart").on("click", ".add_to_cart", function (event) { event.preventDefault; page.cart.toggleCart(event); })
.off("click touchend", "a[data-process-action='creative_qa/cqa_scan_details-v7']").on("click touchend", "a[data-process-action='creative_qa/cqa_scan_details-v7']", function(event) { scan_line.scanDetailsButtonClick(event); })
.off("click touchend", ".btn_more div.btn-right, .btn_more div.drop").on("click touchend", ".btn_more div.btn-right, .btn_more div.drop", function (event) { scan_line.clickButtonDropdown(event); })
.off("click touchend", "a[data-function='export']").on("click touchend", "a[data-function='export']", function(event) { page.cart.exportScanItem(event); })
.off("click touchend", "a[data-function='send_malware_sales_lead']").on("click touchend", "a[data-function='send_malware_sales_lead']", function(event) { scan_line.sendMalwareSalesLead(event); })
// Ad Quality
.off("click touchend", "a[data-function='editTag']").on("click touchend", "a[data-function='editTag']", function(event) { scan_line.editTag(event); })
//Compliance (comp)
.off("click touchend", "a[data-function='notify']").on("click touchend", "a[data-function='notify']", function(event) { scan_line.compDisplayNotifyDialog(event); })
//Security (sec)
.off("click touchend", ".reanalyze_button").on("click touchend", ".reanalyze_button", function(event) { scan_line.secReanalyzeScan(event); })
.off("click touchend", ".malware_alert_scr").on("click touchend", ".malware_alert_scr", function(event) { scan_line.secDisplayAlertDialog(event); })
//Version 9 SEND scan
.off("click touchend", "a[data-function='version_9_send']").on("click touchend", "a[data-function='version_9_send']", function(event) { scan_line.displayVersion9SendDialog(event); })
//Details
.off("click.hubshare").on("click.hubshare", ".tag-right a:has('.ico-chart-bubble')", function() { scan_line.shareWithHub(); })
.off("click touchend", ".ico-red.ico-close").on("click touchend", ".ico-red.ico-close", function() { page.lightbox.hideOverlay(); })
.off("click touchend", ".refresh_scan_details").on("click touchend", ".refresh_scan_details", function() { scan_line.refreshScanDetails(); })
.off("click touchend", "a[data-process-action='creative_qa/cqa_scan_details_tabs-v7']").on("click touchend", "a[data-process-action='creative_qa/cqa_scan_details_tabs-v7']", function(event) { scan_line.scanDetailsTabClick(event); })
.off("click touchend", "a[data-function='scanDetailsMenuToggle']").on("click touchend", "a[data-function='scanDetailsMenuToggle']", function(event) { scan_line.scanDetailsMoreMenuClick(event); })
.off("click touchend", ".ico-bookmark, .ico-bookmark-outline").on("click touchend", ".ico-bookmark, .ico-bookmark-outline", function(event) { scan_line.toggleTabFavorite(event); })
.off("change", ".input_priority").on("change", ".input_priority", function(event) { scan_line.togglePolicyDisplay(event); })
;
//add violation name for subject of send email
$("a[data-function='export']").each(function(idx, elem)
{
var policyName = $(elem).parents(".cre-wrap").find("#vio_policy_name").html();
$(elem).attr("data-violation", policyName);
var incident_name = $(elem).parents(".cre-wrap").find("#scan_incident_name").text();
$(elem).attr ("data-incident", incident_name);
});
//check for specific sub_mode values for page-specific actions
var sub_mode = GeneralUtility.prototype.getParameterByName("sub_mode");
//console.log(sub_mode);
if ( sub_mode == "advertiser_details" ) { $("#main_timeframe").hide(); }
//console.log("scan_line");
$(document).off("click touchend", ".toggle_tagcode").on("click touchend", ".toggle_tagcode", function(event){
$(".adtag_info_row.tag_code").toggle();
var txtval = $(event.target).text();
if(txtval == "Hide Tag Code"){
$(event.target).text("Show Tag Code");
} else {
$(event.target).text("Hide Tag Code");
}
});
//clear dataTables info, display and pagination divs
// $("#main_info").html("");
// $("#main_length").html("");
// $("#main_pagination").html("");
};
//------------- General --------------//
ScanLine.prototype.scanDetailsButtonClick = function(event)
{
event.preventDefault;
var context = $(event.target).data("context");
if ( $("#"+context).is(":visible"))
{
$("#"+context).hide();
}
else if ( $("#"+context).children().length > 0 )
{
$("#"+context).show();
}
else
{
page.dialog.buildMidDialog (event);
}
}
// button dropdown
ScanLine.prototype.clickButtonDropdown = function(event)
{
$(event.target).siblings(".btn_drop").toggleClass("on");
if ( $(event.target).siblings(".btn_drop").hasClass("on") )
{
event.stopPropagation();
$(document).one('click', function(event)
{
$(".btn_drop").removeClass("on");
});
}
}
//--------------- Compliance ---------------//
// open acknowledge and notify dialog
ScanLine.prototype.compDisplayNotifyDialog = function(event)
{
var scan_line = this;
var obj = {};
$.extend(obj, event.target.dataset);
obj.action = "policy_notify_form";
if ( $(event.target).data("tag_id") ) { obj.tag_id = $(event.target).data("tag_id"); }
else if ( $("#display_tag_id").length ) { obj.tag_id = $("#display_tag_id").val(); }
else if ( $("#tag_id").length ) { obj.tag_id = $("#tag_id").val(); }
var callback = function(html)
{
if ( html )
{
$("#policy_notify_"+obj.scanId).html("").html(html);
Dialog.prototype.showModal("#policy_notify_"+obj.scanId);
}
}
page.request.getRender("creative_qa/cqa_rendering_html-v7", obj, callback);
}
//-------------- Security ---------------//
// re-analyze scan
ScanLine.prototype.secReanalyzeScan = function(event)
{
var scan_line = this;
var obj = {};
obj.csid = $(event.target).data("csid");
obj.sid = $(event.target).data("sid");
obj.dropdown_element = ( $(event.target).hasClass("btn") ) ? "": "1";
var callback = function(html)
{
$(event.target).find(".btn-txt").replaceWith(html);
}
page.request.postData("reanalyze-v7", obj, callback);
};
// open malware managed alert dialog
ScanLine.prototype.secDisplayAlertDialog = function(event)
{
var obj = {};
obj.action = "malware_alert_form";
obj.csid = $(event.target).data("csid");
obj.sid = $(event.target).data("sid");
obj.scan_id = $(event.target).data("scan_id");
var callback = function(json)
{
if ( json && json.extension )
{
$("#malware_alert_"+obj.csid).html("").html(json.extension);
Dialog.prototype.showModal("#malware_alert_"+obj.csid);
}
}
page.request.getData("malware/malware_rendering_html-v7", obj, callback);
};
//--------------- Version 9 SEND ---------------//
// open acknowledge and notify dialog
ScanLine.prototype.displayVersion9SendDialog = function(event)
{
var scan_line = this;
var obj = {};
$.extend(obj, event.target.dataset);
obj.action = "version_9_send_form";
var callback = function(html)
{
if ( html )
{
$("#version_9_send_"+obj.scanId).html("").html(html);
Dialog.prototype.showModal("#version_9_send_"+obj.scanId);
if ($("#main_content > #version_9_send_"+obj.scanId).length) {
$("#main_content > #version_9_send_"+obj.scanId).remove();
}
}
}
page.request.getRender("comm/comm_center_rendering_html-v7", obj, callback);
}
ScanLine.prototype.sendMalwareSalesLead = function(event)
{
let data = {
csid: $(event.target).data("csid"),
sid: $(event.target).data("sid"),
action: 'send_malware_sales_lead',
};
let callback = function(html)
{
$(event.target).replaceWith(html);
}
page.request.postData("malware/malware_rendering_html-v7", data, callback);
};
//------------- Details -------------//
/*ScanLine.prototype.initDetails = function ()
{
var scan_line = this;
$(document).ready(function()
{
$("a[data-process-action='creative_qa/cqa_scan_details_tabs-v7']").off("click");
$("a[data-process-action='creative_qa/cqa_scan_details_tabs-v7']").on("click", function (event)
{
scan_line.scanDetailsTabClick (event);
});
$("a[data-function='scanDetailsMenuToggle']").off("click");
$("a[data-function='scanDetailsMenuToggle']").click( function (event)
{
scan_line.scanDetailsMoreMenuClick (event);
});
$(".ico-bookmark, .ico-bookmark-outline").off("click");
$(".ico-bookmark, .ico-bookmark-outline").click( function (event)
{
scan_line.toggleTabFavorite (event);
});
$(".input_priority").off("change");
$(".input_priority").change( function (event)
{
scan_line.togglePolicyDisplay(event);
});
});
}*/
//Force scan details refresh
ScanLine.prototype.refreshScanDetails = function(event)
{
var container = $(this).parents(".cre-wrap").first();
var context = "#" + container.find("[data-context]").data("context");
$(context).empty().hide();
container.find("[data-context][data-csid]").click();
};
ScanLine.prototype.togglePolicyDisplay = function(event)
{
//console.log("togglePolicyDisplay");
if ($(event.target).val() == "all_policies")
{
$(event.target).parents(".subnav-body").find(".scan_result_policy").show();
}
else
{
$(event.target).parents(".subnav-body").find(".scan_result_policy").hide();
}
}
ScanLine.prototype.scanDetailsMoreMenuClick = function(event)
{
$(event.target).parents(".drop_menu").find(".scan_details_tabs_menu").toggle();
page.utility.hideClickOffEvent("scan_details_tabs_menu");
}
ScanLine.prototype.toggleTabFavorite = function(event)
{
//console.log("toggleTabFavorite");
var scan_line = this;
var new_class = ($(event.target).hasClass ("ico-bookmark")) ? "ico-bookmark-outline" : "ico-bookmark";
$(event.target).removeClass ("ico-bookmark ico-bookmark-outline").addClass (new_class);
scan_line.saveTabFavorites (event);
}
ScanLine.prototype.saveTabFavorites = function(event)
{
//console.log("saveTabFavorites");
var tab_favorites = {};
$(event.target).parents(".subnav").find(".ico-bookmark, .ico-bookmark-outline").each(function(idx, elem)
{
var tab = $(elem).data ("tab");
var selected = $(elem).hasClass ("ico-bookmark-outline");
if (tab == "policies")
tab_favorites.policies = selected;
if (tab == "creative")
tab_favorites.creative = selected;
if (tab == "domains")
tab_favorites.domains = selected;
if (tab == "call_chain")
tab_favorites.call_chain = selected;
if (tab == "partner")
tab_favorites.partner = selected;
if ( tab == "scan_vitals" )
{
tab_favorites.scan_vitals = selected;
}
}
);
var user_pref = new UserPref ("scan_details_tab_favorites");
user_pref.save (tab_favorites);
}
ScanLine.prototype.scanDetailsTabClick = function(event)
{
//console.log("scanDetailsTabClick");
var scan_line = this;
scan_line.scanDetailsMoreMenuClick(event);
var tabsContainer = $(event.target).data("context");
var tabDescription = $(event.target).data("active-tab");
if (( $("#"+tabsContainer).children("[data-description='"+tabDescription+"']").length > 0 ) &&
( $("#"+tabsContainer).children("[data-description='"+tabDescription+"']").is(":visible") ))
return;
$("#"+tabsContainer).children(".subnav-body").hide();
$(event.target).parents(".subnav").find("[data-active-tab]").removeClass("on");
//unhide if hidden & select
$(event.target).parents(".subnav").find("[data-active-tab='"+tabDescription+"']").addClass("on");
$(event.target).parents(".subnav").find("[data-active-tab='"+tabDescription+"']").parents("li:not(.drop_menu)").show();
//$(event.target).addClass("on");
if ( $("#"+tabsContainer).children("[data-description='"+tabDescription+"']").length > 0 )
{
$("#"+tabsContainer).children("[data-description='"+tabDescription+"']").show();
}
else
{
page.tab_control.loadTabContent(event);
}
if($(event.target).data("active-tab") == "call_chain")
{
page.utility.tableFlex(".cc_tier", 1);
}
};
ScanLine.prototype.initMultipleCreativesDetailsTab = function() //being called in /user_interface/version_7/objects/mtc_ui_scan_details.php
{
//console.log("initMultipleCreativesDetailsTab");
var scan_line = this;
$(document).ready(function()
{
page.creativeSlider.init();
});
$("ul.cre-list").find("li").off("click touchend");
$("ul.cre-list").find("li").on("click touchend", function(event)
{
scan_line.showCreativeDetails(event);
});
}
ScanLine.prototype.showCreativeDetails = function(event)
{
//console.log("showCreativeDetails");
var data = {};
$.extend (data, $(event.target).data());
// when users click the ico-magnify image to open the lightbox - we ignore these events
if (!data.creativeId)
return;
var detailsElem = $(event.target).parents("[data-description='creative']").find("[data-description='creative-details']");
$(detailsElem).find("[data-description='file-type']").html ((data.filetype) ? data.filetype : null);
$(detailsElem).find("[data-description='width']").html ((data.width) ? data.width : null);
$(detailsElem).find("[data-description='height']").html ((data.height) ? data.height : null);
$(detailsElem).find("[data-description='file-size']").html ((data.filesize) ? data.filesize : null);
// $(detailsElem).find("[data-description='creative-id']").html ((data.creativeId) ? data.creativeId : null);
if ( $("#auth").length )
{
$(detailsElem).find("[data-description='creative-id']").html ((data.creativeId) ? "" + data.creativeId + "" : null);
}
else
{
$(detailsElem).find("[data-description='creative-id']").html ((data.creativeId) ? data.creativeId : null);
}
$(detailsElem).find("[data-description='company-name']").html ((data.companyName) ? data.companyName : null);
$(detailsElem).find("[data-description='industry']").html ((data.industry) ? data.industry : null);
$(detailsElem).find("[data-description='characterization']").html ((data.characterization) ? data.characterization : null);
function categoryDescription()
{
var html = (data.category) ? data.category : null;
if (data.subCat1)
{
html += "