File: skin.js

package info (click to toggle)
php-doc 20241205~git.dfcbb86%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 70,956 kB
  • sloc: xml: 968,269; php: 23,883; javascript: 671; sh: 177; makefile: 37
file content (337 lines) | stat: -rw-r--r-- 14,364 bytes parent folder | download | duplicates (5)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
// phpZ version 1.0.3 PHP Manual CHM version skin by Gonzalo De la Pea <gnz@pistonbroke.com>
// Based partially on the PHP CHM base skin by Gabor Hojtsy 
// Minor enhancements by Richard Quadling <richard.quadling@bandvulc.co.uk>
// 
// system requirements:
// Microsoft Internet Explorer 5.0 minimum
// 800x600 screen resolution
// 16 bit color depth or more recommended

// Get style sheet file
document.write(
	// Get our style file
	'<link rel="stylesheet" type="text/css" href="' + chmfile_path + 'skins/phpZ/style.css">'
);

// sets global variables
function setGlobals() {
	skinpath = chmfile_path + 'skins/phpZ/';
	switcherTabs = new Array('pageText', 'pageNotes');
	switcherTabLabels = new Array('<U>m</U>anual', '<U>u</U>ser contributed notes ('+ getUserNotesCount() +')');
	switcherTabAccessKeys = new Array('m', 'u');
	navIcons = new Array('goToc', 'goToFunctionRef', 'thisPageOnline', 'bugOnPage');
	navIconTitles = new Array('Go to Table Of Contents', 'Go to Function Reference','Navigate to this page online', 'Report a PHP documentation bug');
	if ( document.all('funcPurpose') )
		functionPage = true;
	else
		functionPage = false;
	manualVersion = 'phpZ skin<BR>ver 1.0.3';
	manualDate = '';
}

// Assembles and displays the page
// this is the function that gets called 'onload' by the document 
function displayPage() {
	setGlobals();
	assembleSkin();
	document.all('pageContent').style.display = 'block';
	//showPageCode();
	// RAQ : Thursday, 17 February 2005 02:20 pm : Force focus to document to allow access keys to function.
	document.focus();
	// RAQ : Wednesday, 16 March 2005 01:58 pm : Force notes to be displayed if hash has been provided.
	if (location.hash == '#userNotes')
		showTabPane('pageNotes');
}

// shows the current page source code (after DHTML) in a separate window
var sourceWin;
function showPageCode() {
	var code = document.body.innerHTML;
	if ( ! sourceWin )
		sourceWin = window.open('', 'sourceWin', 'width=550, height=450, toolbar=no, menubar=no, status=yes, scrollbars=yes, resizable=yes');
	sourceWin.document.write('<HTML><HEAD><TITLE>Page source</TITLE></HEAD><BODY></BODY></HTML>');
	sourceWin.document.body.innerText = code;
	// sourceWin.focus();
}

// assembles the skin
function assembleSkin() {
	var pageContent = document.all('pageContent');
	var page = '';
	
	functionPage ? page += getHeaderFunctionPage() : page += getHeaderNonFunctionPage();

	page += getMain();
	page += getFooter();
	
	pageContent.innerHTML = page;
	updateContentSize();
	showTabPane('pageText');
	//document.all('contextMenu').style.display='none';
	//showPageCode();
}

// navigates to the TOC
function goToc() {
	document.location = 'index.html';
}

// navigates to the function ref
function goToFunctionRef() {
	document.location = 'funcref.html';
}

// gets the number of user contributed notes available
function getUserNotesCount() {
	var count = document.all('pageNotes').childNodes.length - 1;
	if ( count < 0 )
		count = 0;
	return count;
}

// the following functions contain the HTML code for the skin
function getHeaderFunctionPage() {
	var path = document.all('navPath');
	var title = document.all('pageTitle').innerHTML;
	var funcUsage = document.all('funcUsage').innerHTML;
	//alert(funcUsage);
	var funcPurpose = document.all('funcPurpose').innerText;
	var funcAvail = document.all('funcAvail').innerText;
	var html = '';
	
	fixPathLinks();
	
	html += '<TABLE cellpadding=0 cellspacing=0 border=0 width="100%"><TR>';
	html += '<TD><A href="http://php.net/" target="web"><IMG src="'+ skinpath +'logo.gif" width=141 height=82 border=0></A></TD>';
	html += '<TD valign="top" width="100%">';
	html += '<DIV style="background-color:#9999ff; height:24px; width:100%;" class="small text"><DIV style="padding-top:5px; overflow:hidden;" nowrap>'+ path.innerHTML +'</DIV></DIV>';
	html += '<DIV style="background-color:#E0E6FF; background-image:url(\''+ skinpath +'\\header_background.gif\'); height:58px; width:100%; overflow:hidden;" class="big text secondaryType">';
	html += '  <TABLE cellpadding=0 cellspacing=0 style="width:100%;"><TR>';
	html += '    <TD><DIV style="padding-top:14px; line-height:22px;">'+ title +'<SPAN class="small lightBlue text"> &nbsp;<NOBR>'+ funcPurpose +'</NOBR></SPAN></DIV></TD>';
	html += '    <TD align="right" class="small"><DIV style="padding-top:20; margin-right:20;"><SPAN class="lightText">available since:</SPAN> '+ funcAvail+'</DIV></TD>';
	html += '  </TR></TABLE>';
	html += '</DIV>';
	html += '</TD>';
	html += '</TR></TABLE>';
	html += '<TABLE cellpadding=0 cellspacing=0 border=0 width="100%"><TR valign="top">';
	html += '<TD rowspan=2><DIV class="tiny centered text" style="color:#0B9C8D; background-color:#316B58; width:85; height:90; background-image:url(\''+ skinpath +'\\header_green_background.gif\');"><A href="mailto:gnz@amorfo.com?subject=phpZ skin feedback" title="skin feedback" style="color:#0B9C8D;">'+ manualVersion +'</A><BR>'+ manualDate +'</DIV></TD>';
	html += '<TD colspan=2><TABLE cellpadding=0 cellspacing=4 border=0 width="100%"><TR>';
	html += '<TD style="background-color:#9999ff;"><DIV style="height:55; width:4;"></DIV></TD>';
	html += '<TD width="100%" style="background-color:#ffffff;"><DIV style="margin:5;" class="text">';
	
	html += '<DIV class="funcUsage"><SPAN class="small lightText">usage:</SPAN> ' + funcUsage + '</DIV>';
	
	html += '</DIV></TD></TR></TABLE></TD>';
	html += '</TR><TR valign="bottom">';
	html += '<TD><DIV style="margin-left:5;">'+ getSwitcherTabs() +'</DIV></TD>';
	html += '<TD width="100%" align="right">'+ getIconBar() +'</TD>';
	html += '</TR></TABLE>';
	
	return html;
}

function getHeaderNonFunctionPage() {
	var path = document.all('navPath');
	var title = document.all('pageTitle').innerHTML;
	var html = '';
	fixPathLinks();
	
	html += '<TABLE cellpadding=0 cellspacing=0 border=0 width="100%"><TR>';
	html += '<TD><A href="http://php.net/" target="web"><IMG src="'+ skinpath +'logo.gif" width=141 height=82 border=0></A></TD>';
	html += '<TD valign="top" width="100%">';
	html += '<DIV style="background-color:#9999ff; height:24px; width:100%;" class="small text"><DIV style="padding-top:5px; overflow:hidden;" nowrap>'+ path.innerHTML +'</DIV></DIV>';
	html += '<DIV style="background-color:#E0E6FF; background-image:url(\''+ skinpath +'\\header_background.gif\'); height:58px; width:100%; overflow:hidden;" class="big text secondaryType">';
	html += '<DIV style="padding-top:16px;">'+ title +'</DIV>';
	html += '</DIV>';
	html += '</TD>';
	html += '</TR></TABLE>';
	html += '<TABLE cellpadding=0 cellspacing=0 border=0 width="100%"><TR>';
	html += '<TD><DIV class="tiny centered text" style="color:#0B9C8D; background-color:#316B58; width:85; height:30; background-image:url(\''+ skinpath +'\\header_green_background.gif\');"><A href="mailto:gnz@amorfo.com?subject=phpZ skin feedback" title="skin feedback" style="color:#0B9C8D;">'+ manualVersion +'</A><BR>'+ manualDate +'</DIV></TD>';
	html += '<TD valign="bottom"><DIV style="margin-left:5;">'+ getSwitcherTabs() +'</DIV></TD>';
	html += '<TD width="100%" align="right">'+ getIconBar() +'</TD>';
	html += '</TR></TABLE>';
	return html;
}

function fixPathLinks() {
	path = document.all('navPath');
	// assigns new class name to the path links
	for ( i = 0; i < path.childNodes.length; i++ )
		path.childNodes[i].tagName == 'A' ? path.childNodes[i].className = 'black ulEd' : '';
}

function getIconBar() {
	var html = '';
	
	html += '<TABLE cellpadding=0 cellspacing=0 border=0><TR>';
	for ( i = 0; i < navIcons.length; i++ )
		html += '<TD><A href="javascript:'+ navIcons[i] +'();"><IMG style="margin:1 3 1 3;" src="'+ skinpath +'icn_'+ navIcons[i] +'.gif" title="'+ navIconTitles[i] +'" width=25 height=25 border=0></A></TD>';
	html += '</TR></TABLE>';
	return html;
}

function getSwitcherTabs() {
	var html = '';
	html += '<TABLE cellpadding=0 cellspacing=0 border=0><TR>';
	for ( i = 0; i < switcherTabs.length; i++ )
	{
		html += '<TD>';
		html += '<A href="#" accesskey="'+ switcherTabAccessKeys[i] +'" onfocus="this.nextSibling.click(); return false;"></A>';
		html += '<DIV class="switcherTabs" onclick="showTabPane(\''+ switcherTabs[i] +'\')" id="switcherTab_'+ switcherTabs[i] +'">';
		html += '<TABLE cellpadding=0 cellspacing=0 border=0><TR>';
		html += '<TD><IMG src="'+ skinpath +'tab_button_'+ switcherTabs[i] +'_inactive.gif" width=31 height=24></TD>';
		html += '<TD style="background-color:#ffffff; background-image:url(\''+ skinpath +'\\tabs_background_inactive.gif\');"><DIV style="margin:0 4 0 4;" class="small text" nowrap>'+ switcherTabLabels[i] +'</DIV></TD>';
		html += '<TD><IMG src="'+ skinpath +'tabs_corner_inactive.gif" width=9 height=24></TD>';
		html += '</TR></TABLE>';
		html += '</DIV>';
		html += '</TD>';
	}
	html += '</TR></TABLE>';
	return html;
}

var activeTabId;
function showTabPane(sTabId) {
	var tabContent = document.all(sTabId);

	activateTab(sTabId);
	tabContent.style.display = 'block';
	
	if ( ie_version_major >= 5.5 )
		tabContent.setActive();

	if ( activeTabId && ( activeTabId != sTabId ) )
	{
		document.all(activeTabId).style.display = 'none';
		deActivateTab(activeTabId);
	}
	activeTabId = sTabId;
}

function activateTab(sTabId) {
	var oTab = document.all('switcherTab_' + sTabId);
	var tabTable = oTab.childNodes[0];
	var tabIcon = tabTable.rows[0].cells[0].childNodes[0];
	var tabLabelCell = tabTable.rows[0].cells[1];
	var tabCorner = tabTable.rows[0].cells[2].childNodes[0];
	
	tabIcon.src = skinpath + '\\tab_button_' + sTabId + '_active.gif';
	tabLabelCell.style.backgroundImage = '';
	tabCorner.src = skinpath + '\\tabs_corner_active.gif';
}

function deActivateTab(sTabId) {
	var oTab = document.all('switcherTab_' + sTabId);
	var tabTable = oTab.childNodes[0];
	var tabIcon = tabTable.rows[0].cells[0].childNodes[0];
	var tabLabelCell = tabTable.rows[0].cells[1];
	var tabCorner = tabTable.rows[0].cells[2].childNodes[0];
	
	tabIcon.src = skinpath + '\\tab_button_' + sTabId + '_inactive.gif';
	tabLabelCell.style.backgroundImage = 'url(\'' + skinpath +'\\tabs_background_inactive.gif\')';
	tabCorner.src = skinpath + '\\tabs_corner_inactive.gif';
}

function getMain() {
	var html = '';
	window.attachEvent('onresize', updateContentSize);
	html += '<DIV style="border-left:4px solid #9999FF; margin-left:4; margin-right:4;">';
	
	// this is the code for the white fader
	html += '<DIV style="position:relative;">';
	html += '<DIV id="whiteFade" style="background-image:url(\''+ skinpath +'white_fade.gif\'); background-repeat:repeat-x; position:absolute; top:0; left:0; height:15px; font-size:1px; z-index:10;">&nbsp;</DIV>'
	html += '</DIV>';
	
	for ( i = 0; i < switcherTabs.length; i++ ) // adds each content div
		html += '<DIV id="'+ switcherTabs[i] +'" style="display:none; background-color:#ffffff; padding:15 0 5 0; overflow:scroll;" class="text">' + document.all(switcherTabs[i]).innerHTML + '</DIV>';
	
	html += '</DIV>';
	
	return html;
}

function updateContentSize() {
	var whiteFade = document.all('whiteFade');
	var sizeElement = getBodySizeElement();
	var contentDivIds = switcherTabs;
	var sizer;
	
	var verticalSizeCorrection;
	
	if ( ie_version_major >= 6 )
		verticalSizeCorrection = 180;
	else
		verticalSizeCorrection = 158;
		
	for ( i = 0; i < contentDivIds.length; i++ )
	{
		sizer = document.all(contentDivIds[i]);
		functionPage ? sizer.style.height = sizeElement.clientHeight - 240 : sizer.style.height = sizeElement.clientHeight - verticalSizeCorrection;
		sizer.style.width = sizeElement.clientWidth - 12;
	}
	whiteFade.style.width = sizeElement.clientWidth - 40;
}

function getFooter() {
	var prev = document.all('navPrev');
	var next = document.all('navNext');
	var html = '';
	// RAQ : Friday, 18 February 2005 09:32 am : Initialise variables
	var prevURL = '';
	var prevText = '';
	var nextURL = '';
	var nextText = '';
	
	if ( ! prev ) {
		prev = document.createElement('DIV');
		prev.innerHTML = '&nbsp;';
	} else {
	// RAQ : Friday, 18 February 2005 09:33 am : Retrieve URL and Text for next and previous.
		prevURL = prev.all.tags('A')(0).href;
		prevText = prev.all.tags('A')(0).innerText;
		prevText = prevText.substring(3);
        }

	if ( ! next ) {
		next = document.createElement('DIV');
		next.innerHTML = '&nbsp;';
	} else {
		nextURL = next.all.tags('A')(0).href;
		nextText = next.all.tags('A')(0).innerText;
		nextText = nextText.substring(0, nextText.length - 3);
	}
	
	html += '<DIV style="background-color:#BABFD4; border-top:2px solid #000000; margin-top:4; height:42; overflow:hidden;">';
	html += '<TABLE cellpadding=0 cellspacing=0 border=0 width="100%"><TR>';
	
	html += '<TD><DIV style="margin:3 10 0 10;"><TABLE cellpadding=0 cellspacing=4 border=0><TR>';
	// RAQ : Thursday, 17 February 2005 02:22 pm : Use auto click on access key and allow image and prev to work as link.
	//	html += '<TD><IMG src="'+ skinpath +'icn_prev.gif" width=24 height=24></TD>';
	//	html += '<TD class="small text"><U>p</U>rev: '+ prev.innerHTML +'</TD>';
	html += '<TD><A HREF="' + prevURL + '"><IMG border="0" src="'+ skinpath +'icn_prev.gif" width=24 height=24></a></TD>';
	html += '<TD class="small text"><A accesskey="p" onfocus="click();" HREF="' + prevURL + '"><U>p</U>rev: '+ prevText +'</a></TD>';
	html += '</TR></TABLE></DIV></TD>';
	
	html += '<TD align="right"><DIV style="margin:3 10 0 10;"><TABLE cellpadding=0 cellspacing=4 border=0><TR>';
	// RAQ : Friday, 18 February 2005 09:52 am : Use auto click on access key and allow image and prev to work as link and allow Index (ALT+N) and next (ALT+X) to coexist.
	//	html += '<TD class="small text"><U>n</U>ext: '+ next.innerHTML +'</TD>';
	//	html += '<TD><IMG src="'+ skinpath +'icn_next.gif" width=24 height=24></TD>';
	html += '<TD class="small text"><A accesskey="x" onfocus="click();" HREF="' + nextURL + '">ne<U>x</U>t: '+ nextText +'</a></TD>';
	html += '<TD><A HREF="' + nextURL + '"><IMG border="0" src="'+ skinpath +'icn_next.gif" width=24 height=24></a></TD>'; // RAQ Thursday, 17 February 2005 Allow next and image act as a link.
	html += '</TR></TABLE></DIV></TD>';
	
	html += '</TR></TABLE>';
	html += '</DIV>';
	return html;
}

function getBodySizeElement() {
	var delement;
	// Thanks to Gabor Hojtsy for this piece of code
	if ( ie_version_major >= 6 )
		delement = document.body.parentElement;
	else
		delement = document.body;         
	
	return delement;
}