-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathDARTIframe.html
100 lines (80 loc) · 2.53 KB
/
DARTIframe.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<HTML>
<HEAD>
</HEAD>
<BODY>
<SCRIPT language=JavaScript>
<!--
function loadIFrameScript() {
try {
var mediaServer = "";
var globalTemplateVersion = "";
var searchString = document.location.search.substr(1);
var parameters = searchString.split('&');
for(var i = 0; i < parameters.length; i++) {
var keyValuePair = parameters[i].split('=');
var parameterName = keyValuePair[0];
var parameterValue = keyValuePair[1];
if(parameterName == "gtVersion")
globalTemplateVersion = unescape(parameterValue);
else if(parameterName == "mediaserver")
mediaServer = unescape(parameterValue);
}
generateScriptBlock(mediaServer, globalTemplateVersion);
}
catch(e) {
}
}
function generateScriptBlock(mediaServerUrl, gtVersion) {
if(!isValid(gtVersion)) {
reportError();
return;
}
var mediaServerParts = mediaServerUrl.split("/");
var host = mediaServerParts[2];
var hostParts = host.split(".");
if(hostParts.length > 4 || hostParts.length < 3) {
reportError();
return;
}
var subdomainOne = hostParts[0];
if(!isValid(subdomainOne)) {
reportError();
return;
}
var subdomainTwo = (hostParts.length == 4) ? hostParts[1] : "";
if(!isValid(subdomainTwo)) {
reportError();
return;
}
var subdomain = subdomainOne + ((subdomainTwo == "") ? "" : "." + subdomainTwo);
var advertiserId = mediaServerParts[3];
if(!isValid(advertiserId)) {
reportError();
return;
}
// Generate call to the script file on DoubleClick server.
var publisherProtocol = window.location.protocol + "//";
var iframeScriptFile = advertiserId + '/DARTIFrame_' + gtVersion + '.js';
var urlStart = publisherProtocol + subdomain;
document.write('<scr' + 'ipt src="' + urlStart + ".doubleclick.net/" + iframeScriptFile + '">');
document.write('</scr'+ 'ipt>');
}
// Validation routine for parameters passed on the URL.
// The parameter should contain only word characters including underscore (limited to '\w')
// and should not exceed 15 characters in length.
function isValid(stringValue) {
var isValid = false;
if(stringValue.length <= 15 && stringValue.search(new RegExp("[^A-Za-z0-9_]")) == -1)
isValid = true;
return isValid;
}
//Report error to the DoubleClick ad server.
function reportError() {
var publisherProtocol = window.location.protocol + "//";
document.write(' <img src="' + publisherProtocol + 'ad.doubleclick.net/activity;badserve=1" style="visibility:hidden" width=1 height=1>');
}
loadIFrameScript();
-->
</SCRIPT>
</BODY>
</HTML>