Copyright (c) 2013, Jocelyn Granger
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of Jocelyn Granger nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SYSTEM REQUIREMENTS:
1) This tool requires an Apple computer, because the tool uses AppleScript. (AppleScript is built into the Mac OS. You don't have to install it.)
2) The tool also requires Apple's Numbers spreadsheet program. The Numbers version must be AppleScriptable.
I tested this tool on
Mac OS X 10.8.4 and 10.8.5 / Safari Version 6.2.8 (8537.85.17.9.1) / AppleScript Editor Version 2.5.1 (138.1), AppleScript 2.2.4 / Numbers '09 version 2.3 (554),
and on
OS X El Capitan 10.11.1 (15B42) / Safari Version 9.0.1 (11601.2.7.2) / ScriptEditor Version 2.8.1 (183.1), AppleScript 2.5 / Numbers Version 3.6 (2557).
WHAT THE TOOL DOES:
This tool lets you enter and save data about books (author, title, etc.). The tool then creates a reference list entry and a citation for that book, according to the author-date system of the Chicago Manual of Style. You then display these reference list entries and citations in a web page. For a citation, you type the page number into the web page. (You can type it into a content-editable span in the web page.) You can then copy the reference list entry or citation to you clipboard, and pasted it into a text document. The tool follows the rules of style given at http://www.chicagomanualofstyle.org/tools_citationguide.html.
HOW TO USE THE TOOL:
1) Update the data in spreadsheets/Book.numbers. (Please note the instructions at the top of the spreadsheet.)
2) Make sure that the Numbers spreadsheet is open. (If it is not open, then the AppleScript might not run.)
Run the AppleScript called “spreadsheetToJavaScript.app”. To run the AppleScript, either double-click the icon in the Finder, or open the script in AppleScript Editor and run it from there. The AppleScript will read the information in the spreadsheet, and put that information into the file addAll.js.
The AppleScript will display the message "Done copying spreadsheet data to .js file" when it has finished.
(Note: The AppleScript will open the spreadsheet and some data to the A1 cell of the spreadsheet. This is part of a workaround from a problem that AppleScript has reading empty cells in a Numbers spreadsheet. After the AppleScript has finished, you can just cancel the change to the Numbers spreadsheet, and close the spreadsheet.)
3) This tool contains a web page called “index.html”. Display or re-display that web page. The function addAll(), which is in file addAll.js, will execute. addAll() will create an object of data for each book (each line) in the Numbers spreadsheet. Other JavaScript functions will read the information in those objects, and will create the web page.
If you don't change the spreadsheet, you can re-display the web page later without running the AppleScript. (The AppleScript copies data from the spreadsheet into a JavaScript file called “addAll.js”. When you display index.html, the code in addAll.js is automatically executed. addAll.js puts the data from the spreadsheet into the web page.)
For each entry in the spreadsheet, you will see a div in the web page. Each div has two lines.
The top line in each div is the reference list for that book. You can copy that line to the clipboard, and paste it into a text document. In the web page, the book's title is italicized. Those italics will be copied into the text document.
The bottom line in each div is the citation for that book. To enter the page number for that citation, first shift-click on the book's div. This selects the page number prompt in the citation, and sets its contentEditable attribute to "true", so that you can change the page number prompt to the actual page number. Then type the page number. Then copy the citation line to the clipboard, and paste it to your text document.