This repository was archived by the owner on Aug 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
126 lines (106 loc) · 3.97 KB
/
index.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Adobe Folio WebViewer</title>
<script type="text/javascript" src="http://cdn-contentviewer.adobe.com/public/pepper/wvel/2/WVEmbed.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
<div id="mainContainer">
<!-- Iframe destination -->
</div>
<script type="text/javascript">
var guid = querystring('guid')[0];
var productId = querystring('product_id')[0];
var foundUnsupported = false;
adobeDPS.libraryService.createLibrary(guid, {}, createLibraryHandler, function(error){console.error(error)});
function createLibraryHandler(folios) {
for (var s in folios) {
folio = folios[s];
if (folio.productId == productId) {
folio.getArticleURL(createViewer);
console.log(folio);
}
}
}
var foundPaywall = false,
foundUnsupported = false,
wvQueryParamGroups = location.search.match(/[?&^#]wv=(s[\/%\-.\w]+)/),
wvQueryParam = wvQueryParamGroups && wvQueryParamGroups.length === 2 ? decodeURIComponent(wvQueryParamGroups[1]) : null;
function createViewer(url) {
var bridge = adobeDPS.frameService.createFrame({
boolIsFullScreen : false,
parentDiv : 'mainContainer',
wrapperClasses : 'uniqueFrame',
iframeID : 'demoFrame',
accountIDs : guid,
wvParam : url,
curtainClasses : 'mask hidden',
eventCallback : eventCallback,
errorCallback : errorCallback,
footer : false,
redirectCallback : redirectCallbackHandler
});
}
function querystring(key) {
var re=new RegExp('(?:\\?|&)'+key+'=(.*?)(?=&|$)','gi');
var r=[], m;
while ((m=re.exec(document.location.search)) != null) r.push(m[1]);
return r;
}
function renderCustomContent(title, coverImages, publicationName) {
var container = document.getElementById('mainContainer');
var coverP = coverImages.portrait;
var coverL = coverImages.portrait.replace('/portrait', '/landscape');
var htmlContent = '<div id="landingDiv">';
htmlContent += '<div id="landscapeImage">';
htmlContent += '<img src="' + coverL + '" alt=""/>';
htmlContent += '</div>';
htmlContent += '<div id="portraitImage">';
htmlContent += '<img src="' + coverP + '" alt=""/>';
htmlContent += '</div>';
htmlContent += '<div class="devicesImage"></div>';
htmlContent += '<div id="deviceMessage">';
htmlContent += '<h1>' + publicationName + ' is not yet supported in this device\'s browser.</h1>';
htmlContent += '<button><a hre="https://itunes.apple.com/us/app/adobe-inspire/id536737621?mt=8">Get the App<a></button>';
htmlContent += '</div>';
htmlContent += '</div>';
var imageL = document.createElement('img');
imageL.src = coverL;
imageL.onload = function() {
var imageP = document.createElement('img');
imageP.src = coverP;
imageP.onload = function() {
container.innerHTML = htmlContent;
};
};
}
function eventCallback(message) {
console.log('Message', message);
if(message.eventType === 'orientationChange') {
foundPaywall = false;
return true; // This will pull the curtain
} else if(message.eventType === 'paywall') {
foundPaywall = true;
return true // This will not pull the curtain
} else if(message.eventType === 'navigateToURL') {
return false; // This will not redirect the page
} else if(foundUnsupported && message.eventType === 'metadata') {
console.log('METADATA: ', message.metadata);
renderCustomContent(message.metadata.articleTitle, message.metadata.coverImage, message.metadata.publicationName);
}
}
function errorCallback(message) {
console.log(message);
if(message.errorCode === '700') {
foundUnsupported = true;
}
return true;
}
function redirectCallbackHandler(message) {
console.log(message);
}
</script>
</body>
</html>