├── .gitattributes ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── compile ├── compile-commands.txt ├── copyright.txt └── minifier.jar ├── example ├── algorithmIV-app.css ├── algorithmIV-app.min.js ├── example-settings.js ├── images │ ├── aIV-icon.ai │ ├── aIV-logo.png │ ├── apple-touch-icon.png │ ├── arrows-small.psd │ ├── arrows.psd │ ├── ext-arrows-small.psd │ ├── ext-close-small.png │ ├── ext-open-small.png │ ├── favicon.ico │ ├── favicon.png │ ├── loading.gif │ ├── next-small.png │ ├── next.png │ ├── prev-small.png │ ├── prev.png │ └── tile-icon.png ├── pre-compiled-settings │ ├── categories.js │ ├── configuration.js │ ├── questions.js │ ├── resources.js │ ├── skeleton.js │ └── sources.js ├── resources │ ├── mock-ajax.js │ ├── mock-ajax.min.js │ └── words.json └── view-example.html ├── src ├── algorithmIV-app.css ├── algorithmIV-app.js ├── algorithmIV-app.min.js └── pre-compiled-parts │ ├── classes │ ├── app │ │ ├── app-elems.js │ │ ├── app-vals.js │ │ └── app.js │ ├── categories.js │ ├── category.js │ ├── config │ │ ├── config.js │ │ ├── defaults-search-bar-config.js │ │ ├── links-config.js │ │ ├── pretty-config.js │ │ ├── questions-config.js │ │ └── search-bar-config.js │ ├── events.js │ ├── question │ │ ├── question-elem.js │ │ ├── question-format.js │ │ └── question.js │ ├── questions.js │ ├── search-bar │ │ ├── search-bar-elems.js │ │ └── search-bar.js │ ├── source.js │ └── sources.js │ ├── dependencies │ └── algorithmIV-utils.min.js │ ├── module-api.js │ ├── module-methods.js │ ├── module-vars.js │ ├── pre-compiled-prettifier │ ├── highlight-syntax.js │ ├── pre-compiled-syntax-highlighter │ │ ├── highlight-syntax-methods.js │ │ ├── highlight-syntax-vars.js │ │ └── highlight-syntax.js │ ├── prettify-methods.js │ ├── prettify-vars.js │ └── prettify.js │ ├── prettify.js │ ├── public-api.js │ └── skeleton.js └── tests ├── algorithmIV-app.css ├── algorithmIV-app.js ├── algorithmIV-debug.min.js ├── algorithmIV-tests.css ├── algorithmIV-tests.js ├── images ├── aIV-icon.ai ├── apple-touch-icon.png ├── arrows-small.psd ├── arrows.psd ├── ext-close-small.png ├── ext-open-small.png ├── favicon.ico ├── favicon.png ├── loading.gif ├── next-small.png ├── next.png ├── prev-small.png ├── prev.png └── tile-icon.png ├── pre-compiled-app ├── classes │ ├── app │ │ ├── app-elems.js │ │ ├── app-vals.js │ │ └── app.js │ ├── categories.js │ ├── category.js │ ├── config │ │ ├── config.js │ │ ├── defaults-search-bar-config.js │ │ ├── links-config.js │ │ ├── pretty-config.js │ │ ├── questions-config.js │ │ └── search-bar-config.js │ ├── events.js │ ├── question │ │ ├── question-elem.js │ │ ├── question-format.js │ │ └── question.js │ ├── questions.js │ ├── search-bar │ │ ├── search-bar-elems.js │ │ └── search-bar.js │ ├── source.js │ └── sources.js ├── dependencies │ └── algorithmIV-utils.min.js ├── discontinued │ ├── app-flags.js │ ├── search-bar.js │ ├── url-config.js │ └── web-worker.js ├── module-api.js ├── module-methods.js ├── module-vars.js ├── pre-compiled-prettifier │ ├── highlight-syntax.js │ ├── pre-compiled-syntax-highlighter │ │ ├── highlight-syntax-methods.js │ │ ├── highlight-syntax-vars.js │ │ └── highlight-syntax.js │ ├── prettify-methods.js │ ├── prettify-vars.js │ └── prettify.js ├── prettify.js ├── public-api.js └── skeleton.js ├── pre-compiled-tests ├── classes │ ├── app.js │ ├── elems.js │ ├── mock-ajax.js │ ├── test-data.js │ └── tests.js ├── module-api.js ├── module-methods.js ├── module-vars.js ├── public-api.js └── skeleton.js └── run-tests.html /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Help Make Learning Easier 2 | 3 | #### All contributors are welcome! 4 | 5 | 6 | ## Directions 7 | 8 | - Fork and clone this repository 9 | - Create a new branch for your additions 10 | - Add your code to [tests/pre-compiled-app/](https://github.com/imaginate/algorithmIV-question-manager/tree/master/tests/pre-compiled-app) 11 | - Compile the app module using the commands found in 12 | [compile/compile-commands.txt](https://github.com/imaginate/algorithmIV-question-manager/blob/ca5db693785/compile/compile-commands.txt#L8-100) 13 | - Load [tests/run-tests.html](https://github.com/imaginate/algorithmIV-question-manager/blob/master/tests/run-tests.html) 14 | in a browser 15 | - Open your console 16 | - Click "Start Tests" 17 | - Manually trigger each of the navigation events 18 | - Fix any bugs that are found and re-run the test app init and events until 19 | no errors occur 20 | - Ensure that you have read and consent to the 21 | [project license](https://github.com/imaginate/algorithmIV-question-manager/blob/master/LICENSE.md) 22 | before submitting a pull request 23 | - Submit a pull request (**note that by submitting a pull request you consent 24 | that your contribution will be subject to the 25 | [project license](https://github.com/imaginate/algorithmIV-question-manager/blob/master/LICENSE.md)**) 26 | 27 | 28 | ## Pointers 29 | 30 | - Follow the coding conventions you see in the existing code (see 31 | [Google's style guide](https://google.github.io/styleguide/javascriptguide.xml#Code_formatting) 32 | for similar conventions) 33 | - Know and use [JSDoc3](http://usejsdoc.org/) with 34 | [Closure Compiler specific syntax](https://developers.google.com/closure/compiler/docs/js-for-compiler) 35 | - Know and use our [JavaScript Debugger](https://github.com/imaginate/algorithmIV-javascript-debugger) 36 | - Ensure that the test app init and events are error-free before submitting a 37 | pull request 38 | 39 | 40 | ## Contact 41 | 42 | - [Open an issue](https://github.com/imaginate/algorithmIV-question-manager/issues) on this GitHub repository 43 | - Send an email to [imagineadamsmith@gmail.com](mailto:imagineadamsmith@gmail.com) 44 | 45 | 46 | ---- 47 | **Thanks for being a part of the aIV team** 48 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | ## License for [Algorithm IV Question Manager](https://github.com/imaginate/algorithmIV-question-manager) 2 | 3 | **Copyright 2014-2022 Adam A Smith [imagineadamsmith@gmail.com](https://github.com/imaginate)** 4 | 5 | Licensed under the **Apache License**, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Clear, Simple, & Easy JavaScript Flash Cards 2 | 3 | Algorithm IV's question manager app is designed to give you the power to 4 | easily organize, answer (in JavaScript), and review practice questions for 5 | learning computer science focused algorithms and data structures, improving 6 | programming skill-sets, and preparing for technical interviews. It is 7 | cross-browser compatible and does not require any server environment or even 8 | the internet to accomplish its basic functionality. 9 | 10 | 11 | ## Getting Started 12 | 13 | - Download [algorithmIV-app.min.js](https://github.com/imaginate/algorithmIV-question-manager/blob/master/src/algorithmIV-app.min.js) 14 | and [algorithmIV-app.css](https://github.com/imaginate/algorithmIV-question-manager/blob/master/src/algorithmIV-app.css) 15 | - Create an HTML document with your settings for the app 16 | ```html 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 41 | 42 | 43 | ``` 44 | - Load your HTML document in any browser 45 | - Learn your algorithms & data structures 46 | 47 | 48 | ## The App's Settings 49 | 50 | 51 | ### Configuration 52 | 53 | The configuration object, ``` settings.config ```, allows you to customize the 54 | look, feel, and actions of the app with minimal effort. As of version 1.1.2 it 55 | contains five sections you may set. Each section and its defaults follow: 56 | - **[Search Settings](https://github.com/imaginate/algorithmIV-question-manager/blob/d0db504b896e/example/pre-compiled-settings/configuration.js#L18-37)** 57 | ~ Allows you to show or hide different search options available to the app. 58 | - **[Search Defaults](https://github.com/imaginate/algorithmIV-question-manager/blob/d0db504b896e/example/pre-compiled-settings/configuration.js#L39-64)** 59 | ~ Allows you to chose the on-load value for each search option available to the app. 60 | - **[Question Format](https://github.com/imaginate/algorithmIV-question-manager/blob/d0db504b896e/example/pre-compiled-settings/configuration.js#L66-95)** 61 | ~ Allows you to show or hide each of the question's sections. 62 | - **[Prettify Format](https://github.com/imaginate/algorithmIV-question-manager/blob/d0db504b896e/example/pre-compiled-settings/configuration.js#L97-114)** 63 | ~ Allows you to format how your JavaScript solutions will be prettified. 64 | - **[Show Links](https://github.com/imaginate/algorithmIV-question-manager/blob/d0db504b896e/example/pre-compiled-settings/configuration.js#L116-133)** 65 | ~ Allows you to show or hide the available shortcut links for the question's sections. 66 | 67 | ### Sources 68 | 69 | The sources object, ``` settings.sources ```, is where you add each source for 70 | your questions. If the object is undefined, null, or empty the source 71 | functionality is disabled for the app. Visit the 72 | [sources example](https://github.com/imaginate/algorithmIV-question-manager/blob/d0db504b896e/example/pre-compiled-settings/sources.js) 73 | to learn more. 74 | 75 | ### Categories 76 | 77 | The categories object, ``` settings.categories ```, is where you add each 78 | category for your questions. If the object is undefined, null, or empty the 79 | category functionality is disabled for the app. Visit the 80 | [categories example](https://github.com/imaginate/algorithmIV-question-manager/blob/d0db504b896e/example/pre-compiled-settings/categories.js) 81 | to learn more. 82 | 83 | ### Resources 84 | 85 | The resources object, ``` settings.resources ```, is where you can load JSON 86 | resources for use in any of your question's solutions. The 87 | [getResource method](https://github.com/imaginate/algorithmIV-question-manager/blob/9c2262196421e/src/pre-compiled-parts/public-api.js#L26-35), 88 | ``` aIV.app.getResource ```, is used to access any uploaded resources from 89 | within your question's solution. Visit the 90 | [resources example](https://github.com/imaginate/algorithmIV-question-manager/blob/d0db504b896e/example/pre-compiled-settings/resources.js) 91 | to learn more. **Note:** Using the resources functionality requires a server 92 | environment due to its use of ajax calls. 93 | 94 | ### Questions 95 | 96 | The questions array, ``` settings.questions ```, is where you add your 97 | questions. Each question's id defined by its order in the array, and each 98 | question is represented by an object with its details. Visit the 99 | [questions example](https://github.com/imaginate/algorithmIV-question-manager/blob/421dfb8122e/example/pre-compiled-settings/questions.js) 100 | to see all of the options available for each question and more. 101 | 102 | 103 | ## Other Important Information 104 | 105 | 106 | ### Example 107 | 108 | Visit this repository's [example section](https://github.com/imaginate/algorithmIV-question-manager/tree/master/example) 109 | for a detailed example of this app in-action. 110 | 111 | ### Contributing 112 | 113 | See our [guideline for contributing](https://github.com/imaginate/algorithmIV-question-manager/blob/master/CONTRIBUTING.md) 114 | 115 | ### Contact Us 116 | 117 | - [Open an issue](https://github.com/imaginate/algorithmIV-question-manager/issues) 118 | on this GitHub repository 119 | - Send an email to [imagineadamsmith@gmail.com](mailto:imagineadamsmith@gmail.com) 120 | 121 | 122 | ---- 123 | **Enjoy Mastering Your Algorithms** 124 | -------------------------------------------------------------------------------- /compile/copyright.txt: -------------------------------------------------------------------------------- 1 | /* Algorithm IV Question Manager App (v1.1.2) (imagineadamsmith@gmail.com) 2 | * Section: The Main JavaScript Module 3 | * Author: Adam Smith 4 | * Copyright (c) 2022 Adam A Smith 5 | * The Apache License (www.apache.org/licenses/LICENSE-2.0) */ 6 | -------------------------------------------------------------------------------- /compile/minifier.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/compile/minifier.jar -------------------------------------------------------------------------------- /example/images/aIV-icon.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/aIV-icon.ai -------------------------------------------------------------------------------- /example/images/aIV-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/aIV-logo.png -------------------------------------------------------------------------------- /example/images/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/apple-touch-icon.png -------------------------------------------------------------------------------- /example/images/arrows-small.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/arrows-small.psd -------------------------------------------------------------------------------- /example/images/arrows.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/arrows.psd -------------------------------------------------------------------------------- /example/images/ext-arrows-small.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/ext-arrows-small.psd -------------------------------------------------------------------------------- /example/images/ext-close-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/ext-close-small.png -------------------------------------------------------------------------------- /example/images/ext-open-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/ext-open-small.png -------------------------------------------------------------------------------- /example/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/favicon.ico -------------------------------------------------------------------------------- /example/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/favicon.png -------------------------------------------------------------------------------- /example/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/loading.gif -------------------------------------------------------------------------------- /example/images/next-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/next-small.png -------------------------------------------------------------------------------- /example/images/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/next.png -------------------------------------------------------------------------------- /example/images/prev-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/prev-small.png -------------------------------------------------------------------------------- /example/images/prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/prev.png -------------------------------------------------------------------------------- /example/images/tile-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/example/images/tile-icon.png -------------------------------------------------------------------------------- /example/pre-compiled-settings/categories.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------- 3 | * The Categories 4 | * ----------------------------------------------- 5 | * @desc An object property of settings that contains all of the 6 | * question manager's category ids and names. 7 | * @type {(Object|{ 8 | * main: Object, 9 | * sub : Object> 10 | * })} 11 | */ 12 | settings.categories = {}; 13 | 14 | /** 15 | * ----------------------------------------------- 16 | * The Main Categories 17 | * ----------------------------------------------- 18 | * @desc An object property of categories that contains all of the 19 | * question manager's main category ids and names. 20 | * @type {Object} 21 | */ 22 | settings.categories.main = { 23 | 'array' : 'Arrays', 24 | 'graph' : 'Graphs', 25 | 'hash' : 'Hashes', 26 | 'list' : 'Linked Lists', 27 | 'search': 'Searching Algorithms', 28 | 'sort' : 'Sorting Algorithms', 29 | 'tree' : 'Trees' 30 | }; 31 | 32 | /** 33 | * ----------------------------------------------- 34 | * The Sub Categories 35 | * ----------------------------------------------- 36 | * @desc An object property of categories that contains all of the 37 | * question manager's sub category ids and names. 38 | * @type {Object>} 39 | */ 40 | settings.categories.sub = { 41 | 'graph': { 42 | 'adjList': 'Adjacency Lists', 43 | 'adjMtrx': 'Adjacency Matrices', 44 | 'arb' : 'Arborescences', 45 | 'digraph': 'Directed Graphs', 46 | 'incList': 'Incidence Lists', 47 | 'incMtrx': 'Incidence Matrices', 48 | 'ungraph': 'Undirected Graphs' 49 | }, 50 | 'hash': { 51 | 'dblHash': 'Double Hashing', 52 | 'fnv' : 'FNV Hash Algorithms', 53 | 'hTable' : 'Hash Tables' 54 | }, 55 | 'list': { 56 | 'sList': 'Singly-Linked Lists', 57 | 'dList': 'Doubly-Linked Lists' 58 | }, 59 | 'search': { 60 | 'back' : 'Backtracking', 61 | 'binSrch': 'Binary Search', 62 | 'bfs' : 'Breadth First Search', 63 | 'brute' : 'Brute Force Search', 64 | 'dfs' : 'Depth First Search', 65 | 'dynam' : 'Dynamic Programming' 66 | }, 67 | 'sort': { 68 | 'bucket': 'Bucket Sort', 69 | 'heapS' : 'Heapsort', 70 | 'insert': 'Insertion Sort', 71 | 'intro' : 'Introsort', 72 | 'merge' : 'Mergesort', 73 | 'quick' : 'Quicksort', 74 | 'radix' : 'Radix Sort', 75 | 'select': 'Select Sort', 76 | 'smooth': 'Smoothsort' 77 | }, 78 | 'tree': { 79 | 'binHeap': 'Binary Heaps', 80 | 'binTree': 'Binary Trees', 81 | 'bst' : 'Binary Search Trees', 82 | 'bnmHeap': 'Binomial Heaps', 83 | 'fibHeap': 'Fibonacci Heaps', 84 | 'red' : 'Red-Black Trees', 85 | 'splay' : 'Splay Trees', 86 | 'trie' : 'Tries' 87 | } 88 | }; 89 | -------------------------------------------------------------------------------- /example/pre-compiled-settings/configuration.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------- 3 | * The Configuration 4 | * ----------------------------------------------- 5 | * @desc An object property of settings that allows you to run 6 | * the question manager like you want. 7 | * @type {{ 8 | * searchSettings: Object, 9 | * searchDefaults: Object, 10 | * questionFormat: Object, 11 | * prettifyFormat: Object, 12 | * showLinks : Object 13 | * }} 14 | */ 15 | settings.config = {}; 16 | 17 | /** 18 | * ----------------------------------------------- 19 | * The Search Settings 20 | * ----------------------------------------------- 21 | * @desc An object property of configuration that allows you to enable or 22 | * disable different search options in the app. 23 | * @type {{ 24 | * stage : boolean, 25 | * source : boolean, 26 | * category: boolean, 27 | * subCat : boolean 28 | * }} 29 | */ 30 | settings.config.searchSettings = { 31 | stage : true, 32 | source : true, 33 | category: true, 34 | subCat : true 35 | }; 36 | 37 | /** 38 | * ----------------------------------------------- 39 | * The Search Defaults 40 | * ----------------------------------------------- 41 | * @desc An object property of configuration that allows you to set the 42 | * default search values for a new app init. 43 | * @type {{ 44 | * view : string, 45 | * order : string, 46 | * stage : string, 47 | * source : string, 48 | * mainCat: string, 49 | * subCat : string, 50 | * startID: number 51 | * }} 52 | */ 53 | settings.config.searchDefaults = { 54 | view : 'one', 55 | order : 'asc', 56 | stage : 'all', 57 | source : 'all', 58 | mainCat: 'all', 59 | subCat : 'all', 60 | startID: 0 61 | }; 62 | 63 | /** 64 | * ----------------------------------------------- 65 | * The Question Format 66 | * ----------------------------------------------- 67 | * @desc An object property of configuration that allows you to enable or 68 | * disable different parts of a question's display. 69 | * @type {{ 70 | * id : boolean, 71 | * complete: boolean, 72 | * source : boolean, 73 | * category: boolean, 74 | * subCat : boolean, 75 | * links : boolean, 76 | * problem : boolean, 77 | * descr : boolean, 78 | * output : boolean 79 | * }} 80 | */ 81 | settings.config.questionFormat = { 82 | id : true, 83 | complete: true, 84 | source : true, 85 | category: true, 86 | subCat : true, 87 | links : true, 88 | problem : true, 89 | descr : false, 90 | output : true 91 | }; 92 | 93 | /** 94 | * ----------------------------------------------- 95 | * The Prettify Format 96 | * ----------------------------------------------- 97 | * @desc An object property of configuration that allows you to configure 98 | * the built-in prettifier to your liking. 99 | * @type {{ 100 | * trimSpace : number, 101 | * tabLength : number, 102 | * commentLinks: boolean 103 | * }} 104 | */ 105 | settings.config.prettifyFormat = { 106 | trimSpace : 0, 107 | tabLength : 2, 108 | commentLinks: true 109 | }; 110 | 111 | /** 112 | * ----------------------------------------------- 113 | * The Show Links 114 | * ----------------------------------------------- 115 | * @desc An object property of configuration that allows you to enable or 116 | * disable whether question parts have shortcut links. 117 | * @type {{ 118 | * id : boolean, 119 | * source : boolean, 120 | * category: boolean 121 | * }} 122 | */ 123 | settings.config.showLinks = { 124 | id : true, 125 | source : false, 126 | category: true 127 | }; 128 | -------------------------------------------------------------------------------- /example/pre-compiled-settings/resources.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------- 3 | * The Resources 4 | * ----------------------------------------------- 5 | * @desc An object property of settings that contains all of the JSON 6 | * resources that are made available for use in the questions via the 7 | * public method aIV.app.getResource(resourceName). 8 | * @type {(string|Array)} 9 | */ 10 | settings.resources = 'words'; 11 | -------------------------------------------------------------------------------- /example/pre-compiled-settings/skeleton.js: -------------------------------------------------------------------------------- 1 | /* Algorithm IV Question Manager (v1.1.2) (imagineadamsmith@gmail.com) 2 | * Section: Example Settings & App Initialization 3 | * Author: Adam Smith 4 | * Copyright (c) 2022 Adam A Smith 5 | * The Apache License (www.apache.org/licenses/LICENSE-2.0) */ 6 | 7 | (function() { 8 | "use strict"; 9 | 10 | /** 11 | * ----------------------------------------------- 12 | * The Settings Object 13 | * ----------------------------------------------- 14 | * @desc Contains all of the settings for running this example 15 | * of Algorithm IV's question manager. For more details see 16 | * [Algorithm IV's online documentation]{@link algorithmiv.com/docs/start}. 17 | * @type {Object} 18 | */ 19 | var settings = {}; 20 | 21 | 22 | /* ----------------------------------------------------------------------------- 23 | * | The Configuration | 24 | * v ------------------------------------------------------------------------- v 25 | example/pre-compiled-settings/configuration.js */ 26 | 27 | 28 | /* ----------------------------------------------------------------------------- 29 | * | The Sources | 30 | * v ------------------------------------------------------------------------- v 31 | example/pre-compiled-settings/sources.js */ 32 | 33 | 34 | /* ----------------------------------------------------------------------------- 35 | * | The Categories | 36 | * v ------------------------------------------------------------------------- v 37 | example/pre-compiled-settings/categories.js */ 38 | 39 | 40 | /* ----------------------------------------------------------------------------- 41 | * | The Resources | 42 | * v ------------------------------------------------------------------------- v 43 | example/pre-compiled-settings/resources.js */ 44 | 45 | 46 | /* ----------------------------------------------------------------------------- 47 | * | The Questions | 48 | * v ------------------------------------------------------------------------- v 49 | example/pre-compiled-settings/questions.js */ 50 | 51 | 52 | /* ----------------------------------------------------------------------------- 53 | * | The Question Manager App Initialization | 54 | * v ------------------------------------------------------------------------- v 55 | */ 56 | aIV.app(settings); 57 | 58 | })(); 59 | -------------------------------------------------------------------------------- /example/pre-compiled-settings/sources.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------- 3 | * The Sources 4 | * ----------------------------------------------- 5 | * @desc An object property of settings that contains all of the 6 | * question manager's source ids and names. 7 | * @type {Object} 8 | */ 9 | settings.sources = { 10 | 'am': 'Amazon', 11 | 'bl': 'Bloomberg', 12 | 'fb': 'Facebook', 13 | 'go': 'Google' 14 | }; 15 | -------------------------------------------------------------------------------- /example/view-example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Algorithm IV's Question Manager 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/classes/categories.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (Categories) 4 | * ----------------------------------------------------- 5 | * @desc The available categories for each question. 6 | * @param {?(objectMap|stringMap)} categories - The user's categories. 7 | * @constructor 8 | */ 9 | var Categories = function(categories) { 10 | 11 | checkArgs(categories, 'objectMap|stringMap'); 12 | 13 | //////////////////////////////////////////////////////////////////////////// 14 | // Prepare The User Supplied Params 15 | //////////////////////////////////////////////////////////////////////////// 16 | 17 | if ( checkType(categories, '!stringMap') ) { 18 | categories = { 19 | main: categories, 20 | sub : {} 21 | }; 22 | } 23 | else { 24 | if (!categories) { 25 | categories = {}; 26 | } 27 | if (!categories.main || !checkType(categories.main, '!stringMap')) { 28 | categories.main = {}; 29 | } 30 | if (!categories.sub || !checkType(categories.sub, '!objectMap')) { 31 | categories.sub = {}; 32 | } 33 | } 34 | 35 | //////////////////////////////////////////////////////////////////////////// 36 | // Define The Public Properties 37 | //////////////////////////////////////////////////////////////////////////// 38 | 39 | /** 40 | * ----------------------------------------------- 41 | * Public Property (Categories.ids) 42 | * ----------------------------------------------- 43 | * @desc Saves an array of all the main category ids in alphabetical order. 44 | * @type {!strings} 45 | */ 46 | this.ids; 47 | 48 | /** 49 | * ----------------------------------------------- 50 | * Public Property (Categories.len) 51 | * ----------------------------------------------- 52 | * @desc Saves the count of main categories. 53 | * @type {number} 54 | */ 55 | this.len; 56 | 57 | //////////////////////////////////////////////////////////////////////////// 58 | // Setup The Public Properties 59 | //////////////////////////////////////////////////////////////////////////// 60 | 61 | /** @type {number} */ 62 | var allIndex; 63 | 64 | this.ids = Object.keys(categories.main); 65 | this.len = this.ids.length; 66 | 67 | // Sort the main category ids 68 | if (this.len) { 69 | this.ids = sortKeys(this.ids, categories.main); 70 | } 71 | 72 | // Fix a category with the id of all 73 | allIndex = this.ids.indexOf('all'); 74 | if (allIndex !== -1) { 75 | this.ids[ allIndex ] = '_all'; 76 | } 77 | 78 | //////////////////////////////////////////////////////////////////////////// 79 | // Define The Protected Properties 80 | //////////////////////////////////////////////////////////////////////////// 81 | 82 | /** 83 | * ----------------------------------------------- 84 | * Protected Property (Categories.data) 85 | * ----------------------------------------------- 86 | * @desc Saves a hash map of the category objects using the ids as keys. 87 | * @type {!Object} 88 | * @private 89 | */ 90 | var data; 91 | 92 | //////////////////////////////////////////////////////////////////////////// 93 | // Setup The Protected Properties 94 | //////////////////////////////////////////////////////////////////////////// 95 | 96 | /** @type {strings} */ 97 | var subIds; 98 | /** @type {string} */ 99 | var mainId; 100 | /** @type {string} */ 101 | var subId; 102 | /** @type {number} */ 103 | var ii; 104 | /** @type {number} */ 105 | var i; 106 | 107 | data = {}; 108 | 109 | // Build the data hash map 110 | i = this.len; 111 | while (i--) { 112 | mainId = this.ids[i]; 113 | 114 | // Save and sort the sub category ids if they exist 115 | subIds = ( (hasOwnProp(categories.sub, mainId)) ? 116 | Object.keys(categories.sub[ mainId ]) : [] 117 | ); 118 | if (subIds.length) { 119 | subIds = sortKeys(subIds, categories.sub[ mainId ]); 120 | } 121 | 122 | // Add main category to the hash map 123 | data[ mainId ] = new Category(categories.main[ mainId ], subIds); 124 | 125 | // Add the sub categories to the hash map 126 | ii = subIds.length; 127 | while (ii--) { 128 | subId = subIds[ii]; 129 | data[ subId ] = new Category(categories.sub[ mainId ][ subId ]); 130 | } 131 | } 132 | 133 | // Deep freeze 134 | freezeObj(data, true); 135 | 136 | //////////////////////////////////////////////////////////////////////////// 137 | // Define & Setup The Public Methods 138 | //////////////////////////////////////////////////////////////////////////// 139 | 140 | /** 141 | * ----------------------------------------------- 142 | * Public Property (Categories.get) 143 | * ----------------------------------------------- 144 | * @desc Get a Catgory's object or protected property. 145 | * @param {string} id - The category id to get. 146 | * @param {string=} prop - The property to get. 147 | * @return {!(Category|string|numbers|boolean)} 148 | */ 149 | this.get = function(id, prop) { 150 | 151 | /** @type {!Category} */ 152 | var category; 153 | /** @type {!(Category|string|numbers)} */ 154 | var result; 155 | 156 | checkArgs(id, 'string', prop, 'string='); 157 | 158 | if ( hasOwnProp(data, id) ) { 159 | prop = prop || ''; 160 | category = data[ id ]; 161 | result = (prop) ? category.get(prop) : category; 162 | } 163 | else { 164 | result = false; 165 | } 166 | 167 | return result; 168 | }; 169 | 170 | //////////////////////////////////////////////////////////////////////////// 171 | // End Of The Class Setup 172 | //////////////////////////////////////////////////////////////////////////// 173 | 174 | // Deep freeze 175 | freezeObj(this, true); 176 | 177 | }; 178 | 179 | //////////////////////////////////////////////////////////////////////////////// 180 | // The Prototype Methods 181 | //////////////////////////////////////////////////////////////////////////////// 182 | 183 | Categories.prototype.constructor = Categories; 184 | 185 | /** 186 | * ----------------------------------------------------- 187 | * Public Method (Categories.prototype.freezeIds) 188 | * ----------------------------------------------------- 189 | * @desc Freezes the ids array for each category. 190 | * @type {function} 191 | */ 192 | Categories.prototype.freezeIds = function() { 193 | 194 | /** @type {string} */ 195 | var id; 196 | /** @type {number} */ 197 | var i; 198 | 199 | i = this.len; 200 | while (i--) { 201 | id = this.ids[i]; 202 | this.get(id).freezeIds(); 203 | } 204 | 205 | }; 206 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/classes/category.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (Category) 4 | * ----------------------------------------------------- 5 | * @desc An object containing the details of a category. 6 | * @param {string} name - The name of the category. 7 | * @param {?strings=} subs - This category's sub ids if they exist. 8 | * If null then category is a sub category. 9 | * @constructor 10 | */ 11 | var Category = function(name, subs) { 12 | 13 | checkArgs(name, 'string', subs, 'strings='); 14 | 15 | //////////////////////////////////////////////////////////////////////////// 16 | // Define The Protected Properties 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | /** 20 | * ----------------------------------------------- 21 | * Protected Property (Category.url) 22 | * ----------------------------------------------- 23 | * @desc The url name for this category. 24 | * @type {string} 25 | * @private 26 | */ 27 | var url; 28 | 29 | /** 30 | * ----------------------------------------------- 31 | * Protected Property (Category.ids) 32 | * ----------------------------------------------- 33 | * @desc The ids of the questions containing this category. 34 | * @type {!numbers} 35 | * @private 36 | */ 37 | var ids; 38 | 39 | //////////////////////////////////////////////////////////////////////////// 40 | // Setup The Protected Properties 41 | //////////////////////////////////////////////////////////////////////////// 42 | 43 | if (!name || !checkType(name, 'string')) { 44 | name = ''; 45 | url = ''; 46 | } 47 | else { 48 | url = makeUrl(name); 49 | } 50 | ids = []; 51 | subs = (subs) ? freezeObj(subs) : null; 52 | 53 | //////////////////////////////////////////////////////////////////////////// 54 | // Define & Setup The Public Methods 55 | //////////////////////////////////////////////////////////////////////////// 56 | 57 | /** 58 | * ----------------------------------------------- 59 | * Public Method (Category.get) 60 | * ----------------------------------------------- 61 | * @desc Gets a protected property's value from the category. 62 | * @param {string} propName - The name of the property to get. 63 | * @return {(string|!numbers)} 64 | */ 65 | this.get = function(propName) { 66 | 67 | /** @type {Object} */ 68 | var props = { 69 | name: name, 70 | url : url, 71 | subs: subs, 72 | ids : ids 73 | }; 74 | 75 | return getter.call(props, propName); 76 | }; 77 | 78 | /** 79 | * ----------------------------------------------- 80 | * Public Method (Category.addId) 81 | * ----------------------------------------------- 82 | * @desc Adds a question id to this category. 83 | * @param {number} id - The id to add. 84 | */ 85 | this.addId = function(id) { 86 | 87 | /** @type {string} */ 88 | var errorMsg; 89 | 90 | checkArgs(id, 'number'); 91 | 92 | if (id < 1) { 93 | errorMsg = 'An aIV.app internal error occurred. A Category.addId '; 94 | errorMsg += 'call was given an invalid question id to add. id= ' + id; 95 | throw new Error(errorMsg); 96 | } 97 | 98 | ids.push(id); 99 | 100 | }; 101 | 102 | /** 103 | * ----------------------------------------------- 104 | * Public Method (Category.freezeIds) 105 | * ----------------------------------------------- 106 | * @desc Freezes this category's question ids. 107 | * @type {function} 108 | */ 109 | this.freezeIds = function() { 110 | 111 | freezeObj(ids); 112 | 113 | }; 114 | 115 | //////////////////////////////////////////////////////////////////////////// 116 | // End Of The Class Setup 117 | //////////////////////////////////////////////////////////////////////////// 118 | 119 | }; 120 | 121 | //////////////////////////////////////////////////////////////////////////////// 122 | // The Prototype Methods 123 | //////////////////////////////////////////////////////////////////////////////// 124 | 125 | Category.prototype.constructor = Category; 126 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/classes/config/config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (Config) 4 | * ----------------------------------------------------- 5 | * @desc The configuration settings for this app. 6 | * @param {Object} config - The user's config settings. 7 | * @constructor 8 | */ 9 | var Config = function(config) { 10 | 11 | checkArgs(config, 'objectMap'); 12 | 13 | //////////////////////////////////////////////////////////////////////////// 14 | // Define The Public Properties 15 | //////////////////////////////////////////////////////////////////////////// 16 | 17 | /** 18 | * ----------------------------------------------- 19 | * Public Property (Config.searchBar) 20 | * ----------------------------------------------- 21 | * @desc The search bar's configuration settings. 22 | * @type {SearchBarConfig} 23 | * @struct 24 | */ 25 | this.searchBar; 26 | 27 | /** 28 | * ----------------------------------------------- 29 | * Public Property (Config.questions) 30 | * ----------------------------------------------- 31 | * @desc The question's formatting settings. 32 | * @type {QuestionsConfig} 33 | * @struct 34 | */ 35 | this.questions; 36 | 37 | /** 38 | * ----------------------------------------------- 39 | * Public Property (Config.prettifier) 40 | * ----------------------------------------------- 41 | * @desc The prettifier's settings. 42 | * @type {PrettyConfig} 43 | * @struct 44 | */ 45 | this.prettifier; 46 | 47 | /** 48 | * ----------------------------------------------- 49 | * Public Property (Config.links) 50 | * ----------------------------------------------- 51 | * @desc Whether to display search links for each question. 52 | * @type {LinksConfig} 53 | */ 54 | this.links; 55 | 56 | //////////////////////////////////////////////////////////////////////////// 57 | // Setup The Public Properties 58 | //////////////////////////////////////////////////////////////////////////// 59 | 60 | // Check the given user's config object 61 | if ( !checkType(config, '!object') ) { 62 | config = {}; 63 | } 64 | 65 | if ( !checkType(config.searchSettings, '!object') ) { 66 | config.searchSettings = {}; 67 | } 68 | if ( !checkType(config.questionFormat, '!object') ) { 69 | config.questionFormat = {}; 70 | } 71 | if ( !checkType(config.prettifyFormat, '!object') ) { 72 | config.prettifyFormat = {}; 73 | } 74 | if ( !checkType(config.showLinks, '!object') ) { 75 | config.showLinks = {}; 76 | } 77 | 78 | // Setup the properties 79 | this.searchBar = new SearchBarConfig(config.searchSettings); 80 | this.questions = new QuestionsConfig(config.questionFormat); 81 | this.prettifier = new PrettyConfig(config.prettifyFormat); 82 | this.links = new LinksConfig(config.showLinks); 83 | 84 | //////////////////////////////////////////////////////////////////////////// 85 | // End Of The Class Setup 86 | //////////////////////////////////////////////////////////////////////////// 87 | 88 | freezeObj(this, true); 89 | 90 | }; 91 | 92 | //////////////////////////////////////////////////////////////////////////////// 93 | // The Prototype Methods 94 | //////////////////////////////////////////////////////////////////////////////// 95 | 96 | Config.prototype.constructor = Config; 97 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/classes/config/links-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (LinksConfig) 4 | * ----------------------------------------------------- 5 | * @desc The configuration settings for whether to show search links for 6 | * portions of each question. 7 | * @param {!Object} config - The user's config settings 8 | * for search link formatting. 9 | * @constructor 10 | */ 11 | var LinksConfig = function(config) { 12 | 13 | checkArgs(config, '!object'); 14 | 15 | //////////////////////////////////////////////////////////////////////////// 16 | // Define The Protected Properties 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | /** 20 | * ----------------------------------------------- 21 | * Protected Property (LinksConfig.id) 22 | * ----------------------------------------------- 23 | * @desc Whether to display an id search option for every question. 24 | * @type {boolean} 25 | * @private 26 | */ 27 | var id; 28 | 29 | /** 30 | * ------------------------------------------------- 31 | * Protected Property (LinksConfig.source) 32 | * ------------------------------------------------- 33 | * @desc Whether to display a source search option for every question. 34 | * @type {boolean} 35 | * @private 36 | */ 37 | var source; 38 | 39 | /** 40 | * ---------------------------------------------------- 41 | * Protected Property (LinksConfig.category) 42 | * ---------------------------------------------------- 43 | * @desc Whether to display a category search option in the url. 44 | * @type {boolean} 45 | * @private 46 | */ 47 | var category; 48 | 49 | //////////////////////////////////////////////////////////////////////////// 50 | // Setup The Protected Properties 51 | //////////////////////////////////////////////////////////////////////////// 52 | 53 | id = !(config.id === false); 54 | source = (config.source === true ); 55 | category = !(config.category === false); 56 | 57 | //////////////////////////////////////////////////////////////////////////// 58 | // Define & Setup The Public Methods 59 | //////////////////////////////////////////////////////////////////////////// 60 | 61 | /** 62 | * ----------------------------------------------- 63 | * Public Method (LinksConfig.get) 64 | * ----------------------------------------------- 65 | * @desc Gets a protected property's value from LinksConfig. 66 | * @param {string} prop - The name of the property to get. 67 | * @return {boolean} The property's value. 68 | */ 69 | this.get = function(prop) { 70 | 71 | /** @type {!Object} */ 72 | var props = { 73 | id : id, 74 | source : source, 75 | category: category 76 | }; 77 | 78 | return getter.call(props, prop); 79 | }; 80 | 81 | //////////////////////////////////////////////////////////////////////////// 82 | // End Of The Class Setup 83 | //////////////////////////////////////////////////////////////////////////// 84 | 85 | }; 86 | 87 | //////////////////////////////////////////////////////////////////////////////// 88 | // The Prototype Methods 89 | //////////////////////////////////////////////////////////////////////////////// 90 | 91 | LinksConfig.prototype.constructor = LinksConfig; 92 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/classes/config/pretty-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (PrettyConfig) 4 | * ----------------------------------------------------- 5 | * @desc The configuration settings for the prettifier. 6 | * @param {!Object} config - The user's 7 | * prettifier configuration settings. 8 | * @constructor 9 | */ 10 | var PrettyConfig = function(config) { 11 | 12 | checkArgs(config, '!object'); 13 | 14 | //////////////////////////////////////////////////////////////////////////// 15 | // Define The Protected Properties 16 | //////////////////////////////////////////////////////////////////////////// 17 | 18 | /** 19 | * ----------------------------------------------- 20 | * Protected Property (PrettyConfig.trimSpace) 21 | * ----------------------------------------------- 22 | * @desc The number of spaces to trim from the beginning of lines. 23 | * @type {number} 24 | * @private 25 | */ 26 | var trimSpace; 27 | 28 | /** 29 | * ----------------------------------------------- 30 | * Protected Property (PrettyConfig.tabLength) 31 | * ----------------------------------------------- 32 | * @desc The number of spaces to convert tab characters. 33 | * @type {number} 34 | * @private 35 | */ 36 | var tabLength; 37 | 38 | /** 39 | * ----------------------------------------------- 40 | * Protected Property (PrettyConfig.commentLinks) 41 | * ----------------------------------------------- 42 | * @desc Whether to allow links in prettified comments. 43 | * @type {boolean} 44 | * @private 45 | */ 46 | var commentLinks; 47 | 48 | //////////////////////////////////////////////////////////////////////////// 49 | // Setup The Protected Properties 50 | //////////////////////////////////////////////////////////////////////////// 51 | 52 | trimSpace = 0; 53 | tabLength = 2; 54 | commentLinks = (config.commentLinks === true); 55 | 56 | if ( hasOwnProp(config, 'trimSpace') ) { 57 | if (checkType(config.trimSpace, 'number') && config.trimSpace >= 0) { 58 | trimSpace = Math.floor(config.trimSpace); 59 | } 60 | else if ( checkType(config.trimSpace, 'string') ) { 61 | config.trimSpace = config.trimSpace.replace(/[^0-9]/g, ''); 62 | if (config.trimSpace) { 63 | trimSpace = Number(config.trimSpace); 64 | } 65 | } 66 | } 67 | 68 | if ( hasOwnProp(config, 'tabLength') ) { 69 | if (checkType(config.tabLength, 'number') && config.tabLength >= 0) { 70 | tabLength = Math.floor(config.tabLength); 71 | } 72 | else if ( checkType(config.tabLength, 'string') ) { 73 | config.tabLength = config.tabLength.replace(/[^0-9]/g, ''); 74 | if (config.tabLength) { 75 | tabLength = Number(config.tabLength); 76 | } 77 | } 78 | } 79 | 80 | //////////////////////////////////////////////////////////////////////////// 81 | // Define & Setup The Public Methods 82 | //////////////////////////////////////////////////////////////////////////// 83 | 84 | /** 85 | * ----------------------------------------------- 86 | * Public Method (PrettyConfig.get) 87 | * ----------------------------------------------- 88 | * @desc Gets a protected property's value from PrettyConfig. 89 | * @param {string} prop - The name of the property to get. 90 | * @return {(number|boolean)} The property's value. 91 | */ 92 | this.get = function(prop) { 93 | 94 | /** @type {!Object} */ 95 | var props = { 96 | trimSpace : trimSpace, 97 | tabLength : tabLength, 98 | commentLinks: commentLinks 99 | }; 100 | 101 | return getter.call(props, prop); 102 | }; 103 | 104 | //////////////////////////////////////////////////////////////////////////// 105 | // End Of The Class Setup 106 | //////////////////////////////////////////////////////////////////////////// 107 | 108 | }; 109 | 110 | //////////////////////////////////////////////////////////////////////////////// 111 | // The Prototype Methods 112 | //////////////////////////////////////////////////////////////////////////////// 113 | 114 | PrettyConfig.prototype.constructor = PrettyConfig; 115 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/classes/config/questions-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (QuestionsConfig) 4 | * ----------------------------------------------------- 5 | * @desc The configuration settings for formatting questions in this app. 6 | * @param {!Object} config - The user's question format config settings. 7 | * @constructor 8 | */ 9 | var QuestionsConfig = function(config) { 10 | 11 | checkArgs(config, '!object'); 12 | 13 | //////////////////////////////////////////////////////////////////////////// 14 | // Define The Protected Properties 15 | //////////////////////////////////////////////////////////////////////////// 16 | 17 | /** 18 | * ----------------------------------------------- 19 | * Protected Property (QuestionsConfig.id) 20 | * ----------------------------------------------- 21 | * @desc Whether to display any question's id. 22 | * @type {boolean} 23 | * @private 24 | */ 25 | var id; 26 | 27 | /** 28 | * ----------------------------------------------- 29 | * Protected Property (QuestionsConfig.complete) 30 | * ----------------------------------------------- 31 | * @desc Whether to display any question's completion status. 32 | * @type {boolean} 33 | * @private 34 | */ 35 | var complete; 36 | 37 | /** 38 | * ----------------------------------------------- 39 | * Protected Property (QuestionsConfig.source) 40 | * ----------------------------------------------- 41 | * @desc Whether to display any question's source. 42 | * @type {boolean} 43 | * @private 44 | */ 45 | var source; 46 | 47 | /** 48 | * ----------------------------------------------- 49 | * Protected Property (QuestionsConfig.category) 50 | * ----------------------------------------------- 51 | * @desc Whether to display any question's categories. 52 | * @type {boolean} 53 | * @private 54 | */ 55 | var category; 56 | 57 | /** 58 | * ----------------------------------------------- 59 | * Protected Property (QuestionsConfig.subCat) 60 | * ----------------------------------------------- 61 | * @desc Whether to display any question's sub categories. 62 | * @type {boolean} 63 | * @private 64 | */ 65 | var subCat; 66 | 67 | /** 68 | * ----------------------------------------------- 69 | * Protected Property (QuestionsConfig.links) 70 | * ----------------------------------------------- 71 | * @desc Whether to display any question's links. 72 | * @type {boolean} 73 | * @private 74 | */ 75 | var links; 76 | 77 | /** 78 | * ----------------------------------------------- 79 | * Protected Property (QuestionsConfig.problem) 80 | * ----------------------------------------------- 81 | * @desc Whether to display any question's problem. 82 | * @type {boolean} 83 | * @private 84 | */ 85 | var problem; 86 | 87 | /** 88 | * ----------------------------------------------- 89 | * Protected Property (QuestionsConfig.descr) 90 | * ----------------------------------------------- 91 | * @desc Whether to display any question's description. 92 | * @type {boolean} 93 | * @private 94 | */ 95 | var descr; 96 | 97 | /** 98 | * ----------------------------------------------- 99 | * Protected Property (QuestionsConfig.output) 100 | * ----------------------------------------------- 101 | * @desc Whether to display the solution's output for any question. 102 | * @type {boolean} 103 | * @private 104 | */ 105 | var output; 106 | 107 | //////////////////////////////////////////////////////////////////////////// 108 | // Setup The Protected Properties 109 | //////////////////////////////////////////////////////////////////////////// 110 | 111 | id = !(config.id === false); 112 | complete = !(config.complete === false); 113 | source = !(config.source === false); 114 | category = !(config.category === false); 115 | subCat = !(config.subCat === false); 116 | links = !(config.links === false); 117 | problem = !(config.problem === false); 118 | descr = (config.descr === true ); 119 | output = !(config.output === false); 120 | 121 | //////////////////////////////////////////////////////////////////////////// 122 | // Define & Setup The Public Methods 123 | //////////////////////////////////////////////////////////////////////////// 124 | 125 | /** 126 | * ----------------------------------------------- 127 | * Public Method (QuestionsConfig.get) 128 | * ----------------------------------------------- 129 | * @desc Gets a protected property's value from QuestionsConfig. 130 | * @param {string} prop - The name of the property to get. 131 | * @return {boolean} The property's value. 132 | */ 133 | this.get = function(prop) { 134 | 135 | /** @type {!Object} */ 136 | var props = { 137 | id : id, 138 | complete: complete, 139 | source : source, 140 | category: category, 141 | subCat : subCat, 142 | links : links, 143 | problem : problem, 144 | descr : descr, 145 | output : output 146 | }; 147 | 148 | return getter.call(props, prop); 149 | }; 150 | 151 | //////////////////////////////////////////////////////////////////////////// 152 | // End Of The Class Setup 153 | //////////////////////////////////////////////////////////////////////////// 154 | 155 | }; 156 | 157 | //////////////////////////////////////////////////////////////////////////////// 158 | // The Prototype Methods 159 | //////////////////////////////////////////////////////////////////////////////// 160 | 161 | QuestionsConfig.prototype.constructor = QuestionsConfig; 162 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/classes/config/search-bar-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (SearchBarConfig) 4 | * ----------------------------------------------------- 5 | * @desc The configuration settings for the search bar in this app. 6 | * @param {!Object} config - The user's search bar config settings. 7 | * @constructor 8 | */ 9 | var SearchBarConfig = function(config) { 10 | 11 | checkArgs(config, '!object'); 12 | 13 | //////////////////////////////////////////////////////////////////////////// 14 | // Define & Setup The Public Properties 15 | //////////////////////////////////////////////////////////////////////////// 16 | 17 | /** 18 | * ----------------------------------------------- 19 | * Public Property (SearchBarConfig.defaults) 20 | * ----------------------------------------------- 21 | * @desc The default search options to display upon app init. 22 | * @type {DefaultsSearchBarConfig} 23 | */ 24 | this.defaults = new DefaultsSearchBarConfig(); 25 | 26 | //////////////////////////////////////////////////////////////////////////// 27 | // Define The Protected Properties 28 | //////////////////////////////////////////////////////////////////////////// 29 | 30 | /** 31 | * ----------------------------------------------- 32 | * Protected Property (SearchBarConfig.stage) 33 | * ----------------------------------------------- 34 | * @desc Whether to display the stage search option. 35 | * @type {boolean} 36 | * @private 37 | */ 38 | var stage; 39 | 40 | /** 41 | * ----------------------------------------------- 42 | * Protected Property (SearchBarConfig.source) 43 | * ----------------------------------------------- 44 | * @desc Whether to display the source search option. 45 | * @type {boolean} 46 | * @private 47 | */ 48 | var source; 49 | 50 | /** 51 | * ----------------------------------------------- 52 | * Protected Property (SearchBarConfig.category) 53 | * ----------------------------------------------- 54 | * @desc Whether to display the category search option. 55 | * @type {boolean} 56 | * @private 57 | */ 58 | var category; 59 | 60 | /** 61 | * ----------------------------------------------- 62 | * Protected Property (SearchBarConfig.subCat) 63 | * ----------------------------------------------- 64 | * @desc Whether to display the sub category search option. 65 | * @type {boolean} 66 | * @private 67 | */ 68 | var subCat; 69 | 70 | //////////////////////////////////////////////////////////////////////////// 71 | // Setup The Protected Properties 72 | //////////////////////////////////////////////////////////////////////////// 73 | 74 | stage = !(config.stage === false); 75 | source = !(config.source === false); 76 | category = !(config.category === false); 77 | subCat = !(config.subCat === false); 78 | 79 | if (!category && subCat) { 80 | subCat = false; 81 | } 82 | 83 | //////////////////////////////////////////////////////////////////////////// 84 | // Define & Setup The Public Methods 85 | //////////////////////////////////////////////////////////////////////////// 86 | 87 | /** 88 | * ----------------------------------------------- 89 | * Public Method (SearchBarConfig.get) 90 | * ----------------------------------------------- 91 | * @desc Gets a protected property's value from SearchBarConfig. 92 | * @param {string} prop - The name of the property to get. 93 | * @return {boolean} The property's value. 94 | */ 95 | this.get = function(prop) { 96 | 97 | /** @type {!Object} */ 98 | var props = { 99 | stage : stage, 100 | source : source, 101 | category: category, 102 | subCat : subCat 103 | }; 104 | 105 | return getter.call(props, prop); 106 | }; 107 | 108 | //////////////////////////////////////////////////////////////////////////// 109 | // End Of The Class Setup 110 | //////////////////////////////////////////////////////////////////////////// 111 | 112 | }; 113 | 114 | //////////////////////////////////////////////////////////////////////////////// 115 | // The Prototype Methods 116 | //////////////////////////////////////////////////////////////////////////////// 117 | 118 | SearchBarConfig.prototype.constructor = SearchBarConfig; 119 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/classes/question/question-format.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (QuestionFormat) 4 | * ----------------------------------------------------- 5 | * @desc An object containing the formatted details of a question. 6 | * @param {!Object} question - The pre-formatted details of the question. 7 | * @param {!booleanMap} config - The settings for question formatting. 8 | * @constructor 9 | */ 10 | var QuestionFormat = function(question, config) { 11 | 12 | checkArgs(question, '!object', config, '!booleanMap'); 13 | 14 | //////////////////////////////////////////////////////////////////////////// 15 | // Define The Protected Properties 16 | //////////////////////////////////////////////////////////////////////////// 17 | 18 | /** 19 | * ----------------------------------------------- 20 | * Protected Property (QuestionFormat.id) 21 | * ----------------------------------------------- 22 | * @desc The id for this question. 23 | * @type {string} 24 | * @private 25 | */ 26 | var id; 27 | 28 | /** 29 | * ----------------------------------------------- 30 | * Protected Property (QuestionFormat.source) 31 | * ----------------------------------------------- 32 | * @desc This question's source. 33 | * @type {string} 34 | * @private 35 | */ 36 | var source; 37 | 38 | /** 39 | * ----------------------------------------------- 40 | * Protected Property (QuestionFormat.complete) 41 | * ----------------------------------------------- 42 | * @desc This question's current completion status. 43 | * @type {string} 44 | * @private 45 | */ 46 | var complete; 47 | 48 | /** 49 | * ----------------------------------------------- 50 | * Protected Property (QuestionFormat.mainCat) 51 | * ----------------------------------------------- 52 | * @desc This question's main categories. 53 | * @type {{ 54 | * h3 : ?string, 55 | * names: ?strings 56 | * }} 57 | * @private 58 | */ 59 | var mainCat; 60 | 61 | /** 62 | * ----------------------------------------------- 63 | * Protected Property (QuestionFormat.subCat) 64 | * ----------------------------------------------- 65 | * @desc This question's sub categories. 66 | * @type {{ 67 | * h3 : ?string, 68 | * names: ?strings 69 | * }} 70 | * @private 71 | */ 72 | var subCat; 73 | 74 | /** 75 | * ----------------------------------------------- 76 | * Protected Property (QuestionFormat.solution) 77 | * ----------------------------------------------- 78 | * @desc This question's solution. 79 | * @type {{ 80 | * prettyCode: string, 81 | * lineCount : number 82 | * }} 83 | * @private 84 | */ 85 | var solution; 86 | 87 | //////////////////////////////////////////////////////////////////////////// 88 | // Setup The Protected Properties 89 | //////////////////////////////////////////////////////////////////////////// 90 | 91 | /** @type {function} */ 92 | var getCategory; 93 | /** @type {!{ result: string, lineCount: number }} */ 94 | var code; 95 | /** @type {number} */ 96 | var len; 97 | /** @type {number} */ 98 | var i; 99 | 100 | id = (config.id && question.id) ? question.id : ''; 101 | if (id) { 102 | id = ( (id < 10) ? 103 | '00' + id : (id < 100) ? 104 | '0' + id : '' + id 105 | ); 106 | } 107 | 108 | source = ( (config.source && question.source) ? 109 | app.sources.get(question.source, 'name') : '' 110 | ); 111 | 112 | complete = ( (!config.complete) ? 113 | '' : (question.complete) ? 114 | 'Yes' : 'No' 115 | ); 116 | 117 | getCategory = app.categories.get; 118 | 119 | // Format the categories 120 | mainCat = { 121 | h3 : null, 122 | names: null 123 | }; 124 | subCat = { 125 | h3 : null, 126 | names: null 127 | }; 128 | if (config.category) { 129 | 130 | // Format the main category 131 | if (question.mainCat.length) { 132 | mainCat.h3 = ( (question.mainCat.length > 1) ? 133 | 'Main Categories:' : 'Main Category:' 134 | ); 135 | len = question.mainCat.length; 136 | mainCat.names = new Array(len); 137 | i = -1; 138 | while (++i < len) { 139 | mainCat.names[i] = getCategory(question.mainCat[i], 'name'); 140 | } 141 | } 142 | 143 | // Format the sub category 144 | if (config.subCat && question.subCat.length) { 145 | subCat.h3 = ( (question.subCat.length > 1) ? 146 | 'Sub Categories:' : 'Sub Category:' 147 | ); 148 | len = question.subCat.length; 149 | subCat.names = new Array(len); 150 | i = -1; 151 | while (++i < len) { 152 | subCat.names[i] = getCategory(question.subCat[i], 'name'); 153 | } 154 | } 155 | } 156 | 157 | // Format the solution 158 | solution = {}; 159 | if (question.solution) { 160 | code = prettify(question.solution); 161 | solution.prettyCode = code.result; 162 | solution.lineCount = code.lineCount; 163 | } 164 | 165 | // Freeze all of the protected properties that are objects 166 | freezeObj(mainCat); 167 | freezeObj(subCat); 168 | freezeObj(solution); 169 | 170 | //////////////////////////////////////////////////////////////////////////// 171 | // Define & Setup The Public Methods 172 | //////////////////////////////////////////////////////////////////////////// 173 | 174 | /** 175 | * ----------------------------------------------- 176 | * Public Method (QuestionFormat.get) 177 | * ----------------------------------------------- 178 | * @desc Gets a protected property's value from the QuestionFormat. 179 | * @param {string} propName - The name of the property to get. 180 | * @return {*} The property's value. 181 | */ 182 | this.get = function(propName) { 183 | 184 | /** @type {!Object} */ 185 | var props = { 186 | id : id, 187 | source : source, 188 | complete: complete, 189 | mainCat : mainCat, 190 | subCat : subCat, 191 | solution: solution 192 | }; 193 | 194 | return getter.call(props, propName); 195 | }; 196 | 197 | //////////////////////////////////////////////////////////////////////////// 198 | // End Of The Class Setup 199 | //////////////////////////////////////////////////////////////////////////// 200 | 201 | freezeObj(this, true); 202 | 203 | }; 204 | 205 | //////////////////////////////////////////////////////////////////////////////// 206 | // The Prototype Methods 207 | //////////////////////////////////////////////////////////////////////////////// 208 | 209 | QuestionFormat.prototype.constructor = QuestionFormat; 210 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/classes/search-bar/search-bar-elems.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (SearchBarElems) 4 | * ----------------------------------------------------- 5 | * @desc The search bar's values and elements for this app. 6 | * @param {!booleanMap} config - The app's search bar config settings. 7 | * @constructor 8 | */ 9 | var SearchBarElems = function(config) { 10 | 11 | checkArgs(config, '!booleanMap'); 12 | 13 | //////////////////////////////////////////////////////////////////////////// 14 | // Define The Public Properties 15 | //////////////////////////////////////////////////////////////////////////// 16 | 17 | /** 18 | * ----------------------------------------------- 19 | * Public Property (SearchBarElems.view) 20 | * ----------------------------------------------- 21 | * @desc The DOM HTMLSelectElement #aIV-view. 22 | * @type {!HTMLSelectElement} 23 | */ 24 | this.view; 25 | 26 | /** 27 | * ----------------------------------------------- 28 | * Public Property (SearchBarElems.order) 29 | * ----------------------------------------------- 30 | * @desc The DOM HTMLSelectElement #aIV-order. 31 | * @type {!HTMLSelectElement} 32 | */ 33 | this.order; 34 | 35 | /** 36 | * ----------------------------------------------- 37 | * Public Property (SearchBarElems.stage) 38 | * ----------------------------------------------- 39 | * @desc The DOM HTMLSelectElement #aIV-stage. 40 | * @type {?HTMLSelectElement} 41 | */ 42 | this.stage; 43 | 44 | /** 45 | * ----------------------------------------------- 46 | * Public Property (SearchBarElems.source) 47 | * ----------------------------------------------- 48 | * @desc The DOM HTMLSelectElement #aIV-source. 49 | * @type {?HTMLSelectElement} 50 | */ 51 | this.source; 52 | 53 | /** 54 | * ----------------------------------------------- 55 | * Public Property (SearchBarElems.mainCat) 56 | * ----------------------------------------------- 57 | * @desc The DOM HTMLSelectElement #aIV-mainCat. 58 | * @type {?HTMLSelectElement} 59 | */ 60 | this.mainCat; 61 | 62 | /** 63 | * ----------------------------------------------- 64 | * Public Property (SearchBarElems.subCat) 65 | * ----------------------------------------------- 66 | * @desc The DOM HTMLSelectElement #aIV-subCat. 67 | * @type {?HTMLSelectElement} 68 | */ 69 | this.subCat; 70 | 71 | //////////////////////////////////////////////////////////////////////////// 72 | // Setup The Public Properties 73 | //////////////////////////////////////////////////////////////////////////// 74 | 75 | this.view = makeElem({ 76 | tag : 'select', 77 | id : 'aIV-view', 78 | className: 'showView' 79 | }); 80 | this.view.onchange = function(event) { 81 | Events.searchView(event.target.value); 82 | }; 83 | 84 | this.order = makeElem({ 85 | tag : 'select', 86 | id : 'aIV-order', 87 | className: 'showOrder' 88 | }); 89 | this.order.onchange = function(event) { 90 | Events.searchOrder(event.target.value); 91 | }; 92 | 93 | this.stage = null; 94 | if (config.stage) { 95 | this.stage = makeElem({ 96 | tag : 'select', 97 | id : 'aIV-stage', 98 | className: 'showStage' 99 | }); 100 | this.stage.onchange = function(event) { 101 | Events.searchStage(event.target.value); 102 | }; 103 | } 104 | 105 | this.source = null; 106 | if (config.source) { 107 | this.source = makeElem({ 108 | tag : 'select', 109 | id : 'aIV-source', 110 | className: 'showSource' 111 | }); 112 | this.source.onchange = function(event) { 113 | Events.searchSource(event.target.value); 114 | }; 115 | } 116 | 117 | this.mainCat = null; 118 | if (config.category) { 119 | this.mainCat = makeElem({ 120 | tag : 'select', 121 | id : 'aIV-mainCat', 122 | className: 'showMainCat' 123 | }); 124 | this.mainCat.onchange = function(event) { 125 | Events.searchMainCat(event.target.value); 126 | }; 127 | } 128 | 129 | this.subCat = null; 130 | if (config.subCat) { 131 | this.subCat = makeElem({ 132 | tag : 'select', 133 | id : 'aIV-subCat', 134 | className: 'showSubCat' 135 | }); 136 | this.subCat.onchange = function(event) { 137 | Events.searchSubCat(event.target.value); 138 | }; 139 | } 140 | 141 | //////////////////////////////////////////////////////////////////////////// 142 | // End Of The Class Setup 143 | //////////////////////////////////////////////////////////////////////////// 144 | 145 | freezeObj(this); 146 | 147 | }; 148 | 149 | //////////////////////////////////////////////////////////////////////////////// 150 | // The Prototype Methods 151 | //////////////////////////////////////////////////////////////////////////////// 152 | 153 | SearchBarElems.prototype.constructor = SearchBarElems; 154 | 155 | /** 156 | * -------------------------------------------------------------- 157 | * Public Method (SearchBarElems.prototype.setValuesToDefaults) 158 | * -------------------------------------------------------------- 159 | * @desc Updates the search bar's values to the defaults. 160 | * @param {!Object} defaults - The default values. 161 | */ 162 | SearchBarElems.prototype.setValuesToDefaults = function(defaults) { 163 | 164 | checkArgs(defaults, '!stringMap'); 165 | 166 | this.view.value = defaults.view; 167 | this.order.value = defaults.order; 168 | if (this.stage) { 169 | this.stage.value = defaults.stage; 170 | } 171 | if (this.source) { 172 | this.source.value = defaults.source; 173 | } 174 | if (this.mainCat) { 175 | this.mainCat.value = defaults.mainCat; 176 | } 177 | if (this.subCat) { 178 | this.subCat.value = defaults.subCat; 179 | } 180 | 181 | }; 182 | 183 | /** 184 | * ------------------------------------------------------- 185 | * Public Method (SearchBarElems.prototype.appendToMain) 186 | * ------------------------------------------------------- 187 | * @desc Appends the search bar's elements to the selections root. 188 | * @type {function} 189 | */ 190 | SearchBarElems.prototype.appendToMain = function() { 191 | 192 | /** @type {!Element} */ 193 | var sel; 194 | 195 | sel = app.elems.sel; 196 | 197 | sel.appendChild(this.view); 198 | sel.appendChild(this.order); 199 | this.stage && sel.appendChild(this.stage); 200 | this.source && sel.appendChild(this.source); 201 | this.mainCat && sel.appendChild(this.mainCat); 202 | this.subCat && sel.appendChild(this.subCat); 203 | 204 | }; 205 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/classes/source.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (Source) 4 | * ----------------------------------------------------- 5 | * @desc An object containing the details of a source. 6 | * @param {string} name - The source's name. 7 | * @constructor 8 | */ 9 | var Source = function(name) { 10 | 11 | checkArgs(name, 'string'); 12 | 13 | //////////////////////////////////////////////////////////////////////////// 14 | // Define The Protected Properties 15 | //////////////////////////////////////////////////////////////////////////// 16 | 17 | /** 18 | * ----------------------------------------------- 19 | * Protected Property (Source.url) 20 | * ----------------------------------------------- 21 | * @desc The source's url name. 22 | * @type {string} 23 | * @private 24 | */ 25 | var url; 26 | 27 | /** 28 | * ----------------------------------------------- 29 | * Protected Property (Source.ids) 30 | * ----------------------------------------------- 31 | * @desc The ids of the questions containing this source. 32 | * @type {!numbers} 33 | * @private 34 | */ 35 | var ids; 36 | 37 | //////////////////////////////////////////////////////////////////////////// 38 | // Setup The Protected Properties 39 | //////////////////////////////////////////////////////////////////////////// 40 | 41 | if (!name || !checkType(name, 'string')) { 42 | name = ''; 43 | url = ''; 44 | } 45 | else { 46 | url = makeUrl(name); 47 | } 48 | ids = []; 49 | 50 | //////////////////////////////////////////////////////////////////////////// 51 | // Define & Setup The Public Methods 52 | //////////////////////////////////////////////////////////////////////////// 53 | 54 | /** 55 | * ----------------------------------------------- 56 | * Public Method (Source.get) 57 | * ----------------------------------------------- 58 | * @desc Gets a protected property's value from the source. 59 | * @param {string} propName - The name of the property to get. 60 | * @return {(string|!numbers)} 61 | */ 62 | this.get = function(propName) { 63 | 64 | /** @type {Object} */ 65 | var props = { 66 | name: name, 67 | url : url, 68 | ids : ids 69 | }; 70 | 71 | return getter.call(props, propName); 72 | }; 73 | 74 | /** 75 | * ----------------------------------------------- 76 | * Public Method (Source.addId) 77 | * ----------------------------------------------- 78 | * @desc Adds a question id to this source. 79 | * @param {number} id - The index to add. 80 | */ 81 | this.addId = function(id) { 82 | 83 | /** @type {string} */ 84 | var errorMsg; 85 | 86 | checkArgs(id, 'number'); 87 | 88 | if (id < 1) { 89 | errorMsg = 'An aIV.app internal error occurred. A Source.addId call '; 90 | errorMsg += 'was given an invalid question id to add. id= ' + id; 91 | throw new Error(errorMsg); 92 | } 93 | 94 | ids.push(id); 95 | 96 | }; 97 | 98 | /** 99 | * ----------------------------------------------- 100 | * Public Method (Source.freezeIds) 101 | * ----------------------------------------------- 102 | * @desc Freezes this category's question ids. 103 | * @type {function} 104 | */ 105 | this.freezeIds = function() { 106 | 107 | freezeObj(ids); 108 | 109 | }; 110 | 111 | //////////////////////////////////////////////////////////////////////////// 112 | // End Of The Class Setup 113 | //////////////////////////////////////////////////////////////////////////// 114 | 115 | }; 116 | 117 | //////////////////////////////////////////////////////////////////////////////// 118 | // The Prototype Methods 119 | //////////////////////////////////////////////////////////////////////////////// 120 | 121 | Source.prototype.constructor = Source; 122 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/classes/sources.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (Sources) 4 | * ----------------------------------------------------- 5 | * @desc The available sources for each question. 6 | * @param {?stringMap} sources - The user's sources. 7 | * @constructor 8 | */ 9 | var Sources = function(sources) { 10 | 11 | checkArgs(sources, 'stringMap'); 12 | 13 | //////////////////////////////////////////////////////////////////////////// 14 | // Prepare The User Supplied Params 15 | //////////////////////////////////////////////////////////////////////////// 16 | 17 | if ( !checkType(sources, '!stringMap') ) { 18 | sources = {}; 19 | } 20 | 21 | //////////////////////////////////////////////////////////////////////////// 22 | // Define The Public Properties 23 | //////////////////////////////////////////////////////////////////////////// 24 | 25 | /** 26 | * ----------------------------------------------- 27 | * Public Property (Sources.ids) 28 | * ----------------------------------------------- 29 | * @desc Saves an array of all the source ids in alphabetical order. 30 | * @type {strings} 31 | */ 32 | this.ids; 33 | 34 | /** 35 | * ----------------------------------------------- 36 | * Public Property (Sources.len) 37 | * ----------------------------------------------- 38 | * @desc Saves the count of sources. 39 | * @type {number} 40 | */ 41 | this.len; 42 | 43 | //////////////////////////////////////////////////////////////////////////// 44 | // Setup The Public Properties 45 | //////////////////////////////////////////////////////////////////////////// 46 | 47 | /** @type {number} */ 48 | var allIndex; 49 | 50 | this.ids = Object.keys(sources); 51 | this.len = this.ids.length; 52 | 53 | // Sort the ids 54 | if (this.len) { 55 | this.ids = sortKeys(this.ids, sources); 56 | } 57 | 58 | // Fix a category with the id of all 59 | allIndex = this.ids.indexOf('all'); 60 | if (allIndex !== -1) { 61 | this.ids[ allIndex ] = '_all'; 62 | } 63 | 64 | //////////////////////////////////////////////////////////////////////////// 65 | // Define The Protected Properties 66 | //////////////////////////////////////////////////////////////////////////// 67 | 68 | /** 69 | * ----------------------------------------------- 70 | * Protected Property (Sources.data) 71 | * ----------------------------------------------- 72 | * @desc Saves a hash map of the source objects using the ids as keys. 73 | * @type {Object} 74 | * @private 75 | */ 76 | var data; 77 | 78 | //////////////////////////////////////////////////////////////////////////// 79 | // Setup The Protected Properties 80 | //////////////////////////////////////////////////////////////////////////// 81 | 82 | /** @type {string} */ 83 | var sourceId; 84 | /** @type {number} */ 85 | var i; 86 | 87 | data = {}; 88 | 89 | // Build the data hash map 90 | i = this.len; 91 | while (i--) { 92 | sourceId = this.ids[i]; 93 | data[ sourceId ] = new Source(sources[ sourceId ]); 94 | } 95 | 96 | // Deep freeze 97 | freezeObj(data, true); 98 | 99 | //////////////////////////////////////////////////////////////////////////// 100 | // Define & Setup The Public Methods 101 | //////////////////////////////////////////////////////////////////////////// 102 | 103 | /** 104 | * ----------------------------------------------- 105 | * Public Method (Sources.get) 106 | * ----------------------------------------------- 107 | * @desc Get a Source's object or protected property. 108 | * @param {string} id - The source id to get. 109 | * @param {string=} prop - The property to get. 110 | * @return {!(Source|string|numbers)} 111 | */ 112 | this.get = function(id, prop) { 113 | 114 | /** @type {string} */ 115 | var errorMsg; 116 | /** @type {!Source} */ 117 | var source; 118 | /** @type {!(Source|string|numbers)} */ 119 | var result; 120 | 121 | checkArgs(id, 'string', prop, 'string='); 122 | 123 | if ( !hasOwnProp(data, id) ) { 124 | errorMsg = 'An aIV.app internal error occurred. A Sources.get call '; 125 | errorMsg += 'was given an invalid source id to get. sourceID= ' + id; 126 | throw new Error(errorMsg); 127 | } 128 | 129 | prop = prop || ''; 130 | source = data[ id ]; 131 | result = (prop) ? source.get(prop) : source; 132 | 133 | return result; 134 | }; 135 | 136 | //////////////////////////////////////////////////////////////////////////// 137 | // End Of The Class Setup 138 | //////////////////////////////////////////////////////////////////////////// 139 | 140 | // Deep freeze 141 | freezeObj(this, true); 142 | 143 | }; 144 | 145 | //////////////////////////////////////////////////////////////////////////////// 146 | // The Prototype Methods 147 | //////////////////////////////////////////////////////////////////////////////// 148 | 149 | Sources.prototype.constructor = Sources; 150 | 151 | /** 152 | * ----------------------------------------------------- 153 | * Public Method (Sources.prototype.freezeIds) 154 | * ----------------------------------------------------- 155 | * @desc Freezes the ids array for each source. 156 | * @type {function} 157 | */ 158 | Sources.prototype.freezeIds = function() { 159 | 160 | /** @type {string} */ 161 | var id; 162 | /** @type {number} */ 163 | var i; 164 | 165 | i = this.len; 166 | while (i--) { 167 | id = this.ids[i]; 168 | this.get(id).freezeIds(); 169 | } 170 | 171 | }; 172 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/module-api.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Variable (appModuleAPI) 4 | * ----------------------------------------------------- 5 | * @desc Holds the app module's public properties and methods. 6 | * @type {!Object} 7 | * @struct 8 | */ 9 | var appModuleAPI = {}; 10 | 11 | /** 12 | * ----------------------------------------------------- 13 | * Public Method (appModuleAPI.startApp) 14 | * ----------------------------------------------------- 15 | * @desc Initializes the app. 16 | * @param {Object} settings - The app's settings. 17 | */ 18 | appModuleAPI.startApp = function(settings) { 19 | 20 | /** @type {?(string|strings)} */ 21 | var resourceList; 22 | /** @type {objectMap} */ 23 | var config; 24 | /** @type {stringMap} */ 25 | var sources; 26 | /** @type {(objectMap|stringMap)} */ 27 | var categories; 28 | /** @type {!objects} */ 29 | var questions; 30 | /** @type {function} */ 31 | var setup; 32 | /** @type {function} */ 33 | var callback; 34 | /** @type {string} */ 35 | var types; 36 | /** @type {number} */ 37 | var i; 38 | 39 | if (appHasBeenInitialized) { 40 | throw new Error('The aIV.app init call was made a second time.'); 41 | } 42 | 43 | // Save the init of this app to prevent second init 44 | appHasBeenInitialized = true; 45 | 46 | if ( !checkType(settings, '!object') ) { 47 | settings = {}; 48 | } 49 | 50 | // Setup the app arguments 51 | resourceList = ( ( hasOwnProp(settings, 'resources') ) ? 52 | settings.resources : null 53 | ); 54 | config = ( ( hasOwnProp(settings, 'config') ) ? 55 | settings.config : ( hasOwnProp(settings, 'configuration') ) ? 56 | settings.configuration : null 57 | ); 58 | sources = ( ( hasOwnProp(settings, 'sources') ) ? 59 | settings.sources : ( hasOwnProp(settings, 'source') ) ? 60 | settings.source : null 61 | ); 62 | categories = ( ( hasOwnProp(settings, 'categories') ) ? 63 | settings.categories : ( hasOwnProp(settings, 'category') ) ? 64 | settings.category : null 65 | ); 66 | questions = ( ( hasOwnProp(settings, 'questions') ) ? 67 | settings.questions : ( hasOwnProp(settings, 'question') ) ? 68 | settings.question : [] 69 | ); 70 | 71 | // Check the types of the arguments 72 | if ( !checkType(resourceList, 'string|strings') ) { 73 | types = 'null, a string, or an array of strings'; 74 | logStartAppTypeError('resources', types, getTypeOf(resourceList)); 75 | resourceList = null; 76 | } 77 | if ( !checkType(config, 'objectMap') ) { 78 | types = 'null or an object with string => object pairs'; 79 | logStartAppTypeError('config', types, getTypeOf(config)); 80 | config = null; 81 | } 82 | if ( !checkType(sources, 'stringMap') ) { 83 | types = 'null or an object with string => string pairs'; 84 | logStartAppTypeError('sources', types, getTypeOf(sources)); 85 | sources = null; 86 | } 87 | if ( !checkType(categories, 'stringMap|objectMap') ) { 88 | types = 'null or an object with string => object or '; 89 | types += 'string => string pairs'; 90 | logStartAppTypeError('categories', types, getTypeOf(categories)); 91 | categories = null; 92 | } 93 | if ( !checkType(questions, '!objects') ) { 94 | types = 'an array of question objects'; 95 | logStartAppTypeError('questions', types, getTypeOf(questions)); 96 | questions = []; 97 | } 98 | 99 | // Setup and start the app 100 | setup = function() { 101 | freezeObj(resources); 102 | App.setup(config, sources, categories, questions); 103 | }; 104 | 105 | // Save the resources 106 | if (resourceList) { 107 | 108 | if ( checkType(resourceList, 'string') ) { 109 | getResource(resourceList, setup); 110 | return; 111 | } 112 | 113 | callback = setup; 114 | i = resourceList.length; 115 | while (--i) { 116 | callback = (function(jsonFile, callback) { 117 | return function() { 118 | getResource(jsonFile, callback); 119 | }; 120 | })(resourceList[i], callback); 121 | } 122 | getResource(resourceList[0], callback); 123 | } 124 | else { 125 | setup(); 126 | } 127 | }; 128 | 129 | /** 130 | * ----------------------------------------------------- 131 | * Public Method (appModuleAPI.getResource) 132 | * ----------------------------------------------------- 133 | * @desc Makes the app's resources publically available. 134 | * @param {string=} prop - The specific resource to retrieve. 135 | * @return {*} Either the entire resources object or one of its properties. 136 | */ 137 | appModuleAPI.getResource = function(prop) { 138 | 139 | /** @type {string} */ 140 | var errorMsg; 141 | /** @type {*} */ 142 | var result; 143 | 144 | prop = prop || ''; 145 | 146 | if (prop && !hasOwnProp(resources, prop)) { 147 | errorMsg = 'The resource you requested does not exist. Please verify that \''; 148 | errorMsg += prop + '\' is a correct json file name in the resources folder '; 149 | errorMsg += 'and that the file name was included in the setup of the app '; 150 | errorMsg += '(see algorithmiv.com/docs/resources).'; 151 | console.error(errorMsg); 152 | } 153 | else { 154 | result = (!!prop) ? resources[ prop ] : resources; 155 | } 156 | 157 | return result; 158 | } 159 | 160 | aIV.utils.freezeObj(appModuleAPI); 161 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/module-vars.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * ----------------------------------------------------- 4 | * Public Variable (appHasBeenInitialized) 5 | * ----------------------------------------------------- 6 | * @desc Indicates whether the app has been initialized. 7 | * @type {boolean} 8 | */ 9 | var appHasBeenInitialized = false; 10 | 11 | /** 12 | * ----------------------------------------------- 13 | * Public Variable (resources) 14 | * ----------------------------------------------- 15 | * @desc The resources for the app. 16 | * @type {!Object} 17 | */ 18 | var resources = {}; 19 | 20 | /** 21 | * ----------------------------------------------- 22 | * Public Variable (app) 23 | * ----------------------------------------------- 24 | * @desc The app instance. 25 | * @type {!{ 26 | * 27 | * 28 | * }} 29 | */ 30 | var app = {}; 31 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/pre-compiled-prettifier/pre-compiled-syntax-highlighter/highlight-syntax-vars.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * --------------------------------------------- 4 | * Private Variable (newLine) 5 | * --------------------------------------------- 6 | * @desc The formatted line of code. 7 | * @type {strings} 8 | * @private 9 | */ 10 | var newLine; 11 | 12 | /** 13 | * --------------------------------------------- 14 | * Private Variable (orgLine) 15 | * --------------------------------------------- 16 | * @desc The original line of code. 17 | * @type {strings} 18 | * @private 19 | */ 20 | var orgLine; 21 | 22 | /** 23 | * --------------------------------------------- 24 | * Private Variable (lineLen) 25 | * --------------------------------------------- 26 | * @desc The length of the line of code. 27 | * @type {number} 28 | * @private 29 | */ 30 | var lineLen; 31 | 32 | /** 33 | * --------------------------------------------- 34 | * Private Variable (lastIndex) 35 | * --------------------------------------------- 36 | * @desc The last index of the line of code. 37 | * @type {number} 38 | * @private 39 | */ 40 | var lastIndex; 41 | 42 | /** 43 | * --------------------------------------------- 44 | * Private Variable (router) 45 | * --------------------------------------------- 46 | * @desc A hash map that stores the matching character 47 | * formatting methods. 48 | * @type {!objectMap} 49 | * @private 50 | */ 51 | var router = { 52 | "'": formatString, 53 | '"': formatString, 54 | ' ': formatSpace, 55 | '{': formatBracket, 56 | '[': formatBracket, 57 | '(': formatBracket, 58 | ')': formatBracket, 59 | ']': formatBracket, 60 | '}': formatBracket, 61 | '*': formatOperator, 62 | '%': formatOperator, 63 | '+': formatOperator, 64 | '-': formatOperator, 65 | '<': formatOperator, 66 | '>': formatOperator, 67 | '&': formatOperator, 68 | '^': formatOperator, 69 | '|': formatOperator, 70 | '=': formatOperator, 71 | '!': formatOperator, 72 | '~': formatOperator, 73 | '?': formatOperator, 74 | ',': formatComma, 75 | ';': formatSemicolon, 76 | ':': formatColon, 77 | '.': formatPeriod, 78 | '0': formatNumber, 79 | '1': formatNumber, 80 | '2': formatNumber, 81 | '3': formatNumber, 82 | '4': formatNumber, 83 | '5': formatNumber, 84 | '6': formatNumber, 85 | '7': formatNumber, 86 | '8': formatNumber, 87 | '9': formatNumber, 88 | '/': handleSlash 89 | }; 90 | 91 | freezeObj(router); 92 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/pre-compiled-prettifier/pre-compiled-syntax-highlighter/highlight-syntax.js: -------------------------------------------------------------------------------- 1 | /** 2 | * --------------------------------------------- 3 | * Private Method (highlightSyntax) 4 | * --------------------------------------------- 5 | * @desc Adds spans around reserved code characters to highlight 6 | * specific syntax for a line of code. 7 | * @param {string} line - The line of code to highlight. 8 | * @return {string} 9 | * @private 10 | */ 11 | var highlightSyntax = (function() { 12 | 13 | var highlightSyntax = function(line) { 14 | 15 | checkArgs(line, 'string'); 16 | 17 | prepareLine(line); 18 | formatLine(); 19 | 20 | return newLine.join(''); 21 | }; 22 | 23 | /* ----------------------------------------------------------------------------- 24 | * The Highlight Syntax Variables (pre-compiled-prettifier/ 25 | * pre-compiled-syntax-highlighter/ 26 | * highlight-syntax-vars.js) 27 | * -------------------------------------------------------------------------- */ 28 | // insert-highlight-syntax-vars 29 | 30 | /* ----------------------------------------------------------------------------- 31 | * The Highlight Syntax Methods (pre-compiled-prettifier/ 32 | * pre-compiled-syntax-highlighter/ 33 | * highlight-syntax-methods.js) 34 | * -------------------------------------------------------------------------- */ 35 | // insert-highlight-syntax-methods 36 | 37 | return highlightSyntax; 38 | 39 | })(); 40 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/pre-compiled-prettifier/prettify-methods.js: -------------------------------------------------------------------------------- 1 | /** 2 | * --------------------------------------------- 3 | * Public Method (prettify.setConfig) 4 | * --------------------------------------------- 5 | * @desc Sets the config settings for the prettifier. 6 | * @param {!Object} newConfig - The config 7 | * settings for the prettifier. 8 | * @private 9 | */ 10 | prettify.setConfig = function(newConfig) { 11 | 12 | checkArgs(newConfig, '!object'); 13 | 14 | config = newConfig; 15 | freezeObj(config); 16 | 17 | } 18 | 19 | /** 20 | * --------------------------------------------- 21 | * Private Method (prepareLines) 22 | * --------------------------------------------- 23 | * @desc Standardizes all line breaks and replaces tabs with spaces. 24 | * @param {string} solution - The problem's solution to be formatted. 25 | * @return {!strings} 26 | * @private 27 | */ 28 | function prepareLines(solution) { 29 | 30 | /** @type {!strings} */ 31 | var lines; 32 | /** @type {string} */ 33 | var spaces; 34 | /** @type {number} */ 35 | var spaceCount; 36 | 37 | checkArgs(solution, 'string'); 38 | 39 | // Standardize all line breaks 40 | solution = solution.replace(/\r\n?/g, '\n'); 41 | 42 | // Replace all tabs with spaces 43 | spaces = ''; 44 | spaceCount = config.tabLength; 45 | while (spaceCount--) { 46 | spaces += ' '; 47 | } 48 | if (spaces) { 49 | solution = solution.replace(/\t/g, ' '); 50 | } 51 | 52 | lines = solution.split('\n'); 53 | 54 | return lines; 55 | } 56 | 57 | /** 58 | * --------------------------------------------- 59 | * Private Method (applyFormatting) 60 | * --------------------------------------------- 61 | * @desc Applies the prettifier formats. 62 | * @param {!strings} lines - An array of code lines. 63 | * @return {!{ 64 | * result : string, 65 | * lineCount: number 66 | * }} 67 | * @private 68 | */ 69 | function applyFormatting(lines) { 70 | 71 | /** @type {number} */ 72 | var i; 73 | /** @type {number} */ 74 | var len; 75 | /** @type {string} */ 76 | var line; 77 | /** @type {!Object} */ 78 | var result; 79 | 80 | checkArgs(lines, '!strings'); 81 | 82 | commentOpen = false; 83 | len = lines.length; 84 | 85 | i = -1; 86 | while (++i < len) { 87 | 88 | line = prepareLine(lines[i]); 89 | 90 | if (line) { 91 | line = highlightSyntax(line, i); 92 | } 93 | 94 | lines[i] = '
  • '+ line +'
  • '; 95 | 96 | } 97 | 98 | result = { 99 | result : lines.join(''), 100 | lineCount: len 101 | }; 102 | 103 | return result; 104 | } 105 | 106 | /** 107 | * --------------------------------------------- 108 | * Private Method (prepareLine) 109 | * --------------------------------------------- 110 | * @desc Removes whitespaces from line beginning and end. 111 | * @param {string} line - The line of code to prepare. 112 | * @return {string} 113 | * @private 114 | */ 115 | function prepareLine(line) { 116 | 117 | /** @type {number} */ 118 | var i; 119 | /** @type {number} */ 120 | var frontTrimCount; 121 | /** @type {string} */ 122 | var trimPart; 123 | 124 | checkArgs(line, 'string'); 125 | 126 | // Trim ending whitespaces 127 | if (line) { 128 | i = line.length - 1; 129 | if (line.charAt(i) === ' ') { 130 | --i; 131 | while (line.charAt(i) === ' ') { 132 | --i; 133 | } 134 | line = line.substr(0, i); 135 | } 136 | } 137 | 138 | // Trim beginning whitespaces 139 | frontTrimCount = config.trimSpace; 140 | if (line && frontTrimCount) { 141 | 142 | trimPart = ( (frontTrimCount < line.length) ? 143 | line.substr(0, frontTrimCount) : '' 144 | ); 145 | if (trimPart && !notSpace.test(trimPart)) { 146 | // Trim full count 147 | line = line.substr(frontTrimCount); 148 | } 149 | else { 150 | // Trim partial count 151 | i = 0; 152 | while (line.charAt(i) === ' ') { 153 | ++i; 154 | } 155 | line = line.substr(i); 156 | } 157 | } 158 | 159 | return line; 160 | } 161 | 162 | /** 163 | * --------------------------------------------- 164 | * Private Method (makeKeywordObj) 165 | * --------------------------------------------- 166 | * @desc Creates a keyword object. 167 | * @param {string} cat - The keyword's category. 168 | * @param {string=} href - The keyword's details link. 169 | * @param {boolean=} props - Whether the keyword has properties. 170 | * @return {!Object} 171 | * @private 172 | */ 173 | function makeKeywordObj(cat, href, props) { 174 | 175 | /** @type {!Object} */ 176 | var obj; 177 | 178 | checkArgs(cat, 'string', href, 'string=', props, 'boolean='); 179 | 180 | href = href || ''; 181 | props = props || false; 182 | 183 | obj = {}; 184 | 185 | obj.cat = cat; 186 | obj.href = href; 187 | obj.props = (props) ? {} : false; 188 | 189 | freezeObj(obj); 190 | 191 | return obj; 192 | } 193 | 194 | /** 195 | * --------------------------------------------- 196 | * Private Method (makePropObj) 197 | * --------------------------------------------- 198 | * @desc Creates a keyword property object. 199 | * @param {string=} href - The keyword's details link. 200 | * @return {!stringMap} 201 | * @private 202 | */ 203 | function makePropObj(href) { 204 | 205 | /** @type {!stringMap} */ 206 | var obj; 207 | 208 | checkArgs(href, 'string='); 209 | 210 | href = href || ''; 211 | 212 | obj = {}; 213 | obj.href = href; 214 | 215 | freezeObj(obj); 216 | 217 | return obj; 218 | } 219 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/pre-compiled-prettifier/prettify.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Method (prettify) 4 | * ----------------------------------------------------- 5 | * @desc The prettifier for this app. 6 | * @param {string} solution - The problem's solution to be formatted. 7 | * @return {{ 8 | * result : string, 9 | * lineCount: number 10 | * }} 11 | */ 12 | var prettify = (function() { 13 | 14 | var prettify = function(solution) { 15 | 16 | /** @type {{ result: string, lineCount: number }} */ 17 | var result; 18 | 19 | checkArgs(solution, 'string'); 20 | 21 | // Format the solution 22 | result = applyFormatting( prepareLines(solution) ); 23 | 24 | return result; 25 | }; 26 | 27 | /* ----------------------------------------------------------------------------- 28 | * The Prettifier Module Variables (pre-compiled-prettifier/prettify-vars.js) 29 | * -------------------------------------------------------------------------- */ 30 | // insert-prettify-vars 31 | 32 | /* ----------------------------------------------------------------------------- 33 | * The Prettifier Module Methods (pre-compiled-prettifier/prettify-methods.js) 34 | * -------------------------------------------------------------------------- */ 35 | // insert-prettify-methods 36 | 37 | /* ----------------------------------------------------------------------------- 38 | * The Highlight Syntax Method (pre-compiled-prettifier/highlight-syntax.js) 39 | * -------------------------------------------------------------------------- */ 40 | // insert-highlight-syntax 41 | 42 | return prettify; 43 | 44 | })(); 45 | -------------------------------------------------------------------------------- /src/pre-compiled-parts/public-api.js: -------------------------------------------------------------------------------- 1 | /** 2 | * --------------------------------------------------- 3 | * Global Variable (aIV) 4 | * --------------------------------------------------- 5 | * @desc Holds the public API for aIV's apps, tools, and libraries. 6 | * @struct 7 | * @global 8 | */ 9 | window.aIV = window.aIV || {}; 10 | 11 | /** 12 | * --------------------------------------------------- 13 | * Global Method (aIV.app) 14 | * --------------------------------------------------- 15 | * @desc Initializes the aIV question management app. 16 | * @param {!Object} settings - The app's settings. 17 | * @param {objectMap=} settings.config - The app's configuration. 18 | * @param {stringMap=} settings.sources - The app's sources. 19 | * @param {(objectMap|stringMap)=} settings.categories - The app's categories. 20 | * @param {!objects} settings.questions - The app's questions. 21 | * @param {(string|strings)=} settings.resources - The app's resources. 22 | * @global 23 | */ 24 | aIV.app = appModuleAPI.startApp; 25 | 26 | /** 27 | * --------------------------------------------------- 28 | * Global Method (aIV.app.getResource) 29 | * --------------------------------------------------- 30 | * @desc Makes the app's resources publically available. 31 | * @param {string=} prop - The specific resource to retrieve. 32 | * @return {*} Either the entire resources object or one of its properties. 33 | * @global 34 | */ 35 | aIV.app.getResource = appModuleAPI.getResource; 36 | -------------------------------------------------------------------------------- /tests/algorithmIV-tests.css: -------------------------------------------------------------------------------- 1 | /* Algorithm IV Question Manager (v1.1.2) (imagineadamsmith@gmail.com) 2 | * Section: CSS - Tests Style Guide 3 | * Author: Adam Smith 4 | * Copyright (c) 2022 Adam A Smith 5 | * The Apache License (www.apache.org/licenses/LICENSE-2.0) */ 6 | 7 | /* ------------------------------- * 8 | * New Section: 9 | * ------------------------------- * 10 | * Interaction Container 11 | * ------------------------------- */ 12 | 13 | #aIV-tests { 14 | display:block; 15 | width:90%; 16 | padding:20px; 17 | margin:0 auto; 18 | text-align:center; 19 | background:#d8f0fa; 20 | } 21 | @media only screen and (min-width:600px) { 22 | #aIV-tests { 23 | width:560px; 24 | padding:30px; 25 | } 26 | } 27 | @media only screen and (min-width:1200px) { 28 | #aIV-tests { 29 | width:700px; 30 | padding:40px; 31 | } 32 | } 33 | 34 | /* ------------------------------- * 35 | * New Section: 36 | * ------------------------------- * 37 | * UI Container 38 | * ------------------------------- */ 39 | 40 | #aIV-tests .ui { 41 | display:block; 42 | width:100%; 43 | min-height:99px; 44 | text-align:center; 45 | font-size:0; 46 | opacity:1; 47 | -webkit-transition:opacity 500ms; 48 | -moz-transition:opacity 500ms; 49 | -o-transition:opacity 500ms; 50 | transition:opacity 500ms; 51 | } 52 | 53 | /* ------------------------------- * 54 | * New Section: 55 | * ------------------------------- * 56 | * Messages 57 | * ------------------------------- */ 58 | 59 | #aIV-tests .msg { 60 | display:block; 61 | min-height:34px; 62 | padding:0; 63 | margin:0 auto 40px; 64 | text-align:center; 65 | line-height:34px; 66 | color:#192037; 67 | font-size:23px; 68 | font-weight:400; 69 | } 70 | 71 | #aIV-tests a { 72 | color:inherit; 73 | } 74 | #aIV-tests a:active, 75 | #aIV-tests a:hover { 76 | text-decoration:none; 77 | } 78 | 79 | /* ------------------------------- * 80 | * New Section: 81 | * ------------------------------- * 82 | * Start 83 | * ------------------------------- */ 84 | 85 | #aIV-tests .start { 86 | display:block; 87 | width:200px; 88 | height:45px; 89 | padding:0; 90 | margin:0 auto; 91 | line-height:45px; 92 | text-align:center; 93 | color:#fff; 94 | font-size:24px; 95 | font-weight:700; 96 | background:#000821; 97 | cursor:pointer; 98 | -webkit-transition:background 500ms; 99 | -moz-transition:background 500ms; 100 | -o-transition:background 500ms; 101 | transition:background 500ms; 102 | } 103 | 104 | #aIV-tests .start:hover, 105 | #aIV-tests .start:active { 106 | background:#002287; 107 | } 108 | -------------------------------------------------------------------------------- /tests/images/aIV-icon.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/aIV-icon.ai -------------------------------------------------------------------------------- /tests/images/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/apple-touch-icon.png -------------------------------------------------------------------------------- /tests/images/arrows-small.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/arrows-small.psd -------------------------------------------------------------------------------- /tests/images/arrows.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/arrows.psd -------------------------------------------------------------------------------- /tests/images/ext-close-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/ext-close-small.png -------------------------------------------------------------------------------- /tests/images/ext-open-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/ext-open-small.png -------------------------------------------------------------------------------- /tests/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/favicon.ico -------------------------------------------------------------------------------- /tests/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/favicon.png -------------------------------------------------------------------------------- /tests/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/loading.gif -------------------------------------------------------------------------------- /tests/images/next-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/next-small.png -------------------------------------------------------------------------------- /tests/images/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/next.png -------------------------------------------------------------------------------- /tests/images/prev-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/prev-small.png -------------------------------------------------------------------------------- /tests/images/prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/prev.png -------------------------------------------------------------------------------- /tests/images/tile-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imaginate/algorithmIV-question-manager/f06a6cb09f279afe3ef5783b74d7654950a07c6a/tests/images/tile-icon.png -------------------------------------------------------------------------------- /tests/pre-compiled-app/classes/categories.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (Categories) 4 | * ----------------------------------------------------- 5 | * @desc The available categories for each question. 6 | * @param {?(objectMap|stringMap)} categories - The user's categories. 7 | * @constructor 8 | */ 9 | var Categories = function(categories) { 10 | 11 | var thisDebug; 12 | 13 | this.debug = aIV.debug('Categories'); 14 | thisDebug = this.debug; 15 | 16 | this.debug.start('init', categories); 17 | 18 | checkArgs(categories, 'objectMap|stringMap'); 19 | 20 | //////////////////////////////////////////////////////////////////////////// 21 | // Prepare The User Supplied Params 22 | //////////////////////////////////////////////////////////////////////////// 23 | 24 | if ( checkType(categories, '!stringMap') ) { 25 | categories = { 26 | main: categories, 27 | sub : {} 28 | }; 29 | } 30 | else { 31 | if (!categories) { 32 | categories = {}; 33 | } 34 | if (!categories.main || !checkType(categories.main, '!stringMap')) { 35 | categories.main = {}; 36 | } 37 | if (!categories.sub || !checkType(categories.sub, '!objectMap')) { 38 | categories.sub = {}; 39 | } 40 | } 41 | 42 | //////////////////////////////////////////////////////////////////////////// 43 | // Define The Public Properties 44 | //////////////////////////////////////////////////////////////////////////// 45 | 46 | /** 47 | * ----------------------------------------------- 48 | * Public Property (Categories.ids) 49 | * ----------------------------------------------- 50 | * @desc Saves an array of all the main category ids in alphabetical order. 51 | * @type {!strings} 52 | */ 53 | this.ids; 54 | 55 | /** 56 | * ----------------------------------------------- 57 | * Public Property (Categories.len) 58 | * ----------------------------------------------- 59 | * @desc Saves the count of main categories. 60 | * @type {number} 61 | */ 62 | this.len; 63 | 64 | //////////////////////////////////////////////////////////////////////////// 65 | // Setup The Public Properties 66 | //////////////////////////////////////////////////////////////////////////// 67 | 68 | /** @type {number} */ 69 | var allIndex; 70 | 71 | this.ids = Object.keys(categories.main); 72 | this.len = this.ids.length; 73 | 74 | // Sort the main category ids 75 | if (this.len) { 76 | this.ids = sortKeys(this.ids, categories.main); 77 | } 78 | 79 | // Fix a category with the id of all 80 | allIndex = this.ids.indexOf('all'); 81 | if (allIndex !== -1) { 82 | this.ids[ allIndex ] = '_all'; 83 | } 84 | 85 | //////////////////////////////////////////////////////////////////////////// 86 | // Define The Protected Properties 87 | //////////////////////////////////////////////////////////////////////////// 88 | 89 | /** 90 | * ----------------------------------------------- 91 | * Protected Property (Categories.data) 92 | * ----------------------------------------------- 93 | * @desc Saves a hash map of the category objects using the ids as keys. 94 | * @type {!Object} 95 | * @private 96 | */ 97 | var data; 98 | 99 | //////////////////////////////////////////////////////////////////////////// 100 | // Setup The Protected Properties 101 | //////////////////////////////////////////////////////////////////////////// 102 | 103 | /** @type {strings} */ 104 | var subIds; 105 | /** @type {string} */ 106 | var mainId; 107 | /** @type {string} */ 108 | var subId; 109 | /** @type {number} */ 110 | var ii; 111 | /** @type {number} */ 112 | var i; 113 | 114 | data = {}; 115 | 116 | // Build the data hash map 117 | i = this.len; 118 | while (i--) { 119 | mainId = this.ids[i]; 120 | 121 | // Save and sort the sub category ids if they exist 122 | subIds = ( (hasOwnProp(categories.sub, mainId)) ? 123 | Object.keys(categories.sub[ mainId ]) : [] 124 | ); 125 | if (subIds.length) { 126 | subIds = sortKeys(subIds, categories.sub[ mainId ]); 127 | } 128 | 129 | // Add main category to the hash map 130 | data[ mainId ] = new Category(categories.main[ mainId ], subIds); 131 | 132 | // Add the sub categories to the hash map 133 | ii = subIds.length; 134 | while (ii--) { 135 | subId = subIds[ii]; 136 | data[ subId ] = new Category(categories.sub[ mainId ][ subId ]); 137 | } 138 | } 139 | 140 | // Deep freeze 141 | freezeObj(data, true); 142 | 143 | //////////////////////////////////////////////////////////////////////////// 144 | // Define & Setup The Public Methods 145 | //////////////////////////////////////////////////////////////////////////// 146 | 147 | /** 148 | * ----------------------------------------------- 149 | * Public Property (Categories.get) 150 | * ----------------------------------------------- 151 | * @desc Get a Catgory's object or protected property. 152 | * @param {string} id - The category id to get. 153 | * @param {string=} prop - The property to get. 154 | * @return {!(Category|string|numbers|boolean)} 155 | */ 156 | this.get = function(id, prop) { 157 | 158 | thisDebug.start('get', id, prop); 159 | 160 | /** @type {!Category} */ 161 | var category; 162 | /** @type {!(Category|string|numbers)} */ 163 | var result; 164 | 165 | checkArgs(id, 'string', prop, 'string='); 166 | 167 | if ( hasOwnProp(data, id) ) { 168 | prop = prop || ''; 169 | category = data[ id ]; 170 | result = (prop) ? category.get(prop) : category; 171 | } 172 | else { 173 | result = false; 174 | } 175 | 176 | thisDebug.end('get', result); 177 | 178 | return result; 179 | }; 180 | 181 | //////////////////////////////////////////////////////////////////////////// 182 | // End Of The Class Setup 183 | //////////////////////////////////////////////////////////////////////////// 184 | 185 | // Deep freeze 186 | freezeObj(this, true); 187 | 188 | this.debug.end('init'); 189 | }; 190 | 191 | //////////////////////////////////////////////////////////////////////////////// 192 | // The Prototype Methods 193 | //////////////////////////////////////////////////////////////////////////////// 194 | 195 | Categories.prototype.constructor = Categories; 196 | 197 | /** 198 | * ----------------------------------------------------- 199 | * Public Method (Categories.prototype.freezeIds) 200 | * ----------------------------------------------------- 201 | * @desc Freezes the ids array for each category. 202 | * @type {function} 203 | */ 204 | Categories.prototype.freezeIds = function() { 205 | 206 | this.debug.start('freezeIds'); 207 | 208 | /** @type {string} */ 209 | var id; 210 | /** @type {number} */ 211 | var i; 212 | 213 | i = this.len; 214 | while (i--) { 215 | id = this.ids[i]; 216 | this.get(id).freezeIds(); 217 | } 218 | 219 | this.debug.end('freezeIds'); 220 | }; 221 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/classes/category.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (Category) 4 | * ----------------------------------------------------- 5 | * @desc An object containing the details of a category. 6 | * @param {string} name - The name of the category. 7 | * @param {?strings=} subs - This category's sub ids if they exist. 8 | * If null then category is a sub category. 9 | * @constructor 10 | */ 11 | var Category = function(name, subs) { 12 | 13 | var thisDebug; 14 | 15 | this.debug = aIV.debug('Category'); 16 | thisDebug = this.debug; 17 | 18 | this.debug.start('init', name, subs); 19 | 20 | checkArgs(name, 'string', subs, 'strings='); 21 | 22 | //////////////////////////////////////////////////////////////////////////// 23 | // Define The Protected Properties 24 | //////////////////////////////////////////////////////////////////////////// 25 | 26 | /** 27 | * ----------------------------------------------- 28 | * Protected Property (Category.url) 29 | * ----------------------------------------------- 30 | * @desc The url name for this category. 31 | * @type {string} 32 | * @private 33 | */ 34 | var url; 35 | 36 | /** 37 | * ----------------------------------------------- 38 | * Protected Property (Category.ids) 39 | * ----------------------------------------------- 40 | * @desc The ids of the questions containing this category. 41 | * @type {!numbers} 42 | * @private 43 | */ 44 | var ids; 45 | 46 | //////////////////////////////////////////////////////////////////////////// 47 | // Setup The Protected Properties 48 | //////////////////////////////////////////////////////////////////////////// 49 | 50 | if (!name || !checkType(name, 'string')) { 51 | name = ''; 52 | url = ''; 53 | } 54 | else { 55 | url = makeUrl(name); 56 | } 57 | ids = []; 58 | subs = (subs) ? freezeObj(subs) : null; 59 | 60 | //////////////////////////////////////////////////////////////////////////// 61 | // Define & Setup The Public Methods 62 | //////////////////////////////////////////////////////////////////////////// 63 | 64 | /** 65 | * ----------------------------------------------- 66 | * Public Method (Category.get) 67 | * ----------------------------------------------- 68 | * @desc Gets a protected property's value from the category. 69 | * @param {string} propName - The name of the property to get. 70 | * @return {(string|!numbers)} 71 | */ 72 | this.get = function(propName) { 73 | 74 | /** @type {Object} */ 75 | var props = { 76 | debug: thisDebug, 77 | name: name, 78 | url : url, 79 | subs: subs, 80 | ids : ids 81 | }; 82 | 83 | return getter.call(props, propName); 84 | }; 85 | 86 | /** 87 | * ----------------------------------------------- 88 | * Public Method (Category.addId) 89 | * ----------------------------------------------- 90 | * @desc Adds a question id to this category. 91 | * @param {number} id - The id to add. 92 | */ 93 | this.addId = function(id) { 94 | 95 | this.debug.start('addId', id); 96 | 97 | /** @type {string} */ 98 | var errorMsg; 99 | 100 | checkArgs(id, 'number'); 101 | 102 | if (id < 1) { 103 | errorMsg = 'An aIV.app internal error occurred. A Category.addId '; 104 | errorMsg += 'call was given an invalid question id to add. id= ' + id; 105 | throw new Error(errorMsg); 106 | } 107 | 108 | ids.push(id); 109 | 110 | this.debug.end('addId'); 111 | }; 112 | 113 | /** 114 | * ----------------------------------------------- 115 | * Public Method (Category.freezeIds) 116 | * ----------------------------------------------- 117 | * @desc Freezes this category's question ids. 118 | * @type {function} 119 | */ 120 | this.freezeIds = function() { 121 | 122 | this.debug.start('freezeIds'); 123 | 124 | freezeObj(ids); 125 | 126 | this.debug.end('freezeIds'); 127 | }; 128 | 129 | //////////////////////////////////////////////////////////////////////////// 130 | // End Of The Class Setup 131 | //////////////////////////////////////////////////////////////////////////// 132 | 133 | this.debug.end('init'); 134 | }; 135 | 136 | //////////////////////////////////////////////////////////////////////////////// 137 | // The Prototype Methods 138 | //////////////////////////////////////////////////////////////////////////////// 139 | 140 | Category.prototype.constructor = Category; 141 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/classes/config/config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (Config) 4 | * ----------------------------------------------------- 5 | * @desc The configuration settings for this app. 6 | * @param {Object} config - The user's config settings. 7 | * @constructor 8 | */ 9 | var Config = function(config) { 10 | 11 | this.debug = aIV.debug('Config'); 12 | 13 | this.debug.start('init', config); 14 | 15 | checkArgs(config, 'objectMap'); 16 | 17 | //////////////////////////////////////////////////////////////////////////// 18 | // Define The Public Properties 19 | //////////////////////////////////////////////////////////////////////////// 20 | 21 | /** 22 | * ----------------------------------------------- 23 | * Public Property (Config.searchBar) 24 | * ----------------------------------------------- 25 | * @desc The search bar's configuration settings. 26 | * @type {SearchBarConfig} 27 | * @struct 28 | */ 29 | this.searchBar; 30 | 31 | /** 32 | * ----------------------------------------------- 33 | * Public Property (Config.questions) 34 | * ----------------------------------------------- 35 | * @desc The question's formatting settings. 36 | * @type {QuestionsConfig} 37 | * @struct 38 | */ 39 | this.questions; 40 | 41 | /** 42 | * ----------------------------------------------- 43 | * Public Property (Config.prettifier) 44 | * ----------------------------------------------- 45 | * @desc The prettifier's settings. 46 | * @type {PrettyConfig} 47 | * @struct 48 | */ 49 | this.prettifier; 50 | 51 | /** 52 | * ----------------------------------------------- 53 | * Public Property (Config.links) 54 | * ----------------------------------------------- 55 | * @desc Whether to display search links for each question. 56 | * @type {LinksConfig} 57 | */ 58 | this.links; 59 | 60 | //////////////////////////////////////////////////////////////////////////// 61 | // Setup The Public Properties 62 | //////////////////////////////////////////////////////////////////////////// 63 | 64 | // Check the given user's config object 65 | if ( !checkType(config, '!object') ) { 66 | config = {}; 67 | } 68 | 69 | if ( !checkType(config.searchSettings, '!object') ) { 70 | config.searchSettings = {}; 71 | } 72 | if ( !checkType(config.questionFormat, '!object') ) { 73 | config.questionFormat = {}; 74 | } 75 | if ( !checkType(config.prettifyFormat, '!object') ) { 76 | config.prettifyFormat = {}; 77 | } 78 | if ( !checkType(config.showLinks, '!object') ) { 79 | config.showLinks = {}; 80 | } 81 | 82 | // Setup the properties 83 | this.searchBar = new SearchBarConfig(config.searchSettings); 84 | this.questions = new QuestionsConfig(config.questionFormat); 85 | this.prettifier = new PrettyConfig(config.prettifyFormat); 86 | this.links = new LinksConfig(config.showLinks); 87 | 88 | //////////////////////////////////////////////////////////////////////////// 89 | // End Of The Class Setup 90 | //////////////////////////////////////////////////////////////////////////// 91 | 92 | freezeObj(this, true); 93 | 94 | this.debug.end('init'); 95 | }; 96 | 97 | //////////////////////////////////////////////////////////////////////////////// 98 | // The Prototype Methods 99 | //////////////////////////////////////////////////////////////////////////////// 100 | 101 | Config.prototype.constructor = Config; 102 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/classes/config/links-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (LinksConfig) 4 | * ----------------------------------------------------- 5 | * @desc The configuration settings for whether to show search links for 6 | * portions of each question. 7 | * @param {!Object} config - The user's config settings 8 | * for search link formatting. 9 | * @constructor 10 | */ 11 | var LinksConfig = function(config) { 12 | 13 | var thisDebug; 14 | 15 | this.debug = aIV.debug('LinksConfig'); 16 | thisDebug = this.debug; 17 | 18 | this.debug.start('init', config); 19 | 20 | checkArgs(config, '!object'); 21 | 22 | //////////////////////////////////////////////////////////////////////////// 23 | // Define The Protected Properties 24 | //////////////////////////////////////////////////////////////////////////// 25 | 26 | /** 27 | * ----------------------------------------------- 28 | * Protected Property (LinksConfig.id) 29 | * ----------------------------------------------- 30 | * @desc Whether to display an id search option for every question. 31 | * @type {boolean} 32 | * @private 33 | */ 34 | var id; 35 | 36 | /** 37 | * ------------------------------------------------- 38 | * Protected Property (LinksConfig.source) 39 | * ------------------------------------------------- 40 | * @desc Whether to display a source search option for every question. 41 | * @type {boolean} 42 | * @private 43 | */ 44 | var source; 45 | 46 | /** 47 | * ---------------------------------------------------- 48 | * Protected Property (LinksConfig.category) 49 | * ---------------------------------------------------- 50 | * @desc Whether to display a category search option in the url. 51 | * @type {boolean} 52 | * @private 53 | */ 54 | var category; 55 | 56 | //////////////////////////////////////////////////////////////////////////// 57 | // Setup The Protected Properties 58 | //////////////////////////////////////////////////////////////////////////// 59 | 60 | id = !(config.id === false); 61 | source = (config.source === true ); 62 | category = !(config.category === false); 63 | 64 | //////////////////////////////////////////////////////////////////////////// 65 | // Define & Setup The Public Methods 66 | //////////////////////////////////////////////////////////////////////////// 67 | 68 | /** 69 | * ----------------------------------------------- 70 | * Public Method (LinksConfig.get) 71 | * ----------------------------------------------- 72 | * @desc Gets a protected property's value from LinksConfig. 73 | * @param {string} prop - The name of the property to get. 74 | * @return {boolean} The property's value. 75 | */ 76 | this.get = function(prop) { 77 | 78 | /** @type {!Object} */ 79 | var props = { 80 | debug : thisDebug, 81 | id : id, 82 | source : source, 83 | category: category 84 | }; 85 | 86 | return getter.call(props, prop); 87 | }; 88 | 89 | //////////////////////////////////////////////////////////////////////////// 90 | // End Of The Class Setup 91 | //////////////////////////////////////////////////////////////////////////// 92 | 93 | this.debug.end('init'); 94 | }; 95 | 96 | //////////////////////////////////////////////////////////////////////////////// 97 | // The Prototype Methods 98 | //////////////////////////////////////////////////////////////////////////////// 99 | 100 | LinksConfig.prototype.constructor = LinksConfig; 101 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/classes/config/pretty-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (PrettyConfig) 4 | * ----------------------------------------------------- 5 | * @desc The configuration settings for the prettifier. 6 | * @param {!Object} config - The user's 7 | * prettifier configuration settings. 8 | * @constructor 9 | */ 10 | var PrettyConfig = function(config) { 11 | 12 | var thisDebug; 13 | 14 | this.debug = aIV.debug('PrettyConfig'); 15 | thisDebug = this.debug; 16 | 17 | this.debug.start('init', config); 18 | 19 | checkArgs(config, '!object'); 20 | 21 | //////////////////////////////////////////////////////////////////////////// 22 | // Define The Protected Properties 23 | //////////////////////////////////////////////////////////////////////////// 24 | 25 | /** 26 | * ----------------------------------------------- 27 | * Protected Property (PrettyConfig.trimSpace) 28 | * ----------------------------------------------- 29 | * @desc The number of spaces to trim from the beginning of lines. 30 | * @type {number} 31 | * @private 32 | */ 33 | var trimSpace; 34 | 35 | /** 36 | * ----------------------------------------------- 37 | * Protected Property (PrettyConfig.tabLength) 38 | * ----------------------------------------------- 39 | * @desc The number of spaces to convert tab characters. 40 | * @type {number} 41 | * @private 42 | */ 43 | var tabLength; 44 | 45 | /** 46 | * ----------------------------------------------- 47 | * Protected Property (PrettyConfig.commentLinks) 48 | * ----------------------------------------------- 49 | * @desc Whether to allow links in prettified comments. 50 | * @type {boolean} 51 | * @private 52 | */ 53 | var commentLinks; 54 | 55 | //////////////////////////////////////////////////////////////////////////// 56 | // Setup The Protected Properties 57 | //////////////////////////////////////////////////////////////////////////// 58 | 59 | trimSpace = 0; 60 | tabLength = 2; 61 | commentLinks = (config.commentLinks === true); 62 | 63 | if ( hasOwnProp(config, 'trimSpace') ) { 64 | if (checkType(config.trimSpace, 'number') && config.trimSpace >= 0) { 65 | trimSpace = Math.floor(config.trimSpace); 66 | } 67 | else if ( checkType(config.trimSpace, 'string') ) { 68 | config.trimSpace = config.trimSpace.replace(/[^0-9]/g, ''); 69 | if (config.trimSpace) { 70 | trimSpace = Number(config.trimSpace); 71 | } 72 | } 73 | } 74 | 75 | if ( hasOwnProp(config, 'tabLength') ) { 76 | if (checkType(config.tabLength, 'number') && config.tabLength >= 0) { 77 | tabLength = Math.floor(config.tabLength); 78 | } 79 | else if ( checkType(config.tabLength, 'string') ) { 80 | config.tabLength = config.tabLength.replace(/[^0-9]/g, ''); 81 | if (config.tabLength) { 82 | tabLength = Number(config.tabLength); 83 | } 84 | } 85 | } 86 | 87 | //////////////////////////////////////////////////////////////////////////// 88 | // Define & Setup The Public Methods 89 | //////////////////////////////////////////////////////////////////////////// 90 | 91 | /** 92 | * ----------------------------------------------- 93 | * Public Method (PrettyConfig.get) 94 | * ----------------------------------------------- 95 | * @desc Gets a protected property's value from PrettyConfig. 96 | * @param {string} prop - The name of the property to get. 97 | * @return {(number|boolean)} The property's value. 98 | */ 99 | this.get = function(prop) { 100 | 101 | /** @type {!Object} */ 102 | var props = { 103 | debug : thisDebug, 104 | trimSpace : trimSpace, 105 | tabLength : tabLength, 106 | commentLinks: commentLinks 107 | }; 108 | 109 | return getter.call(props, prop); 110 | }; 111 | 112 | //////////////////////////////////////////////////////////////////////////// 113 | // End Of The Class Setup 114 | //////////////////////////////////////////////////////////////////////////// 115 | 116 | this.debug.end('init'); 117 | }; 118 | 119 | //////////////////////////////////////////////////////////////////////////////// 120 | // The Prototype Methods 121 | //////////////////////////////////////////////////////////////////////////////// 122 | 123 | PrettyConfig.prototype.constructor = PrettyConfig; 124 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/classes/config/questions-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (QuestionsConfig) 4 | * ----------------------------------------------------- 5 | * @desc The configuration settings for formatting questions in this app. 6 | * @param {!Object} config - The user's question format config settings. 7 | * @constructor 8 | */ 9 | var QuestionsConfig = function(config) { 10 | 11 | var thisDebug; 12 | 13 | this.debug = aIV.debug('QuestionsConfig'); 14 | thisDebug = this.debug; 15 | 16 | this.debug.start('init', config); 17 | 18 | checkArgs(config, '!object'); 19 | 20 | //////////////////////////////////////////////////////////////////////////// 21 | // Define The Protected Properties 22 | //////////////////////////////////////////////////////////////////////////// 23 | 24 | /** 25 | * ----------------------------------------------- 26 | * Protected Property (QuestionsConfig.id) 27 | * ----------------------------------------------- 28 | * @desc Whether to display any question's id. 29 | * @type {boolean} 30 | * @private 31 | */ 32 | var id; 33 | 34 | /** 35 | * ----------------------------------------------- 36 | * Protected Property (QuestionsConfig.complete) 37 | * ----------------------------------------------- 38 | * @desc Whether to display any question's completion status. 39 | * @type {boolean} 40 | * @private 41 | */ 42 | var complete; 43 | 44 | /** 45 | * ----------------------------------------------- 46 | * Protected Property (QuestionsConfig.source) 47 | * ----------------------------------------------- 48 | * @desc Whether to display any question's source. 49 | * @type {boolean} 50 | * @private 51 | */ 52 | var source; 53 | 54 | /** 55 | * ----------------------------------------------- 56 | * Protected Property (QuestionsConfig.category) 57 | * ----------------------------------------------- 58 | * @desc Whether to display any question's categories. 59 | * @type {boolean} 60 | * @private 61 | */ 62 | var category; 63 | 64 | /** 65 | * ----------------------------------------------- 66 | * Protected Property (QuestionsConfig.subCat) 67 | * ----------------------------------------------- 68 | * @desc Whether to display any question's sub categories. 69 | * @type {boolean} 70 | * @private 71 | */ 72 | var subCat; 73 | 74 | /** 75 | * ----------------------------------------------- 76 | * Protected Property (QuestionsConfig.links) 77 | * ----------------------------------------------- 78 | * @desc Whether to display any question's links. 79 | * @type {boolean} 80 | * @private 81 | */ 82 | var links; 83 | 84 | /** 85 | * ----------------------------------------------- 86 | * Protected Property (QuestionsConfig.problem) 87 | * ----------------------------------------------- 88 | * @desc Whether to display any question's problem. 89 | * @type {boolean} 90 | * @private 91 | */ 92 | var problem; 93 | 94 | /** 95 | * ----------------------------------------------- 96 | * Protected Property (QuestionsConfig.descr) 97 | * ----------------------------------------------- 98 | * @desc Whether to display any question's description. 99 | * @type {boolean} 100 | * @private 101 | */ 102 | var descr; 103 | 104 | /** 105 | * ----------------------------------------------- 106 | * Protected Property (QuestionsConfig.output) 107 | * ----------------------------------------------- 108 | * @desc Whether to display the solution's output for any question. 109 | * @type {boolean} 110 | * @private 111 | */ 112 | var output; 113 | 114 | //////////////////////////////////////////////////////////////////////////// 115 | // Setup The Protected Properties 116 | //////////////////////////////////////////////////////////////////////////// 117 | 118 | id = !(config.id === false); 119 | complete = !(config.complete === false); 120 | source = !(config.source === false); 121 | category = !(config.category === false); 122 | subCat = !(config.subCat === false); 123 | links = !(config.links === false); 124 | problem = !(config.problem === false); 125 | descr = (config.descr === true ); 126 | output = !(config.output === false); 127 | 128 | //////////////////////////////////////////////////////////////////////////// 129 | // Define & Setup The Public Methods 130 | //////////////////////////////////////////////////////////////////////////// 131 | 132 | /** 133 | * ----------------------------------------------- 134 | * Public Method (QuestionsConfig.get) 135 | * ----------------------------------------------- 136 | * @desc Gets a protected property's value from QuestionsConfig. 137 | * @param {string} prop - The name of the property to get. 138 | * @return {boolean} The property's value. 139 | */ 140 | this.get = function(prop) { 141 | 142 | /** @type {!Object} */ 143 | var props = { 144 | debug : thisDebug, 145 | id : id, 146 | complete: complete, 147 | source : source, 148 | category: category, 149 | subCat : subCat, 150 | links : links, 151 | problem : problem, 152 | descr : descr, 153 | output : output 154 | }; 155 | 156 | return getter.call(props, prop); 157 | }; 158 | 159 | //////////////////////////////////////////////////////////////////////////// 160 | // End Of The Class Setup 161 | //////////////////////////////////////////////////////////////////////////// 162 | 163 | this.debug.end('init'); 164 | }; 165 | 166 | //////////////////////////////////////////////////////////////////////////////// 167 | // The Prototype Methods 168 | //////////////////////////////////////////////////////////////////////////////// 169 | 170 | QuestionsConfig.prototype.constructor = QuestionsConfig; 171 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/classes/config/search-bar-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (SearchBarConfig) 4 | * ----------------------------------------------------- 5 | * @desc The configuration settings for the search bar in this app. 6 | * @param {!Object} config - The user's search bar config settings. 7 | * @constructor 8 | */ 9 | var SearchBarConfig = function(config) { 10 | 11 | var thisDebug; 12 | 13 | this.debug = aIV.debug('SearchBarConfig'); 14 | thisDebug = this.debug; 15 | 16 | this.debug.start('init', config); 17 | 18 | checkArgs(config, '!object'); 19 | 20 | //////////////////////////////////////////////////////////////////////////// 21 | // Define & Setup The Public Properties 22 | //////////////////////////////////////////////////////////////////////////// 23 | 24 | /** 25 | * ----------------------------------------------- 26 | * Public Property (SearchBarConfig.defaults) 27 | * ----------------------------------------------- 28 | * @desc The default search options to display upon app init. 29 | * @type {DefaultsSearchBarConfig} 30 | */ 31 | this.defaults = new DefaultsSearchBarConfig(); 32 | 33 | //////////////////////////////////////////////////////////////////////////// 34 | // Define The Protected Properties 35 | //////////////////////////////////////////////////////////////////////////// 36 | 37 | /** 38 | * ----------------------------------------------- 39 | * Protected Property (SearchBarConfig.stage) 40 | * ----------------------------------------------- 41 | * @desc Whether to display the stage search option. 42 | * @type {boolean} 43 | * @private 44 | */ 45 | var stage; 46 | 47 | /** 48 | * ----------------------------------------------- 49 | * Protected Property (SearchBarConfig.source) 50 | * ----------------------------------------------- 51 | * @desc Whether to display the source search option. 52 | * @type {boolean} 53 | * @private 54 | */ 55 | var source; 56 | 57 | /** 58 | * ----------------------------------------------- 59 | * Protected Property (SearchBarConfig.category) 60 | * ----------------------------------------------- 61 | * @desc Whether to display the category search option. 62 | * @type {boolean} 63 | * @private 64 | */ 65 | var category; 66 | 67 | /** 68 | * ----------------------------------------------- 69 | * Protected Property (SearchBarConfig.subCat) 70 | * ----------------------------------------------- 71 | * @desc Whether to display the sub category search option. 72 | * @type {boolean} 73 | * @private 74 | */ 75 | var subCat; 76 | 77 | //////////////////////////////////////////////////////////////////////////// 78 | // Setup The Protected Properties 79 | //////////////////////////////////////////////////////////////////////////// 80 | 81 | stage = !(config.stage === false); 82 | source = !(config.source === false); 83 | category = !(config.category === false); 84 | subCat = !(config.subCat === false); 85 | 86 | if (!category && subCat) { 87 | subCat = false; 88 | } 89 | 90 | //////////////////////////////////////////////////////////////////////////// 91 | // Define & Setup The Public Methods 92 | //////////////////////////////////////////////////////////////////////////// 93 | 94 | /** 95 | * ----------------------------------------------- 96 | * Public Method (SearchBarConfig.get) 97 | * ----------------------------------------------- 98 | * @desc Gets a protected property's value from SearchBarConfig. 99 | * @param {string} prop - The name of the property to get. 100 | * @return {boolean} The property's value. 101 | */ 102 | this.get = function(prop) { 103 | 104 | /** @type {!Object} */ 105 | var props = { 106 | debug : thisDebug, 107 | stage : stage, 108 | source : source, 109 | category: category, 110 | subCat : subCat 111 | }; 112 | 113 | return getter.call(props, prop); 114 | }; 115 | 116 | //////////////////////////////////////////////////////////////////////////// 117 | // End Of The Class Setup 118 | //////////////////////////////////////////////////////////////////////////// 119 | 120 | this.debug.end('init'); 121 | }; 122 | 123 | //////////////////////////////////////////////////////////////////////////////// 124 | // The Prototype Methods 125 | //////////////////////////////////////////////////////////////////////////////// 126 | 127 | SearchBarConfig.prototype.constructor = SearchBarConfig; 128 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/classes/question/question-format.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (QuestionFormat) 4 | * ----------------------------------------------------- 5 | * @desc An object containing the formatted details of a question. 6 | * @param {!Object} question - The pre-formatted details of the question. 7 | * @param {!booleanMap} config - The settings for question formatting. 8 | * @constructor 9 | */ 10 | var QuestionFormat = function(question, config) { 11 | 12 | var thisDebug; 13 | 14 | this.debug = aIV.debug('QuestionFormat'); 15 | thisDebug = this.debug; 16 | 17 | this.debug.start('init', question, config); 18 | 19 | checkArgs(question, '!object', config, '!booleanMap'); 20 | 21 | //////////////////////////////////////////////////////////////////////////// 22 | // Define The Protected Properties 23 | //////////////////////////////////////////////////////////////////////////// 24 | 25 | /** 26 | * ----------------------------------------------- 27 | * Protected Property (QuestionFormat.id) 28 | * ----------------------------------------------- 29 | * @desc The id for this question. 30 | * @type {string} 31 | * @private 32 | */ 33 | var id; 34 | 35 | /** 36 | * ----------------------------------------------- 37 | * Protected Property (QuestionFormat.source) 38 | * ----------------------------------------------- 39 | * @desc This question's source. 40 | * @type {string} 41 | * @private 42 | */ 43 | var source; 44 | 45 | /** 46 | * ----------------------------------------------- 47 | * Protected Property (QuestionFormat.complete) 48 | * ----------------------------------------------- 49 | * @desc This question's current completion status. 50 | * @type {string} 51 | * @private 52 | */ 53 | var complete; 54 | 55 | /** 56 | * ----------------------------------------------- 57 | * Protected Property (QuestionFormat.mainCat) 58 | * ----------------------------------------------- 59 | * @desc This question's main categories. 60 | * @type {{ 61 | * h3 : ?string, 62 | * names: ?strings 63 | * }} 64 | * @private 65 | */ 66 | var mainCat; 67 | 68 | /** 69 | * ----------------------------------------------- 70 | * Protected Property (QuestionFormat.subCat) 71 | * ----------------------------------------------- 72 | * @desc This question's sub categories. 73 | * @type {{ 74 | * h3 : ?string, 75 | * names: ?strings 76 | * }} 77 | * @private 78 | */ 79 | var subCat; 80 | 81 | /** 82 | * ----------------------------------------------- 83 | * Protected Property (QuestionFormat.solution) 84 | * ----------------------------------------------- 85 | * @desc This question's solution. 86 | * @type {{ 87 | * prettyCode: string, 88 | * lineCount : number 89 | * }} 90 | * @private 91 | */ 92 | var solution; 93 | 94 | //////////////////////////////////////////////////////////////////////////// 95 | // Setup The Protected Properties 96 | //////////////////////////////////////////////////////////////////////////// 97 | 98 | /** @type {function} */ 99 | var getCategory; 100 | /** @type {!{ result: string, lineCount: number }} */ 101 | var code; 102 | /** @type {number} */ 103 | var len; 104 | /** @type {number} */ 105 | var i; 106 | 107 | id = (config.id && question.id) ? question.id : ''; 108 | if (id) { 109 | id = ( (id < 10) ? 110 | '00' + id : (id < 100) ? 111 | '0' + id : '' + id 112 | ); 113 | } 114 | 115 | source = ( (config.source && question.source) ? 116 | app.sources.get(question.source, 'name') : '' 117 | ); 118 | 119 | complete = ( (!config.complete) ? 120 | '' : (question.complete) ? 121 | 'Yes' : 'No' 122 | ); 123 | 124 | getCategory = app.categories.get; 125 | 126 | // Format the categories 127 | mainCat = { 128 | h3 : null, 129 | names: null 130 | }; 131 | subCat = { 132 | h3 : null, 133 | names: null 134 | }; 135 | if (config.category) { 136 | 137 | // Format the main category 138 | if (question.mainCat.length) { 139 | mainCat.h3 = ( (question.mainCat.length > 1) ? 140 | 'Main Categories:' : 'Main Category:' 141 | ); 142 | len = question.mainCat.length; 143 | mainCat.names = new Array(len); 144 | i = -1; 145 | while (++i < len) { 146 | mainCat.names[i] = getCategory(question.mainCat[i], 'name'); 147 | } 148 | } 149 | 150 | // Format the sub category 151 | if (config.subCat && question.subCat.length) { 152 | subCat.h3 = ( (question.subCat.length > 1) ? 153 | 'Sub Categories:' : 'Sub Category:' 154 | ); 155 | len = question.subCat.length; 156 | subCat.names = new Array(len); 157 | i = -1; 158 | while (++i < len) { 159 | subCat.names[i] = getCategory(question.subCat[i], 'name'); 160 | } 161 | } 162 | } 163 | 164 | // Format the solution 165 | solution = {}; 166 | if (question.solution) { 167 | code = prettify(question.solution); 168 | solution.prettyCode = code.result; 169 | solution.lineCount = code.lineCount; 170 | } 171 | 172 | // Freeze all of the protected properties that are objects 173 | freezeObj(mainCat); 174 | freezeObj(subCat); 175 | freezeObj(solution); 176 | 177 | //////////////////////////////////////////////////////////////////////////// 178 | // Define & Setup The Public Methods 179 | //////////////////////////////////////////////////////////////////////////// 180 | 181 | /** 182 | * ----------------------------------------------- 183 | * Public Method (QuestionFormat.get) 184 | * ----------------------------------------------- 185 | * @desc Gets a protected property's value from the QuestionFormat. 186 | * @param {string} propName - The name of the property to get. 187 | * @return {*} The property's value. 188 | */ 189 | this.get = function(propName) { 190 | 191 | /** @type {!Object} */ 192 | var props = { 193 | debug : thisDebug, 194 | id : id, 195 | source : source, 196 | complete: complete, 197 | mainCat : mainCat, 198 | subCat : subCat, 199 | solution: solution 200 | }; 201 | 202 | return getter.call(props, propName); 203 | }; 204 | 205 | //////////////////////////////////////////////////////////////////////////// 206 | // End Of The Class Setup 207 | //////////////////////////////////////////////////////////////////////////// 208 | 209 | freezeObj(this, true); 210 | 211 | this.debug.end('init'); 212 | }; 213 | 214 | //////////////////////////////////////////////////////////////////////////////// 215 | // The Prototype Methods 216 | //////////////////////////////////////////////////////////////////////////////// 217 | 218 | QuestionFormat.prototype.constructor = QuestionFormat; 219 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/classes/search-bar/search-bar-elems.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (SearchBarElems) 4 | * ----------------------------------------------------- 5 | * @desc The search bar's values and elements for this app. 6 | * @param {!booleanMap} config - The app's search bar config settings. 7 | * @constructor 8 | */ 9 | var SearchBarElems = function(config) { 10 | 11 | this.debug = aIV.debug('SearchBarElems'); 12 | 13 | this.debug.start('init', config); 14 | 15 | checkArgs(config, '!booleanMap'); 16 | 17 | //////////////////////////////////////////////////////////////////////////// 18 | // Define The Public Properties 19 | //////////////////////////////////////////////////////////////////////////// 20 | 21 | /** 22 | * ----------------------------------------------- 23 | * Public Property (SearchBarElems.view) 24 | * ----------------------------------------------- 25 | * @desc The DOM HTMLSelectElement #aIV-view. 26 | * @type {!HTMLSelectElement} 27 | */ 28 | this.view; 29 | 30 | /** 31 | * ----------------------------------------------- 32 | * Public Property (SearchBarElems.order) 33 | * ----------------------------------------------- 34 | * @desc The DOM HTMLSelectElement #aIV-order. 35 | * @type {!HTMLSelectElement} 36 | */ 37 | this.order; 38 | 39 | /** 40 | * ----------------------------------------------- 41 | * Public Property (SearchBarElems.stage) 42 | * ----------------------------------------------- 43 | * @desc The DOM HTMLSelectElement #aIV-stage. 44 | * @type {?HTMLSelectElement} 45 | */ 46 | this.stage; 47 | 48 | /** 49 | * ----------------------------------------------- 50 | * Public Property (SearchBarElems.source) 51 | * ----------------------------------------------- 52 | * @desc The DOM HTMLSelectElement #aIV-source. 53 | * @type {?HTMLSelectElement} 54 | */ 55 | this.source; 56 | 57 | /** 58 | * ----------------------------------------------- 59 | * Public Property (SearchBarElems.mainCat) 60 | * ----------------------------------------------- 61 | * @desc The DOM HTMLSelectElement #aIV-mainCat. 62 | * @type {?HTMLSelectElement} 63 | */ 64 | this.mainCat; 65 | 66 | /** 67 | * ----------------------------------------------- 68 | * Public Property (SearchBarElems.subCat) 69 | * ----------------------------------------------- 70 | * @desc The DOM HTMLSelectElement #aIV-subCat. 71 | * @type {?HTMLSelectElement} 72 | */ 73 | this.subCat; 74 | 75 | //////////////////////////////////////////////////////////////////////////// 76 | // Setup The Public Properties 77 | //////////////////////////////////////////////////////////////////////////// 78 | 79 | this.view = makeElem({ 80 | tag : 'select', 81 | id : 'aIV-view', 82 | className: 'showView' 83 | }); 84 | this.view.onchange = function(event) { 85 | Events.searchView(event.target.value); 86 | }; 87 | 88 | this.order = makeElem({ 89 | tag : 'select', 90 | id : 'aIV-order', 91 | className: 'showOrder' 92 | }); 93 | this.order.onchange = function(event) { 94 | Events.searchOrder(event.target.value); 95 | }; 96 | 97 | 98 | this.stage = null; 99 | if (config.stage) { 100 | this.stage = makeElem({ 101 | tag : 'select', 102 | id : 'aIV-stage', 103 | className: 'showStage' 104 | }); 105 | this.stage.onchange = function(event) { 106 | Events.searchStage(event.target.value); 107 | }; 108 | } 109 | 110 | this.source = null; 111 | if (config.source) { 112 | this.source = makeElem({ 113 | tag : 'select', 114 | id : 'aIV-source', 115 | className: 'showSource' 116 | }); 117 | this.source.onchange = function(event) { 118 | Events.searchSource(event.target.value); 119 | }; 120 | } 121 | 122 | this.mainCat = null; 123 | if (config.category) { 124 | this.mainCat = makeElem({ 125 | tag : 'select', 126 | id : 'aIV-mainCat', 127 | className: 'showMainCat' 128 | }); 129 | this.mainCat.onchange = function(event) { 130 | Events.searchMainCat(event.target.value); 131 | }; 132 | } 133 | 134 | this.subCat = null; 135 | if (config.subCat) { 136 | this.subCat = makeElem({ 137 | tag : 'select', 138 | id : 'aIV-subCat', 139 | className: 'showSubCat' 140 | }); 141 | this.subCat.onchange = function(event) { 142 | Events.searchSubCat(event.target.value); 143 | }; 144 | } 145 | 146 | //////////////////////////////////////////////////////////////////////////// 147 | // End Of The Class Setup 148 | //////////////////////////////////////////////////////////////////////////// 149 | 150 | freezeObj(this); 151 | 152 | this.debug.end('init'); 153 | }; 154 | 155 | //////////////////////////////////////////////////////////////////////////////// 156 | // The Prototype Methods 157 | //////////////////////////////////////////////////////////////////////////////// 158 | 159 | SearchBarElems.prototype.constructor = SearchBarElems; 160 | 161 | /** 162 | * -------------------------------------------------------------- 163 | * Public Method (SearchBarElems.prototype.setValuesToDefaults) 164 | * -------------------------------------------------------------- 165 | * @desc Updates the search bar's values to the defaults. 166 | * @param {!Object} defaults - The default values. 167 | */ 168 | SearchBarElems.prototype.setValuesToDefaults = function(defaults) { 169 | 170 | this.debug.start('setValuesToDefaults', defaults); 171 | 172 | checkArgs(defaults, '!stringMap'); 173 | 174 | this.view.value = defaults.view; 175 | this.order.value = defaults.order; 176 | if (this.stage) { 177 | this.stage.value = defaults.stage; 178 | } 179 | if (this.source) { 180 | this.source.value = defaults.source; 181 | } 182 | if (this.mainCat) { 183 | this.mainCat.value = defaults.mainCat; 184 | } 185 | if (this.subCat) { 186 | this.subCat.value = defaults.subCat; 187 | } 188 | 189 | this.debug.end('setValuesToDefaults'); 190 | }; 191 | 192 | /** 193 | * ------------------------------------------------------- 194 | * Public Method (SearchBarElems.prototype.appendToMain) 195 | * ------------------------------------------------------- 196 | * @desc Appends the search bar's elements to the selections root. 197 | * @type {function} 198 | */ 199 | SearchBarElems.prototype.appendToMain = function() { 200 | 201 | this.debug.start('appendToMain'); 202 | 203 | /** @type {!Element} */ 204 | var sel; 205 | 206 | sel = app.elems.sel; 207 | 208 | sel.appendChild(this.view); 209 | sel.appendChild(this.order); 210 | this.stage && sel.appendChild(this.stage); 211 | this.source && sel.appendChild(this.source); 212 | this.mainCat && sel.appendChild(this.mainCat); 213 | this.subCat && sel.appendChild(this.subCat); 214 | 215 | this.debug.end('appendToMain'); 216 | }; 217 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/classes/source.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (Source) 4 | * ----------------------------------------------------- 5 | * @desc An object containing the details of a source. 6 | * @param {string} name - The source's name. 7 | * @constructor 8 | */ 9 | var Source = function(name) { 10 | 11 | var thisDebug; 12 | 13 | this.debug = aIV.debug('Source'); 14 | thisDebug = this.debug; 15 | 16 | this.debug.start('init', name); 17 | 18 | checkArgs(name, 'string'); 19 | 20 | //////////////////////////////////////////////////////////////////////////// 21 | // Define The Protected Properties 22 | //////////////////////////////////////////////////////////////////////////// 23 | 24 | /** 25 | * ----------------------------------------------- 26 | * Protected Property (Source.url) 27 | * ----------------------------------------------- 28 | * @desc The source's url name. 29 | * @type {string} 30 | * @private 31 | */ 32 | var url; 33 | 34 | /** 35 | * ----------------------------------------------- 36 | * Protected Property (Source.ids) 37 | * ----------------------------------------------- 38 | * @desc The ids of the questions containing this source. 39 | * @type {!numbers} 40 | * @private 41 | */ 42 | var ids; 43 | 44 | //////////////////////////////////////////////////////////////////////////// 45 | // Setup The Protected Properties 46 | //////////////////////////////////////////////////////////////////////////// 47 | 48 | if (!name || !checkType(name, 'string')) { 49 | name = ''; 50 | url = ''; 51 | } 52 | else { 53 | url = makeUrl(name); 54 | } 55 | ids = []; 56 | 57 | //////////////////////////////////////////////////////////////////////////// 58 | // Define & Setup The Public Methods 59 | //////////////////////////////////////////////////////////////////////////// 60 | 61 | /** 62 | * ----------------------------------------------- 63 | * Public Method (Source.get) 64 | * ----------------------------------------------- 65 | * @desc Gets a protected property's value from the source. 66 | * @param {string} propName - The name of the property to get. 67 | * @return {(string|!numbers)} 68 | */ 69 | this.get = function(propName) { 70 | 71 | /** @type {Object} */ 72 | var props = { 73 | debug: thisDebug, 74 | name: name, 75 | url : url, 76 | ids : ids 77 | }; 78 | 79 | return getter.call(props, propName); 80 | }; 81 | 82 | /** 83 | * ----------------------------------------------- 84 | * Public Method (Source.addId) 85 | * ----------------------------------------------- 86 | * @desc Adds a question id to this source. 87 | * @param {number} id - The index to add. 88 | */ 89 | this.addId = function(id) { 90 | 91 | this.debug.start('addId', id); 92 | 93 | /** @type {string} */ 94 | var errorMsg; 95 | 96 | checkArgs(id, 'number'); 97 | 98 | if (id < 1) { 99 | errorMsg = 'An aIV.app internal error occurred. A Source.addId call '; 100 | errorMsg += 'was given an invalid question id to add. id= ' + id; 101 | throw new Error(errorMsg); 102 | } 103 | 104 | ids.push(id); 105 | 106 | this.debug.end('addId'); 107 | }; 108 | 109 | /** 110 | * ----------------------------------------------- 111 | * Public Method (Source.freezeIds) 112 | * ----------------------------------------------- 113 | * @desc Freezes this category's question ids. 114 | * @type {function} 115 | */ 116 | this.freezeIds = function() { 117 | 118 | this.debug.start('freezeIds'); 119 | 120 | freezeObj(ids); 121 | 122 | this.debug.end('freezeIds'); 123 | }; 124 | 125 | //////////////////////////////////////////////////////////////////////////// 126 | // End Of The Class Setup 127 | //////////////////////////////////////////////////////////////////////////// 128 | 129 | this.debug.end('init'); 130 | }; 131 | 132 | //////////////////////////////////////////////////////////////////////////////// 133 | // The Prototype Methods 134 | //////////////////////////////////////////////////////////////////////////////// 135 | 136 | Source.prototype.constructor = Source; 137 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/classes/sources.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (Sources) 4 | * ----------------------------------------------------- 5 | * @desc The available sources for each question. 6 | * @param {?stringMap} sources - The user's sources. 7 | * @constructor 8 | */ 9 | var Sources = function(sources) { 10 | 11 | var thisDebug; 12 | 13 | this.debug = aIV.debug('Sources'); 14 | thisDebug = this.debug; 15 | 16 | this.debug.start('init', sources); 17 | 18 | checkArgs(sources, 'stringMap'); 19 | 20 | //////////////////////////////////////////////////////////////////////////// 21 | // Prepare The User Supplied Params 22 | //////////////////////////////////////////////////////////////////////////// 23 | 24 | if ( !checkType(sources, '!stringMap') ) { 25 | sources = {}; 26 | } 27 | 28 | //////////////////////////////////////////////////////////////////////////// 29 | // Define The Public Properties 30 | //////////////////////////////////////////////////////////////////////////// 31 | 32 | /** 33 | * ----------------------------------------------- 34 | * Public Property (Sources.ids) 35 | * ----------------------------------------------- 36 | * @desc Saves an array of all the source ids in alphabetical order. 37 | * @type {strings} 38 | */ 39 | this.ids; 40 | 41 | /** 42 | * ----------------------------------------------- 43 | * Public Property (Sources.len) 44 | * ----------------------------------------------- 45 | * @desc Saves the count of sources. 46 | * @type {number} 47 | */ 48 | this.len; 49 | 50 | //////////////////////////////////////////////////////////////////////////// 51 | // Setup The Public Properties 52 | //////////////////////////////////////////////////////////////////////////// 53 | 54 | /** @type {number} */ 55 | var allIndex; 56 | 57 | this.ids = Object.keys(sources); 58 | this.len = this.ids.length; 59 | 60 | // Sort the ids 61 | if (this.len) { 62 | this.ids = sortKeys(this.ids, sources); 63 | } 64 | 65 | // Fix a category with the id of all 66 | allIndex = this.ids.indexOf('all'); 67 | if (allIndex !== -1) { 68 | this.ids[ allIndex ] = '_all'; 69 | } 70 | 71 | //////////////////////////////////////////////////////////////////////////// 72 | // Define The Protected Properties 73 | //////////////////////////////////////////////////////////////////////////// 74 | 75 | /** 76 | * ----------------------------------------------- 77 | * Protected Property (Sources.data) 78 | * ----------------------------------------------- 79 | * @desc Saves a hash map of the source objects using the ids as keys. 80 | * @type {Object} 81 | * @private 82 | */ 83 | var data; 84 | 85 | //////////////////////////////////////////////////////////////////////////// 86 | // Setup The Protected Properties 87 | //////////////////////////////////////////////////////////////////////////// 88 | 89 | /** @type {string} */ 90 | var sourceId; 91 | /** @type {number} */ 92 | var i; 93 | 94 | data = {}; 95 | 96 | // Build the data hash map 97 | i = this.len; 98 | while (i--) { 99 | sourceId = this.ids[i]; 100 | data[ sourceId ] = new Source(sources[ sourceId ]); 101 | } 102 | 103 | // Deep freeze 104 | freezeObj(data, true); 105 | 106 | //////////////////////////////////////////////////////////////////////////// 107 | // Define & Setup The Public Methods 108 | //////////////////////////////////////////////////////////////////////////// 109 | 110 | /** 111 | * ----------------------------------------------- 112 | * Public Method (Sources.get) 113 | * ----------------------------------------------- 114 | * @desc Get a Source's object or protected property. 115 | * @param {string} id - The source id to get. 116 | * @param {string=} prop - The property to get. 117 | * @return {!(Source|string|numbers)} 118 | */ 119 | this.get = function(id, prop) { 120 | 121 | thisDebug.start('get', id, prop); 122 | 123 | /** @type {string} */ 124 | var errorMsg; 125 | /** @type {!Source} */ 126 | var source; 127 | /** @type {!(Source|string|numbers)} */ 128 | var result; 129 | 130 | checkArgs(id, 'string', prop, 'string='); 131 | 132 | if ( !hasOwnProp(data, id) ) { 133 | errorMsg = 'An aIV.app internal error occurred. A Sources.get call '; 134 | errorMsg += 'was given an invalid source id to get. sourceID= ' + id; 135 | throw new Error(errorMsg); 136 | } 137 | 138 | prop = prop || ''; 139 | source = data[ id ]; 140 | result = (prop) ? source.get(prop) : source; 141 | 142 | thisDebug.end('get', result); 143 | 144 | return result; 145 | }; 146 | 147 | //////////////////////////////////////////////////////////////////////////// 148 | // End Of The Class Setup 149 | //////////////////////////////////////////////////////////////////////////// 150 | 151 | // Deep freeze 152 | freezeObj(this, true); 153 | 154 | this.debug.end('init'); 155 | }; 156 | 157 | //////////////////////////////////////////////////////////////////////////////// 158 | // The Prototype Methods 159 | //////////////////////////////////////////////////////////////////////////////// 160 | 161 | Sources.prototype.constructor = Sources; 162 | 163 | /** 164 | * ----------------------------------------------------- 165 | * Public Method (Sources.prototype.freezeIds) 166 | * ----------------------------------------------------- 167 | * @desc Freezes the ids array for each source. 168 | * @type {function} 169 | */ 170 | Sources.prototype.freezeIds = function() { 171 | 172 | this.debug.start('freezeIds'); 173 | 174 | /** @type {string} */ 175 | var id; 176 | /** @type {number} */ 177 | var i; 178 | 179 | i = this.len; 180 | while (i--) { 181 | id = this.ids[i]; 182 | this.get(id).freezeIds(); 183 | } 184 | 185 | this.debug.end('freezeIds'); 186 | }; 187 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/discontinued/app-flags.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (AppFlags) 4 | * ----------------------------------------------------- 5 | * @desc The flags that explain states of the environment in the app. 6 | * @param {boolean} pass - Indicates whether the user's supplied settings 7 | * were the correct data types. 8 | * @constructor 9 | */ 10 | var AppFlags = function(pass) { 11 | 12 | var thisDebug; 13 | 14 | this.debug = aIV.debug('AppFlags'); 15 | thisDebug = this.debug; 16 | 17 | this.debug.start('init', pass); 18 | 19 | checkArgs(pass, 'boolean'); 20 | 21 | //////////////////////////////////////////////////////////////////////////// 22 | // Define & Setup The Protected Properties 23 | //////////////////////////////////////////////////////////////////////////// 24 | 25 | /** 26 | * ----------------------------------------------- 27 | * Protected Property (AppFlags.initArgs) 28 | * ----------------------------------------------- 29 | * @desc Indicates whether the app was initialized with correct arguments. 30 | * @type {boolean} 31 | * @private 32 | */ 33 | var initArgs = pass; 34 | 35 | //////////////////////////////////////////////////////////////////////////// 36 | // Define & Setup The Public Methods 37 | //////////////////////////////////////////////////////////////////////////// 38 | 39 | /** 40 | * ----------------------------------------------- 41 | * Public Method (AppFlags.get) 42 | * ----------------------------------------------- 43 | * @desc Gets an AppFlags protected property. 44 | * @param {string} prop - The name of the flag to get. 45 | * @return {boolean} The flag's value. 46 | */ 47 | this.get = function(prop) { 48 | 49 | /** @type {!Object} */ 50 | var props = { 51 | debug : thisDebug, 52 | initArgs: initArgs 53 | }; 54 | 55 | return getter.call(props, prop); 56 | }; 57 | 58 | /** 59 | * ----------------------------------------------- 60 | * Public Method (AppFlags.set) 61 | * ----------------------------------------------- 62 | * @desc Sets an AppFlags protected property. 63 | * @param {string} prop - The name of the flag to set. 64 | * @param {boolean} val - The value to set the flag to. 65 | * @return {boolean} The setter's success. 66 | */ 67 | this.set = function(prop, val) { 68 | 69 | /** @type {Object} */ 70 | var setters = { 71 | debug : thisDebug, 72 | initArgs: function(val) { 73 | initArgs = val; 74 | return checkType(val, 'boolean'); 75 | } 76 | }; 77 | 78 | return setter.call(setters, prop, val); 79 | }; 80 | 81 | //////////////////////////////////////////////////////////////////////////// 82 | // End Of The Class Setup 83 | //////////////////////////////////////////////////////////////////////////// 84 | 85 | freezeObj(this, true); 86 | 87 | this.debug.end('init'); 88 | }; 89 | 90 | //////////////////////////////////////////////////////////////////////////////// 91 | // The Prototype Methods 92 | //////////////////////////////////////////////////////////////////////////////// 93 | 94 | AppFlags.prototype.constructor = AppFlags; 95 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/discontinued/url-config.js: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * ------- AS OF VERSION 1.1.1 THE URL CONFIG CLASS WAS DISCONTINUED -------- * 3 | * -------------------------------------------------------------------------- * 4 | * Due to the increased complexity in usability that url updates cost and the * 5 | * lack of perceived benefits this class development has been discontinued. * 6 | * -------------------------------------------------------------------------- * 7 | * In case development for dynamic url updates is brought back the previous * 8 | * development completed can be found below. * 9 | * -------------------------------------------------------------------------- */ 10 | 11 | /** 12 | * ----------------------------------------------------- 13 | * Public Class (UrlConfig) 14 | * ----------------------------------------------------- 15 | * @desc The configuration settings for creating urls for the questions. 16 | * @param {Object} config - The user's config settings for url searches. 17 | * @constructor 18 | */ 19 | var UrlConfig = function(config) { 20 | 21 | this.debug = aIV.debug('UrlConfig'); 22 | 23 | this.debug.start('init', config); 24 | 25 | this.debug.args('init', config, 'object'); 26 | 27 | //////////////////////////////////////////////////////////////////////////// 28 | // Define The Protected Properties 29 | //////////////////////////////////////////////////////////////////////////// 30 | 31 | /** 32 | * ----------------------------------------------- 33 | * Protected Property (UrlConfig.id) 34 | * ----------------------------------------------- 35 | * @desc Whether to display an id search option in the url. 36 | * @type {boolean} 37 | * @private 38 | */ 39 | var id; 40 | 41 | /** 42 | * ----------------------------------------------- 43 | * Protected Property (UrlConfig.category) 44 | * ----------------------------------------------- 45 | * @desc Whether to display a category search option in the url. 46 | * @type {boolean} 47 | * @private 48 | */ 49 | var category; 50 | 51 | //////////////////////////////////////////////////////////////////////////// 52 | // Setup The Protected Properties 53 | //////////////////////////////////////////////////////////////////////////// 54 | 55 | id = false; 56 | category = false; 57 | 58 | if (config.hasOwnProperty('id') && config.id === true) { 59 | id = true; 60 | } 61 | if (config.hasOwnProperty('category') && config.category === true) { 62 | category = true; 63 | } 64 | 65 | //////////////////////////////////////////////////////////////////////////// 66 | // Define & Setup The Public Methods 67 | //////////////////////////////////////////////////////////////////////////// 68 | 69 | /** 70 | * ----------------------------------------------- 71 | * Public Method (UrlConfig.get) 72 | * ----------------------------------------------- 73 | * @desc Gets a protected property's value from UrlConfig. 74 | * @param {string} prop - The name of the property to get. 75 | * @return {boolean} 76 | */ 77 | this.get = function(prop) { 78 | 79 | this.debug.start('get', prop); 80 | this.debug.args('get', prop, 'string'); 81 | 82 | /** @type {Object} */ 83 | var props = { 84 | id : id, 85 | category: category 86 | }; 87 | 88 | debugCheck = props.hasOwnProperty(prop); 89 | debugMsg = 'Error: The given property does not exist. property= $$'; 90 | this.debug.fail('get', debugCheck, debugMsg, prop); 91 | 92 | return props[ prop ]; 93 | }; 94 | 95 | // Freeze all of the methods 96 | freezeObj(this.get); 97 | 98 | //////////////////////////////////////////////////////////////////////////// 99 | // End Of The Class Setup 100 | //////////////////////////////////////////////////////////////////////////// 101 | 102 | // Freeze this class instance 103 | freezeObj(this); 104 | }; 105 | 106 | //////////////////////////////////////////////////////////////////////////////// 107 | // The Prototype Methods 108 | //////////////////////////////////////////////////////////////////////////////// 109 | 110 | UrlConfig.prototype.constructor = UrlConfig; 111 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/module-api.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Variable (appModuleAPI) 4 | * ----------------------------------------------------- 5 | * @desc Holds the app module's public properties and methods. 6 | * @type {!Object} 7 | * @struct 8 | */ 9 | var appModuleAPI = {}; 10 | 11 | /** 12 | * ----------------------------------------------------- 13 | * Public Method (appModuleAPI.startApp) 14 | * ----------------------------------------------------- 15 | * @desc Initializes the app. 16 | * @param {Object} settings - The app's settings. 17 | */ 18 | appModuleAPI.startApp = function(settings) { 19 | 20 | debug.start('startApp', settings); 21 | debug.args('startApp', settings, 'object'); 22 | 23 | /** @type {?(string|strings)} */ 24 | var resourceList; 25 | /** @type {objectMap} */ 26 | var config; 27 | /** @type {stringMap} */ 28 | var sources; 29 | /** @type {(objectMap|stringMap)} */ 30 | var categories; 31 | /** @type {!objects} */ 32 | var questions; 33 | /** @type {function} */ 34 | var setup; 35 | /** @type {function} */ 36 | var callback; 37 | /** @type {string} */ 38 | var types; 39 | /** @type {number} */ 40 | var i; 41 | 42 | if (appHasBeenInitialized) { 43 | throw new Error('The aIV.app init call was made a second time.'); 44 | } 45 | 46 | // Save the init of this app to prevent second init 47 | appHasBeenInitialized = true; 48 | 49 | if ( !checkType(settings, '!object') ) { 50 | settings = {}; 51 | } 52 | 53 | // Setup the app arguments 54 | resourceList = ( ( hasOwnProp(settings, 'resources') ) ? 55 | settings.resources : null 56 | ); 57 | config = ( ( hasOwnProp(settings, 'config') ) ? 58 | settings.config : ( hasOwnProp(settings, 'configuration') ) ? 59 | settings.configuration : null 60 | ); 61 | sources = ( ( hasOwnProp(settings, 'sources') ) ? 62 | settings.sources : ( hasOwnProp(settings, 'source') ) ? 63 | settings.source : null 64 | ); 65 | categories = ( ( hasOwnProp(settings, 'categories') ) ? 66 | settings.categories : ( hasOwnProp(settings, 'category') ) ? 67 | settings.category : null 68 | ); 69 | questions = ( ( hasOwnProp(settings, 'questions') ) ? 70 | settings.questions : ( hasOwnProp(settings, 'question') ) ? 71 | settings.question : [] 72 | ); 73 | 74 | // Check the types of the arguments 75 | if ( !checkType(resourceList, 'string|strings') ) { 76 | types = 'null, a string, or an array of strings'; 77 | logStartAppTypeError('resources', types, getTypeOf(resourceList)); 78 | resourceList = null; 79 | } 80 | if ( !checkType(config, 'objectMap') ) { 81 | types = 'null or an object with string => object pairs'; 82 | logStartAppTypeError('config', types, getTypeOf(config)); 83 | config = null; 84 | } 85 | if ( !checkType(sources, 'stringMap') ) { 86 | types = 'null or an object with string => string pairs'; 87 | logStartAppTypeError('sources', types, getTypeOf(sources)); 88 | sources = null; 89 | } 90 | if ( !checkType(categories, 'stringMap|objectMap') ) { 91 | types = 'null or an object with string => object or '; 92 | types += 'string => string pairs'; 93 | logStartAppTypeError('categories', types, getTypeOf(categories)); 94 | categories = null; 95 | } 96 | if ( !checkType(questions, '!objects') ) { 97 | types = 'an array of question objects'; 98 | logStartAppTypeError('questions', types, getTypeOf(questions)); 99 | questions = []; 100 | } 101 | 102 | // Setup and start the app 103 | setup = function() { 104 | freezeObj(resources); 105 | App.setup(config, sources, categories, questions); 106 | }; 107 | 108 | // Save the resources 109 | if (resourceList) { 110 | 111 | if ( checkType(resourceList, 'string') ) { 112 | getResource(resourceList, setup); 113 | return; 114 | } 115 | 116 | callback = setup; 117 | i = resourceList.length; 118 | while (--i) { 119 | callback = (function(jsonFile, callback) { 120 | return function() { 121 | getResource(jsonFile, callback); 122 | }; 123 | })(resourceList[i], callback); 124 | } 125 | getResource(resourceList[0], callback); 126 | } 127 | else { 128 | setup(); 129 | } 130 | }; 131 | 132 | /** 133 | * ----------------------------------------------------- 134 | * Public Method (appModuleAPI.getResource) 135 | * ----------------------------------------------------- 136 | * @desc Makes the app's resources publically available. 137 | * @param {string=} prop - The specific resource to retrieve. 138 | * @return {*} Either the entire resources object or one of its properties. 139 | */ 140 | appModuleAPI.getResource = function(prop) { 141 | 142 | debug.start('getResource', prop); 143 | debug.args('getResource', prop, 'string='); 144 | debug.state('getResource', 'resources= $$', resources); 145 | 146 | /** @type {string} */ 147 | var errorMsg; 148 | /** @type {*} */ 149 | var result; 150 | 151 | prop = prop || ''; 152 | 153 | if (prop && !hasOwnProp(resources, prop)) { 154 | errorMsg = 'The resource you requested does not exist. Please verify that \''; 155 | errorMsg += prop + '\' is a correct json file name in the resources folder '; 156 | errorMsg += 'and that the file name was included in the setup of the app '; 157 | errorMsg += '(see algorithmiv.com/docs/resources).'; 158 | console.error(errorMsg); 159 | debugger; 160 | } 161 | else { 162 | result = (!!prop) ? resources[ prop ] : resources; 163 | } 164 | 165 | debug.end('getResource', result); 166 | 167 | return result; 168 | } 169 | 170 | aIV.utils.freezeObj(appModuleAPI); 171 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/module-vars.js: -------------------------------------------------------------------------------- 1 | 2 | var debug = aIV.debug({ // $s$ 3 | classTitle: 'appModule', 4 | openGroups: true 5 | }); 6 | var debugHelp = aIV.debug('appHelpers'); // $e$ 7 | var debugArgs, debugMsg, debugCheck; 8 | 9 | /** 10 | * ----------------------------------------------------- 11 | * Public Variable (appHasBeenInitialized) 12 | * ----------------------------------------------------- 13 | * @desc Indicates whether the app has been initialized. 14 | * @type {boolean} 15 | */ 16 | var appHasBeenInitialized = false; 17 | 18 | /** 19 | * ----------------------------------------------- 20 | * Public Variable (resources) 21 | * ----------------------------------------------- 22 | * @desc The resources for the app. 23 | * @type {!Object} 24 | */ 25 | var resources = {}; 26 | 27 | /** 28 | * ----------------------------------------------- 29 | * Public Variable (app) 30 | * ----------------------------------------------- 31 | * @desc The app instance. 32 | * @type {!{ 33 | * 34 | * 35 | * }} 36 | */ 37 | var app = {}; 38 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/pre-compiled-prettifier/pre-compiled-syntax-highlighter/highlight-syntax-vars.js: -------------------------------------------------------------------------------- 1 | // The syntax highlighter's debugger object 2 | highlightSyntax.debug = aIV.debug('highlightSyntax'); 3 | 4 | /** 5 | * --------------------------------------------- 6 | * Private Variable (newLine) 7 | * --------------------------------------------- 8 | * @desc The formatted line of code. 9 | * @type {strings} 10 | * @private 11 | */ 12 | var newLine; 13 | 14 | /** 15 | * --------------------------------------------- 16 | * Private Variable (orgLine) 17 | * --------------------------------------------- 18 | * @desc The original line of code. 19 | * @type {strings} 20 | * @private 21 | */ 22 | var orgLine; 23 | 24 | /** 25 | * --------------------------------------------- 26 | * Private Variable (lineLen) 27 | * --------------------------------------------- 28 | * @desc The length of the line of code. 29 | * @type {number} 30 | * @private 31 | */ 32 | var lineLen; 33 | 34 | /** 35 | * --------------------------------------------- 36 | * Private Variable (lastIndex) 37 | * --------------------------------------------- 38 | * @desc The last index of the line of code. 39 | * @type {number} 40 | * @private 41 | */ 42 | var lastIndex; 43 | 44 | /** 45 | * --------------------------------------------- 46 | * Private Variable (router) 47 | * --------------------------------------------- 48 | * @desc A hash map that stores the matching character 49 | * formatting methods. 50 | * @type {!objectMap} 51 | * @private 52 | */ 53 | var router = { 54 | "'": formatString, 55 | '"': formatString, 56 | ' ': formatSpace, 57 | '{': formatBracket, 58 | '[': formatBracket, 59 | '(': formatBracket, 60 | ')': formatBracket, 61 | ']': formatBracket, 62 | '}': formatBracket, 63 | '*': formatOperator, 64 | '%': formatOperator, 65 | '+': formatOperator, 66 | '-': formatOperator, 67 | '<': formatOperator, 68 | '>': formatOperator, 69 | '&': formatOperator, 70 | '^': formatOperator, 71 | '|': formatOperator, 72 | '=': formatOperator, 73 | '!': formatOperator, 74 | '~': formatOperator, 75 | '?': formatOperator, 76 | ',': formatComma, 77 | ';': formatSemicolon, 78 | ':': formatColon, 79 | '.': formatPeriod, 80 | '0': formatNumber, 81 | '1': formatNumber, 82 | '2': formatNumber, 83 | '3': formatNumber, 84 | '4': formatNumber, 85 | '5': formatNumber, 86 | '6': formatNumber, 87 | '7': formatNumber, 88 | '8': formatNumber, 89 | '9': formatNumber, 90 | '/': handleSlash 91 | }; 92 | 93 | freezeObj(router); 94 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/pre-compiled-prettifier/pre-compiled-syntax-highlighter/highlight-syntax.js: -------------------------------------------------------------------------------- 1 | /** 2 | * --------------------------------------------- 3 | * Private Method (highlightSyntax) 4 | * --------------------------------------------- 5 | * @desc Adds spans around reserved code characters to highlight 6 | * specific syntax for a line of code. 7 | * @param {string} line - The line of code to highlight. 8 | * @return {string} 9 | * @private 10 | */ 11 | var highlightSyntax = (function() { 12 | 13 | var highlightSyntax = function(line) { 14 | 15 | highlightSyntax.debug.start('init', line); 16 | 17 | checkArgs(line, 'string'); 18 | 19 | prepareLine(line); 20 | formatLine(); 21 | 22 | return newLine.join(''); 23 | }; 24 | 25 | /* ----------------------------------------------------------------------------- 26 | * The Highlight Syntax Variables (pre-compiled-prettifier/ 27 | * pre-compiled-syntax-highlighter/ 28 | * highlight-syntax-vars.js) 29 | * -------------------------------------------------------------------------- */ 30 | // insert-highlight-syntax-vars 31 | 32 | /* ----------------------------------------------------------------------------- 33 | * The Highlight Syntax Methods (pre-compiled-prettifier/ 34 | * pre-compiled-syntax-highlighter/ 35 | * highlight-syntax-methods.js) 36 | * -------------------------------------------------------------------------- */ 37 | // insert-highlight-syntax-methods 38 | 39 | return highlightSyntax; 40 | 41 | })(); 42 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/pre-compiled-prettifier/prettify-methods.js: -------------------------------------------------------------------------------- 1 | /** 2 | * --------------------------------------------- 3 | * Public Method (prettify.setConfig) 4 | * --------------------------------------------- 5 | * @desc Sets the config settings for the prettifier. 6 | * @param {!Object} newConfig - The config 7 | * settings for the prettifier. 8 | * @private 9 | */ 10 | prettify.setConfig = function(newConfig) { 11 | 12 | prettify.debug.start('setConfig', newConfig); 13 | 14 | checkArgs(newConfig, '!object'); 15 | 16 | config = newConfig; 17 | freezeObj(config); 18 | 19 | prettify.debug.end('setConfig'); 20 | } 21 | 22 | /** 23 | * --------------------------------------------- 24 | * Private Method (prepareLines) 25 | * --------------------------------------------- 26 | * @desc Standardizes all line breaks and replaces tabs with spaces. 27 | * @param {string} solution - The problem's solution to be formatted. 28 | * @return {!strings} 29 | * @private 30 | */ 31 | function prepareLines(solution) { 32 | 33 | prettify.debug.group('init', 'coll', 'Open to see original string'); 34 | prettify.debug.start('prepareLines', solution); 35 | prettify.debug.group('init', 'end'); 36 | 37 | /** @type {!strings} */ 38 | var lines; 39 | /** @type {string} */ 40 | var spaces; 41 | /** @type {number} */ 42 | var spaceCount; 43 | 44 | checkArgs(solution, 'string'); 45 | 46 | // Standardize all line breaks 47 | solution = solution.replace(/\r\n?/g, '\n'); 48 | 49 | // Replace all tabs with spaces 50 | spaces = ''; 51 | spaceCount = config.tabLength; 52 | while (spaceCount--) { 53 | spaces += ' '; 54 | } 55 | if (spaces) { 56 | solution = solution.replace(/\t/g, ' '); 57 | } 58 | 59 | lines = solution.split('\n'); 60 | 61 | prettify.debug.end('prepareLines', lines); 62 | 63 | return lines; 64 | } 65 | 66 | /** 67 | * --------------------------------------------- 68 | * Private Method (applyFormatting) 69 | * --------------------------------------------- 70 | * @desc Applies the prettifier formats. 71 | * @param {!strings} lines - An array of code lines. 72 | * @return {!{ 73 | * result : string, 74 | * lineCount: number 75 | * }} 76 | * @private 77 | */ 78 | function applyFormatting(lines) { 79 | 80 | prettify.debug.start('applyFormatting', lines); 81 | 82 | /** @type {number} */ 83 | var i; 84 | /** @type {number} */ 85 | var len; 86 | /** @type {string} */ 87 | var line; 88 | /** @type {!Object} */ 89 | var result; 90 | 91 | checkArgs(lines, '!strings'); 92 | 93 | commentOpen = false; 94 | len = lines.length; 95 | 96 | i = -1; 97 | while (++i < len) { 98 | 99 | debugMsg = 'lineNumber= $$'; 100 | prettify.debug.group('applyFormatting', 'coll', debugMsg, (i + 1)); 101 | 102 | line = prepareLine(lines[i]); 103 | 104 | if (line) { 105 | line = highlightSyntax(line, i); 106 | } 107 | 108 | lines[i] = '
  • '+ line +'
  • '; 109 | 110 | prettify.debug.state('applyFormatting', 'lineOutput= $$', lines[i]); 111 | prettify.debug.group('applyFormatting', 'end'); 112 | } 113 | 114 | result = { 115 | result : lines.join(''), 116 | lineCount: len 117 | }; 118 | 119 | prettify.debug.end('applyFormatting', result); 120 | 121 | return result; 122 | } 123 | 124 | /** 125 | * --------------------------------------------- 126 | * Private Method (prepareLine) 127 | * --------------------------------------------- 128 | * @desc Removes whitespaces from line beginning and end. 129 | * @param {string} line - The line of code to prepare. 130 | * @return {string} 131 | * @private 132 | */ 133 | function prepareLine(line) { 134 | 135 | prettify.debug.start('prepareLine', line); 136 | 137 | /** @type {number} */ 138 | var i; 139 | /** @type {number} */ 140 | var frontTrimCount; 141 | /** @type {string} */ 142 | var trimPart; 143 | 144 | checkArgs(line, 'string'); 145 | 146 | // Trim ending whitespaces 147 | if (line) { 148 | i = line.length - 1; 149 | if (line.charAt(i) === ' ') { 150 | --i; 151 | while (line.charAt(i) === ' ') { 152 | --i; 153 | } 154 | line = line.substr(0, i); 155 | } 156 | } 157 | 158 | // Trim beginning whitespaces 159 | frontTrimCount = config.trimSpace; 160 | if (line && frontTrimCount) { 161 | 162 | trimPart = ( (frontTrimCount < line.length) ? 163 | line.substr(0, frontTrimCount) : '' 164 | ); 165 | if (trimPart && !notSpace.test(trimPart)) { 166 | // Trim full count 167 | line = line.substr(frontTrimCount); 168 | } 169 | else { 170 | // Trim partial count 171 | i = 0; 172 | while (line.charAt(i) === ' ') { 173 | ++i; 174 | } 175 | line = line.substr(i); 176 | } 177 | } 178 | 179 | prettify.debug.end('prepareLine', line); 180 | 181 | return line; 182 | } 183 | 184 | /** 185 | * --------------------------------------------- 186 | * Private Method (makeKeywordObj) 187 | * --------------------------------------------- 188 | * @desc Creates a keyword object. 189 | * @param {string} cat - The keyword's category. 190 | * @param {string=} href - The keyword's details link. 191 | * @param {boolean=} props - Whether the keyword has properties. 192 | * @return {!Object} 193 | * @private 194 | */ 195 | function makeKeywordObj(cat, href, props) { 196 | 197 | prettify.debug.start('makeKeywordObj', cat, href, props); 198 | 199 | /** @type {!Object} */ 200 | var obj; 201 | 202 | checkArgs(cat, 'string', href, 'string=', props, 'boolean='); 203 | 204 | href = href || ''; 205 | props = props || false; 206 | 207 | obj = {}; 208 | 209 | obj.cat = cat; 210 | obj.href = href; 211 | obj.props = (props) ? {} : false; 212 | 213 | freezeObj(obj); 214 | 215 | prettify.debug.end('makeKeywordObj', obj); 216 | 217 | return obj; 218 | } 219 | 220 | /** 221 | * --------------------------------------------- 222 | * Private Method (makePropObj) 223 | * --------------------------------------------- 224 | * @desc Creates a keyword property object. 225 | * @param {string=} href - The keyword's details link. 226 | * @return {!stringMap} 227 | * @private 228 | */ 229 | function makePropObj(href) { 230 | 231 | prettify.debug.start('makePropObj', href); 232 | 233 | /** @type {!stringMap} */ 234 | var obj; 235 | 236 | checkArgs(href, 'string='); 237 | 238 | href = href || ''; 239 | 240 | obj = {}; 241 | obj.href = href; 242 | 243 | freezeObj(obj); 244 | 245 | prettify.debug.end('makePropObj', obj); 246 | 247 | return obj; 248 | } 249 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/pre-compiled-prettifier/prettify.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Method (prettify) 4 | * ----------------------------------------------------- 5 | * @desc The prettifier for this app. 6 | * @param {string} solution - The problem's solution to be formatted. 7 | * @return {{ 8 | * result : string, 9 | * lineCount: number 10 | * }} 11 | */ 12 | var prettify = (function() { 13 | 14 | var prettify = function(solution) { 15 | 16 | prettify.debug.group('init', 'coll', 'Open to see original string'); 17 | prettify.debug.start('init', solution); 18 | prettify.debug.group('init', 'end'); 19 | 20 | /** @type {{ result: string, lineCount: number }} */ 21 | var result; 22 | 23 | checkArgs(solution, 'string'); 24 | 25 | // Format the solution 26 | result = applyFormatting( prepareLines(solution) ); 27 | 28 | prettify.debug.end('init', result); 29 | 30 | return result; 31 | }; 32 | 33 | /* ----------------------------------------------------------------------------- 34 | * The Prettifier Module Variables (pre-compiled-prettifier/prettify-vars.js) 35 | * -------------------------------------------------------------------------- */ 36 | // insert-prettify-vars 37 | 38 | /* ----------------------------------------------------------------------------- 39 | * The Prettifier Module Methods (pre-compiled-prettifier/prettify-methods.js) 40 | * -------------------------------------------------------------------------- */ 41 | // insert-prettify-methods 42 | 43 | /* ----------------------------------------------------------------------------- 44 | * The Highlight Syntax Method (pre-compiled-prettifier/highlight-syntax.js) 45 | * -------------------------------------------------------------------------- */ 46 | // insert-highlight-syntax 47 | 48 | return prettify; 49 | 50 | })(); 51 | -------------------------------------------------------------------------------- /tests/pre-compiled-app/public-api.js: -------------------------------------------------------------------------------- 1 | /** 2 | * --------------------------------------------------- 3 | * Global Variable (aIV) 4 | * --------------------------------------------------- 5 | * @desc Holds the public API for aIV's apps, tools, and libraries. 6 | * @struct 7 | * @global 8 | */ 9 | window.aIV = window.aIV || {}; 10 | 11 | /** 12 | * --------------------------------------------------- 13 | * Global Method (aIV.app) 14 | * --------------------------------------------------- 15 | * @desc Initializes the aIV question management app. 16 | * @param {!Object} settings - The app's settings. 17 | * @param {objectMap=} settings.config - The app's configuration. 18 | * @param {stringMap=} settings.sources - The app's sources. 19 | * @param {(objectMap|stringMap)=} settings.categories - The app's categories. 20 | * @param {!objects} settings.questions - The app's questions. 21 | * @param {(string|strings)=} settings.resources - The app's resources. 22 | * @global 23 | */ 24 | aIV.app = appModuleAPI.startApp; 25 | 26 | /** 27 | * --------------------------------------------------- 28 | * Global Method (aIV.app.getResource) 29 | * --------------------------------------------------- 30 | * @desc Makes the app's resources publically available. 31 | * @param {string=} prop - The specific resource to retrieve. 32 | * @return {*} Either the entire resources object or one of its properties. 33 | * @global 34 | */ 35 | aIV.app.getResource = appModuleAPI.getResource; 36 | -------------------------------------------------------------------------------- /tests/pre-compiled-tests/classes/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (App) 4 | * ----------------------------------------------------- 5 | * @desc The base class for the app. 6 | * @constructor 7 | */ 8 | var App = function() { 9 | 10 | //////////////////////////////////////////////////////////////////////////// 11 | // Define & Setup The Public Properties 12 | //////////////////////////////////////////////////////////////////////////// 13 | 14 | /** 15 | * --------------------------------------------------- 16 | * Public Property (App.elems) 17 | * --------------------------------------------------- 18 | * @desc The elements for this app. 19 | * @type {Object} 20 | */ 21 | this.elems = new Elems(); 22 | 23 | //////////////////////////////////////////////////////////////////////////// 24 | // End Of The Class Setup 25 | //////////////////////////////////////////////////////////////////////////// 26 | 27 | freezeObj(this); 28 | }; 29 | 30 | //////////////////////////////////////////////////////////////////////////////// 31 | // The Prototype Methods 32 | //////////////////////////////////////////////////////////////////////////////// 33 | 34 | App.prototype.constructor = App; 35 | 36 | /** 37 | * ----------------------------------------------- 38 | * Public Method (App.prototype.runTests) 39 | * ----------------------------------------------- 40 | * @desc Sets up the display for the app. 41 | * @type {function} 42 | */ 43 | App.prototype.runTests = function() { 44 | 45 | this.elems.ui.style.opacity = '0'; 46 | 47 | setTimeout(function() { 48 | 49 | // Remove the body's current elements 50 | while (document.body.firstChild) { 51 | document.body.removeChild(document.body.firstChild); 52 | } 53 | 54 | Tests.runApp(); 55 | }, 500); 56 | }; 57 | -------------------------------------------------------------------------------- /tests/pre-compiled-tests/classes/elems.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (Elems) 4 | * ----------------------------------------------------- 5 | * @desc Important app elements. 6 | * @constructor 7 | */ 8 | var Elems = function() { 9 | 10 | //////////////////////////////////////////////////////////////////////////// 11 | // Define & Setup The Public Properties 12 | //////////////////////////////////////////////////////////////////////////// 13 | 14 | /** @type {!Element} */ 15 | var root; 16 | 17 | root = getElemById('aIV-tests'); 18 | 19 | // Set the following getElemByClass calls to use #aIV-tests as their root 20 | aIV.utils.set({ getElemByClassRoot: root }); 21 | 22 | /** 23 | * --------------------------------------------------- 24 | * Private Property (Elems.root) 25 | * --------------------------------------------------- 26 | * @desc Element: #aIV-tests 27 | * @type {!Element} 28 | */ 29 | this.root = root; 30 | 31 | /** 32 | * --------------------------------------------------- 33 | * Private Property (Elems.msg) 34 | * --------------------------------------------------- 35 | * @desc Element: #aIV-tests .msg 36 | * @type {!Element} 37 | */ 38 | this.msg = getElemByClass('msg'); 39 | 40 | /** 41 | * --------------------------------------------------- 42 | * Private Property (Elems.ui) 43 | * --------------------------------------------------- 44 | * @desc Element: #aIV-tests .ui 45 | * @type {!Element} 46 | */ 47 | this.ui = getElemByClass('ui'); 48 | 49 | /** 50 | * --------------------------------------------------- 51 | * Private Property (Elems.start) 52 | * --------------------------------------------------- 53 | * @desc Element: #aIV-tests .start 54 | * @type {!Element} 55 | */ 56 | this.start = getElemByClass('start'); 57 | 58 | //////////////////////////////////////////////////////////////////////////// 59 | // End Of The Class Setup 60 | //////////////////////////////////////////////////////////////////////////// 61 | 62 | freezeObj(this); 63 | }; 64 | 65 | //////////////////////////////////////////////////////////////////////////////// 66 | // The Prototype Methods 67 | //////////////////////////////////////////////////////////////////////////////// 68 | 69 | Elems.prototype.constructor = Elems; 70 | -------------------------------------------------------------------------------- /tests/pre-compiled-tests/classes/tests.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Class (Tests) 4 | * ----------------------------------------------------- 5 | * @desc The tests to run. 6 | * @struct 7 | */ 8 | var Tests = {}; 9 | 10 | /** 11 | * ----------------------------------------------------- 12 | * Public Method (Tests.runApp) 13 | * ----------------------------------------------------- 14 | * @desc Runs the question manager app with test data. 15 | * @type {function} 16 | */ 17 | Tests.runApp = (function() { 18 | 19 | // These calls run immediately to ensure that desired 20 | // settings are set before the app is processed 21 | 22 | aIV.debug.set({ 23 | addBreakpoints: 'args fail', 24 | turnOnGroups : true, 25 | turnOnProfiles: false, 26 | turnOnTimers : true 27 | }); 28 | 29 | aIV.debug({ 30 | classTitle : 'prettify', 31 | turnOffMethods: 'all', 32 | turnOnGroups : false, 33 | turnOnTimers : false 34 | }); 35 | 36 | aIV.debug({ 37 | classTitle : 'highlightSyntax', 38 | turnOffMethods: 'all', 39 | turnOnGroups : false, 40 | turnOnTimers : false 41 | }); 42 | 43 | // END of immediate calls 44 | 45 | return function runApp() { 46 | 47 | /** @type {!MockAjax} */ 48 | var mockAjax; 49 | /** @type {!ajaxResults} */ 50 | var ajaxResults; 51 | 52 | ajaxResults = { 53 | responseText: TestData.exampleResource, 54 | status : 200, 55 | statusText : '200 OK' 56 | }; 57 | mockAjax = new MockAjax([ ajaxResults ]); 58 | aIV.app(TestData.example); 59 | mockAjax.reset(); 60 | }; 61 | })(); 62 | 63 | freezeObj(Tests, true); 64 | -------------------------------------------------------------------------------- /tests/pre-compiled-tests/module-api.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Variable (testsModuleAPI) 4 | * ----------------------------------------------------- 5 | * @desc The API for the Tests Module. 6 | * @type {!Object} 7 | */ 8 | var testsModuleAPI = {}; 9 | 10 | /** 11 | * ----------------------------------------------------- 12 | * Public Method (testsModuleAPI.startTests) 13 | * ----------------------------------------------------- 14 | * @desc Initializes the aIV.app tests. 15 | * @type {function} 16 | */ 17 | testsModuleAPI.startTests = function() { 18 | 19 | if (!appHasBeenInitialized) { 20 | 21 | appHasBeenInitialized = true; 22 | 23 | // Setup the tests app 24 | app = new App(); 25 | 26 | // Run the tests 27 | app.runTests(); 28 | } 29 | }; 30 | 31 | aIV.utils.freezeObj(testsModuleAPI, true); 32 | -------------------------------------------------------------------------------- /tests/pre-compiled-tests/module-methods.js: -------------------------------------------------------------------------------- 1 | /** 2 | * --------------------------------------------- 3 | * Public Method (getElemById) 4 | * --------------------------------------------- 5 | * @desc A shortcut for the native DOM method - document.getElementById. 6 | * @param {string} id - The id of the element to select. 7 | * @return {!HTMLElement} The DOM element with the given id. 8 | */ 9 | var getElemById = aIV.utils.getElemById; 10 | 11 | /** 12 | * --------------------------------------------------- 13 | * Public Method (getElemByClass) 14 | * --------------------------------------------------- 15 | * @desc A shortcut for the native DOM method - 16 | * [DOM Node].getElementsByClassName[ [index] ]. 17 | * @param {string} classname - The class name of the element to select. 18 | * @param {number=} index - The index of the array of found elements to 19 | * select. The default is 0. 20 | * @param {!(Document|Element)=} root - Limit the selections to this element's 21 | * children. The default is document or the element set with 22 | * aIV.utils.set({ getElemByClassRoot: [DOM Node] }). 23 | * @return {!HTMLElement} The selected DOM element. 24 | */ 25 | var getElemByClass = aIV.utils.getElemByClass; 26 | 27 | /** 28 | * --------------------------------------------------- 29 | * Public Method (getElemsByClass) 30 | * --------------------------------------------------- 31 | * @desc A shortcut for the native DOM method - 32 | * [DOM Node].getElementsByClassName. 33 | * @param {string} classname - The class name of the elements to select. 34 | * @param {!(Document|Element)=} root - Limit the selections to this element's 35 | * children. The default is document or the element set with 36 | * aIV.utils.set({ getElemsByClassRoot: [DOM Node] }). 37 | * @return {!Array} The selected DOM elements. 38 | */ 39 | var getElemsByClass = aIV.utils.getElemsByClass; 40 | 41 | /** 42 | * --------------------------------------------------- 43 | * Public Method (freezeObj) 44 | * --------------------------------------------------- 45 | * @desc A shortcut for the Object.freeze method with a deep freeze option. 46 | * @param {!(Object|function)} obj - The object to freeze. 47 | * @param {boolean=} deep - Deep freeze the object. The default is false. 48 | * @return {!(Object|function)} The frozen object. 49 | */ 50 | var freezeObj = aIV.utils.freezeObj; 51 | 52 | /** 53 | * --------------------------------------------------- 54 | * Public Method (hasOwnProp) 55 | * --------------------------------------------------- 56 | * @desc A shortcut for the Object.prototype.hasOwnProperty method. 57 | * @param {!object|function} obj - The object to check. 58 | * @param {string} prop - The property to check. 59 | * @return {boolean} The result of the check. 60 | */ 61 | var hasOwnProp = aIV.utils.hasOwnProp; 62 | 63 | /** 64 | * --------------------------------------------------- 65 | * Public Method (checkType) 66 | * --------------------------------------------------- 67 | * @desc Checks a value's data type against the given optional types. 68 | * @param {*} val - The value to be evaluated. 69 | * @param {string} type - A string of the data types to evaluate the value 70 | * against. For a complete list of acceptable strings 71 | * [see aIV.utils.checkType]{@link https://github.com/imaginate/algorithmIV-javascript-shortcuts/blob/master/src/pre-compiled-parts/methods/checkType.js}. 72 | * @param {boolean=} noTypeValCheck - If true skips the data type string checks. 73 | * The default is false. Use to avoid duplicating checks. 74 | * @return {boolean} The evaluation result. 75 | */ 76 | var checkType = aIV.utils.checkType; 77 | 78 | /** 79 | * --------------------------------------------------- 80 | * Public Method (isValidTypeString) 81 | * --------------------------------------------------- 82 | * @desc Evaluates whether a string is a valid data type string. 83 | * @param {string} type - The string to evaluate. 84 | * @return {boolean} The evaluation result. 85 | */ 86 | var isValidTypeString = aIV.utils.isValidTypeString; 87 | 88 | /** 89 | * --------------------------------------------- 90 | * Public Method (copyObj) 91 | * --------------------------------------------- 92 | * @desc A shortcut that creates a new object with the same properties and 93 | * values as the given object. 94 | * @param {!Object} oldObj - The object to copy from. 95 | * @return {!Object} The new copied object. 96 | */ 97 | var copyObj = (function setup_copyObj() { 98 | 99 | /** @type {string} */ 100 | var errorMsg; 101 | /** @type {function} */ 102 | var throwTypeError; 103 | 104 | errorMsg = 'An aIV.tests copyObj call received an invalid oldObj param.'; 105 | throwTypeError = function() { 106 | throw new TypeError(errorMsg); 107 | }; 108 | 109 | return function copyObj(oldObj) { 110 | 111 | /** @type {!Object} */ 112 | var newObj; 113 | /** @type {string} */ 114 | var prop; 115 | 116 | if ( !checkType(oldObj, '!object|function') ) { 117 | throwTypeError(); 118 | oldObj = {}; 119 | } 120 | 121 | newObj = {}; 122 | 123 | for (prop in oldObj) { 124 | if ( hasOwnProp(oldObj, prop) ) { 125 | newObj[ prop ] = oldObj[ prop ]; 126 | } 127 | } 128 | 129 | return newObj; 130 | }; 131 | })(); 132 | 133 | /** 134 | * --------------------------------------------- 135 | * Public Method (makeObj) 136 | * --------------------------------------------- 137 | * @desc A shortcut that creates a new object with the given keys and 138 | * values. 139 | * @param {(string|!strings)} keys - The new object's keys. 140 | * @param {*} val - The value to set the new object's properties to. 141 | * @return {!Object} The new object. 142 | */ 143 | var makeObj = (function setup_makeObj() { 144 | 145 | /** @type {string} */ 146 | var errorMsg; 147 | /** @type {function} */ 148 | var throwTypeError; 149 | 150 | errorMsg = 'An aIV.tests makeObj call received an invalid keys param.'; 151 | throwTypeError = function() { 152 | throw new TypeError(errorMsg); 153 | }; 154 | 155 | return function makeObj(keys, val) { 156 | 157 | /** @type {string} */ 158 | var prop; 159 | /** @type {!Object} */ 160 | var obj; 161 | /** @type {number} */ 162 | var i; 163 | 164 | if ( checkType(keys, 'string') ) { 165 | keys = keys.split(' '); 166 | } 167 | 168 | obj = {}; 169 | 170 | if ( checkType(keys, '!strings') ) { 171 | i = keys.length; 172 | while (i--) { 173 | prop = keys[i]; 174 | obj[ prop ] = val; 175 | } 176 | } 177 | else { 178 | throwTypeError(); 179 | } 180 | 181 | return obj; 182 | }; 183 | })(); 184 | 185 | /** 186 | * --------------------------------------------- 187 | * Public Method (concatObj) 188 | * --------------------------------------------- 189 | * @desc A shortcut that copies an object's properties and 190 | * values to an existing object. 191 | * @param {!Object} baseObj - The object to copy to. 192 | * @param {!Object} addObj - The object to copy from. 193 | * @return {!Object} The base object. 194 | */ 195 | var concatObj = (function setup_concatObj() { 196 | 197 | /** @type {string} */ 198 | var errorMsg; 199 | /** @type {function} */ 200 | var throwTypeError; 201 | 202 | errorMsg = 'An aIV.tests concatObj call received an invalid param type.'; 203 | throwTypeError = function() { 204 | throw new TypeError(errorMsg); 205 | }; 206 | 207 | return function concatObj(baseObj, addObj) { 208 | 209 | /** @type {string} */ 210 | var prop; 211 | 212 | if (!checkType(baseObj, '!object|function') || 213 | !checkType(addObj, '!object|function')) { 214 | throwTypeError(); 215 | baseObj = {}; 216 | addObj = {}; 217 | } 218 | 219 | for (prop in addObj) { 220 | if (hasOwnProp(addObj, prop) && !hasOwnProp(baseObj, prop)) { 221 | baseObj[ prop ] = addObj[ prop ]; 222 | } 223 | } 224 | 225 | return baseObj; 226 | }; 227 | })(); 228 | -------------------------------------------------------------------------------- /tests/pre-compiled-tests/module-vars.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------- 3 | * Public Variable (appHasBeenInitialized) 4 | * ----------------------------------------------------- 5 | * @desc Indicates whether the Tests app has been initialized. 6 | * @type {boolean} 7 | */ 8 | var appHasBeenInitialized = false; 9 | 10 | /** 11 | * ----------------------------------------------- 12 | * Public Variable (app) 13 | * ----------------------------------------------- 14 | * @desc The instance of App for the tests. 15 | * @type {App} 16 | */ 17 | var app; 18 | -------------------------------------------------------------------------------- /tests/pre-compiled-tests/public-api.js: -------------------------------------------------------------------------------- 1 | /** 2 | * --------------------------------------------------- 3 | * Global Variable (aIV) 4 | * --------------------------------------------------- 5 | * @desc Holds the public API for aIV's apps, tools, and libraries. 6 | * @struct 7 | * @global 8 | */ 9 | window.aIV = window.aIV || {}; 10 | 11 | /** 12 | * --------------------------------------------------- 13 | * Global Method (aIV.tests) 14 | * --------------------------------------------------- 15 | * @desc Runs the tests for aIV.app. 16 | * @type {function} 17 | * @global 18 | */ 19 | aIV.runTests = testsModuleAPI.startTests; 20 | -------------------------------------------------------------------------------- /tests/pre-compiled-tests/skeleton.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ----------------------------------------------------------------------------- 3 | * Algorithm IV Question Manager Tests (v1.1.2) 4 | * ----------------------------------------------------------------------------- 5 | * @file The module used to run all tests for aIV's question manager app. 6 | * @module aIVAppTests 7 | * @version 1.1.2 8 | * @author Adam Smith [imagineadamsmith@gmail.com]{@link https://github.com/imaginate} 9 | * @copyright 2022 Adam A Smith [https://github.com/imaginate]{@link https://github.com/imaginate} 10 | * @license The Apache License [www.apache.org/licenses/LICENSE-2.0]{@link http://www.apache.org/licenses/LICENSE-2.0} 11 | * @desc More details about the module for aIV.tests: 12 | *
      13 | *
    1. annotations: 14 | * [See Closure Compiler specific JSDoc]{@link https://developers.google.com/closure/compiler/js-for-compiler} 15 | * and [See JSDoc3]{@link http://usejsdoc.org/} 16 | *
    2. 17 | *
    3. contributing: 18 | * [See the guideline]{@link https://github.com/imaginate/algorithmIV-question-manager/blob/master/CONTRIBUTING.md} 19 | *
    4. 20 | *
    21 | */ 22 | 23 | /** 24 | * ----------------------------------------------------------------------------- 25 | * Pre-Defined JSDoc Types 26 | * ----------------------------------------------------------------------------- 27 | * @typedef {*} val 28 | * @typedef {Array<*>} vals 29 | * @typedef {Array} strings 30 | * @typedef {Array} numbers 31 | * @typedef {Array} objects 32 | */ 33 | 34 | //////////////////////////////////////////////////////////////////////////////// 35 | // The Public API 36 | //////////////////////////////////////////////////////////////////////////////// 37 | 38 | ;(function setupTheTestsPublicAPI(testsModuleAPI, undefined) { 39 | "use strict"; 40 | 41 | /* ----------------------------------------------------------------------------- 42 | * The Public API (public-api.js) 43 | * -------------------------------------------------------------------------- */ 44 | // insert-public-api 45 | 46 | })( 47 | 48 | //////////////////////////////////////////////////////////////////////////////// 49 | // The Tests Module 50 | //////////////////////////////////////////////////////////////////////////////// 51 | 52 | (function setupTheTestsModule(undefined) { 53 | "use strict"; 54 | 55 | /* ----------------------------------------------------------------------------- 56 | * The Tests Module API (module-api.js) 57 | * -------------------------------------------------------------------------- */ 58 | // insert-module-api 59 | 60 | /* ----------------------------------------------------------------------------- 61 | * The Public Module Variables (module-vars.js) 62 | * -------------------------------------------------------------------------- */ 63 | // insert-module-vars 64 | 65 | /* ----------------------------------------------------------------------------- 66 | * The Public Module Methods (module-methods.js) 67 | * -------------------------------------------------------------------------- */ 68 | // insert-module-methods 69 | 70 | /* ----------------------------------------------------------------------------- 71 | * The App Class (classes/app.js) 72 | * -------------------------------------------------------------------------- */ 73 | // insert-app 74 | 75 | /* ----------------------------------------------------------------------------- 76 | * The MockAjax Class (classes/mock-ajax.js) 77 | * -------------------------------------------------------------------------- */ 78 | // insert-mock-ajax 79 | 80 | /* ----------------------------------------------------------------------------- 81 | * The Elems Class (classes/elems.js) 82 | * -------------------------------------------------------------------------- */ 83 | // insert-elems 84 | 85 | /* ----------------------------------------------------------------------------- 86 | * The Tests Class (classes/tests.js) 87 | * -------------------------------------------------------------------------- */ 88 | // insert-tests 89 | 90 | /* ----------------------------------------------------------------------------- 91 | * The Test Data Class (classes/test-data.js) 92 | * -------------------------------------------------------------------------- */ 93 | // insert-test-data 94 | 95 | //////////////////////////////////////////////////////////////////////////////// 96 | // The Tests Module End 97 | //////////////////////////////////////////////////////////////////////////////// 98 | 99 | return testsModuleAPI; 100 | 101 | })()); 102 | -------------------------------------------------------------------------------- /tests/run-tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Algorithm IV 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |

    Tests for the Question Manager

    25 |
    26 |
    27 |

    For now tests must be run manually. Upon clicking "Start Tests" the question manager app will be setup with dummy data. Please test all user interactions (i.e. make on-page actions and check the console for errors).

    NOTE: With the large volume of console logs that are made (50,000+) we highly recommend using Chrome to debug this app. It will may take a few seconds to process, but it is nothing compared to the time that Firefox or IE will take (minutes).

    28 |
    Start Tests
    29 |
    30 |
    31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | --------------------------------------------------------------------------------