The Syntax Breakdown

Fortunately, this application requires only two files. Better yet, we’ll only be looking at the code in one of them. The two files are index.html and dhtml.js (dhtml.js is covered in Chapter 6). Before we look at any code, let’s consider a few abstract concepts about how this application might “look.” This application is constructed from a very basic object-oriented perspective. The shopping cart in Chapter 8 , covers another application that utilizes object orientation, but the cipher app takes that approach a little further.

There are two ciphers in this application. Each cipher has certain things in common with all other ciphers, no matter what kind of cipher each may be. Remember that there are three basic types of ciphers—concealment, transposition, and substitution. This application contains two substitution ciphers: the Caesar cipher and the Vigenére cipher. Figure 9.5 shows a basic structure of the hierarchy just described.

The cipher structure

Figure 9-5. The cipher structure

Extending the cipher structure

Figure 9-6. Extending the cipher structure

The figure shows that the ConcealmentCipher , TranspositionCipher , and SubstitutionCipher objects inherit everything from the Cipher object, somewhat like a subclass. Therefore, the Vigenére cipher and the Caesar cipher are instances of the ...

Get JavaScript Application Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.