source: main/trunk/model-sites-dev/pei-jones/collect/written-works/realbooks/owhiro/RealisticBook.js@ 31893

Last change on this file since 31893 was 31893, checked in by kjdon, 7 years ago

these are the source files for the realalistic books

  • Property svn:executable set to *
File size: 7.6 KB
Line 
1/*
2# A component of the Realistic Book software
3# from the New Zealand Digital Library Project at the
4# University of Waikato, New Zealand.
5#
6# Copyright (C) 2007 New Zealand Digital Library Project
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21*/
22
23/*****************************************************************
24Realistic Book application
25 Detect Flash Player 8.0.24 or more plugin
26 Specify the XHTML input and image cover URL to program
27 Embed the program to the div tag with id = bookdiv
28
29by Veronica Liesaputra --- 1 August 2007
30******************************************************************/
31
32var doc_url;//XHTML url
33var img_cover;//image cover url
34
35//check internet browser type
36var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
37var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
38var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
39var doc_width = -1;
40var doc_height = -1;
41var doc_style = "";
42
43//These functions will be called by the program
44function getDocURL() { return doc_url; }
45function getImgCover() { return img_cover; }
46function getStageW() { return doc_width; }
47function getStageH() { return doc_height; }
48function setDocumentTitle(doc_title) { document.title = doc_title; }
49function getStyleFile() { return doc_style; }
50
51//set the style of the book
52function setBookStyle(s) {doc_style = s;}
53//set the size of the book
54function setBookSize(dw,dh) {doc_width = dw; doc_height = dh;}
55
56//overload function
57function embedBookProgram(args)
58{
59 if (args.length == 0)
60 alert("Please type the URL for the XHTML input");
61 else
62 {
63 var xhtml_url = args[0];
64 var height = -1;
65 var width = -1;
66 var image_url = "";
67 if (args.length > 1)
68 {
69 if (isNaN(args[1]) == true)
70 image_url = args[1];
71 else
72 height = args[1];
73 }
74
75 if (args.length > 2)
76 width = args[2];
77
78 embedProgram(xhtml_url,image_url,height,width);
79 }
80}
81
82/*
83 If user has Flash player 8.0.24 or more,
84 Embed the program to your HTML file inside the div tag with id = bookdiv
85 Set the doc_url, img_cover, stage_width and stage_height value
86 Otherwise,
87 Show user the links to get the flash player
88*/
89function embedProgram(xhtml_url, image_url, stage_height, stage_width)
90{
91 var flash_plug_html = "";
92 var flash_width = "100%";
93 if (stage_width != -1)
94 flash_width = "" + stage_width;
95 var flash_height = "100%";
96 if (stage_height != -1)
97 flash_height = "" + stage_height;
98
99 if (detectFlashPlayerVersion(8,0,24) == false)
100 {
101 flash_plug_html += 'This content requires the Adobe Flash Player 8.0.24 or greater.';
102 flash_plug_html += '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
103 }
104 else
105 {
106 doc_url = escape(''+xhtml_url);//just in case user forgot the quote
107 img_cover = escape(''+image_url);
108
109 //embed inside object tag for IE
110 flash_plug_html += '<OBJECT align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" \n';
111 flash_plug_html += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" \n';
112 flash_plug_html += ' height="' + flash_height + '" id="Book" swLiveConnect="true" align="middle"\n';
113 flash_plug_html += ' width="' + flash_width + '">\n';
114 //embed inside embed tag for netscape, mozilla
115 flash_plug_html += '<PARAM name="allowScriptAccess" value="always" />\n';
116 flash_plug_html += '<PARAM name="movie" value="RealisticBook.swf';
117 flash_plug_html += '?src_image=' + img_cover;
118 flash_plug_html += '&amp;stageW=' + doc_width;
119 flash_plug_html += '&amp;stageH=' + doc_height;
120 flash_plug_html += '&amp;doc_url=' + doc_url;
121 flash_plug_html += '" />\n';
122 flash_plug_html += '<PARAM name="quality" value="high" />\n';
123 flash_plug_html += '<PARAM name="bgcolor" value="#FFFFFF" />\n';
124 flash_plug_html += '<EMBED align="middle" \n';
125 flash_plug_html += ' allowScriptAccess="always" swLiveConnect="true" \n';
126 flash_plug_html += ' bgcolor="#FFFFFF" height="' + flash_height + '" name="Book" \n';
127 flash_plug_html += ' pluginspage="http://www.macromedia.com/go/getflashplayer" \n';
128 flash_plug_html += ' quality="high" \n';
129 flash_plug_html += ' src=\'RealisticBook.swf';
130 flash_plug_html += '?src_image=' + img_cover;
131 flash_plug_html += '&amp;stageW=' + doc_width;
132 flash_plug_html += '&amp;stageH=' + doc_height;
133 flash_plug_html += '&amp;doc_url=' + doc_url;
134 flash_plug_html += '\'\n';
135 flash_plug_html += ' type="application/x-shockwave-flash" width="' + flash_width + '" />\n';
136 flash_plug_html += '</OBJECT>\n';
137 }
138
139 var flash_div = document.getElementById('bookdiv');
140 flash_div.innerHTML = flash_plug_html;
141}
142
143function detectFlashPlayerVersion(reqMajor,reqMinor,reqRevision)
144{
145 if (navigator.plugins != null && navigator.plugins.length > 0)
146 {
147 if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"])
148 {
149 var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
150 var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
151 var descArray = flashDescription.split(" ");
152 var tempArrayMajor = descArray[2].split(".");
153 var versionMajor = tempArrayMajor[0];
154 var versionMinor = tempArrayMajor[1];
155 var versionRevision = descArray[3];
156 if (versionRevision == "")
157 {
158 versionRevision = descArray[4];
159 }
160 if (versionRevision[0] == "d")
161 {
162 versionRevision = versionRevision.substring(1);
163 }
164 else if (versionRevision[0] == "r")
165 {
166 versionRevision = versionRevision.substring(1);
167 if (versionRevision.indexOf("d") > 0)
168 {
169 versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
170 }
171 }
172
173 var isGood = isGoodPlugin(reqMajor,reqMinor,reqRevision,versionMajor,versionMinor,versionRevision);
174 return isGood;
175 }
176 }
177 else if ( isIE && isWin && !isOpera )
178 {
179 var version;
180 var axo;
181 var e;
182
183 try
184 {
185 // version will be set for 7.X or greater players
186 axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
187 version = axo.GetVariable("$version");
188
189 // Given "WIN 2,0,0,11"
190 var tempArray = version.split(" "); // ["WIN", "2,0,0,11"]
191 var tempString = tempArray[1]; // "2,0,0,11"
192 var versionArray = tempString.split(","); // ['2', '0', '0', '11']
193
194 var isGood = isGoodPlugin(reqMajor,reqMinor,reqRevision,versionArray[0],versionArray[1],versionArray[2]);
195 return isGood;
196 }
197 catch (e) {}
198 }
199
200 return false;
201}
202
203/*
204 Check whether the current flash player plugin passed the required version
205*/
206function isGoodPlugin(reqMajor,reqMinor,reqRevision,currMajor,currMinor,currRevision)
207{
208 if (currMajor > parseFloat(reqMajor))
209 {
210 return true;
211 }
212 else if (currMajor == parseFloat(reqMajor))
213 {
214 if (currMinor > parseFloat(reqMinor))
215 {
216 return true;
217 }
218 else if (currMinor == parseFloat(reqMinor))
219 {
220 if (currRevision >= parseFloat(reqRevision))
221 {
222 return true;
223 }
224 }
225 }
226
227 return false;
228}
Note: See TracBrowser for help on using the repository browser.