adding images and sundry other old files from archive, merged amz.js into global.js, got ToC working from data array instead of database

This commit is contained in:
Richard Rutter
2014-02-26 16:07:57 +00:00
parent 92a7e01d18
commit cad8846aae
37 changed files with 756 additions and 144 deletions

61
bibliography.php Normal file
View File

@@ -0,0 +1,61 @@
<?php
$dr = $_SERVER["DOCUMENT_ROOT"];
$dr2 = preg_replace("/\/[^\/]+$/","/includes_webtype",$dr);
include($dr2 . "/db_connect.php");
// format text function
include($dr . "/includes/format.php");
// get item
$sql = "SELECT title, item FROM items WHERE filename='bibliography'";
$result = mysql_query($sql);
if ($myitem = mysql_fetch_array($result)) {;
$title = $myitem["title"];
$item = $myitem["item"];
// format item
$title = strip_tags(format($title));
$item = format($item);
} else {
$error = "badFilename";
$mySQLsaid = mysql_error();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title><?php echo $title?> | The Elements of Typographic Style Applied to the Web</title>
<?php include($dr . "/includes/headlinks.inc") ?>
</head>
<body class="bits">
<?php include($dr . "/includes/header.inc") ?>
<?php
if (!isset($error) || $error != "badFilename") { # good filename
?>
<div id="main">
<h1><?php echo $title?></h1>
<?php echo $item?>
</div> <!-- /main -->
<div id="supp">
<h2><a href="/toc/#reference">Reference</a></h2>
<?php include($dr . "/includes/references.inc") ?>
<?php include($dr . "/includes/book.inc") ?>
</div> <!-- /supp -->
<?php
}
?>
<?php include($dr . "/includes/footer.inc") ?>
</body>
</html>

3
css/ie-lte-7.css Normal file
View File

@@ -0,0 +1,3 @@
.ex2-3-4 pre {
text-align: center;
}

BIN
i/2-2-2i.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
i/amz-drop.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
i/amz.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 732 B

BIN
i/bg-home.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
i/bg-home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

BIN
i/book.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
i/drop.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

BIN
i/drop.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

BIN
i/drop2.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
i/elements-shot.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
i/newdrop.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

23
i/tiny/.svn/all-wcprops Normal file
View File

@@ -0,0 +1,23 @@
K 25
svn:wc:ra_dav:version-url
V 30
/svn/webtype/!svn/ver/1/i/tiny
END
gridsystems.gif
K 25
svn:wc:ra_dav:version-url
V 46
/svn/webtype/!svn/ver/1/i/tiny/gridsystems.gif
END
newtypography.gif
K 25
svn:wc:ra_dav:version-url
V 48
/svn/webtype/!svn/ver/1/i/tiny/newtypography.gif
END
bringhurst.gif
K 25
svn:wc:ra_dav:version-url
V 45
/svn/webtype/!svn/ver/1/i/tiny/bringhurst.gif
END

67
i/tiny/.svn/entries Normal file
View File

@@ -0,0 +1,67 @@
10
dir
41
http://webtypography.net/svn/webtype/i/tiny
http://webtypography.net/svn/webtype
2007-02-03T13:13:53.285948Z
1
webtype
a64e1b0d-9228-0410-8f5a-917beb66dd7b
gridsystems.gif
file
2007-02-03T21:05:28.000000Z
dbedbc40f7b1744a44705951099686b5
2007-02-03T13:13:53.285948Z
1
webtype
has-props
newtypography.gif
file
2007-02-03T21:05:28.000000Z
62fccae84198a36f74c767b91856b7a6
2007-02-03T13:13:53.285948Z
1
webtype
has-props
bringhurst.gif
file
2007-02-03T21:05:28.000000Z
1580688e412b0771e32f98caa31d882f
2007-02-03T13:13:53.285948Z
1
webtype
has-props

View File

@@ -0,0 +1,9 @@
K 14
svn:executable
V 1
*
K 13
svn:mime-type
V 24
application/octet-stream
END

View File

@@ -0,0 +1,9 @@
K 14
svn:executable
V 1
*
K 13
svn:mime-type
V 24
application/octet-stream
END

View File

@@ -0,0 +1,5 @@
K 13
svn:mime-type
V 24
application/octet-stream
END

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1008 B

BIN
i/tiny/bringhurst.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

BIN
i/tiny/gridsystems.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

BIN
i/tiny/newtypography.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1008 B

3
includes/book.inc.php Executable file
View File

@@ -0,0 +1,3 @@
<div id="thebook">
<p><a href="/bibliography/" title="More information on &#8216;The Elements of Typographic Style&#8217; at Amazon"><img src="/i/book.png" alt="Cover of &#8216;The Elements of Typographic Style&#8217; by Robert Bringhurst" title="" /></a></p>
</div> <!-- /thebook -->

45
includes/data.inc.php Normal file
View File

@@ -0,0 +1,45 @@
<?php
return array(
'chapters' => array(
'2' => 'Rhythm & Proportion',
'3' => 'Harmony & Counterpoint'
),
'sections' => array(
'2.1' => 'Horizontal Motion',
'2.2' => 'Vertical Motion',
'2.3' => 'Blocks & Paragraphs',
'2.4' => 'Etiquette of Hyphenation & Pagination',
'3.1' => 'Size',
'3.2' => 'Numerals, Capitals & Small Caps',
),
'items' => array(
'2.1.1' => "Define the word space to suit the size and natural letterfit of the font",
'2.1.2' => "Choose a comfortable measure",
'2.1.3' => "Set ragged if ragged setting suits the text and page",
'2.1.4' => "Use a single word space between sentences",
'2.1.5' => "Add little or no space within strings of initials",
'2.1.6' => "Letterspace all strings of capitals and small caps, and all long strings of digits",
'2.1.7' => "Don't letterspace the lower case without a reason",
'2.1.8' => "Kern consistently and modestly or not at all",
'2.1.9' => "Don't alter the widths or shapes of letters without cause",
'2.1.10' => "Don't stretch the space until it breaks",
'2.2.1' => "Choose a basic leading that suits the typeface, text and measure",
'2.2.2' => "Add and delete vertical space in measured intervals",
'2.3.1' => "Set opening paragraphs flush left",
'2.3.2' => "In continuous text mark all paragraphs after the first with an indent of at least one en",
'2.3.3' => "Add extra lead before and after block quotations",
'2.3.4' => "Indent or center verse quotations",
'2.4.1' => "At hyphenated line-ends, leave at least two characters behind and take at least three forward",
'2.4.3' => "Avoid more than three consecutive hyphenated lines",
'2.4.5' => "Hyphenate according to the conventions of the language",
'2.4.6' => "Link short numerical and mathematical expressions with hard spaces",
'2.4.8' => "Never begin a page with the last line of a multi-line paragraph",
'3.1.1' => "Don't compose without a scale",
'3.2.1' => "Use titling figures with full caps, and text figures in all other circumstances",
)
);
?>

View File

@@ -0,0 +1,5 @@
<div id="deck">
<a href="http://fontdeck.com/"><img src="/i/fontdeck.png" alt="Fontdeck" /></a>
<p>Real typography for your website<br />
<a href="http://fontdeck.com/">Free to use</a>, <a href="http://fontdeck.com/typefaces">pro fonts</a>, <a href="http://fontdeck.com/">easy setup</a></p>
</div>

6
includes/footer.inc.php Normal file
View File

@@ -0,0 +1,6 @@
<div><br /></div>
<p id="footer">
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/">Creative Commons Attribution-NonCommercial 4.0 International License</a>.
It was created and is maintained by <a href="http://www.clagnut.com/blog/1600/">Richard Rutter</a>.<br />
Extracts from &#8216;The Elements of Typographic Style&#8217; &copy; Robert Bringhurst.
</p>

3
includes/header.inc.php Normal file
View File

@@ -0,0 +1,3 @@
<div id="header">
<a href="/toc/" title="Go to table of contents">The Elements <span class="of">of</span> Typographic Style Applied <span>to the</span> Web</a>
</div>

View File

@@ -0,0 +1,11 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/css/screen.css" />
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" href="/css/ie-lte-7.css" />
<![endif]-->
<link
rel="stylesheet"
href="http://fontdeck.com/s/css/p+zwVqq4agQiKsiAkUNVfzsNquo/<?php echo $_SERVER['SERVER_NAME']; ?>/1575.css"
type="text/css"
/>
<script type="text/javascript" src="/js/global.js"></script>

8
includes/references.inc.php Executable file
View File

@@ -0,0 +1,8 @@
<div id="refs">
<h3>Reference</h3>
<ul>
<li><a href="/toc/">Table of Contents</a></li>
<li><a href="/intro/">Introduction</a></li>
<li><a href="/bibliography/">Bibliography</a></li>
</ul>
</div> <!-- /refs -->

View File

@@ -1,23 +1,18 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<!DOCTYPE html>
<html lang="en-gb">
<head>
<title>The Elements of Typographic Style Applied to the Web &ndash; a practical guide to web typography</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel='stylesheet' href='http://f.fontdeck.com/s/css/GERHYe/hNqcZuLwYNms1N98PLak/webtypography.net/1575.css' type='text/css' /><style type="text/css" media="screen"><!--
@import "/css/screen.css?1";
--></style>
<link rel="stylesheet" type="text/css" href="/css/screen.css" />
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" href="/css/ie-lte-7.css" />
<![endif]-->
<link
rel="stylesheet"
href="http://fontdeck.com/s/css/p+zwVqq4agQiKsiAkUNVfzsNquo/<?php echo $_SERVER['SERVER_NAME']; ?>/1575.css"
type="text/css"
/>
<script type="text/javascript" src="/js/global.js"></script>
<script type="text/javascript" src="/js/amz.js"></script>
<meta name="MSSmartTagsPreventParsing" content="true" />
<link rel="start" title="Home page" href="/" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0 feed" href="http://feeds.feedburner.com/webtype" />
<script src="/mint/?js" type="text/javascript"></script>
<style type="text/css">
#cover {
color: #fff;

61
intro.php Normal file
View File

@@ -0,0 +1,61 @@
<?php
$dr = $_SERVER["DOCUMENT_ROOT"];
$dr2 = preg_replace("/\/[^\/]+$/","/includes_webtype",$dr);
include($dr2 . "/db_connect.php");
// format text function
include($dr . "/includes/format.php");
// get item
$error = false;
$sql = "SELECT title, item FROM items WHERE filename='intro'";
$result = mysql_query($sql);
if ($myitem = mysql_fetch_array($result)) {;
$intro_title = $myitem["title"];
$item = $myitem["item"];
// format item
$intro_title = strip_tags(format($intro_title));
$item = format($item);
} else {
$error = "badFilename";
$mySQLsaid = mysql_error();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title><?php echo $intro_title?> | The Elements of Typographic Style Applied to the Web</title>
<?php include($dr . "/includes/headlinks.inc") ?>
</head>
<body class="bits">
<?php include($dr . "/includes/header.inc") ?>
<?php
if ($error != "badFilename") { # good filename
?>
<div id="main">
<h1><?php echo $intro_title?></h1>
<?php echo $item?>
</div> <!-- /main -->
<div id="supp">
<h2><?php echo $title?></h2>
<?php include($dr . "/includes/references.inc") ?>
<?php include($dr . "/includes/book.inc") ?>
</div> <!-- /supp -->
<?php
}
?>
<?php include($dr . "/includes/footer.inc") ?>
</body>
</html>

225
item.php Normal file
View File

@@ -0,0 +1,225 @@
<?php
$dr = $_SERVER["DOCUMENT_ROOT"];
$dr2 = preg_replace("/\/[^\/]+$/","/includes_webtype",$dr);
include($dr2 . "/db_connect.php");
// format text function
include($dr . "/includes/format.php");
// get variables from query
$item_number = $_REQUEST["item"];
// if there is a valid looking ID present
if (preg_match("/[0-9]+/", $item_number)) {
$number = $item_number;
} else {
die("Bad or missing id.");
}
// get item
$sql = "SELECT item_id, title, quote, item, chapters.chapter AS chapter, sections.section AS section, sections.number AS section_number, chapters.number AS chapter_number FROM items, chapters,chapters AS sections WHERE items.number='$number' AND sections.chapter_id = items.chapter_id AND chapters.chapter_id = sections.chapter";
#echo "<textarea>$sql</textarea>";
$result = mysql_query($sql);
if ($myitem = mysql_fetch_array($result)) {;
$item_id = $myitem["item_id"];
$title = $myitem["title"];
$quote = trim($myitem["quote"]);
$item = $myitem["item"];
$chapter_number = $myitem["chapter_number"];
$section_number = $myitem["section_number"];
$chapter = $myitem["chapter"];
$section = $myitem["section"];
$chapter_dir = str_replace(" ", "_", $chapter);
$section_dir = str_replace(" ", "_", $section);
// format item
$title = trim(strip_tags(format($title)));
//$title = preg_replace("/\s(\S+)$/", "&nbsp;$1", $title);
if ($quote != "") {
$quote = "<span class='ic'>&#8220;</span>" . $quote . "&#8221;";
$quote = format($quote);
}
$item = format($item);
$chapter = strip_tags(format($chapter));
$section = strip_tags(format($section));
$chapter = str_replace(" and", " &amp;", $chapter);
$chapter = str_replace("_ ", ", ", $chapter);
$section = str_replace(" and", " &amp;", $section);
$section = str_replace("_ ", ", ", $section);
// get next/prev item
$nexttitle = false;
$prevtitle = false;
$sql = "SELECT item_id, title, items.number, sections.section AS section_name, chapters.chapter AS chapter_name, RIGHT(items.number, 2) AS itemnum, sections.number AS chapternum FROM items, chapters, chapters AS sections WHERE items.live='true' AND sections.chapter_id = items.chapter_id AND chapters.chapter_id = sections.chapter ORDER BY chapternum, itemnum";
#echo "<textarea>$sql</textarea>";
$result = mysql_query($sql);
if ($myitems = mysql_fetch_array($result)) {
do {
$myitem_id = $myitems["item_id"];
$mytitle = $myitems["title"];
$mynumber = $myitems["number"];
$mychapter = $myitems["chapter_name"];
$mysection = $myitems["section_name"];
$allitems_id[] = $myitem_id;
$allitems_number[] = $mynumber;
$allitems_title[] = $mytitle;
$allitems_chapter[] = $mychapter;
$allitems_section[] = $mysection;
} while ($myitems = mysql_fetch_array($result));
// loop through array of items
for($i = 0; $i < count($allitems_id); $i++) {
if($allitems_id[$i] == $item_id) {
$nexttitle = (isset($allitems_title[$i+1]))?$allitems_title[$i+1]:"";
$prevtitle = $allitems_title[$i-1];
$nextnumber = (isset($allitems_number[$i+1]))?$allitems_number[$i+1]:"";
$prevnumber = $allitems_number[$i-1];
$nextchapter = (isset($allitems_chapter[$i+1]))?$allitems_chapter[$i+1]:"";
$nextchapter = str_replace(" ", "_", $nextchapter);
$prevchapter = (isset($allitems_chapter[$i-1]))?$allitems_chapter[$i-1]:"";
$prevchapter = str_replace(" ", "_", $prevchapter);
$nextsection = (isset($allitems_section[$i+1]))?$allitems_section[$i+1]:"";
$nextsection = str_replace(" ", "_", $nextsection);
$prevsection = (isset($allitems_section[$i-1]))?$allitems_section[$i-1]:"";
$prevsection = str_replace(" ", "_", $prevsection);
break;
}
}
# format next/prev titles
$nexttitle = trim(strip_tags(format($nexttitle)));
$prevtitle = trim(strip_tags(format($prevtitle)));
} else {
$error .= "badNextPrev";
$mySQLsaid = mysql_error();
}
# get annotations
/*
$sql = "SELECT annotation_id, name, url, annotation, UNIX_TIMESTAMP(annotationstamp) AS annotationstamp FROM annotations WHERE item_id = '$item_id' ORDER BY annotationstamp";
$annotationresult = mysql_query($sql);
*/
} else {
$error = "badItemNumber";
$mySQLsaid = mysql_error();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title><?php echo $title?> | The Elements of Typographic Style Applied to the Web</title>
<?php include($dr . "/includes/headlinks.inc") ?>
</head>
<body>
<?php include($dr . "/includes/header.inc") ?>
<?php
if (!isset($error) || $error != "badItemNumber") { # good guideline number
?>
<div id="main">
<h1><span><?php echo $number?> </span><?php echo $title?></h1>
<?php
if ($quote != "") {
echo "<blockquote class='quote-from-book'>" . $quote . "</blockquote>";
}
?>
<?php echo $item?>
</div> <!-- /main -->
<div id="supp">
<h2><a href="/toc#<?php echo $chapter_dir?>" title="View chapter contents"><?php echo $chapter?></a></h2>
<h3><span>&#167; </span><a href="/toc#<?php echo $section_dir?>" title="View section contents"><?php echo $section?></a></h3>
<?php
if (!isset($error) || $error != "badNextPrev") { # good guideline number
?>
<ul id="nextprev">
<?php
if ($nexttitle) {
echo "<li><span>&#8594;</span><a href='/$nextchapter/$nextsection/$nextnumber/' title='Read next guideline'>$nexttitle</a></li>";
}
if ($prevtitle) {
echo "<li><span>&#8592;</span><a href='/$prevchapter/$prevsection/$prevnumber/' title='Read previous guideline'>$prevtitle</a></li>";
}
?>
</ul>
<?php
}
?>
<!-- /annotations
<div id="annotations">
<h3>Annotations</h3>
<?php /*
// pull annotations from database
$sql = "SELECT annotation_id,author,web,annotation,UNIX_TIMESTAMP(annotationstamp) AS annotationstamp FROM annotations WHERE item_id = $item_id ORDER BY annotationstamp DESC";
$result = mysql_query($sql);
if($myannotation = mysql_fetch_array($result)) {
echo "<ol id='annotations'>\n";
do {
// get and format annotation
$annotationdate = date('j M Y, H:i', $myannotation["annotationstamp"]);
#get annotation
$theannotation_id = $myannotation["annotation_id"];
$theannotation = $myannotation["annotation"];
# turn all HTML to entities
$theannotation = htmlentities($theannotation);
# strip PHP and HTML tags to be sure
$theannotation = strip_tags($theannotation);
# put quotes back so textile works
$theannotation = str_replace("&quot;", "\"", $theannotation);
# turn non-Textile URLs into HTML links
$theannotation = preg_replace("/(\s)((http(s?):\/\/)|(www\.))(\S+)/i", "$1<a href=\"http$4://$5$6\">$3$5$6</a>", $theannotation);
# Textilise annotation
$theannotation = textile($theannotation);
# strip tags again
$theannotation = strip_tags($theannotation);
# split annotation into sentences
$sentences = preg_split("/\./", $theannotation);
# get first 2 sentences
$theannotation = $sentences[0] . ".";
if ($sentences[1]) {$theannotation .= $sentences[1] . ".";}
# add ellipsis if required
if (count($sentences)>2) {$theannotation .= "&#8230;";}
echo "<li>";
printf("<a href='/$chapter_dir/$section_dir/$number/comments/#%s' title='View this comment.'>%s</a>\n", $theannotation_id, $theannotation);
echo "</li>";
} while ($myannotation = mysql_fetch_array($result));
echo "</ol>\n";
} else {
echo "\n<ol id='annotations'><li><a href='/$chapter_dir/$section_dir/$number/comments/'>Add the first annotation</a></li></ol>\n";
}*/
?>
</div> -->
<?php include($dr . "/includes/references.inc");
include($dr . "/includes/fontdeck.inc.php"); ?>
</div> <!-- /supp -->
<?php
} else { # bad guildeine number
?>
<div id="main">
<h1>There is no entry for the specified guideline number</h1>
</div>
<div id="supp">
<?php include($dr . "/includes/references.inc") ?>
</div>
<?php
}
?>
<?php include($dr . "/includes/footer.inc") ?>
</body>
</html>

131
js/amz.js
View File

@@ -1,131 +0,0 @@
// Intercept Amazon links to set preferred store
// URL components for the different affiliate schemes
var amz_schemes = new Array("uk", "ca", "com");
var amz_affil = new Array();
amz_affil["uk"] = new Array(".co.uk", "jalfrezi-21", "UK and the rest of Europe");
amz_affil["ca"] = new Array(".ca", "clagnut0d-20", "Canada");
amz_affil["com"] = new Array(".com", "clagnut-20", "US and the rest of the world");
function initLinks() {
// Test for cookies
if (testCookies()) { // if cookies are enabled
// Get existing store setting
var amz_dest = readCookie("amz_dest");
var allLinks = document.getElementsByTagName('a');
for (var i=0; i < allLinks.length; i++) { // loop through all links on page
var aLink = allLinks[i];
var url = aLink.href;
var amzMatch = url.search(/amazon\./);
if (amzMatch > -1) { // crude check for link to Amazon
if (amz_dest) {
// If store is set then rebuild link
var country = amz_affil[amz_dest][0];
var affil = amz_affil[amz_dest][1];
// Change all possible urls to the desired country and affil
for (var j=0; j<amz_schemes.length; j++) {
c2 = amz_affil[amz_schemes[j]][0];
a2 = amz_affil[amz_schemes[j]][1];
url = url.replace(c2,country);
url = url.replace(a2,affil);
}
aLink.href = url
} else { // store is not set
aLink.onclick = function(e) {
return interceptAmzLinks(this);
}
}
}
}
}
}
function interceptAmzLinks(theLink) {
// create new div
var div = document.createElement("div");
// create new img
var amzimg = document.createElement("img");
amzimg.src = "/i/amz.gif";
amzimg.setAttribute("alt","Amazon");
// create new p
var para1 = document.createElement("p");
para1.appendChild(amzimg);
var para1txt = document.createTextNode("You are about to follow a link to Amazon. Which store would you prefer to visit?");
para1.appendChild(para1txt);
para1.className = "first";
div.appendChild(para1);
// create new ul
var ul = document.createElement("ul");
// build list of links
var i, scheme, country, afil, desc, key, func, url, li, litxt, a, atxt;
for (i=0; i < amz_schemes.length; i++) {
scheme = amz_schemes[i];
country = amz_affil[scheme][0];
affil = amz_affil[scheme][1];
desc = amz_affil[scheme][2];
li = document.createElement("li");
a = document.createElement("a");
a.setAttribute("title","Go to product page on Amazon"+country);
a.setAttribute("onclick","setAmzDest('"+scheme+"')");
url = theLink.href;
url = url.replace(/\.co\.uk/,country);
url = url.replace(/jalfrezi-21/,affil);
a.href = url;
atxt = document.createTextNode("Amazon" + country);
a.appendChild(atxt);
li.appendChild(a);
litxt = document.createTextNode(" - " + desc);
li.appendChild(litxt);
ul.appendChild(li);
}
div.appendChild(ul);
// style box
div.className = "amzbox";
// position box
viewportHeight=getInnerHeight();
viewportWidth=getInnerWidth();
downScroll = getVertScroll();
rightScroll = getHorizScroll();
topPos = ((viewportHeight - 200) / 2) + downScroll;
leftPos = ((viewportWidth - 500) / 2) + rightScroll;
div.style.left = leftPos+"px";
div.style.top = topPos+"px";
// create new p
var para2 = document.createElement("p");
var para2txt = document.createTextNode("You will only be bothered with this once.");
para2.appendChild(para2txt);
div.appendChild(para2);
// attach div to body
document.body.appendChild(div);
return false;
}
function setAmzDest(amz_dest) {
createCookie("amz_dest",amz_dest,"365");
initLinks();
return true;
}
function changeLink(theLink) {
}

View File

@@ -118,3 +118,135 @@ window.onload = function() {
highlight();
initLinks();
}
// Intercept Amazon links to set preferred store
// URL components for the different affiliate schemes
var amz_schemes = new Array("uk", "ca", "com");
var amz_affil = new Array();
amz_affil["uk"] = new Array(".co.uk", "jalfrezi-21", "UK and the rest of Europe");
amz_affil["ca"] = new Array(".ca", "clagnut0d-20", "Canada");
amz_affil["com"] = new Array(".com", "clagnut-20", "US and the rest of the world");
function initLinks() {
// Test for cookies
if (testCookies()) { // if cookies are enabled
// Get existing store setting
var amz_dest = readCookie("amz_dest");
var allLinks = document.getElementsByTagName('a');
for (var i=0; i < allLinks.length; i++) { // loop through all links on page
var aLink = allLinks[i];
var url = aLink.href;
var amzMatch = url.search(/amazon\./);
if (amzMatch > -1) { // crude check for link to Amazon
if (amz_dest) {
// If store is set then rebuild link
var country = amz_affil[amz_dest][0];
var affil = amz_affil[amz_dest][1];
// Change all possible urls to the desired country and affil
for (var j=0; j<amz_schemes.length; j++) {
c2 = amz_affil[amz_schemes[j]][0];
a2 = amz_affil[amz_schemes[j]][1];
url = url.replace(c2,country);
url = url.replace(a2,affil);
}
aLink.href = url
} else { // store is not set
aLink.onclick = function(e) {
return interceptAmzLinks(this);
}
}
}
}
}
}
function interceptAmzLinks(theLink) {
// create new div
var div = document.createElement("div");
// create new img
var amzimg = document.createElement("img");
amzimg.src = "/i/amz.gif";
amzimg.setAttribute("alt","Amazon");
// create new p
var para1 = document.createElement("p");
para1.appendChild(amzimg);
var para1txt = document.createTextNode("You are about to follow a link to Amazon. Which store would you prefer to visit?");
para1.appendChild(para1txt);
para1.className = "first";
div.appendChild(para1);
// create new ul
var ul = document.createElement("ul");
// build list of links
var i, scheme, country, afil, desc, key, func, url, li, litxt, a, atxt;
for (i=0; i < amz_schemes.length; i++) {
scheme = amz_schemes[i];
country = amz_affil[scheme][0];
affil = amz_affil[scheme][1];
desc = amz_affil[scheme][2];
li = document.createElement("li");
a = document.createElement("a");
a.setAttribute("title","Go to product page on Amazon"+country);
a.setAttribute("onclick","setAmzDest('"+scheme+"')");
url = theLink.href;
url = url.replace(/\.co\.uk/,country);
url = url.replace(/jalfrezi-21/,affil);
a.href = url;
atxt = document.createTextNode("Amazon" + country);
a.appendChild(atxt);
li.appendChild(a);
litxt = document.createTextNode(" - " + desc);
li.appendChild(litxt);
ul.appendChild(li);
}
div.appendChild(ul);
// style box
div.className = "amzbox";
// position box
viewportHeight=getInnerHeight();
viewportWidth=getInnerWidth();
downScroll = getVertScroll();
rightScroll = getHorizScroll();
topPos = ((viewportHeight - 200) / 2) + downScroll;
leftPos = ((viewportWidth - 500) / 2) + rightScroll;
div.style.left = leftPos+"px";
div.style.top = topPos+"px";
// create new p
var para2 = document.createElement("p");
var para2txt = document.createTextNode("You will only be bothered with this once.");
para2.appendChild(para2txt);
div.appendChild(para2);
// attach div to body
document.body.appendChild(div);
return false;
}
function setAmzDest(amz_dest) {
createCookie("amz_dest",amz_dest,"365");
initLinks();
return true;
}
function changeLink(theLink) {
}

72
toc.php Normal file
View File

@@ -0,0 +1,72 @@
<?php
// Turn on PHP Error Reporting
ini_set("display_errors","2");
ERROR_REPORTING(E_ALL);
$dr = str_replace($_SERVER['SCRIPT_NAME'], '/includes/', $_SERVER['SCRIPT_FILENAME']);
$data = require_once($dr . "data.inc.php");
$chapters = $data['chapters'];
$sections = $data['sections'];
$items = $data['items'];
?>
<!DOCTYPE html>
<html lang="en-gb">
<head>
<title>Table of Contents | The Elements of Typographic Style Applied to the Web</title>
<?php include($dr . "headlinks.inc.php") ?>
<style type="text/css">
OL {list-style:none}
</style>
</head>
<body class="bits">
<?php include($dr . "header.inc.php") ?>
<div id="main">
<h1>Table of Contents</h1>
<ol id='toc'>
<li><a href="/">Front cover</a></li>
<li style="margin-bottom:1.5em"><a href="/intro/">Introduction</a></li>
<?php
foreach($chapters as $chapter_num => $chapter) {
echo "<li id='$chapter_num'><span>$chapter_num </span><h3>$chapter</h3>\n<ol>\n";
foreach($sections as $section_num => $section) {
$section_chapter = explode("." , $section_num)[0];
if($section_chapter == $chapter_num) {
echo "<li id='$section_num'><span>$section_num </span><h4>$section</h4>\n<ol>\n";
foreach($items as $item_num => $item) {
$item_ar = explode("." , $item_num);
$item_section = $item_ar[0] . "." . $item_ar[1];
if($item_section == $section_num) {
echo "<li id='$item_num'><span>$item_num </span><a href='/$item_num'>$item</a></li>\n";
}
}
echo "</ol>\n</li>\n";
}
}
echo "</ol>\n</li>\n";
}
?>
<li><h3>Reference</h3>
<ol id="reference">
<li><a href="/bibliography/">Bibliography</a></li>
</ol>
</li>
</ol>
</div> <!-- /main -->
<div id="supp">
<h3>Note</h3>
<p>This is a work in progress. The entire site is now open source, so please feel free to contribute by <a href="https://github.com/clagnut/webtypography">forking it on GitHub</a>.</p>
</p>
</div> <!-- /supp -->
<?php include($dr . "footer.inc.php") ?>
</body>
</html>