Adds some javascript functions to NPL template to improve handling of

missing Amazon images (only used if AmazonContent is enabled).
This commit is contained in:
kados 2006-02-08 18:38:58 +00:00
parent 95e889bde5
commit bdb22fdf37
3 changed files with 29 additions and 1 deletions

View File

@ -0,0 +1,15 @@
// http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
function verify_images() {
for (var i = 0; i < document.images.length; i++) {
img = document.images[i];
if ((img.src.indexOf('images.amazon.com') >= 0) || (img.src.indexOf('g-images.amazon.com') >=0)) {
w = img.width;
h = img.height;
if ((w == 1) || (h == 1)) {
img.src = 'http://g-images.amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
} else if ((img.complete != null) && (!img.complete)) {
img.src = 'http://g-images.amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
}
}
}
}

View File

@ -12,6 +12,10 @@
@import url(<TMPL_VAR NAME="themelang">/includes/marc-editor.css);
</style>
<!-- /TMPL_IF -->
<script type="text/javascript" language="javascript" src="<TMPL_VAR NAME="themelang">/includes/main.js"></script>
<!-- TMPL_IF NAME="AmazonContent" -->
<script type="text/javascript" language="javascript" src="<TMPL_VAR NAME="themelang">/includes/amazonimages.js"></script>
<! /TMPL_IF -->
<script type="text/javascript" language="javascript" src="<TMPL_VAR NAME="themelang">/includes/script.js"></script>
<script type="text/javascript" language="javascript" src="<TMPL_VAR NAME="themelang">/includes/basket.js"></script>
<script type="text/javascript" language="javascript">
@ -24,4 +28,4 @@
var MSG_NO_RECORD_ADDED = "No item was added to your book bag";
</script>
</head>
<body>
<body>

View File

@ -0,0 +1,9 @@
// one window.onload to rule them all
window.onload=kohajs;
// check to see if functions exist before loading them
function kohajs() {
if ( typeof window.verify_images == "function" ) verify_images();
}