JavaScript Zone

Script Tutorials

Introduction
Pre-requisites
Installation
Notes

Archive Viewer

Introduction

This Javascript demonstrates how to create a document archive viewer.

The html page shows archive pages of 20 documents at a time, although this number can be customised. There are functions to move to the next and previous pages, choose a random page, or move to the latest (asumed to be the last) page.

A document (in pure text format) can be selected, and it is displayed in a text area. There are then more functions to move to the previous and next documents, choose a random document, or go to the latest (last) document.

Note - the documents must live in a single folder, and follow a similar naming standard, namely prefix-nn-suffix, e.g., joke1.txt, joke2.txt, etc. 'joke' is the prefix and '.txt' is the suffix.

Future enhancements will include a proper index showing more descriptive file names.

In the demo below, register yourself a password, return to the joke zone page, enter your password, then click on the jokes link to proceed to the jokes archive page.

Archive Viewer Demo (Jokes)

Pre-requisites

  • none
Installation

  1. Cut and paste the following code to your html page as indicated:

Notes

  • this tutorial demonstrates:
    • how to use cookies
    • how to display lists of items, scroll through them or select random items
    • how to display text documents, scroll through them or select random items
  • the code for maintaining cookies is taken from the original date last visited / number of visits javascript from the JavaScript Source - thanks
  • if you use this script, amend the variable names' prefix from pt_ to something meaningful to your site
  • a method of maintaining a descriptive index will be added in the future.


Page last updated 8th August 2001