├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── __init__.py ├── addon-conf.json ├── build.py ├── config.py ├── dist └── interactive.apkg ├── models_def.py ├── notes_def.py ├── requirements.txt ├── screenshots ├── basic.png ├── choice.png ├── cloze.png ├── cloze_c.png ├── cloze_e.png ├── compl.png ├── order.png └── overview.png ├── src ├── base-back.html ├── base-back.js ├── base-front.html ├── base-front.js ├── base-top.html ├── choice-back.html ├── choice-back.js ├── choice-front.html ├── choice-front.js ├── clean.css ├── cloze-back.html ├── cloze-back.js ├── cloze-front.html ├── cloze-front.js ├── complete-front.html ├── complete-front.js ├── debug-back.html ├── debug-front.html ├── main.css ├── my-chips.js ├── my-choices.js ├── my-clozen.js ├── my-input.js ├── order-front.html ├── order-front.js ├── persistence.js ├── random.js ├── theme.css ├── utils.js └── webcomponents-ce.js ├── test ├── android-assets │ ├── chess.css │ ├── flashcard.css │ ├── ruby.css │ └── scripts │ │ └── card.js ├── anki-cover.png ├── demo.html ├── demo.js ├── layout-android.html ├── layout-iphone.html ├── layout-linux-review.html ├── layout-web.html ├── linux-assets │ ├── browsersel.js │ ├── jquery.js │ ├── reviewer.css │ ├── reviewer.js │ ├── webview.css │ └── webview.js └── web-assets │ ├── activity.gif │ ├── anki-logo2.png │ ├── app.css │ ├── app.js │ └── vendor.js └── tmp ├── Interactive Demo.apkg └── Interactive.Demo.zip /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: qwiglydee # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | !.gitignore 3 | 4 | # Byte-compiled / optimized / DLL files 5 | __pycache__/ 6 | *.py[cod] 7 | *$py.class 8 | 9 | # C extensions 10 | *.so 11 | 12 | # Distribution / packaging 13 | .Python 14 | build/ 15 | develop-eggs/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | lib/ 20 | lib64/ 21 | parts/ 22 | sdist/ 23 | var/ 24 | wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | .hypothesis/ 50 | .pytest_cache/ 51 | 52 | # Translations 53 | *.mo 54 | *.pot 55 | 56 | # Django stuff: 57 | *.log 58 | local_settings.py 59 | db.sqlite3 60 | 61 | # Flask stuff: 62 | instance/ 63 | .webassets-cache 64 | 65 | # Scrapy stuff: 66 | .scrapy 67 | 68 | # Sphinx documentation 69 | docs/_build/ 70 | 71 | # PyBuilder 72 | target/ 73 | 74 | # Jupyter Notebook 75 | .ipynb_checkpoints 76 | 77 | # pyenv 78 | .python-version 79 | 80 | # celery beat schedule file 81 | celerybeat-schedule 82 | 83 | # SageMath parsed files 84 | *.sage.py 85 | 86 | # Environments 87 | .env 88 | .venv 89 | env/ 90 | venv/ 91 | ENV/ 92 | env.bak/ 93 | venv.bak/ 94 | 95 | # Spyder project settings 96 | .spyderproject 97 | .spyproject 98 | 99 | # Rope project settings 100 | .ropeproject 101 | 102 | # mkdocs documentation 103 | /site 104 | 105 | # mypy 106 | .mypy_cache/ 107 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | > The project is abandoned 3 | > 4 | > The reasons are that Anki itself is not designed for such kind of content: 5 | > - not supposed to be cross-platform (each variation have it's own peculiariries) 6 | > - interactive stuff not supported (no good support for javascript) 7 | > - custom feedback not supported (no way to keep/show answer) 8 | > - internals are not documented and may break in any version 9 | > 10 | > All those make developing for ani a pain in the arse. 11 | > 12 | 13 | > 14 | > Maybe, some parts of these cards will be released in another project 15 | > 16 | 17 | # Interactive Cards for Anki 18 | 19 | The cards enable some interactive features to enter and edit answers and receive feedback, similar to what's often found in exercises of many language-learning applications. 20 | 21 | The features are: 22 | * typing answer in input field 23 | * typing missing words right inside a text 24 | * selecting words or answers from list of options 25 | * placing words in proper order. 26 | 27 | Also, there is quite a design and user-friendly feedback. 28 | 29 | Detailed description is in [the wiki](https://github.com/qwiglydee/anki-interactive/wiki) 30 | Discussion goes [here at reddit](https://www.reddit.com/r/Anki/comments/8n4qt1/anki21_interactive_cards_for_language_learning/) 31 | 32 | ## Installation 33 | 34 | Packaged version is [at the dist folder](https://github.com/qwiglydee/anki-interactive/raw/master/dist/interactive.apkg) 35 | 36 | ## Development 37 | 38 | The templates for models are compiled from a pretty big set of html, css and javascript files. In order to modify them you need to install anki sources, clone this repo and use compiling scripts. 39 | 40 | For the scripts to work, PYTHONPATH should contains anki sources as well as all its requirements. 41 | 42 | Key points: 43 | * `src` -- all the source files for templates 44 | * `models_def.py` -- configuration of models 45 | * `notes_def.py` -- configuration of notes in demo deck 46 | * `build.py` -- script to compile all the stuff into apkg file, and put all the addon stuff. 47 | * `dist` -- directory containing built package 48 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwiglydee/anki-interactive/cfe5b2b61baac67e6ed4d12d1146c251e6585987/__init__.py -------------------------------------------------------------------------------- /addon-conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "skip_timestamp_check": false, 3 | "skip_demo_deck": false 4 | } -------------------------------------------------------------------------------- /build.py: -------------------------------------------------------------------------------- 1 | """ 2 | Assembling addon 3 | """ 4 | from os import mkdir 5 | import shutil 6 | import zipfile 7 | import re 8 | 9 | import anki 10 | 11 | import config 12 | import models_def 13 | import notes_def 14 | 15 | 16 | class Sources(dict): 17 | """ 18 | Caching dictionary of all sources in SRCPATH 19 | """ 20 | def __getitem__(self, name): 21 | if name not in self: 22 | with open(config.SRCDIR / name) as f: 23 | self[name] = f.read() 24 | return super().__getitem__(name) 25 | 26 | def compile_html(self, html): 27 | html = re.sub('{{> (.*)}}', lambda m: self[m.group(1)+".html"], html) 28 | html = re.sub('', lambda m: "\n", html) 29 | return html 30 | 31 | def compile_css(self, csslist): 32 | return "\n".join(map(lambda f: self[f], csslist)) 33 | 34 | 35 | sources = Sources() 36 | 37 | 38 | def create_models(coll): 39 | for name, conf in models_def.MODELS.items(): 40 | create_model(coll, name, conf) 41 | 42 | 43 | def create_model(coll, name, conf): 44 | model = coll.models.new(name) 45 | model['type'] = conf['type'] 46 | 47 | for fld in conf['fields']: 48 | f = coll.models.newField(fld) 49 | if fld in models_def.COMMON_FIELDS: 50 | f['sticky'] = True 51 | coll.models.addField(model, f) 52 | model['sortf'] = 0 53 | model['latexPre'] = "" 54 | model['latexPost'] = "" 55 | model['css'] = sources.compile_css(conf['css']) 56 | tmpl = coll.models.newTemplate(name) 57 | tmpl['qfmt'] = sources.compile_html(sources[conf['html'][0]]) 58 | tmpl['afmt'] = sources.compile_html(sources[conf['html'][1]]) 59 | coll.models.addTemplate(model, tmpl) 60 | coll.models.add(model) 61 | 62 | 63 | def create_notes(coll): 64 | for conf in notes_def.NOTES: 65 | create_note(coll, conf) 66 | 67 | 68 | def create_note(coll, conf): 69 | model = coll.models.byName(conf['model']) 70 | note = anki.notes.Note(coll, model) 71 | note.guid = conf['guid'] 72 | for fld, val in conf['fields'].items(): 73 | note[fld] = val 74 | coll.addNote(note) 75 | 76 | 77 | # def make_zip(): 78 | # addon = zipfile.ZipFile(config.ADDONFILE, "w") 79 | # for entry in config.ADDONDIR: 80 | # if entry.name in ('__pycache__', 'meta.json'): 81 | # continue 82 | # addon.write(entry.path, entry.name) 83 | # addon.close() 84 | 85 | 86 | if __name__ == "__main__": 87 | print("Rebuilding...") 88 | if not config.BUILDDIR.exists(): 89 | config.BUILDDIR.mkdir() 90 | 91 | if not config.DISTDIR.exists(): 92 | config.DECKFILE.mkdir() 93 | 94 | 95 | # creating new collection file 96 | print(f"Saving to {config.DECKFILE}...") 97 | 98 | config.DECKFILE.unlink(missing_ok=True) 99 | coll = anki.Collection(config.DECKFILE, server=False, log=False) 100 | coll.decks.add_config("Interactive Demo") 101 | 102 | create_models(coll) 103 | print(f"Added {len(coll.models.all())} models") 104 | 105 | create_notes(coll) 106 | print(f"Added {coll.noteCount()} notes") 107 | 108 | # remove all default models 109 | for m in coll.models.all(): 110 | if m['name'] not in models_def.MODELS: 111 | coll.models.remove(m['id']) 112 | 113 | coll.close() 114 | 115 | apkg = zipfile.ZipFile(config.APKGFILE, "w") 116 | apkg.write(config.DECKFILE, "collection.anki2") 117 | apkg.writestr('media', "{}") 118 | apkg.close() 119 | 120 | print(f"Created apkg in {config.APKGFILE}") -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | WORKDIR = Path(__file__).parent 4 | SRCDIR = WORKDIR / "src" 5 | BUILDDIR = WORKDIR / "build" 6 | DISTDIR = WORKDIR / "dist" 7 | DECKFILE = BUILDDIR / "interactive.anki2" 8 | APKGFILE = DISTDIR / "interactive.apkg" -------------------------------------------------------------------------------- /dist/interactive.apkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwiglydee/anki-interactive/cfe5b2b61baac67e6ed4d12d1146c251e6585987/dist/interactive.apkg -------------------------------------------------------------------------------- /models_def.py: -------------------------------------------------------------------------------- 1 | from anki.consts import MODEL_STD, MODEL_CLOZE 2 | 3 | COMMON_FIELDS = ('Header', 'Intro', 'Cover', 'Instruction', 'Explanation', 'Reference') 4 | STICKY_FIELDS = ('Header', 'Intro', 'Cover', 'Instruction', 'Reference') 5 | 6 | MODELS = { 7 | 'InteractiveDebug': { 8 | 'type': MODEL_STD, 9 | 'fields': ('Front', 'Back') + COMMON_FIELDS, 10 | 'css': ("clean.css", "main.css", "theme.css"), 11 | 'html': ("debug-front.html", "debug-back.html") 12 | }, 13 | 'InteractiveBase': { 14 | 'type': MODEL_STD, 15 | 'fields': ('Question', 'Answer') + COMMON_FIELDS, 16 | 'css': ("clean.css", "main.css", "theme.css"), 17 | 'html': ("base-front.html", "base-back.html") 18 | }, 19 | 'InteractiveChoice': { 20 | 'type': MODEL_STD, 21 | 'fields': ('Question', 'Choices') + COMMON_FIELDS, 22 | 'css': ("clean.css", "main.css", "theme.css"), 23 | 'html': ("choice-front.html", "choice-back.html") 24 | }, 25 | 'InteractiveCloze': { 26 | 'type': MODEL_CLOZE, 27 | 'fields': ('Text', 'Words') + COMMON_FIELDS, 28 | 'css': ("clean.css", "main.css", "theme.css"), 29 | 'html': ("cloze-front.html", "cloze-back.html") 30 | }, 31 | 'InteractiveComplete': { 32 | 'type': MODEL_CLOZE, 33 | 'fields': ('Text', 'Choices') + COMMON_FIELDS, 34 | 'css': ("clean.css", "main.css", "theme.css"), 35 | 'html': ("complete-front.html", "cloze-back.html") 36 | }, 37 | 'InteractiveOrder': { 38 | 'type': MODEL_CLOZE, 39 | 'fields': ('Text', 'Words') + COMMON_FIELDS, 40 | 'css': ("clean.css", "main.css", "theme.css"), 41 | 'html': ("order-front.html", "cloze-back.html") 42 | }, 43 | } -------------------------------------------------------------------------------- /notes_def.py: -------------------------------------------------------------------------------- 1 | NOTES = [ 2 | { 3 | 'model': 'InteractiveBase', 4 | 'guid': 'qmax000001', 5 | 'fields': { 6 | 'Header': "Basic card", 7 | 'Intro': "Anyone who needs to remember things in their daily life need a program to practice remembering.", 8 | 'Question': "What is the program which makes remembering things easy?", 9 | 'Answer': "Anki", 10 | 'Instruction': "Type-in answer.", 11 | 'Explanation': "Because there are two simple concepts behind Anki: active recall testing and spaced repetition", 12 | 'Reference': "https://apps.ankiweb.net/docs/manual.html" 13 | } 14 | }, 15 | { 16 | 'model': 'InteractiveChoice', 17 | 'guid': 'qmax000002', 18 | 'fields': { 19 | 'Header': "Choice card", 20 | 'Intro': "Anki is a program which makes remembering things easy.", 21 | 'Question': "There are two simple concepts behind Anki:", 22 | 'Choices': "+ active recall | + spaced repetition | active repetition | spaced recall", 23 | 'Instruction': "Select all correct answers.", 24 | } 25 | }, 26 | { 27 | 'model': 'InteractiveCloze', 28 | 'guid': 'qmax000003', 29 | 'fields': { 30 | 'Header': "Cloze card with input", 31 | 'Intro': "Anki is a program which makes remembering things easy.", 32 | 'Text': "There are two simple concepts behind Anki: active {{c1::recall::remembering}} and spaced {{c1::repetition::iteration}}", 33 | 'Instruction': "Type-in missed words.", 34 | } 35 | }, 36 | { 37 | 'model': 'InteractiveCloze', 38 | 'guid': 'qmax000004', 39 | 'fields': { 40 | 'Header': "Clozing card with editable words", 41 | 'Intro': "Anki is a program which makes remembering things easy.
There are two simple concepts behind Anki: active recall testing and spaced repetition.", 42 | 'Text': "They are not {{c1::known::~know}} to most learners, despite having been {{c1::written::~write}} about in the scientific literature for many years.", 43 | 'Instruction': "Put words into proper form.", 44 | } 45 | }, 46 | { 47 | 'model': 'InteractiveCloze', 48 | 'guid': 'qmax000005', 49 | 'fields': { 50 | 'Header': "Cloze card with choices", 51 | 'Intro': "Anki is a program which makes remembering things easy.", 52 | 'Text': "There are two simple concepts behind Anki: {{c1::active}} recall and {{c1::spaced}} repetition.", 53 | 'Words': "active|alive|energetic|spaced|separated|isolated", 54 | 'Instruction': "Select words to insert.", 55 | } 56 | }, 57 | { 58 | 'model': 'InteractiveCloze', 59 | 'guid': 'qmax000006', 60 | 'fields': { 61 | 'Header': "Cloze card with editable choices", 62 | 'Intro': "Anki is a program which makes remembering things easy. There are two simple concepts behind Anki: active recall testing and spaced repetition.", 63 | 'Text': "They are not {{c1::known::~}} to most learners, despite having been {{c1::written::~}} about in the scientific literature for many years.", 64 | 'Words': "know|learn|recognize|write|describe|record", 65 | 'Instruction': "Select words to insert and put them in proper form.", 66 | } 67 | }, 68 | { 69 | 'model': 'InteractiveComplete', 70 | 'guid': 'qmax000007', 71 | 'fields': { 72 | 'Header': "Completion card", 73 | 'Intro': "Anki is a program which makes remembering things easy. There are two simple concepts behind Anki: active recall testing and spaced repetition.", 74 | 'Text': "They are not known to most learners, {{c1::despite having been written about}} in the scientific literature for many years.", 75 | 'Choices': "despite having been written about | in spite of being written about | despite being written about", 76 | 'Instruction': "Select correct sentence completion.", 77 | } 78 | }, 79 | { 80 | 'model': 'InteractiveOrder', 81 | 'guid': 'qmax000008', 82 | 'fields': { 83 | 'Header': "Ordering card", 84 | 'Intro': "Anki is a program which makes remembering things easy. There are two simple concepts behind Anki: active recall testing and spaced repetition.", 85 | 'Text': "They {{c1::are not known}} to most learners, despite {{c1::having been written}} about in the scientific literature for many years.", 86 | 'Words': "are|not|known|knowing|have|having|been|being|writing|written", 87 | 'Instruction': "Insert words in proper order.", 88 | } 89 | } 90 | ] 91 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | anki==2.1.44 -------------------------------------------------------------------------------- /screenshots/basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwiglydee/anki-interactive/cfe5b2b61baac67e6ed4d12d1146c251e6585987/screenshots/basic.png -------------------------------------------------------------------------------- /screenshots/choice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwiglydee/anki-interactive/cfe5b2b61baac67e6ed4d12d1146c251e6585987/screenshots/choice.png -------------------------------------------------------------------------------- /screenshots/cloze.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwiglydee/anki-interactive/cfe5b2b61baac67e6ed4d12d1146c251e6585987/screenshots/cloze.png -------------------------------------------------------------------------------- /screenshots/cloze_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwiglydee/anki-interactive/cfe5b2b61baac67e6ed4d12d1146c251e6585987/screenshots/cloze_c.png -------------------------------------------------------------------------------- /screenshots/cloze_e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwiglydee/anki-interactive/cfe5b2b61baac67e6ed4d12d1146c251e6585987/screenshots/cloze_e.png -------------------------------------------------------------------------------- /screenshots/compl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwiglydee/anki-interactive/cfe5b2b61baac67e6ed4d12d1146c251e6585987/screenshots/compl.png -------------------------------------------------------------------------------- /screenshots/order.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwiglydee/anki-interactive/cfe5b2b61baac67e6ed4d12d1146c251e6585987/screenshots/order.png -------------------------------------------------------------------------------- /screenshots/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwiglydee/anki-interactive/cfe5b2b61baac67e6ed4d12d1146c251e6585987/screenshots/overview.png -------------------------------------------------------------------------------- /src/base-back.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 | {{> base-top}} 8 |
9 |

{{Question}}

10 |
11 |
12 | 13 |
14 |
15 | {{#Explanation}}

{{Explanation}}

{{/Explanation}} 16 | {{#Reference}}

{{Reference}}

{{/Reference}} 17 |
18 | 19 | -------------------------------------------------------------------------------- /src/base-back.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | let answered = Persistence.getItem('answer') || ""; 3 | let correct = "{{Answer}}"; 4 | let the_input = document.querySelector("my-input"); 5 | 6 | let case_sens = answered != answered.toLowerCase(); 7 | 8 | function compare() { 9 | if( ! answered ) return 'ground'; 10 | let ans = answered, tru = correct; 11 | if(!case_sens) { 12 | ans = answered.toLowerCase(); 13 | tru = correct.toLowerCase(); 14 | } 15 | if( ans !== tru ) return 'missed'; 16 | return 'correct' 17 | } 18 | 19 | the_input.classList.add(compare()); 20 | 21 | the_input.addEventListener('click', ev => { 22 | if( the_input.classList.contains('answered') ) { 23 | the_input.value = correct; 24 | the_input.classList.remove('answered'); 25 | the_input.classList.add(compare()); 26 | } else if ( answered ) { 27 | the_input.value = answered; 28 | the_input.classList.remove('ground', 'correct', 'missed'); 29 | the_input.classList.add('answered'); 30 | } 31 | }); 32 | })(); 33 | -------------------------------------------------------------------------------- /src/base-front.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 | {{> base-top}} 8 |
9 |

{{Question}}

10 |
11 |
12 | 13 | 14 |
15 |
16 | {{#Instruction}}

{{Instruction}}

{{/Instruction}} 17 |
18 | 19 | -------------------------------------------------------------------------------- /src/base-front.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | Persistence.setItem('answer', null); 3 | let the_input = document.querySelector("my-input"); 4 | the_input.addEventListener('input', e=>{ 5 | Persistence.setItem('answer', the_input.value); 6 | }) 7 | })(); 8 | -------------------------------------------------------------------------------- /src/base-top.html: -------------------------------------------------------------------------------- 1 | {{^Cover}}{{#Header}} 2 |
3 |

{{Header}}

4 |
5 | {{/Header}}{{/Cover}} 6 | {{#Cover}} 7 |
8 | {{Cover}} 9 | {{#Header}} 10 |
11 |

{{Header}}

12 |
13 | {{/Header}} 14 |
15 | {{/Cover}} 16 | {{#Intro}} 17 |
18 |

{{Intro}}

19 |
20 |
21 | {{/Intro}} 22 | -------------------------------------------------------------------------------- /src/choice-back.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | {{> base-top}} 9 |
10 |

{{Question}}

11 |
12 |
13 | 14 |
15 |
16 | {{#Explanation}}

{{Explanation}}

{{/Explanation}} 17 | {{#Reference}}

{{Reference}}

{{/Reference}} 18 |
19 | 20 | -------------------------------------------------------------------------------- /src/choice-back.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | let the_choices = document.querySelector("my-choices"); 3 | the_choices.shuffle(Persistence.getItem('seed') || new Date().valueOf()); 4 | 5 | let answered = Persistence.getItem('answer') || []; // list of selected choices 6 | 7 | let items = split_choices("{{Choices}}"), 8 | items_p = items.filter((i) => i[0] == '+').map((i)=>i.replace(/^\+\s*/, '')), 9 | items_m = items.filter((i) => i[0] == '-').map((i)=>i.replace(/^\-\s*/, '')); 10 | let correct = items_p.length ? items_p : items_m; 11 | 12 | the_choices.items.forEach(li => { 13 | let val = li.dataset['value']; 14 | if(correct.indexOf(val) === -1) { // incorrect 15 | li.classList.add('disabled'); 16 | } else { // correct 17 | li.classList.add('selected'); 18 | if(answered.length) { 19 | li.classList.add(answered.indexOf(val) >= 0 ? 'correct' : 'missed'); 20 | } else { 21 | li.classList.add('ground'); 22 | } 23 | } 24 | }); 25 | })(); 26 | -------------------------------------------------------------------------------- /src/choice-front.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | {{> base-top}} 9 |
10 |

{{Question}}

11 |
12 |
13 | 14 |
15 |
16 | {{#Instruction}}

{{Instruction}}

{{/Instruction}} 17 |
18 | 19 | -------------------------------------------------------------------------------- /src/choice-front.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | let the_choices = document.querySelector("my-choices"); 3 | let seed = new Date().valueOf(); 4 | Persistence.setItem('seed', seed); 5 | the_choices.shuffle(seed); 6 | 7 | Persistence.setItem('answer', []); // list of selected choices 8 | the_choices.addEventListener('change', ev => { 9 | Persistence.setItem('answer', ev.detail); 10 | }); 11 | })(); 12 | -------------------------------------------------------------------------------- /src/clean.css: -------------------------------------------------------------------------------- 1 | html,body { 2 | display: block; 3 | height: 100%; 4 | } 5 | 6 | html, body, *, #content, #qa { 7 | box-sizing: border-box; 8 | margin: 0; 9 | padding: 0; 10 | } 11 | 12 | /* webanki: body main.container > div#quiz > div#qa_box.card > div#qa */ 13 | /* linux-edit: body.card > div#qa */ 14 | /* linux-preview|review: body > div#qa || body.card > div#qa */ 15 | /* android: body.card > div#content > div.question || body.card > div#content > div.answer */ 16 | 17 | body > div#qa .main, 18 | body > div#content .main { 19 | position: absolute; 20 | top: 0; bottom: 0; left: 0; right: 0; 21 | overflow: auto; 22 | } 23 | 24 | ul { 25 | list-style: none; 26 | margin: 0; 27 | padding: 0; 28 | } 29 | 30 | *:focus { 31 | outline: none; 32 | } 33 | 34 | .hidden { 35 | display: none; 36 | } 37 | 38 | .flex { 39 | flex: 1 1; 40 | } 41 | -------------------------------------------------------------------------------- /src/cloze-back.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | {{> base-top}} 9 |
10 |

{{cloze:Text}}

11 |
12 |
13 |
14 | {{#Explanation}}

{{Explanation}}

{{/Explanation}} 15 | {{#Reference}}

{{Reference}}

{{/Reference}} 16 |
17 | 18 | -------------------------------------------------------------------------------- /src/cloze-back.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | let answered = Persistence.getItem('answer') || []; // list of cloze insertions 3 | answered = answered.map(s => s.stripspaces().trim()); 4 | 5 | let the_clozen = clozify(document.querySelector(".my-clozen")); 6 | 7 | let correct = the_clozen.items.map(cloze => cloze.value).map(val => val ? val.splitrim('/') : []); 8 | let case_sens = answered && answered.filter((e) => e && e.toLowerCase() !== e).length > 0; 9 | 10 | function compare(idx) { 11 | if( answered.length == 0 ) return 'ground'; 12 | let ans = answered[idx], tru = correct[idx]; 13 | if( !ans ) return 'missed'; 14 | if (!case_sens) { 15 | ans = ans.toLowerCase(); 16 | tru = tru.map((e) => e.toLowerCase()); 17 | } 18 | if( tru.indexOf(ans) === -1 ) return 'missed'; 19 | return 'correct'; 20 | } 21 | 22 | the_clozen.items.forEach((cloze, idx) => { 23 | cloze.classList.add(compare(idx)); 24 | 25 | cloze.addEventListener('click', ev => { 26 | if( cloze.classList.contains('answered') ) { 27 | cloze.value = correct[idx].join(" / "); 28 | cloze.classList.remove('answered'); 29 | cloze.classList.add(compare(idx)); 30 | } else if ( answered[idx] ) { 31 | cloze.value = answered[idx]; 32 | cloze.classList.remove('ground', 'correct', 'missed'); 33 | cloze.classList.add('answered'); 34 | } 35 | }); 36 | }); 37 | })(); 38 | -------------------------------------------------------------------------------- /src/cloze-front.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 |
9 | {{> base-top}} 10 |
11 |

{{cloze:Text}}

12 |
13 |
14 | {{#Words}} 15 | 16 | {{/Words}} 17 |
18 | {{#Instruction}}

{{Instruction}}

{{/Instruction}} 19 |
20 | 21 | -------------------------------------------------------------------------------- /src/cloze-front.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | let answer = []; 3 | Persistence.setItem('answer', answer); // list of cloze insertions 4 | 5 | let the_chips = document.querySelector("my-chips"); 6 | let the_clozen = clozify(document.querySelector(".my-clozen"), {editable: !the_chips}), 7 | current = null; 8 | 9 | the_clozen.addEventListener('focus', ev => { 10 | current = ev.detail; 11 | if( the_chips ) show(the_chips); 12 | }); 13 | 14 | the_clozen.addEventListener('blur', ev => { 15 | current = null; 16 | if( the_chips ) hide(the_chips); 17 | }); 18 | 19 | the_clozen.addEventListener('input', ev => { 20 | answer[current.idx] = ev.detail; 21 | Persistence.setItem('answer', answer); 22 | }) 23 | 24 | if( the_chips ) { 25 | hide(the_chips); 26 | the_chips.shuffle(); 27 | 28 | the_chips.addEventListener('select', ev => { 29 | if(current) { 30 | current.cloze.value = ev.detail; 31 | current.cloze.focus(); 32 | answer[current.idx] = ev.detail; 33 | Persistence.setItem('answer', answer); 34 | } 35 | }); 36 | } 37 | 38 | })(); 39 | -------------------------------------------------------------------------------- /src/complete-front.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 |
9 | {{> base-top}} 10 |
11 |

{{cloze:Text}}

12 |
13 |
14 | 15 |
16 | {{#Instruction}}

{{Instruction}}

{{/Instruction}} 17 |
18 | 19 | -------------------------------------------------------------------------------- /src/complete-front.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | let answer = []; 3 | Persistence.setItem('answer', answer); // list of cloze insertions 4 | 5 | let the_choices = document.querySelector("my-choices"); 6 | the_choices.shuffle(); 7 | 8 | let the_clozen = clozify(document.querySelector(".my-clozen"), {placeholder: "… … …"}), 9 | current = null; 10 | 11 | hide(the_choices); 12 | 13 | the_clozen.addEventListener('focus', ev => { 14 | current = ev.detail; 15 | show(the_choices); 16 | }); 17 | 18 | the_clozen.addEventListener('blur', ev => { 19 | current = null; 20 | hide(the_choices); 21 | }); 22 | 23 | the_choices.addEventListener('change', ev => { 24 | if(current) { 25 | let val = ev.detail[0]; 26 | current.cloze.value = val; 27 | current.cloze.focus(); 28 | answer[current.idx] = val; 29 | Persistence.setItem('answer', answer); 30 | } 31 | }); 32 | 33 | })(); 34 | -------------------------------------------------------------------------------- /src/debug-back.html: -------------------------------------------------------------------------------- 1 |
2 |

{{Back}}

3 |

4 | 
5 | -------------------------------------------------------------------------------- /src/debug-front.html: -------------------------------------------------------------------------------- 1 |
2 |

{{Front}}

3 |

4 | 
5 | -------------------------------------------------------------------------------- /src/main.css: -------------------------------------------------------------------------------- 1 | .main { 2 | padding: 8px; 3 | display: flex; 4 | flex-flow: column nowrap; 5 | align-items: center; 6 | background-color: var(--theme-background0); 7 | } 8 | 9 | hr { 10 | width: 100%; 11 | height: 1px; 12 | border: none; 13 | background-color: var(--theme-divider); 14 | } 15 | 16 | p { 17 | margin: .5em 0; 18 | } 19 | 20 | .reference { 21 | font-size: x-small; 22 | } 23 | 24 | .answer { 25 | padding: .3ex; 26 | } 27 | 28 | 29 | .text .cloze.correct, 30 | .text .cloze.missed { 31 | border-radius: 2px; 32 | border-bottom: none; 33 | } 34 | 35 | li.ground { 36 | border-bottom: none; 37 | } 38 | 39 | /* material design card */ 40 | 41 | .md-card { 42 | width: 36em; /* ~60 chars */ 43 | max-width: 100%; 44 | min-width: 24em; 45 | margin-bottom: 8px; 46 | border-radius: 2px; 47 | box-shadow: var(--md-shadow-z2); 48 | background-color: var(--theme-background1); 49 | } 50 | 51 | .md-card .header { 52 | margin: 24px 0 16px; 53 | padding: 0 16px; 54 | } 55 | 56 | .md-card .cover { 57 | position: relative; 58 | padding-top: 56.25%; /* 16:9 aspect ratio */ 59 | } 60 | 61 | .md-card .cover img { 62 | display: block; 63 | position: absolute; 64 | z-index: 0; 65 | top: 0; bottom:0; left:0; right: 0; 66 | max-width: 100%; 67 | max-height: 100%; 68 | width: 100%; 69 | height: 100%; 70 | object-fit: cover; 71 | } 72 | 73 | .md-card .cover .header { 74 | position: absolute; 75 | z-index: 1; 76 | bottom: 0; left:0; right: 0; 77 | margin: 0; 78 | padding: 24px 16px 16px; 79 | } 80 | 81 | .md-card .text, 82 | .md-card > my-input { 83 | display: block; 84 | margin: 16px 0; 85 | padding: 0 16px; 86 | } 87 | 88 | .md-card .text img { 89 | display: block; 90 | margin: 8px auto; 91 | } 92 | 93 | /* my-cloze */ 94 | 95 | my-cloze { 96 | display: inline; 97 | padding: .15ex .5ex; 98 | margin: 0 -.5ex; /* compensate */ 99 | border-bottom: 1px solid var(--theme-primary); 100 | border-radius: 2px 2px 0 0 ; 101 | color: var(--theme-primary-dark); 102 | } 103 | 104 | my-cloze.contracted { 105 | padding-left: 0; 106 | } 107 | 108 | my-cloze:empty:after { 109 | content:attr(placeholder); 110 | color: var(--theme-placeholder); 111 | } 112 | 113 | my-cloze:hover { 114 | background-color: var(--theme-hover); 115 | } 116 | 117 | my-cloze:focus, my-cloze.focus { 118 | background-color: var(--theme-focus); 119 | } 120 | 121 | my-cloze.ground { 122 | color: var(--theme-foreground1); 123 | background-color: transparent; 124 | border-color: var(--theme-secondary); 125 | } 126 | 127 | my-cloze.correct { 128 | color: var(--theme-foreground1); 129 | background-color: var(--theme-correct); 130 | border-color: var(--theme-correct-dark); 131 | } 132 | 133 | my-cloze.missed { 134 | color: var(--theme-foreground1); 135 | background-color: var(--theme-missed); 136 | border-color: var(--theme-missed-dark); 137 | } 138 | 139 | /* my-choices */ 140 | 141 | ul.md-list { 142 | margin: 8px 0; 143 | } 144 | 145 | 146 | ul.md-list li { 147 | display: flex; 148 | flex-flow: row nowrap; 149 | align-items: center; 150 | justify-content: flex-start; 151 | min-height: 48px; 152 | padding-right: 16px; 153 | } 154 | 155 | .main > my-choices { 156 | min-width: 24em; 157 | border: 1px solid var(--theme-divider); 158 | border-radius: 2px; 159 | } 160 | 161 | ul.md-list li:hover { 162 | background-color: var(--theme-hover); 163 | } 164 | 165 | ul.md-list li:focus { 166 | background-color: var(--theme-focus); 167 | } 168 | 169 | ul.md-list li.correct { 170 | background-color: var(--theme-correct); 171 | } 172 | 173 | ul.md-list li.missed { 174 | background-color: var(--theme-missed); 175 | } 176 | 177 | ul.md-list li.disabled { 178 | color: var(--theme-disabled); 179 | } 180 | 181 | /* my-chips */ 182 | 183 | ul.md-chips { 184 | display: flex; 185 | flex-flow: row wrap; 186 | justify-content: center; 187 | min-width: 24em; /* ~40 chars */ 188 | max-width: 36em; /* ~60 chars */ 189 | } 190 | 191 | ul.md-chips li { 192 | display: flex; 193 | align-items: center; 194 | margin: 4px; 195 | padding: 0 12px; 196 | height: 32px; 197 | border-radius: 16px; 198 | background-color: var(--theme-fieldbox); 199 | box-shadow: var(--md-shadow-z1); 200 | } 201 | 202 | ul.md-chips li[tabindex]:active { 203 | background-color: var(--theme-active); 204 | box-shadow: var(--md-shadow-z8); 205 | } 206 | 207 | ul.md-chips li:hover { 208 | background-color: var(--theme-fieldbox-hover); 209 | } 210 | 211 | ul.md-chips li:focus { 212 | background-color: var(--theme-focus); 213 | } 214 | 215 | ul.md-chips li label, 216 | ul.md-chips li i { 217 | font-size: 1rem; 218 | line-height: 1rem; 219 | color: var(--theme-foreground1); 220 | font-style: normal; 221 | } 222 | 223 | .md-control { 224 | width: 40px; 225 | height: 40px; 226 | /* 16px from left to icon, sum up to 72px */ 227 | margin-left: 5px; 228 | margin-right: 27px; 229 | } 230 | 231 | .md-control__outline { 232 | margin: 11px; 233 | height: 18px; 234 | width: 18px; 235 | border: 2px solid var(--theme-primary); 236 | } 237 | 238 | .md-radio .md-control__outline { 239 | border-radius: 50%; 240 | } 241 | 242 | .md-check .md-control__outline { 243 | border-radius: 2px; 244 | } 245 | 246 | .md-control__inline { 247 | display: none; 248 | } 249 | 250 | .selected .md-control__inline { 251 | display: block; 252 | margin: 2px; 253 | width: 10px; 254 | height: 10px; 255 | background-color: var(--theme-primary); 256 | } 257 | 258 | .md-radio .md-control__inline { 259 | border-radius: 50%; 260 | } 261 | 262 | .md-check .md-control__inline { 263 | border-radius: 2px; 264 | } 265 | 266 | .disabled .md-control__outline, 267 | [readonly] .md-control__outline { 268 | border-color: var(--theme-disabled); 269 | } 270 | 271 | .ground .md-control__outline { 272 | border-color: var(--theme-secondary); 273 | } 274 | .ground.selected .md-control__inline { 275 | background-color: var(--theme-secondary); 276 | } 277 | 278 | .correct .md-control__outline { 279 | border-color: var(--theme-correct-dark); 280 | } 281 | .correct.selected .md-control__inline { 282 | background-color: var(--theme-correct-dark); 283 | } 284 | 285 | .missed .md-control__outline { 286 | border-color: var(--theme-missed-dark); 287 | } 288 | .missed.selected .md-control__inline { 289 | background-color: var(--theme-missed-dark); 290 | } 291 | 292 | 293 | /* my-input */ 294 | 295 | .md-textbox { 296 | flex: 0 0 36px; 297 | height: 36px; 298 | margin: 8px auto; 299 | background-color: var(--theme-fieldbox); 300 | border-radius: 4px; 301 | padding: 8px 16px; 302 | position: relative; 303 | overflow: hidden; 304 | } 305 | 306 | .md-textbox hr { 307 | position: absolute; 308 | left: 0; 309 | right: 0; 310 | bottom: 0; 311 | height: 0; 312 | border: none; 313 | margin: 0; 314 | border-bottom: 2px solid var(--theme-primary); 315 | } 316 | 317 | .md-textbox input { 318 | width: 20em; /* Betäubungsmittel-Verschreibungsverordnung */ 319 | margin: 0; 320 | padding: 0; 321 | border: none; 322 | font-size: 1rem; 323 | font-weight: 400; 324 | background: transparent; 325 | } 326 | 327 | .md-textbox 328 | { 329 | background-color: var(--theme-fieldbox); 330 | } 331 | .md-textbox:hover 332 | { 333 | background-color: var(--theme-fieldbox-hover); 334 | } 335 | 336 | .focus .md-textbox, 337 | .focus .md-textbox hr 338 | { 339 | background-color: var(--theme-focus); 340 | } 341 | 342 | .ground .md-textbox, 343 | [readonly].ground .md-textbox hr { 344 | border-color: var(--theme-secondary); 345 | } 346 | 347 | [readonly] .md-textbox hr 348 | { 349 | border-color: var(--theme-divider); 350 | } 351 | 352 | .correct .md-textbox, 353 | .correct .md-textbox hr 354 | { 355 | background-color: var(--theme-correct); 356 | border-color: var(--theme-correct-dark); 357 | } 358 | 359 | .missed .md-textbox, 360 | .missed .md-textbox hr 361 | { 362 | background-color: var(--theme-missed); 363 | border-color: var(--theme-missed-dark); 364 | } 365 | -------------------------------------------------------------------------------- /src/my-chips.js: -------------------------------------------------------------------------------- 1 | if( customElements.get('my-chips') === undefined ) { 2 | customElements.define('my-chips', class MyChips extends HTMLElement { 3 | /** list of choices like MD chips 4 | * @param {string} items value of field from card, |-joined items 5 | * @param {boolean} removable toadd 'backspace' button 6 | * @fires select {detail: value|null} when chip clicked 7 | */ 8 | connectedCallback() { 9 | this.readonly = this.hasAttribute('readonly'); 10 | this.removable = this.hasAttribute('removable'); 11 | this.items = split_choices(this.getAttribute('items')); 12 | 13 | this._render(); 14 | if( !this.readonly ) { 15 | this._bind_events(); 16 | } 17 | } 18 | 19 | shuffle(seed) { 20 | this.items.shuffle(seed); 21 | this._render(); 22 | if( !this.readonly ) { 23 | this._bind_events(); 24 | } 25 | } 26 | 27 | _render() { 28 | let l = this.items.map(i => `
  • `); 29 | if( this.removable ) { 30 | l.push(`
  • `); 31 | } 32 | this.innerHTML = `
      ${l.join("")}
    `; 33 | this._items = Array.from(this.querySelectorAll('li')); 34 | } 35 | 36 | _bind_events() { 37 | this._items.forEach(li => { 38 | li.addEventListener('click', e => { 39 | if( li.classList.contains('remove') ) { 40 | this.dispatchEvent(new CustomEvent('select', {detail: null})); 41 | } else { 42 | this._items.forEach(li=>li.classList.remove('selected')); 43 | li.classList.add('selected'); 44 | this.dispatchEvent(new CustomEvent('select', {detail: li.dataset['value']})); 45 | } 46 | }); 47 | }); 48 | } 49 | }); 50 | } 51 | -------------------------------------------------------------------------------- /src/my-choices.js: -------------------------------------------------------------------------------- 1 | if( customElements.get('my-choices') === undefined ) { 2 | customElements.define('my-choices', class MyChoices extends HTMLElement { 3 | /** list of choices like MD list/items with controls 4 | * @param {string} items value of field from card, |-joined items, +/- are stripped 5 | * @param {string} type of control 'radio' or 'checkbox' 6 | * @fires change {detail: [values]} when items are reselected 7 | */ 8 | connectedCallback() { 9 | this.readonly = this.hasAttribute('readonly'); 10 | this.type = this.getAttribute('type') || 'checkbox'; 11 | this.choices = split_choices(this.getAttribute('items')).map((i)=>i.replace(/^[\+\-]\s*/, '')); 12 | 13 | this._render(); 14 | if( !this.readonly ) { 15 | this._bind_events(); 16 | } 17 | } 18 | 19 | shuffle(seed) { 20 | this.choices.shuffle(seed); 21 | this._render(); 22 | if( !this.readonly ) { 23 | this._bind_events(); 24 | } 25 | } 26 | 27 | _render() { 28 | let l = this.choices.map(i => 29 | `
  • ` 30 | ); 31 | this.innerHTML = `
      ${l.join("")}
    `; 32 | this.items = Array.from(this.querySelectorAll('li')); 33 | } 34 | 35 | _bind_events() { 36 | this.items.forEach(li => { 37 | li.addEventListener('click', e => { 38 | if( li.classList.contains('selected') ) { 39 | li.classList.remove('selected'); 40 | } else { 41 | if( this.type === 'radio') { 42 | this.items.forEach(li => li.classList.remove('selected')); 43 | } 44 | li.classList.add('selected'); 45 | } 46 | this.dispatchEvent(new CustomEvent('change', {detail: this.value})); 47 | }); 48 | }); 49 | } 50 | 51 | get value() { 52 | return this.items.filter(i => i.classList.contains('selected')).map(i => i.dataset['value']); 53 | } 54 | }); 55 | } 56 | -------------------------------------------------------------------------------- /src/my-clozen.js: -------------------------------------------------------------------------------- 1 | if( customElements.get('my-cloze') === undefined ) { 2 | customElements.define('my-cloze', class MyCloze extends HTMLElement { 3 | /** single cloze deletion 4 | * @param textContent -> value 5 | * @param {string} placholder 6 | * @param {string} fill -- initial value for editable 7 | * @fires input (standard, if editable) 8 | */ 9 | connectedCallback() { 10 | this.tabIndex = "1"; 11 | if( !this.getAttribute('placeholder') ) this.setAttribute('placeholder', "…") 12 | this.fill = this.getAttribute('fill'); 13 | this._bind_events(); 14 | this._contracted(this.textContent); 15 | } 16 | 17 | _bind_events() { 18 | this.addEventListener('focus', e => { 19 | if( !this.value && this.fill ) this.value = this.fill; 20 | }); 21 | this.addEventListener('keypress', e => { 22 | if( e.key === 'Enter') { 23 | e.preventDefault(); 24 | } 25 | }); 26 | this.addEventListener('input', e => { 27 | this._contracted(this.textContent); 28 | }); 29 | } 30 | 31 | get value() { 32 | return this.textContent.trim(); 33 | } 34 | 35 | set value(val) { 36 | this.textContent = val; 37 | this._contracted(val); 38 | } 39 | 40 | _contracted(val) { 41 | this.classList.toggle("contracted", val && (val[0] === "'" || val[0] === "’")); 42 | } 43 | }); 44 | } 45 | 46 | function clozify(root, params) { 47 | /** wraper for anki-generated cloze-content. 48 | * replaces spans with my-cloze elements, tracks focused cloze with delayed blur. 49 | * 50 | * @param {Element} root 51 | * @param {placeholder: String, editable: boolean} params 52 | * 53 | * @property {Array[MyCloze]} items 54 | * 55 | * @fires focus { detail: my-cloze } 56 | * @fires blur when a cloze is blured and not refocused within 100ms 57 | * @fires input { detail: my-cloze.value } 58 | * 59 | */ 60 | if(!params) params = {}; 61 | root.items = []; 62 | Array.from(root.childNodes).forEach(child => { 63 | // [text] -> 64 | // [~text] -> 65 | // [~] -> 66 | // text -> text 67 | if( child.tagName === 'SPAN' && child.classList.contains('cloze') ) { 68 | let cloze = document.createElement("my-cloze"); 69 | if( params.placeholder ) cloze.setAttribute('placeholder', params.placeholder); 70 | if( params.editable ) cloze.contentEditable = true; 71 | let text = child.textContent; 72 | if (text[0] === '[') { // front side hints 73 | text = text.substr(1, text.length - 2); 74 | if (text[0] === '~') { // editable cloze 75 | text = text.substr(1).trim(); 76 | cloze.contentEditable = true; 77 | if( text ) cloze.setAttribute('fill', text); 78 | } 79 | if ( text && text !== '...') { // placeholder/prefill 80 | cloze.setAttribute('placeholder', text); 81 | } 82 | } else { // back side answers 83 | // using setter to check 'contracted' class 84 | cloze.value = text; 85 | } 86 | root.replaceChild(cloze, child); 87 | root.items.push(cloze); 88 | } 89 | }); 90 | 91 | let current = null; 92 | 93 | let blur_delay = null; 94 | root.items.forEach((cloze, idx) => { 95 | cloze.addEventListener('focus', ev => { 96 | if( blur_delay ) window.clearTimeout(blur_delay); 97 | blur_delay = undefined; 98 | 99 | cloze.classList.add('focus'); 100 | if( cloze.contentEditable ) placeCaretAtEnd(cloze); 101 | 102 | if( cloze !== root.current ) { 103 | if( root.current ) { 104 | root.current.classList.remove('focus'); 105 | } 106 | root.current = cloze; 107 | root.dispatchEvent(new CustomEvent('focus', {detail: { cloze: cloze, idx: idx}})); 108 | } 109 | }); 110 | 111 | cloze.addEventListener('blur', ev => { 112 | if( blur_delay ) return; 113 | blur_delay = window.setTimeout(() => { 114 | if( root.current ) { 115 | root.current.classList.remove('focus'); 116 | } 117 | root.current = undefined; 118 | root.current_idx = undefined; 119 | blur_delay = undefined; 120 | 121 | root.dispatchEvent(new CustomEvent('blur')); 122 | }, 150); 123 | }); 124 | 125 | cloze.addEventListener('input', ev => { 126 | ev.stopPropagation(); 127 | root.dispatchEvent(new CustomEvent('input', {detail: cloze.value})); 128 | }); 129 | }); 130 | 131 | return root; 132 | } 133 | -------------------------------------------------------------------------------- /src/my-input.js: -------------------------------------------------------------------------------- 1 | if( customElements.get('my-input') === undefined ) { 2 | customElements.define('my-input', class MyInput extends HTMLElement { 3 | /** Wrapper around input to make it like MD text field box 4 | * @prop placholder -- to pass to input 5 | */ 6 | connectedCallback() { 7 | this.readonly = this.hasAttribute('readonly'); 8 | this.placeholder = this.getAttribute('placeholder') || "…"; 9 | 10 | this._render(); 11 | this.value = (this.getAttribute('value') || "").trim(); 12 | 13 | if(!this.readonly) { 14 | this._bind_events(); 15 | } 16 | } 17 | 18 | _render() { 19 | this.innerHTML = `

    `; 20 | this._input = this.querySelector('input'); 21 | } 22 | 23 | _bind_events() { 24 | this._input.addEventListener('focus', e => { 25 | this.classList.add('focus'); 26 | }); 27 | this._input.addEventListener('blur', e => { 28 | this.classList.remove('focus'); 29 | }); 30 | } 31 | 32 | get value() { 33 | return this._input.value.trim(); 34 | } 35 | 36 | set value(val) { 37 | this._input.value = val; 38 | } 39 | }); 40 | } -------------------------------------------------------------------------------- /src/order-front.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
    8 |
    9 | {{> base-top}} 10 |
    11 |

    {{cloze:Text}}

    12 |
    13 |
    14 | 15 |
    16 | {{#Instruction}}

    {{Instruction}}

    {{/Instruction}} 17 |
    18 | 19 | -------------------------------------------------------------------------------- /src/order-front.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | let answer = []; 3 | Persistence.setItem('answer', answer); // list of cloze insertions 4 | 5 | let the_chips = document.querySelector("my-chips"); 6 | the_chips.shuffle(); 7 | 8 | let the_clozen = clozify(document.querySelector(".my-clozen"), {placeholder: "… … …"}), 9 | current = null; 10 | 11 | hide(the_chips); 12 | 13 | the_clozen.addEventListener('focus', ev => { 14 | current = ev.detail; 15 | show(the_chips); 16 | }); 17 | 18 | the_clozen.addEventListener('blur', ev => { 19 | current = null; 20 | hide(the_chips); 21 | }); 22 | 23 | the_chips.addEventListener('select', ev => { 24 | if( current ) { 25 | let ans = answer[current.idx]; 26 | ans = ans ? ans.split("\t") : []; 27 | 28 | if( ev.detail ) { 29 | ans.push(ev.detail); 30 | } else if( ans.length ) { 31 | ans.pop(); 32 | } 33 | 34 | update_cloze(current.cloze, ans); 35 | current.cloze.focus(); 36 | answer[current.idx] = ans.join("\t"); 37 | Persistence.setItem('answer', answer); 38 | } 39 | }); 40 | 41 | function update_cloze(cloze, words) { 42 | if( words.length ) { 43 | cloze.value = words.join("\u0009") + "…"; 44 | } else { 45 | cloze.value = null; 46 | } 47 | } 48 | })(); 49 | -------------------------------------------------------------------------------- /src/persistence.js: -------------------------------------------------------------------------------- 1 | // v0.5.0 - https://github.com/SimonLammer/anki-persistence/blob/3e08d4437272b869dc3ccb48369b3482ccea4c9f/script.js 2 | if(void 0===window.Persistence){var _persistenceKey="github.com/SimonLammer/anki-persistence/",_defaultKey="_default";if(window.Persistence_sessionStorage=function(){var e=!1;try{"object"==typeof window.sessionStorage&&(e=!0,this.clear=function(){for(var e=0;e0&&titleContentIndex>0&&titleContentIndex-titleStartIndex<10&&(window.Persistence=new Persistence_windowKey("qt"))}} -------------------------------------------------------------------------------- /src/random.js: -------------------------------------------------------------------------------- 1 | if( window.Random === undefined ) { 2 | // https://gist.github.com/blixt/f17b47c62508be59987b 3 | /** 4 | * Creates a pseudo-random value generator. The seed must be an integer. 5 | * 6 | * Uses an optimized version of the Park-Miller PRNG. 7 | * http://www.firstpr.com.au/dsp/rand31/ 8 | */ 9 | function Random(seed) { 10 | this._seed = seed % 2147483647; 11 | if (this._seed <= 0) this._seed += 2147483646; 12 | } 13 | 14 | /** 15 | * Returns a pseudo-random value between 1 and 2^32 - 2. 16 | */ 17 | Random.prototype.next = function () { 18 | return this._seed = this._seed * 16807 % 2147483647; 19 | }; 20 | 21 | 22 | /** 23 | * Returns a pseudo-random floating point number in range [0, 1). 24 | */ 25 | Random.prototype.nextFloat = function (opt_minOrMax, opt_max) { 26 | // We know that result of next() will be 1 to 2147483646 (inclusive). 27 | return (this.next() - 1) / 2147483646; 28 | }; 29 | } 30 | 31 | Array.prototype.shuffle = function (seed) { 32 | // Fisher–Yates shuffle 33 | var random = new Random(seed || new Date().valueOf()) 34 | if( !random ) throw "No random generator"; 35 | for (let i = this.length-1; i >= 1; i--) { 36 | let j = Math.floor(random.nextFloat() * i); 37 | [this[i], this[j]] = [this[j], this[i]]; 38 | } 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /src/theme.css: -------------------------------------------------------------------------------- 1 | .cover .header { 2 | background-image: linear-gradient(to bottom, transparent 0%, hsla(199, 100%, 10%, .6) 24px, hsla(199, 100%, 10%, .95) 100%); 3 | color: white; 4 | } 5 | 6 | input::-webkit-input-placeholder { 7 | color: var(--theme-placeholder); 8 | } 9 | 10 | /* material design typography */ 11 | 12 | body { 13 | font-family: Roboto, sans-serif; 14 | -moz-osx-font-smoothing: grayscale; 15 | -webkit-font-smoothing: antialiased; 16 | color: var(--theme-foreground1); 17 | } 18 | 19 | .md-headline6 { 20 | font-size: 1.25rem; 21 | line-height: 2rem; 22 | font-weight: 500; 23 | letter-spacing: 0.0125em; 24 | text-decoration: inherit; 25 | text-transform: inherit; } 26 | 27 | .md-body1 { 28 | font-size: 1rem; 29 | line-height: 1.5rem; 30 | font-weight: 400; 31 | letter-spacing: 0.03125em; 32 | text-decoration: inherit; 33 | text-transform: inherit; } 34 | 35 | .md-body2 { 36 | font-size: 0.875rem; 37 | line-height: 1.25rem; 38 | font-weight: 400; 39 | letter-spacing: 0.01786em; 40 | text-decoration: inherit; 41 | text-transform: inherit; } 42 | 43 | .md-caption { 44 | font-size: 0.75rem; 45 | line-height: 1.25rem; 46 | font-weight: 400; 47 | letter-spacing: 0.03333em; 48 | text-decoration: inherit; 49 | text-transform: inherit; } 50 | 51 | :root { 52 | --theme-primary: hsl(199, 100%, 50%); 53 | --theme-primary-dark: hsl(199, 100%, 20%); 54 | --theme-secondary: hsl(36, 100%, 50%); 55 | 56 | --theme-correct: hsl(120, 80%, 80%); 57 | --theme-correct-dark: hsl(120, 50%, 50%); 58 | --theme-missed: hsl(50, 100%, 80%); 59 | --theme-missed-dark: hsl(50, 50%, 50%); 60 | 61 | --theme-background0: hsl(199, 100%, 95%); 62 | --theme-background1: hsl(0, 0%, 98%); 63 | --theme-foreground1: rgba(0, 0, 0, .87); 64 | --theme-foreground2: rgba(0, 0, 0, .54); 65 | --theme-divider: hsla(199, 100%, 20%, .12); 66 | --theme-disabled: hsla(199, 100%, 20%, .26); 67 | --theme-placeholder: hsla(199, 100%, 20%, .38); 68 | 69 | --state-hover: .04; 70 | --state-selected: .08; 71 | --state-focus: .12; 72 | --state-activated: .12; 73 | 74 | --theme-fieldbox: rgba(0, 0, 0, .05); 75 | --theme-fieldbox-hover: rgba(0, 0, 0, .09); 76 | --theme-hover: rgba(0, 0, 0, var(--state-hover)); 77 | --theme-selected: rgba(0, 0, 0, var(--state-selected)); 78 | --theme-focus: rgba(0, 0, 0, var(--state-focus)); 79 | --theme-active: rgba(0,0,0, var(--state-activated)); 80 | 81 | --md-shadow-z1: 0 2px 1px -1px rgba(0,0,0,.2), 0 1px 1px 0 rgba(0,0,0,.14), 0 1px 3px 0 rgba(0,0,0,.12); 82 | --md-shadow-z2: 0 3px 1px -2px rgba(0,0,0,.2), 0 2px 2px 0 rgba(0,0,0,.14), 0 1px 5px 0 rgba(0,0,0,.12); 83 | --md-shadow-z8: 0 5px 5px -3px rgba(0,0,0,.2), 0 8px 10px 1px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12); 84 | } 85 | -------------------------------------------------------------------------------- /src/utils.js: -------------------------------------------------------------------------------- 1 | if(!Persistence.isAvailable()) { 2 | /* dumb implementaion */ 3 | window.Persistence = { 4 | isAvailable: function() { return false; }, 5 | clear: function(){}, 6 | getItem: function(){}, 7 | setItem: function(){}, 8 | removeItem: function(){} 9 | }; 10 | } 11 | 12 | function debug(message) { 13 | let d = document.querySelector("#debug"); 14 | if(!d) return; 15 | d.textContent += "\n"+message; 16 | } 17 | 18 | String.prototype.splitrim = function (sep) { 19 | return this.split(sep).map(e => e.trim()); 20 | }; 21 | 22 | function split_choices(str) { 23 | return str.splitrim(/
    |\|/).filter(e => e !== ""); 24 | } 25 | 26 | String.prototype.stripspaces = function() { 27 | return this.replace(/\s+/g, ' '); 28 | }; 29 | 30 | function placeCaretAtEnd(el) { 31 | if (typeof window.getSelection != "undefined" 32 | && typeof document.createRange != "undefined") { 33 | var range = document.createRange(); 34 | range.selectNodeContents(el); 35 | range.collapse(false); 36 | var sel = window.getSelection(); 37 | sel.removeAllRanges(); 38 | sel.addRange(range); 39 | } else if (typeof document.body.createTextRange != "undefined") { 40 | var textRange = document.body.createTextRange(); 41 | textRange.moveToElementText(el); 42 | textRange.collapse(false); 43 | textRange.select(); 44 | } 45 | } 46 | 47 | function hide(elem) { elem.classList.add('hidden'); }; 48 | 49 | function show(elem) { elem.classList.remove('hidden'); }; 50 | 51 | function toggle(elem) { elem.classList.toggle('hidden'); }; -------------------------------------------------------------------------------- /src/webcomponents-ce.js: -------------------------------------------------------------------------------- 1 | /** 2 | @license @nocompile 3 | Copyright (c) 2018 The Polymer Project Authors. All rights reserved. 4 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 5 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 6 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 7 | Code distributed by Google as part of the polymer project is also 8 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 9 | */ 10 | (function(){'use strict';var aa=new Set("annotation-xml color-profile font-face font-face-src font-face-uri font-face-format font-face-name missing-glyph".split(" "));function g(b){var a=aa.has(b);b=/^[a-z][.0-9_a-z]*-[\-.0-9_a-z]*$/.test(b);return!a&&b}function l(b){var a=b.isConnected;if(void 0!==a)return a;for(;b&&!(b.__CE_isImportDocument||b instanceof Document);)b=b.parentNode||(window.ShadowRoot&&b instanceof ShadowRoot?b.host:void 0);return!(!b||!(b.__CE_isImportDocument||b instanceof Document))} 11 | function n(b,a){for(;a&&a!==b&&!a.nextSibling;)a=a.parentNode;return a&&a!==b?a.nextSibling:null} 12 | function p(b,a,d){d=void 0===d?new Set:d;for(var c=b;c;){if(c.nodeType===Node.ELEMENT_NODE){var e=c;a(e);var f=e.localName;if("link"===f&&"import"===e.getAttribute("rel")){c=e.import;if(c instanceof Node&&!d.has(c))for(d.add(c),c=c.firstChild;c;c=c.nextSibling)p(c,a,d);c=n(b,e);continue}else if("template"===f){c=n(b,e);continue}if(e=e.__CE_shadowRoot)for(e=e.firstChild;e;e=e.nextSibling)p(e,a,d)}c=c.firstChild?c.firstChild:n(b,c)}}function r(b,a,d){b[a]=d};function u(){this.a=new Map;this.s=new Map;this.f=[];this.b=!1}function ba(b,a,d){b.a.set(a,d);b.s.set(d.constructor,d)}function v(b,a){b.b=!0;b.f.push(a)}function w(b,a){b.b&&p(a,function(a){return x(b,a)})}function x(b,a){if(b.b&&!a.__CE_patched){a.__CE_patched=!0;for(var d=0;d -1) { 26 | document.body.className = document.body.className + " chrome"; 27 | } else { 28 | if (window.innerWidth === 0 || window.innerHeight === 0) { 29 | return; 30 | } 31 | var maxWidth = window.innerWidth * 0.90; 32 | var maxHeight = window.innerHeight * 0.90; 33 | var ratio = 0; 34 | var images = document.getElementsByTagName('img'); 35 | for (var i = 0; i < images.length; i++) { 36 | var img = images[i]; 37 | var scale = 1; 38 | var zoom = window.getComputedStyle(img).getPropertyValue("zoom"); 39 | if (!isNaN(zoom)) { 40 | scale = zoom; 41 | } 42 | var width = img.width * scale; 43 | var height = img.height * scale; 44 | if (width > maxWidth) { 45 | img.width = maxWidth; 46 | img.height = height * (maxWidth / width); 47 | width = img.width; 48 | height = img.height; 49 | img.style.zoom = 1; 50 | } 51 | if (height > maxHeight) { 52 | img.width = width * (maxHeight / height); 53 | img.height = maxHeight; 54 | img.style.zoom = 1; 55 | } 56 | } 57 | } 58 | resizeDone = true; 59 | }; 60 | 61 | /* Tell the app that the input box got focus. See also 62 | * AbstractFlashcardViewer and CompatV15 */ 63 | function taFocus() { 64 | window.location.href = "signal:typefocus"; 65 | } 66 | 67 | /* Tell the app the text in the input box when it loses focus */ 68 | function taBlur(itag) { 69 | window.location.href = "typeblurtext:" + itag.value; 70 | } 71 | 72 | /* Look at the text enterend into the input box and send the text on a return */ 73 | function taKey(itag, e) { 74 | var keycode; 75 | if (window.event) { 76 | keycode = window.event.keyCode; 77 | } else if (e) { 78 | keycode = e.which; 79 | } else { 80 | return true; 81 | } 82 | 83 | if (keycode == 13) { 84 | window.location.href = "typeentertext:" + itag.value; 85 | return false; 86 | } else { 87 | return true; 88 | } 89 | } 90 | 91 | window.onload = function() { 92 | /* If the WebView loads too early on Android <= 4.3 (which happens 93 | on the first card or regularly with WebView switching enabled), 94 | the window dimensions returned to us will be default built-in 95 | values. In this case, issuing a scroll event will force the 96 | browser to recalculate the dimensions and give us the correct 97 | values, so we do this every time. This lets us resize images 98 | correctly. */ 99 | window.scrollTo(0,0); 100 | resizeImages(); 101 | window.location.href = "#answer"; 102 | }; 103 | 104 | var onPageFinished = function() { 105 | if (!resizeDone) { 106 | resizeImages(); 107 | /* Re-anchor to answer after image resize since the point changes */ 108 | window.location.href = "#answer"; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /test/anki-cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwiglydee/anki-interactive/cfe5b2b61baac67e6ed4d12d1146c251e6585987/test/anki-cover.png -------------------------------------------------------------------------------- /test/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | layout and style 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
    22 |
    23 | 24 | 25 | 26 |
    27 |
    28 | 29 |
    30 |
    31 |

    Some fundamental concepts

    32 |
    33 |
    34 |
    35 |

    36 | Anki is a program which makes remembering things easy. 37 | Because it is a lot more efficient than traditional study methods, 38 | you can either greatly decrease your time spent studying, 39 | or greatly increase the amount you learn. 40 |

    41 |
    42 |
    43 |
    44 |

    48 | Anki is a program which makes remembering things easy. 49 | Anki is a program which makes remembering things easy. 50 |
    51 | Empty clozes: [...], placeholder: [placeholder]. 52 | Editable clozes: [~], fill: [~fill]. 53 | Backside clozes: ground: ground, correct: correct, missed: missed. 54 |
    55 | Anki is a program which makes remembering things easy. 56 | Anki is a program which makes remembering things easy. 57 |

    58 |
    59 |
    60 | 64 | 65 | 66 | 67 | 68 | 69 |
    70 | 72 | 73 | 76 | 77 |
    78 |

    Some explanation

    79 |

    https://apps.ankiweb.net/docs/manual.html 80 |

    81 |
    82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /test/demo.js: -------------------------------------------------------------------------------- 1 | var the_clozen = clozify(document.querySelector(".my-clozen")); //, {placeholder: "???"}); 2 | var cur_cloze = null; 3 | 4 | // the_clozen.items.forEach(cloze => { 5 | // if( cloze.value ) { // ground/correct/missed 6 | // cloze.classList.add(cloze.value); 7 | // } 8 | // }); 9 | 10 | function on_cloze_focus(ev) { 11 | console.debug("cloze focus", ev, ev.detail); 12 | cur_cloze = ev.detail; 13 | } 14 | 15 | function on_cloze_blur(ev) { 16 | console.debug("cloze blur", ev, ev.detail); 17 | cur_cloze = null; 18 | } 19 | 20 | function on_cloze_input(ev) { 21 | console.debug("cloze change", ev, ev.detail); 22 | } 23 | 24 | function on_input(ev) { 25 | console.debug("input change", ev, ev.detail, " = ", the_input.value); 26 | }; 27 | 28 | function on_chip_select(ev) { 29 | console.debug("chip select", ev, ev.detail); 30 | if( cur_cloze ) { 31 | cur_cloze.cloze.value = ev.detail; 32 | cur_cloze.cloze.focus(); 33 | } 34 | } 35 | 36 | function on_chip_remove(ev) { 37 | console.debug("chip remove", ev, ev.detail); 38 | } 39 | 40 | function on_choice_change(ev) { 41 | console.debug("choices change", ev, ev.detail); 42 | } 43 | 44 | var the_input = document.querySelector('my-input'); 45 | 46 | var the_choices = document.querySelector('my-choices'); 47 | the_choices.items[1].classList.add('correct'); 48 | the_choices.items[1].classList.add('selected'); 49 | the_choices.items[2].classList.add('missed'); 50 | the_choices.items[2].classList.add('selected'); 51 | the_choices.items[3].classList.add('disabled'); 52 | 53 | 54 | -------------------------------------------------------------------------------- /test/layout-android.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AnkidDroid Flashcard 5 | 6 | 7 | 8 | 9 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 |
    75 |
    76 | 77 | 78 |
    79 |
    80 |
    81 | 82 |
    83 |

    Header

    84 |
    85 |
    86 |
    87 |

    Intro

    88 |
    89 |
    90 |
    91 |

    card text

    92 |
    93 |
    94 | some controls 95 |
    96 | chips/choices 97 |
    98 |

    Instruction

    99 |
    100 |
    101 |
    102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /test/layout-iphone.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | 15 | 51 | 52 | 54 | 55 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 |
    111 | 113 | 114 |
    115 |
    116 |
    117 | 118 |
    119 |

    Header

    120 |
    121 |
    122 |
    123 |

    Intro

    124 |
    125 |
    126 |
    127 |

    card text

    128 |
    129 |
    130 | some controls 131 |
    132 | chips/choices 133 |
    134 |

    Instruction

    135 |
    136 | 137 |
    138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /test/layout-linux-review.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | main webview 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 56 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 66 | 68 | 70 |
    71 | 73 | 74 |
    75 |
    76 |
    77 | 78 |
    79 |

    Header

    80 |
    81 |
    82 |
    83 |

    Intro

    84 |
    85 |
    86 |
    87 |

    card text

    88 |
    89 |
    90 | some controls 91 |
    92 | chips/choices 93 |
    94 |

    Instruction

    95 |
    96 |
    97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /test/linux-assets/browsersel.js: -------------------------------------------------------------------------------- 1 | /* CSS Browser Selector v0.4.0 (Nov 02, 2010) Rafael Lima (http://rafael.adm.br) */function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent); 2 | -------------------------------------------------------------------------------- /test/linux-assets/reviewer.css: -------------------------------------------------------------------------------- 1 | hr { 2 | background-color: #ccc; 3 | } 4 | 5 | body { 6 | margin: 20px; 7 | overflow-wrap: break-word; 8 | } 9 | 10 | body.nightMode { 11 | background-color: black; 12 | color: white; 13 | } 14 | 15 | img { 16 | max-width: 95%; 17 | max-height: 95%; 18 | } 19 | 20 | #_flag { 21 | position: fixed; 22 | right: 10px; 23 | top: 0; 24 | font-size: 30px; 25 | display: none; 26 | -webkit-text-stroke-width: 1px; 27 | -webkit-text-stroke-color: black; 28 | } 29 | 30 | #_mark { 31 | position: fixed; 32 | left: 10px; 33 | top: 0; 34 | font-size: 30px; 35 | color: yellow; 36 | display: none; 37 | -webkit-text-stroke-width: 1px; 38 | -webkit-text-stroke-color: black; 39 | } 40 | 41 | #typeans { 42 | width: 100%; 43 | } 44 | 45 | .typeGood { 46 | background: #0f0; 47 | } 48 | 49 | .typeBad { 50 | background: #f00; 51 | } 52 | 53 | .typeMissed { 54 | background: #ccc; 55 | } 56 | -------------------------------------------------------------------------------- /test/linux-assets/reviewer.js: -------------------------------------------------------------------------------- 1 | var ankiPlatform = "desktop"; 2 | var typeans; 3 | var _updatingQA = false; 4 | 5 | var qFade = 100; 6 | var aFade = 0; 7 | 8 | var onUpdateHook; 9 | var onShownHook; 10 | 11 | function _runHook(arr) { 12 | for (var i=0; i')},actOff:function(){(0,a["default"])("#act").remove()},select:function(t){var e=this;this.actOn(t);var r="select/"+t;a["default"].post(r,{},function(t){e.actOff(),window.location=_host+"/study/"})},deckok:function(t){return!/::$|^::|::::/.test(t)},rem:function(t){var e=this;return"1"===t?void alert("The default deck can not be removed at the moment. You can delete cards that are inside it with the computer version."):void(confirm("Delete all cards in deck? This can not be undone.")&&(this.actOn(t),a["default"].getJSON("delete",{id:t},function(t){e.actOff(),window.location.reload()})))},share:function(t){if("1"===t){var e="Unfortunately the default deck can't be shared at the moment. Please move your cards into a new deck using the computer version, and then try again.";return void alert(e)}window.location="/decks/share/"+t},rename:function(t){var e=this,r=(0,a["default"])("#did"+t),n=r.data("full"),i=prompt("Enter new name",n);if(i&&n!==i){if(!this.deckok(i))return void alert("Invalid name");this.actOn(t),a["default"].getJSON("rename",{id:t,"new":i},function(t){e.actOff(),"ok"===t.status?window.location.reload():"exists"===t.status&&alert("The provided deck already exists.")})}},updateTimezone:function(){var t=(new Date).getTimezoneOffset();a["default"].post("/decks/updateTimezone",{offset:t},function(t){t.needRefresh&&location.reload(!0)}).fail(function(){return window.alert("Error communicating with server.")})}};(0,a["default"])(function(){return o.init()}),t["default"]=o}),require.register("editor.js",function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function t(t,e){var r=[],n=!0,i=!1,a=void 0;try{for(var o,s=t[Symbol.iterator]();!(n=(o=s.next()).done)&&(r.push(o.value),!e||r.length!==e);n=!0);}catch(l){i=!0,a=l}finally{try{!n&&s["return"]&&s["return"]()}finally{if(i)throw a}}return r}return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=e("jquery"),o=n(a),s={version:"20170111",data:[],init:function(){"add"===this.mode?(this.setupModels(),this.setupDecks()):((0,o["default"])("#modelarea").hide(),(0,o["default"])("#save2").show(),this.drawFields(),this.fillFields())},setupModels:function(){var t=this,e="",r=0;this.models.sort(function(t,e){return t.name.localeCompare(e.name)});var n=!0,i=!1,a=void 0;try{for(var s,l=Array.from(this.models)[Symbol.iterator]();!(n=(s=l.next()).done);n=!0){var d,u=s.value;u.id.toString()===this.curModelID.toString()?(d="selected",this.curModel=u):d="",e+="",r+=1}}catch(c){i=!0,a=c}finally{try{!n&&l["return"]&&l["return"]()}finally{if(i)throw a}}(0,o["default"])("#models").html(e),(0,o["default"])("#models").change(function(){return t.onModelChange()}),this.onModelChange()},setupDecks:function(){var t=[];for(var e in this.decks){var r=this.decks[e];t.push(r.name)}t.sort(),(0,o["default"])("#deck").completer({source:t,suggest:!0})},onModelChange:function(){var t=(0,o["default"])("#models").val();this.curModel=this.models[t];var e=this.decks[this.curModel.did];e?(0,o["default"])("#deck").val(e.name):(0,o["default"])("#deck").val("Default"),this.drawFields()},drawFields:function(){var t="",e=0,r=[],n=!0,a=!1,s=void 0;try{for(var l,d=Array.from(this.curModel.flds)[Symbol.iterator]();!(n=(l=d.next()).done);n=!0){var u=l.value;r.push([u.name,e]),e++}}catch(c){a=!0,s=c}finally{try{!n&&d["return"]&&d["return"]()}finally{if(a)throw s}}r.push(["Tags",-1]);var f=!0,h=!1,v=void 0;try{for(var y,m=Array.from(r)[Symbol.iterator]();!(f=(y=m.next()).done);f=!0){var w=i(y.value,2),p=w[0],g=w[1];t+='\n
    \n \n
    \n
    \n'}}catch(c){h=!0,v=c}finally{try{!f&&m["return"]&&m["return"]()}finally{if(h)throw v}}(0,o["default"])("#fields").html(t),this.setFonts()},setFonts:function(){var t=0;Array.from(this.curModel.flds).map(function(e){return(0,o["default"])("#f"+t).css("font-family",e.font).css("font-size",e.size),t++})},fillFields:function(){for(var t=0;t"+l.name+"").appendTo(t),l.id.toString()===this.deck.conf.toString()&&(this.idx=e),e++}}catch(d){n=!0,i=d}finally{try{!r&&s["return"]&&s["return"]()}finally{if(n)throw i}}t.val(this.idx)},readOpts:function(){var t=this.confs[this.idx];(0,a["default"])("#newDay").val(t["new"].perDay),(0,a["default"])("#revDay").val(t.rev.perDay)},writeOpts:function(t){var e={revDay:(0,a["default"])("#revDay").val(),newDay:(0,a["default"])("#newDay").val()};a["default"].post("saveOpts",{data:JSON.stringify(e)},function(e){t&&t()})},save:function(){return this.writeOpts(function(){window.location="/study/"}),!1}};(0,a["default"])(function(){return o.init()}),t["default"]=o}),require.register("sharedlist.js",function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(t,"__esModule",{value:!0});var i=e("jquery"),a=n(i),o={init:function(){this.sortStars()},cmp:function(t,e){return t>e?1:t0",l=u[7]?u[7]:"0"),t+=''+u[1]+"\n"+this.stars(u)+'\n'+this.mod(u[4])+"",this.decks&&(t+=""+d+'\n'+s+'\n'+l+"")}}catch(c){r=!0,n=c}finally{try{!e&&o["return"]&&o["return"]()}finally{if(r)throw n}}t+="";var f='\n\n\n';this.decks&&(f+='\n'),f+="",t=f+t+"
    TitleRatingsModifiedNotesAudioImages
    ",1e3===this.files.length&&(t+="

    More that 1000 matches found; please narrow your search."),(0,a["default"])("#list").html(t)}},stars:function(t){var e=t[2]+t[3],r=Math.round(t[2]/e*25);return'
    '+e+"
    "},mod:function(t){var e=new Date(t*=1e3),r=e.getMonth()+1;r<10&&(r="0"+r);var n=e.getDate();return n<10&&(n="0"+n),e.getFullYear()+"-"+r+"-"+n},search:function(){window.location="/shared/decks/"+(0,a["default"])("#q").val()}};(0,a["default"])(function(){return o.init()}),t["default"]=o}),require.register("study.js",function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(t,"__esModule",{value:!0});var i=e("jquery"),a=n(i);String.prototype.format=function(){var t=/\{\d+\}/g,e=arguments;return this.replace(t,function(t){return e[t.match(/\d+/)]})};var o={state:"initial",lastCardShown:0,currentCard:null,activityCount:0,CID:0,CQUESTION:1,CANSWER:2,CQUEUE:3,CNID:4,CINTS:5,CORD:6,deck:{stats:[0,0,0],cards:[],answers:[]},targetURL:null,zoom:1,cacheBust:1,initStudy:function(){var t=this;(0,a["default"])("#overview").hide(),(0,a["default"])("#quiz").show(),window.onbeforeunload=function(){return t.deck.answers.length?"Please save first.":null},(0,a["default"])(document).keyup(function(e){e.which>=49&&e.which<=52&&t.answerCard(e.which-48)}),(0,a["default"])("content").addClass("contentAjax"),this.checkForNextCard()},getNextCard:function(){this.currentCard=this.deck.cards.shift()},getCards:function(t){var e=this;if(null==t&&(t=!1),0!==this.deck.cards.length&&!t)return this.drawQuestion();0===this.deck.cards.length&&this.showWaiting();var r=this.deck.answers;this.deck.answers=[];var n={answers:r};t&&(n.force=!0),this.getJSON(_ihost+"/study/getCards",n,function(r){if(e.targetURL)return void(window.parent.location=e.targetURL);if(e.hideWaiting(),t)return void e.updateStatus();r.error&&alert("Your collection is in an inconsistent state. Please use Tools>Check Database on the computer version."),e.deck.stats=r.counts;var n=!0,i=!1,a=void 0;try{for(var o,s=Array.from(r.cards)[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var l=o.value;e.deck.cards.push(l)}}catch(d){i=!0,a=d}finally{try{!n&&s["return"]&&s["return"]()}finally{if(i)throw a}}e.deck.cards.length?e.drawQuestion():window.location.reload()})},saveThenGoto:function(t){this.targetURL=_host+t,this.getCards(!0)},checkForNextCard:function(){this.state="initial",(0,a["default"])("#qa").html(""),this.vhide("#easebuts"),this.vshow("#quiz"),this.getCards()},save:function(){this.deck.answers.length&&this.getCards(!0)},drawQuestion:function(){if("initial"===this.state){this.getNextCard(),this.state="questionShown",this.lastCardShown=(new Date).getTime(),this.updateStatus();var t=(0,a["default"])("#qa_box");t[0].className="card card"+(this.currentCard[this.CORD]+1),(0,a["default"])("#qa").html(this.wrappedQA("q")),this._resizeFonts(),this.vshow("#ansbut"),(0,a["default"])("#ansbuta").focus(),document.getElementById("quiz").scrollIntoView()}},drawAnswer:function(){var t=void 0;if("questionShown"!==this.state)return!1;var e=this._getButtons(),r="

    ",n=!0,i=!1,o=void 0;try{for(var s,l=Array.from(e)[Symbol.iterator]();!(n=(s=l.next()).done);n=!0){var d=s.value,u=void 0;"Good"===d[1]?(u="btn-primary",t=d[0]):u="btn-secondary",r+=""}}catch(c){i=!0,o=c}finally{try{!n&&l["return"]&&l["return"]()}finally{if(i)throw o}}r+="
    \n"+d[2]+"
    ",this.vhide("#ansbut"),(0,a["default"])("#easebuts").html(r),this.state="answerShown",this.vshow("#easebuts"),(0,a["default"])("#qa").html(this.wrappedQA("a")),this._resizeFonts(),(0,a["default"])("#ease"+t).focus();var f=document.getElementById("answer");return f&&setTimeout(function(){f.scrollIntoView()},10),!1},_getButtons:function(){var t=this.currentCard[this.CINTS];return 4===t.length?[[1,"Again",t[0]],[2,"Hard",t[1]],[3,"Good",t[2]],[4,"Easy",t[3]]]:3===t.length?[[1,"Again",t[0]],[2,"Good",t[1]],[3,"Easy",t[2]]]:[[1,"Again",t[0]],[2,"Good",t[1]]]},answerCard:function(t){"answerShown"===this.state&&(t>this.currentCard[this.CINTS].length||(this.state="initial",this.deck.answers.push([this.currentCard[this.CID],t,(new Date).getTime()-this.lastCardShown]),this.currentCard=null,this.checkForNextCard()))},updateStatus:function(){var t=void 0,e=void 0,r=void 0,n=this.deck.stats;if(this.currentCard){var i=this.currentCard[this.CQUEUE];e="{0}".format(n[1]),r="{0}".format(n[2]),t="{0}".format(n[0]),0===i?t="{0}".format(t):1===i?e="{0}".format(e):r="{0}".format(r),(0,a["default"])("#rightStudyMenu").html("{0} + {1} + {2}".format(t,e,r))}else e=0,r=0,t=0,(0,a["default"])("#rightStudyMenu").html("");var o="";if(this.currentCard){var s=void 0;o="Edit ".format(this.currentCard[this.CNID])+o,s=this.deck.answers.length?"btn btn-secondary":"btn btn-secondary disabled",o+=" Save",o+='\n \n \n'}(0,a["default"])("#leftStudyMenu").html(o)},randomUniform:function(t,e){return Math.random()*(e-t)+t},vshow:function(t){return(0,a["default"])(t).removeClass("invisible")},vhide:function(t){return(0,a["default"])(t).addClass("invisible")},showWaiting:function(){return this.vshow("#activity")},hideWaiting:function(){return this.vhide("#activity")},showQuiz:function(){return this.vshow("#quiz")},getJSON:function(t,e,r,n){var i=this;null==n&&(n=!1);var o=!0,s=!1,l=void 0;try{for(var d,u=Object.keys(e||{})[Symbol.iterator]();!(o=(d=u.next()).done);o=!0){var c=d.value;e[c]=JSON.stringify(e[c])}}catch(f){s=!0,l=f}finally{try{!o&&u["return"]&&u["return"]()}finally{if(s)throw l}}e.ts=(new Date).getTime(),n||this.showWaiting();var h=a["default"].post(t,e,function(t){try{r(t)}catch(e){console.warn(e);try{console.warn(e.stack)}catch(e){}}},"json");h.fail(function(t,e,r){i.hideWaiting(),alert("Error while saving latest answers. Reloading..."),window.location.reload()})},wrappedQA:function(t){var e="q"===t?this.CQUESTION:this.CANSWER,r=this.currentCard[e],n="",i=1,a=function(t,e){if(/.mp3/i.test(e)){var r='
    \n
    \n \n \n
    \n';return i+=1,r}return""};return r=r.replace(/\[sound:(.+?)\]/g,a),r=r.replace(/\[\[type:.+?\]\]/g,""),r+=n},showDesc:function(){return(0,a["default"])("#shortdesc").hide(),(0,a["default"])("#fulldesc").show(),!1},bigger:function(){this._adjSize(.1)},smaller:function(){this._adjSize(-.1)},_adjSize:function(t){this.zoom+=t,this._resizeFonts()},_resizeFonts:function(){(0,a["default"])("#qa, #qa *").css("zoom",this.zoom)}};(0,a["default"])(function(){return(0,a["default"])("#studynow").focus()}),t["default"]=o}),require.register("tools.js",function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(t,"__esModule",{value:!0});var i=e("jquery"),a=n(i),o={renderTimestamps:function(){(0,a["default"])(".timestamp").each(function(t,e){(0,a["default"])(this).text(new Date(1e3*(0,a["default"])(this).text()).toLocaleDateString())})}};t["default"]=o}),require.alias("process/browser.js","process"),t=require("process"),require.register("___globals___",function(t,e,r){window.$=e("jquery"),window.jQuery=e("jquery")})}(),require("___globals___"); -------------------------------------------------------------------------------- /tmp/Interactive Demo.apkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwiglydee/anki-interactive/cfe5b2b61baac67e6ed4d12d1146c251e6585987/tmp/Interactive Demo.apkg -------------------------------------------------------------------------------- /tmp/Interactive.Demo.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwiglydee/anki-interactive/cfe5b2b61baac67e6ed4d12d1146c251e6585987/tmp/Interactive.Demo.zip --------------------------------------------------------------------------------