<commit_before>require("prebid-universal-creative");

window.PWT = window.PWT || {};
window.pbjs = window.pbjs || {};

var refThis = this;

// exports.createScriptTag = function(url,onLoadCallback,onErrorCallback){
// 	var scriptTag = document.createElement("script");
// 	scriptTag.onload = onLoadCallback || function(){};
// 	scriptTag.onerror = onErrorCallback || function(){};
// 	scriptTag.src = url;
// 	return scriptTag;
// };

// Note : Below function is written in window scope cause when file is build and minified, this function could not be found in current scope of script tag which
// is calling this callback.
// window.displayCreativeCallback=function(creativeCode){
// 	if(creativeCode){
// 		var div =  document.createElement("div");
// 		div.innerHTML = creativeCode;
// 		var bodyTag = document.getElementsByTagName("body")[0];
// 		bodyTag.appendChild(div);
// 	}
// };

// exports.displayCreativeCallback = displayCreativeCallback;

// exports.getCreative = function(cacheUrl,cacheId){
// 	if(cacheUrl && cacheId){
// 		var url = cacheUrl + "/cache?uuid=" + cacheId + "&callback=displayCreativeCallback"; // TODO : Pass more parameters to this
// 		var scriptTag =  refThis.createScriptTag(url,
//             function(res){
//                 // TODO : Fire Success Pixel if appplicable
//                 // debugger;
// },
//             function(err){
//                 // TODO: Log error to new error endpoint with pubid and profileid
//                 // debugger;
// }
//         );
// 		try{
// 			var bodyTag = document.getElementsByTagName("body")[0];
// 			bodyTag.appendChild(scriptTag);
// 		}
// 		catch(err){
//             // Error with DOM.
// 		}
// 	}
// 	else{
//          // Missing Parameters : Log Error
// 	}
//      // Pass pub id and profile id to cache for error reporting
//      // Error Logging
//      // Build process is soft build of copying triggered through UI
//      //
// };

exports.renderCreative = function(cacheUrl,uuid){
	window.pbjs.renderAd(document,"", {
		cacheHost: cacheUrl,
		cachePath: "/cache",
		uuid: uuid,
		mediaType: "banner",
	});
};

window.PWT.renderAMPAd = function (targetingKeys) {
	var pwtecp = targetingKeys.pwtecp;
	var pwtbst = targetingKeys.pwtbst;
	var pwtdid = targetingKeys.pwtdid;
	var pwtpid = targetingKeys.pwtpid;
	var cacheid = targetingKeys.cacheid;
	var cacheURL = targetingKeys.cacheURL;
    // refThis.getCreative(cacheURL,cacheid);
    //Only execute below code if protocol is there in cacheurl, prebid attacjjed 
    cacheURL = cacheURL.replace(/^https:\/\//i, "");
    refThis.renderCreative(cacheURL,cacheid);
};<commit_msg>Removed params which are not used right now<commit_after>require("prebid-universal-creative");

window.PWT = window.PWT || {};
window.pbjs = window.pbjs || {};

var refThis = this;

// exports.createScriptTag = function(url,onLoadCallback,onErrorCallback){
// 	var scriptTag = document.createElement("script");
// 	scriptTag.onload = onLoadCallback || function(){};
// 	scriptTag.onerror = onErrorCallback || function(){};
// 	scriptTag.src = url;
// 	return scriptTag;
// };

// Note : Below function is written in window scope cause when file is build and minified, this function could not be found in current scope of script tag which
// is calling this callback.
// window.displayCreativeCallback=function(creativeCode){
// 	if(creativeCode){
// 		var div =  document.createElement("div");
// 		div.innerHTML = creativeCode;
// 		var bodyTag = document.getElementsByTagName("body")[0];
// 		bodyTag.appendChild(div);
// 	}
// };

// exports.displayCreativeCallback = displayCreativeCallback;

// exports.getCreative = function(cacheUrl,cacheId){
// 	if(cacheUrl && cacheId){
// 		var url = cacheUrl + "/cache?uuid=" + cacheId + "&callback=displayCreativeCallback"; // TODO : Pass more parameters to this
// 		var scriptTag =  refThis.createScriptTag(url,
//             function(res){
//                 // TODO : Fire Success Pixel if appplicable
//                 // debugger;
// },
//             function(err){
//                 // TODO: Log error to new error endpoint with pubid and profileid
//                 // debugger;
// }
//         );
// 		try{
// 			var bodyTag = document.getElementsByTagName("body")[0];
// 			bodyTag.appendChild(scriptTag);
// 		}
// 		catch(err){
//             // Error with DOM.
// 		}
// 	}
// 	else{
//          // Missing Parameters : Log Error
// 	}
//      // Pass pub id and profile id to cache for error reporting
//      // Error Logging
//      // Build process is soft build of copying triggered through UI
//      //
// };

exports.renderCreative = function(cacheUrl,uuid){
	window.pbjs.renderAd(document,"", {
		cacheHost: cacheUrl,
		cachePath: "/cache",
		uuid: uuid,
		mediaType: "banner",
	});
};

/// TODO : Change name to general render function : renderOWCreative
window.PWT.renderOWCreative = function (targetingKeys) {
	var cacheid = targetingKeys.cacheid;
	var cacheURL = targetingKeys.cacheURL;
    // refThis.getCreative(cacheURL,cacheid);
    //Only execute below code if protocol is there in cacheurl, prebid attacjjed 
    cacheURL = cacheURL.replace(/^https:\/\//i, "");
    refThis.renderCreative(cacheURL,cacheid);
};
{'fraction_non_alphanumeric': 0.14490811638591117, 'fraction_numerical': 0.0007656967840735069, 'mean_word_length': 2.797238372093023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3704151', 'n_tokens_mistral': 1644, 'n_tokens_neox': 1594, 'n_words': 389}