+
From 09fc8f8c76848ee053831d2e1c86aec6fdd2d468 Mon Sep 17 00:00:00 2001 From: zunaidahmed96 <123038546+zunaidahmed96@users.noreply.github.com> Date: Sun, 25 Feb 2024 23:01:57 +0000 Subject: [PATCH] Latest build deployed. --- .mapping.json | 1 + Discrete-Math-with-SageMath.html | 263 + OOP.html | 273 + _static/pretext/css/banner_crc.css | 336 ++ _static/pretext/css/banner_default.css | 141 + _static/pretext/css/banner_wide.css | 20 + _static/pretext/css/catalog.css | 94 + _static/pretext/css/colors_blue_green.css | 118 + _static/pretext/css/colors_blue_grey.css | 74 + _static/pretext/css/colors_blue_red.css | 72 + _static/pretext/css/colors_blue_red_dark.css | 130 + _static/pretext/css/colors_bluegreen_grey.css | 119 + _static/pretext/css/colors_brown_gold.css | 37 + .../pretext/css/colors_darkmartiansands.css | 74 + _static/pretext/css/colors_default.css | 82 + .../pretext/css/colors_focused_gray_aqua.css | 47 + _static/pretext/css/colors_focused_light.css | 44 + _static/pretext/css/colors_green_blue.css | 72 + _static/pretext/css/colors_green_plum.css | 72 + _static/pretext/css/colors_maroon_grey.css | 37 + _static/pretext/css/colors_martiansands.css | 74 + _static/pretext/css/colors_orange_navy.css | 72 + .../pretext/css/colors_pastel_blue_orange.css | 32 + _static/pretext/css/colors_red_blue.css | 35 + _static/pretext/css/colors_ruby_amethyst.css | 72 + _static/pretext/css/colors_ruby_emerald.css | 72 + _static/pretext/css/colors_ruby_turquoise.css | 72 + _static/pretext/css/edit.css | 493 ++ _static/pretext/css/epub.css | 58 + _static/pretext/css/features.css | 324 ++ _static/pretext/css/kindle.css | 103 + _static/pretext/css/knowls_default.css | 230 + _static/pretext/css/navbar_crc.css | 358 ++ _static/pretext/css/navbar_default.css | 194 + _static/pretext/css/navbar_wide.css | 39 + _static/pretext/css/pretext.css | 1151 ++++ _static/pretext/css/pretext_add_on.css | 3178 +++++++++++ _static/pretext/css/pretext_search.css | 173 + _static/pretext/css/reveal.css | 75 + _static/pretext/css/setcolors.css | 452 ++ _static/pretext/css/shell_crc.css | 408 ++ _static/pretext/css/shell_default.css | 260 + _static/pretext/css/shell_min.css | 273 + _static/pretext/css/shell_wide.css | 350 ++ _static/pretext/css/style_default.css | 332 ++ _static/pretext/css/style_oscarlevin.css | 471 ++ _static/pretext/css/style_soundwriting.css | 156 + _static/pretext/css/style_wide.css | 225 + _static/pretext/css/toc_crc.css | 276 + _static/pretext/css/toc_default.css | 274 + _static/pretext/css/toc_min.css | 144 + _static/pretext/css/toc_wide.css | 36 + _static/pretext/css/webwork.css | 72 + _static/pretext/js/answer.js | 552 ++ _static/pretext/js/edit.js | 4988 +++++++++++++++++ _static/pretext/js/highlight.js | 480 ++ _static/pretext/js/instructor.js | 131 + _static/pretext/js/lib/jquery.espy.min.js | 195 + _static/pretext/js/lib/jquery.min.js | 2 + _static/pretext/js/lib/jquery.sticky.js | 161 + _static/pretext/js/lib/knowl.js | 216 + _static/pretext/js/lib/mathjaxknowl.js | 110 + _static/pretext/js/lib/mathjaxknowl3.js | 48 + _static/pretext/js/login.js | 322 ++ .../pretext-webwork/2.16/pretext-webwork.js | 752 +++ .../pretext-webwork/2.17/pretext-webwork.js | 1057 ++++ .../pretext-webwork/2.18/pretext-webwork.js | 1057 ++++ _static/pretext/js/pretext.js | 165 + _static/pretext/js/pretext_add_on.js | 984 ++++ _static/pretext/js/pretext_search.js | 307 + _static/pretext/js/ptx_search.js | 112 + _static/pretext/js/user_preferences.js | 510 ++ about-sage.html | 276 + backmatter-2.html | 245 + backmatter.html | 242 + cardinality.html | 274 + ch-combinatorics.html | 257 + ch-functions.html | 260 + ch-getting-started.html | 266 + ch-logic.html | 261 + ch-relations.html | 263 + ch-set-theory.html | 261 + creating-sets.html | 289 + data-types.html | 331 ++ debugging.html | 291 + digraphs.html | 271 + documentation.html | 247 + equivalence.html | 358 ++ frontmatter-2.html | 247 + frontmatter.html | 250 + generated/.web_assets.pkl | 1 + index.html | 20 + intro-relations.html | 330 ++ iteration.html | 244 + lunr-pretext-search-index.js | 455 ++ partial-order.html | 316 ++ printing.html | 279 + relations-on-a-set.html | 275 + sage-browser.html | 262 + sec-combinatorics.html | 287 + sec-functions.html | 281 + sec-logical-operation.html | 296 + sec-operation-on-sets.html | 353 ++ sec-recursion.html | 295 + sec-tautology.html | 284 + sec-truth-table.html | 266 + 106 files changed, 33922 insertions(+) create mode 100644 .mapping.json create mode 100644 Discrete-Math-with-SageMath.html create mode 100644 OOP.html create mode 100644 _static/pretext/css/banner_crc.css create mode 100644 _static/pretext/css/banner_default.css create mode 100644 _static/pretext/css/banner_wide.css create mode 100644 _static/pretext/css/catalog.css create mode 100644 _static/pretext/css/colors_blue_green.css create mode 100644 _static/pretext/css/colors_blue_grey.css create mode 100644 _static/pretext/css/colors_blue_red.css create mode 100644 _static/pretext/css/colors_blue_red_dark.css create mode 100644 _static/pretext/css/colors_bluegreen_grey.css create mode 100644 _static/pretext/css/colors_brown_gold.css create mode 100644 _static/pretext/css/colors_darkmartiansands.css create mode 100644 _static/pretext/css/colors_default.css create mode 100644 _static/pretext/css/colors_focused_gray_aqua.css create mode 100644 _static/pretext/css/colors_focused_light.css create mode 100644 _static/pretext/css/colors_green_blue.css create mode 100644 _static/pretext/css/colors_green_plum.css create mode 100644 _static/pretext/css/colors_maroon_grey.css create mode 100644 _static/pretext/css/colors_martiansands.css create mode 100644 _static/pretext/css/colors_orange_navy.css create mode 100644 _static/pretext/css/colors_pastel_blue_orange.css create mode 100644 _static/pretext/css/colors_red_blue.css create mode 100644 _static/pretext/css/colors_ruby_amethyst.css create mode 100644 _static/pretext/css/colors_ruby_emerald.css create mode 100644 _static/pretext/css/colors_ruby_turquoise.css create mode 100644 _static/pretext/css/edit.css create mode 100644 _static/pretext/css/epub.css create mode 100644 _static/pretext/css/features.css create mode 100644 _static/pretext/css/kindle.css create mode 100644 _static/pretext/css/knowls_default.css create mode 100644 _static/pretext/css/navbar_crc.css create mode 100644 _static/pretext/css/navbar_default.css create mode 100644 _static/pretext/css/navbar_wide.css create mode 100644 _static/pretext/css/pretext.css create mode 100644 _static/pretext/css/pretext_add_on.css create mode 100644 _static/pretext/css/pretext_search.css create mode 100644 _static/pretext/css/reveal.css create mode 100644 _static/pretext/css/setcolors.css create mode 100644 _static/pretext/css/shell_crc.css create mode 100644 _static/pretext/css/shell_default.css create mode 100644 _static/pretext/css/shell_min.css create mode 100644 _static/pretext/css/shell_wide.css create mode 100644 _static/pretext/css/style_default.css create mode 100644 _static/pretext/css/style_oscarlevin.css create mode 100644 _static/pretext/css/style_soundwriting.css create mode 100644 _static/pretext/css/style_wide.css create mode 100644 _static/pretext/css/toc_crc.css create mode 100644 _static/pretext/css/toc_default.css create mode 100644 _static/pretext/css/toc_min.css create mode 100644 _static/pretext/css/toc_wide.css create mode 100644 _static/pretext/css/webwork.css create mode 100644 _static/pretext/js/answer.js create mode 100644 _static/pretext/js/edit.js create mode 100644 _static/pretext/js/highlight.js create mode 100644 _static/pretext/js/instructor.js create mode 100644 _static/pretext/js/lib/jquery.espy.min.js create mode 100644 _static/pretext/js/lib/jquery.min.js create mode 100644 _static/pretext/js/lib/jquery.sticky.js create mode 100644 _static/pretext/js/lib/knowl.js create mode 100644 _static/pretext/js/lib/mathjaxknowl.js create mode 100644 _static/pretext/js/lib/mathjaxknowl3.js create mode 100644 _static/pretext/js/login.js create mode 100644 _static/pretext/js/pretext-webwork/2.16/pretext-webwork.js create mode 100644 _static/pretext/js/pretext-webwork/2.17/pretext-webwork.js create mode 100644 _static/pretext/js/pretext-webwork/2.18/pretext-webwork.js create mode 100644 _static/pretext/js/pretext.js create mode 100644 _static/pretext/js/pretext_add_on.js create mode 100644 _static/pretext/js/pretext_search.js create mode 100644 _static/pretext/js/ptx_search.js create mode 100644 _static/pretext/js/user_preferences.js create mode 100644 about-sage.html create mode 100644 backmatter-2.html create mode 100644 backmatter.html create mode 100644 cardinality.html create mode 100644 ch-combinatorics.html create mode 100644 ch-functions.html create mode 100644 ch-getting-started.html create mode 100644 ch-logic.html create mode 100644 ch-relations.html create mode 100644 ch-set-theory.html create mode 100644 creating-sets.html create mode 100644 data-types.html create mode 100644 debugging.html create mode 100644 digraphs.html create mode 100644 documentation.html create mode 100644 equivalence.html create mode 100644 frontmatter-2.html create mode 100644 frontmatter.html create mode 100644 generated/.web_assets.pkl create mode 100644 index.html create mode 100644 intro-relations.html create mode 100644 iteration.html create mode 100644 lunr-pretext-search-index.js create mode 100644 partial-order.html create mode 100644 printing.html create mode 100644 relations-on-a-set.html create mode 100644 sage-browser.html create mode 100644 sec-combinatorics.html create mode 100644 sec-functions.html create mode 100644 sec-logical-operation.html create mode 100644 sec-operation-on-sets.html create mode 100644 sec-recursion.html create mode 100644 sec-tautology.html create mode 100644 sec-truth-table.html diff --git a/.mapping.json b/.mapping.json new file mode 100644 index 00000000..86717597 --- /dev/null +++ b/.mapping.json @@ -0,0 +1 @@ +{"source/main.ptx": ["Discrete-Math-with-SageMath"], "source/frontmatter.ptx": ["frontmatter"], "source/getting-started/ch-getting-started.ptx": ["ch-getting-started"], "source/getting-started/sec-intro-to-sage.ptx": ["about-sage"], "source/getting-started/sec-printing.ptx": ["printing"], "source/getting-started/sec-OOP.ptx": ["OOP"], "source/getting-started/sec-data-types.ptx": ["data-types"], "source/getting-started/sec-iteration.ptx": ["iteration"], "source/getting-started/sec-debugging.ptx": ["debugging"], "source/getting-started/sec-documentation.ptx": ["documentation"], "source/getting-started/sec-sage-browser.ptx": ["sage-browser"], "source/set-theory/ch-set-theory.ptx": ["ch-set-theory"], "source/set-theory/sec-creating-sets.ptx": ["creating-sets"], "source/set-theory/sec-cardinality.ptx": ["cardinality"], "source/set-theory/sec-operation-on-sets.ptx": ["sec-operation-on-sets"], "source/combinatorics/ch-combinatorics.ptx": ["ch-combinatorics"], "source/combinatorics/sec-combinatorics.ptx": ["sec-combinatorics"], "source/logic/ch-logic.ptx": ["ch-logic"], "source/logic/sec-logical-operation.ptx": ["sec-logical-operation"], "source/logic/sec-truth-table.ptx": ["sec-truth-table"], "source/logic/sec-tautology.ptx": ["sec-tautology"], "source/relations/ch-relations.ptx": ["ch-relations"], "source/relations/sec-intro-relations.ptx": ["intro-relations"], "source/relations/sec-relations-on-a-set.ptx": ["relations-on-a-set"], "source/relations/sec-digraphs.ptx": ["digraphs"], "source/relations/sec-equivalence.ptx": ["equivalence"], "source/relations/sec-partial-order.ptx": ["partial-order"], "source/functions/ch-functions.ptx": ["ch-functions"], "source/functions/sec-functions.ptx": ["sec-functions"], "source/functions/sec-recursion.ptx": ["sec-recursion"], "source/backmatter.ptx": ["backmatter"]} \ No newline at end of file diff --git a/Discrete-Math-with-SageMath.html b/Discrete-Math-with-SageMath.html new file mode 100644 index 00000000..35ac63af --- /dev/null +++ b/Discrete-Math-with-SageMath.html @@ -0,0 +1,263 @@ + + + + + + + + +
+ +xml:id<;>">\n'], + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + "mp": { + "html": { + "tag": "p", + "pieces": [["content", ""]], + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="mp"'], + "data_editable": "99" + }, + "pretext": { + "tag_opening": "", + "tag_closing": "", + "attributes": [], + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + "fp": { + "html": { + "tag": "p", + "pieces": [["content", ""]], + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="fp"'], + "data_editable": "99" + }, + "pretext": { + "tag_opening": "", + "tag_closing": "\n
\n", + "attributes": [], + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + + "li": { + "html": { + "tag": "li", + "pieces": [["content", ""]], + "attributes": ['id="<&>xml:id<;>"'], + "data_editable": "98aZ" + }, + "pretext": { + "tag": "li", + "pieces": [["title", "title"], ["content", ""]] + }, + "source": { + "pieces": [["title", ""], ["content", "p"]] + } + }, + + "blockquote": { + "html": { + "tag": "blockquote", + "pieces": [["content", ""], ["attribution", ""]], + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "cssclass": "blockquote", + "data_editable": "44?" + }, + "pretext": { + "tag": "blockquote", + "pieces": [["content", ""], ["attribution", "attribution"]], + }, + "source": { + "pieces": [["content", "p"], ["attribution", ""]] // attribution can contain a "line". come back to that + } + }, + + "list": { + "html": { + "tag": "ol", + "pieces": [["content", ""]], + "attributes": ['id="<&>xml:id<;>"', 'list-style-type="a"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "data_editable": "AAA" + }, + "pretext": { + "tag": "ol", + "pieces": [["content", ""]], + "attributes": ['label="A"'] + }, + "source": { + "pieces": [["title", ""], ["content", "li"]], + "attributes": [["label", "A"]] + } + }, + + "figure": { + "html": { + "tag": "figure", + "pieces": [["content",""],["{caption}", ""]], + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "data_editable": "32", + "cssclass": "figure figure-like" + }, + "pretext": { + "tag": "figure", + "pieces": [["content"], ["{caption}"]], + "attributes": ['xml:id="<&>xml:id<;>"'] + }, + "source": { + "pieces": [["content", ""], ["captiontext", ""]], + "attributes": [] + } + }, + + "image": { + "html": { + "tag": "div", + "pieces": [["{bareimage}",""]], + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"', 'style="width: <&>width<;>%; margin-right: <&>marginright<;>%; margin-left: <&>marginleft<;>%"'], + "data_editable": "31", + "cssclass": "image-box" + }, + "pretext": { + "tag": "image", + "pieces": [], + "attributes": ['xml:id="<&>xml:id<;>"', 'source="<&>source<;>"', 'alt="<&>alt<;>"', 'width="<&>width<;>%"', 'margins="<&>marginleft<;>% <&>marginright<;>%"'] + }, + "source": { + "pieces": [["",""]], + "attributes": [["source", ""], ["width", "40"], ["marginleft", "20"], ["marginright", "40"], ["alt", ""]] + } + }, + + "bareimage": { + "html": { + "tag": "img", + "pieces": [], + "attributes": ['src="<&>source<;>"', 'alt="<&>alt<;>"', 'class="contained"'], + } + }, + + "sidebyside": { + "html": { + "tag": "div", + "pieces": [["{sbsrow}",""]], + "attributes": ['id="<&>xml:id<;>"', 'class="<&>{cssclass}<;>"'], + "cssclass": "sidebyside" + }, + "pretext": { + "tag": "sidebyside", + "pieces": [["content", ""]], + "attributes": ['xml:id="<&>xml:id<;>"', 'margins="<&>marginleft<;>% <&>marginright<;>%"', 'width="<&>(percentlist,widths)<;>"'], + }, + "source": { + "pieces": [["content",""]], + "attributes": [["marginleft", ""], ["marginright", ""], ["widths", ""]] + } + }, + "sbsrow": { + "html": { + "tag": "div", + "pieces": [["content",""]], // ???? + "attributes": ['class="<&>{cssclass}<;>"', 'style="margin-right: <&>marginright<;>%; margin-left: <&>marginleft<;>%"'], + "data_editable": "89", + "cssclass": "sbsrow" + }, + "pretext": { + "tag": "", + "pieces": [["content",""]], + "attributes": [] + }, + "source": { + "pieces": [["content",""]], + "attributes": [["marginleft", "20"], ["marginright", "40"]] + } + }, + "sbspanel": { + "html": { + "tag": "div", + "pieces": [["content",""]], + "attributes": ['id="<&>xml:id<;>"', 'class="<&>{cssclass}<;>"', 'style="width:<&>(nthitem,widths)<;>%"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "data_editable": "90", + "cssclass": "sbspanel" + }, + "pretext": { + "tag": "stack", + "pieces": [["content", ""]], + "attributes": ['xml:id="<&>xml:id<;>"'] + }, + "source": { + "pieces": [["content",""]] + } + }, + + "proof": { + "html": { + "tag": "article", + "cssclass": "proof", + "pieces": [["{proof_heading}", ""], ["proof",""]], + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "data_editable": "60" + }, + "pretext": { + "tag": "proof", + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["proof", ""]] + }, + "source": { + "pieces": [["content", "p"]] + } + }, + "proof-standalone": { + "html": { + "tag": "article", + "cssclass": "proof", + "pieces": [["{XXXXXnorbeingusedXXXXXXX_proof_heading}", ""], ["content",""]], + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "data_editable": "60" + }, + "pretext": { + "tag": "proof", + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", "p"]] + } + }, + + "caption": { + "html": { + "tag": "figcaption", + "data_editable": "321", + // "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "attributes": ['id="<&>xml:id<;>"'], + "pieces": [["{caption_like_heading}", ""], ["{captiontext}",""]] + // "pieces": [["(literal, caption goes here)",""]] + }, + "pretext": { + "tag": "caption", + "attributes": [], + "pieces": [["captiontext", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + "captiontext": { /* not used */ + "html": { + "tag": "p", + "data_editable": "321", + // "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], +// do it like editabe title? + "attributes": ['data-source_id="<&>xml:id<;>"', 'data-component="caption"', 'class="caption"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "pieces": [["captiontext",""]] + }, + "pretext": { + "tag": "", + "attributes": [], + "pieces": [["captiontext", ""]] + }, + "source": { + "pieces": [["captiontext", ""]] + } + }, + + "references": { + "html": { + "tag": "article", + "cssclass": "bib", + "data_editable": "33", + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "pieces": [["{section_like_heading}", ""], ["content",""]] + }, + "pretext": { + "tag": "references", + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["title", ""], ["content",""]] + }, + "source": { + "pieces": [["title", ""], ["content",""]] + } + }, + +/* biblio, the items directly following it, and the refrences above, + are not usable at this time. references have to be handled in + a text editor. 3 Dec 2021 +*/ + "biblio": { + "html": { + "tag": "div", + "cssclass": "bibentry", + "data_editable": "333", + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "pieces": [["{bib-title}", ""], ["{journal}",""], ["{volume}",""], ["{number}",""], ["{author}",""], ["{pages}",""]] + }, + "pretext": { + "tag": "biblio", + "attributes": ['xml:id="<&>xml:id<;>"', 'type="raw"'], + "pieces": [["title", ""], ["journal",""], ["volume",""], ["number",""], ["author",""], ["pages",""]] + }, + "source": { + "pieces": [["title", ""], ["journal",""], ["volume",""], ["number",""], ["author",""], ["pages",""]] + } + }, + + "bib-title": { + "html": { + "tag": "i", + "pieces": [["title", "zz"]] + } + }, + "author": { + "html": { + "tag": "", + "pieces": [["author", ""], ["{comma}", ""]] + } + }, + "journal": { + "html": { + "tag": "", + "pieces": [["journal", ""]] + } + }, + "volume": { + "html": { + "tag": "b", + "pieces": [["volume", ""]] + } + }, + "pages": { + "html": { + "tag": "jjj", + "pieces": [["pages", ""]] + } + }, + "number": { + "html": { + "tag_opening": "no. ", + "tag_closing": " ", + "pieces": [["number", ""]] + } + }, + + "remark-like": { + "html": { + "tag": "article", + "cssclass": "remark-like", + "data_editable": "92", + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "pieces": [["{theorem_like_heading}", ""], ["statement",""]] + }, + "pretext": { + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["title", "title"], ["statement", "statement"]] + }, + "source": { + "pieces": [["title", ""], ["statement", "p"]] + } + }, + + "project-like-tasks": { + "html": { + "tag": "article", + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "cssclass": "project-like", + "data_editable": "194", + "pieces": [["{theorem_like_heading}", ""], ["content",""], ["tasks", ""]] + }, + "pretext": { + "tag": "sourcetag", + "pieces": [["title", "title"], ["content", ""], ["tasks", ""]], + "attributes": ['xml:id="<&>xml:id<;>"'] + }, + "source": { + "pieces": [["title", ""], ["content", "p"], ["tasks", ""]] + // "attributes": [["workspace", "0"]] + } + }, + "project-like": { + "html": { + "tag": "article", + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "cssclass": "project-like", + "data_editable": "94", + "pieces": [["{theorem_like_heading}", ""], ["statement",""], ["%hint%", "hint"], ["%answer%", "answer"], ["%solution%", "solution"], ["{workspace}", ""]] + }, + "pretext": { + "tag": "sourcetag", + "pieces": [["title", "title"], ["statement", "statement"], ["hint", "hint"], ["answer", "answer"], ["solution", "solution"]], + "attributes": ['xml:id="<&>xml:id<;>"', 'workspace="<&>workspace<;>"'] + }, + "source": { + "pieces": [["title", ""], ["statement", "p"], ["hint", ""], ["answer", ""], ["solution", ""]], + "attributes": [["workspace", "0"]] + } + }, + + "definition-like": { + "html": { + "tag": "article", + "cssclass": "definition-like", + "data_editable": "95a", + "pieces": [["{theorem_like_heading}", ""], ["statement", ""]], + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'] + }, + "pretext": { + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["title", "title"], ["statement", "statement"]] + }, + "source": { + "pieces": [["title", ""], ["statement", "p"]] + } + }, + + "theorem-like": { + "html": { + "tag": "article", + "cssclass": "theorem-like", + "data_editable": "93", + "pieces": [["{theorem_like_heading}", ""], ["statement", ""], ["{proof}", ""]], + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'] + }, + "pretext": { + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["title", "title"], ["statement", "statement"], ["{proof}", ""]] + }, + "source": { + "pieces": [["title", ""], ["statement", "p"], ["proof", ""]] + } + }, + + "task": { + "html": { + "tag": "article", + "cssclass": "exercise-like task", + "data_editable": "94ZZZA", + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "pieces": [["{task_like_heading}", ""], ["statement",""], ["%hint%", "hint"], ["%answer%", "answer"], ["%solution%", "solution"], ["{workspace}", ""]] + }, + "pretext": { + "tag": "task", + "pieces": [["title", "title"], ["statement", "statement"], ["hint", ""], ["answer", ""], ["solution", ""]], + "attributes": ['workspace="<&>workspace<;>"'] + }, + "source": { + "pieces": [["title", ""], ["statement", "p"], ["hint", ""], ["answer", ""], ["solution", ""]], + "attributes": [["workspace", "0"]] + } + }, + +/* consolidate H/A/S */ + "hint": { + "html": { + "tag": "article", + "cssclass": "solution-like hint", + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "pieces": [["{proof_like_heading}", ""], ["content",""]], +// go back and make the lack of data_editable automatically make the contained p editable +/* "data_editable": "454", */ + "data_editable": "hhhh" + }, + "pretext": { + "tag": "hint", + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["title", "title"], ["content", ""]] + }, + "source": { + "pieces": [["content", "p"]] + } + }, + "answer": { + "html": { + "tag": "article", + "cssclass": "solution-like answer", + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "pieces": [["{proof_like_heading}", ""], ["content",""]], +// go back and make the lack of data_editable automatically make the contained p editable +/* "data_editable": "454", */ + "data_editable": "hhhh" + }, + "pretext": { + "tag": "answer", + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["title", "title"], ["content", ""]] + }, + "source": { + "pieces": [["content", "p"]] + } + }, + "solution": { + "html": { + "tag": "article", + "cssclass": "solution-like solution", + "attributes": ['id="<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "pieces": [["{proof_like_heading}", ""], ["content",""]], +// go back and make the lack of data_editable automatically make the contained p editable +/* "data_editable": "454", */ + "data_editable": "hhhh" + }, + "pretext": { + "tag": "solution", + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["title", "title"], ["content", ""]] + }, + "source": { + "pieces": [["content", "p"]] + } + }, + + "workspace": { + "html": { + "tag": "div", + "cssclass": "workspace", + "data_editable": "WwW", + "attributes": ['data-parent_id="<&>xml:id<;>"', 'data-space="<&>workspace<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"', 'class="<&>{cssclass}<;>"'], + "pieces": [] + } + }, + + "term": { // need to mark it as inline + "html": { + "tag": "dfn", + "attributes": ['id="<&>xml:id<;>"', 'class="terminology"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "data_editable": "ttt", + "pieces": [["content", ""]] + }, + "pretext": { + "tag": "term", + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + + "em": { // need to mark it as inline + "html": { + "tag": "em", + "attributes": ['id="<&>xml:id<;>"', 'class="emphasis"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "data_editable": "eemm", + "pieces": [["content", ""]] + }, + "pretext": { + "tag": "em", + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + "fn": { // need to mark it as inline + "html": { + "tag": "a", + "attributes": ['id="<&>xml:id<;>"', 'class="id-ref fn-knowl original"', 'data-knowl=" "', 'href=" "', 'data-refid="hk-<&>xml:id<;>"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "data_editable": "fnfnfn", +// "pieces": [["content", "sup"]] + "pieces": [["(literal,footnote)", "sup"]] + }, + "pretext": { + "tag": "fn", + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + "alert": { // need to mark it as inline + "html": { + "tag": "em", + "attributes": ['id="<&>xml:id<;>"', 'class="alert"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "data_editable": "aall", + "pieces": [["content", ""]] + }, + "pretext": { + "tag": "alert", + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + "init": { // need to mark it as inline + "html": { + "tag": "abbr", + "attributes": ['id="<&>xml:id<;>"', 'class="initialism"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "data_editable": "iinniitt", + "pieces": [["content", ""]] + }, + "pretext": { + "tag": "init", + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + "c": { // need to mark it as inline + "html": { + "tag": "code", + "attributes": ['id="<&>xml:id<;>"', 'class="code-inline tex2jax_ignore"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "data_editable": "ccoo", + "pieces": [["content", ""]] + }, + "pretext": { + "tag": "c", + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + + "ellipsis": { // need to mark it as inline + "html": { + "tag": "span", + "attributes": ['id="<&>xml:id<;>"', 'class="abbrev"', 'contenteditable="false"'], + "data_editable": "abbr", + "pieces": [["(literal,…)", ""]] + }, + "pretext": { + "tag": "ellipsis", + "pieces": [] + }, + "source": { + } + }, + "etc": { // need to mark it as inline + "html": { + "tag": "span", + "attributes": ['id="<&>xml:id<;>"', 'class="abbrev"', 'contenteditable="false"'], + "pieces": [["(literal,etc)", ""]] + }, + "pretext": { + "tag": "etc", + "pieces": [] + }, + "source": { + } + }, + + "q": { // need to mark it as inline + "html": { + "tag": "q", + "attributes": ['id="<&>xml:id<;>"', 'class="quote"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "data_editable": "qqq", + "pieces": [["content", ""]] + }, + "pretext": { + "tag": "q", + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + + "m": { // need to mark it as inline + "html": { + "tag_opening": "\\(", + "tag_closing": "\\)", + // "tag": "script", + // "attributes": ['type="math/tex"'], + "pieces": [["content", ""]] + }, + "pretext": { + "tag": "m", + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + + "me": { + "html": { + "tag": "div", + "attributes": ['id="<&>xml:id<;>"', 'class="displaymath process-math"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "data_editable": "42", + "pieces": [["{me_raw}", ""]] + }, + "pretext": { + "tag": "me", + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + "men": { + "html": { + "tag": "div", + "attributes": ['id="<&>xml:id<;>"', 'class="displaymath process-math"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "data_editable": "42", + "pieces": [["{me_raw}", ""]] + }, + "pretext": { + "tag": "men", + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + "md": { + "html": { + "tag": "div", + "attributes": ['id="<&>xml:id<;>"', 'class="displaymath process-math"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "data_editable": "42", + "pieces": [["{md_raw}", ""]] + }, + "pretext": { + "tag": "md", + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + "mdn": { + "html": { + "tag": "div", + "attributes": ['id="<&>xml:id<;>"', 'class="displaymath process-math"', 'data-editable="<&>{data_editable}<;>"', 'tabindex="-1"'], + "data_editable": "42", + "pieces": [["{me_raw}", ""]] + }, + "pretext": { + "tag": "mdn", + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + }, + "me_raw": { + "html": { + "tag_opening": "\\begin{equation*}", + "tag_closing": "\\end{equation*}", + "pieces": [["content", ""]] + } + }, + "md_raw": { + "html": { + "tag_opening": "\\begin{align*}", + "tag_closing": "\\end{align*}", + "pieces": [["content", ""]] + } + }, +// check if mrow is actually used + "mrow": { + "html": { + "tag_opening": "", + "tag_closing": "\\cr", + "data_editable": "422", + "pieces": [["content", ""]] + }, + "pretext": { + "tag": "mrow", + "attributes": ['xml:id="<&>xml:id<;>"'], + "pieces": [["content", ""]] + }, + "source": { + "pieces": [["content", ""]] + } + } + +} + +var environment_instances = { + "definition-like": ["definition", "conjecture", "axiom", "principle", "heuristic", "hypothesis", "assumption"], + "theorem-like": ["lemma", "proposition", "theorem", "corollary", "claim", "fact", "identity", "algorithm"], + "remark-like": ["remark", "warning", "note", "observation", "convention", "insight"], + "project-like-tasks": ["investigation", "exploration", "project"], + "project-like": ["exercise", "activity"] +} + +for (const [owner, instances] of Object.entries(environment_instances)) { + var data_editable_base = objectStructure[owner].html.data_editable; + var cssclass_base = objectStructure[owner].html.cssclass; + var source_pieces = objectStructure[owner].source.pieces; + var pretext_pieces = objectStructure[owner].pretext.pieces; + var pretext_attributes = (objectStructure[owner].pretext.attributes || []); + var source_attributes = (objectStructure[owner].source.attributes || []); + for (var j=0; j < instances.length; ++j) { + var this_tag = instances[j]; + objectStructure[this_tag] = { + "owner": owner, + "html": { + "tag": objectStructure[owner].html.tag, + "pieces": objectStructure[owner].html.pieces, + "attributes": objectStructure[owner].html.attributes, + "cssclass": cssclass_base + " " + this_tag, + "data_editable": data_editable_base + j.toString(), + "heading": objectStructure[owner].html.heading + }, + "pretext": { + "tag": this_tag, + "pieces": pretext_pieces, + "attributes": pretext_attributes + }, + "source": { + "tag": this_tag, + "pieces": source_pieces, + "attributes": source_attributes + } + } + } +} + +editorLog('objectStructure["exercise"]', objectStructure["exercise"]); + +var sidebyside_instances = { +"sbs": [["2 panels", "sbs2"], ["3 panels", "sbs3"], ["4 panels", "sbs4"]], +//"sbs2": [["full across XX", "sbs2_0_50_50_0"], ["gap but no margin", "sbs2_0_40_40_0"], ["spaced equally", "sbs2_5_40_40_5"]], +"sbs2": [["full across", "sbs_0_50_50_0"], ["gap but no margin", "sbs_0_45_45_0"], ["spaced equally", "sbs_5_40_40_5"]], +"sbs3": [["full across", "sbs_0_34_32_34_0"], ["gap but no margin", "sbs_0_28_28_38_0"], ["spaced equally", "sbs_5_25_26_25_5"]], +"sbs4": [["full across", "sbs_0_25_25_25_25_0"], ["gap but no margin", "sbs_0_20_20_20_20_0"], ["spaced equally", "sbs_3_18_18_18_18_3"]] +} + +Object.assign(objectStructure, sidebyside_instances); + +// shoudl we distinguish empty tags by format? +var always_empty_tags = ["img", "image", "xref"]; +// eventially xref will move to allowed_empty_tags +var allowed_empty_tags = ["div", "span", "p", "stack"]; +var tag_display = { /* the default is "block" */ + "inline": ["m", "em", "ellipsis", "span", "term", "dfn", "q", "c", "code", "alert", "nbsp", "xref", "idx", "h", "init"], + "title": ["title", "idx", "h1", "h2", "h3", "h4", "h5", "h6", "div", "usage", "image"], + "block-tight": [] // ["mp", "mrow"] +} + +inline_tags = tag_display["inline"]; +inline_math = ["m"]; +inline_abbrev = ["ellipsis", "ie", "eg", "etc"]; + +// contained_objects are a componnet of another object, not just buried in content +var contained_objects =["title", "statement", "caption", "captiontext", "proof", + "author", "journal", "volume", "number", "pages"]; + +function tag_type(tag) { + var this_type; + + if (["p", "ip", "mp", "fp"].includes(tag)) { this_type = "p" } + else if (["me", "men", "md", "mdn"].includes(tag)) { this_type = "md" } + else { this_type = tag } + + return this_type +} + +function process_value_from_source(fcn, piece, src) { + + editorLog(fcn, "process_value_from_source", piece, "in", src); + var content_raw = ""; + if (["literal", "codenumber", "period", "titleperiod", "space"].includes(fcn)) { + content_raw = piece; + } else { + if (piece in src) { + content_raw = src[piece] + } else { + if ("parent" in src) { + var parent_src = internalSource[src["parent"][0]]; + if (piece in parent_src) { + content_raw = parent_src[piece] + } else { + errorLog("Error: piece", piece, "fcn", fcn, "from", parent_src, "not in src or parent_src") + } + } else { + errorLog("at the top, or else there is an error") + } + } + } /* fcn != literal */ + +/* + if (typeof myVar == 'string') { + content_raw = content_raw.replace(/-standalone$/, "") // hack because we need alternate to sourcetag + } +*/ + if (fcn == "capitalize") { + content = content_raw.charAt(0).toUpperCase() + content_raw.slice(1); + } else if (fcn == "literal") { + editorLog("literally", piece); + // alert(piece); + content = piece + } else if (fcn == "space") { + content = content_raw + " " + } else if (fcn == "period") { + content = content_raw + "." + } else if (fcn == "comma") { + content = content_raw + "," + } else if (fcn == "titleperiod") { + if (src.title && !(/[!?]$/.test(src.title))) { + content = content_raw + "." + } + } else if (fcn == "percentlist") { + if (content_raw) { + content = content_raw.join("% ") + "%" + } else { + content = "MISSING" + "%" + } + } else if (fcn == "nthitem") { + + editorLog("calculating nthitem", piece, "from ", content_raw, "within", src); + var item_index = 0; // need to be its location among siblings + content = content_raw[item_index]; + } else if (fcn == "codenumber") { + editorLog(" CODENUMBER", src); + content = internalSource.root_data.number_base; + if (src["xml:id"] == top_level_id) { + // no need to add locan number + } else { + content += ".N" + } + } else { + content = content_raw + } + + return content +} + +$(".autopermalink > a").attr("tabindex", -1); + +var editable_objects = [["p", 99], ["ol", 97], ["ul", 96], ["article", 95], ["blockquote", 80], ["section", 66], + ["title", 20], ["caption", 890]]; +for(var j=0; j < editable_objects.length; ++j) { + $(editable_objects[j][0]).attr("data-editable", editable_objects[j][1]); + $(editable_objects[j][0]).attr("tabindex", -1); +} + +/* the code */ + +editorLog(" enabling edit"); + +user_level = "novice"; + +// we have to keep track of multiple consecutive carriage returns +this_char = ""; +prev_char = ""; +prev_prev_char = ""; + +// for resizing and layout changes +// clobal variables so we can adjust them dynamically +move_scale = 1; +magnify_scale = 1; + +final_added_object = ""; +previous_added_object = ""; + +// sometimes we have to prevent Tab from changing focus +this_focused_element = ""; +prev_focused_element = ""; +prev_prev_focused_element = ""; + +var menu_neutral_background = "#ddb"; +var menu_active_background = "#fdd"; + +var recent_editing_actions = []; // we unshift to this, so most recent edit is first. + // currently just a human-readable list +var ongoing_editing_actions = []; +var old_content = {}; // to hold old versions of changed materials + +// what will happen with internationalization? +var keyletters = ["KeyA", "KeyB", "KeyC", "KeyD", "KeyE", "KeyF", "KeyG", "KeyH", "KeyI", "KeyJ", "KeyK", "KeyL", "KeyM", "KeyN", "KeyO", "KeyP", "KeyQ", "KeyR", "KeyS", "KeyT", "KeyU", "KeyV", "KeyW", "KeyX", "KeyY", "KeyZ"]; + +var movement_location_options = []; +var movement_location = 0; +var first_move = true; // used when starting to move, because object no longer occupies its original location + +Storage.prototype.setObject = function(key, value) { +// this.setItem(key, JSON.stringify(value)); + this.setItem(key, JSON.stringify(value, function(key, val) { +// console.log("key", key, "value", value, "val", val); + return val.toFixed ? Number(val.toFixed(3)) : val; +})); +} + +Storage.prototype.getObject = function(key) { + var value = this.getItem(key); + return value && JSON.parse(value); +} + +function randomstring(len) { + if (!len) { len = 10 } + return "tMP" + (Math.random() + 1).toString(36).substring(2,len) +} + +function removeItemFromList(lis, value) { + var index = lis.indexOf(value); + if (index > -1) { + lis.splice(index, 1); + } + return lis; +} + +function rescale(width, max, margin_left, margin_right) { + var available_width = max - parseFloat(margin_left) - parseFloat(margin_right); + return width * 100 / available_width +} + +function spacemath_to_tex(text) { + thetext = text; + + thetext = thetext.replace(/ d([a-zA-Z])(\s|$)/, " \\,d$1$2"); + thetext = thetext.replace(/ *< */, " < "); + + return thetext +} + +function split_paragraphs(paragraph_content) { + + // does the textbox contain more than one paragraph? + var paragraph_content_list = paragraph_content.split(""shift-tab", or "up arrow", to move up
"return" or "escape" to set in place
"tab" or "down arrow" to move down
quote, which will then be processed + the_text = the_text.replace(/(^|\s)"([^"]+)"(\s|$|[.,!?;:])/g, '$1<q>$2<\/q>$3'); + the_text = the_text.replace(/(^|\s)“([^”]+)”(\s|$|[.,!?;:])/g, '$1<q>$2<\/q>$3'); + the_text = the_text.replace(/(^|\s)‘([^’]+)’(\s|$|[.,!?;:])/g, '$1<q>$2<\/q>$3'); + + for (var j=0; j < inline_tags.length; ++j) { + var this_tag = inline_tags[j]; + editorLog("this_tag", this_tag); + var this_tag_search = "<(" + this_tag + ") *>" + "(.*?)" + "<\\/" + this_tag + ">"; + editorLog("searching for", this_tag_search); + var this_tag_search_re = new RegExp(this_tag_search,"g"); + the_text = the_text.replace(this_tag_search_re, extract_new_inline) + } + + return the_text +} + +function extract_new_math(match, sp_before, math_content, sp_after) { + var new_math_id = randomstring(); + internalSource[new_math_id] = { "xml:id": new_math_id, "sourcetag": "m", + "content": math_content} + return sp_before + "<&>" + new_math_id + "<;>" + sp_after +} +function extract_new_inline(match, the_tag, the_content) { + var new_id = randomstring(); + editorLog("extracting", the_content, "inside", the_tag); + internalSource[new_id] = { "xml:id": new_id, "sourcetag": the_tag, + "content": the_content}; + return "<&>" + new_id + "<;>" +} +function extract_new_abbrev(match, the_tag) { + var new_id = randomstring(); + editorLog("extracting", the_content, "inside", the_tag); + internalSource[new_id] = { "xml:id": new_id, "sourcetag": the_tag}; + return "<&>" + new_id + "<;>" +} + +// rename this next function +function save_internal_cont(match, contains_id, the_contents) { + this_id = contains_id.replace(/.*id="(.+?)".*/, '$1'); + + editorLog("id", this_id, "now has contents", the_contents); + if ("content" in internalSource[this_id]) { // not all objects have content + internalSource[this_id]["content"] = the_contents; + } else if (internalSource[this_id]["sourcetag"] == "xref") { + // this needs work once we have text="custom" references + internalSource[this_id]["ref"] = the_contents; + } + editorLog("all of it is now", internalSource[this_id]); + return "<&>" + this_id + "<;>" +} +function assemble_internal_version_changes(object_being_edited) { + editorLog("in assemble_internal_version_changes"); + editorLog("current active element to be saved", object_being_edited); + editorLog("which has parent", object_being_edited.parentElement); + editorLog("whose age is", object_being_edited.parentElement.getAttribute("data-age")); + + var oldornew = object_being_edited.parentElement.getAttribute("data-age"); + if (!oldornew) { oldornew = object_being_edited.getAttribute("data-age") } + editorLog(" OLDorNEW", oldornew); + + var possibly_changed_ids_and_entry = []; + var nature_of_the_change = ""; + +// var object_being_edited = document.activeElement; + var location_of_change = object_being_edited.parentElement; + var this_arrangement_of_objects = ""; + + if (object_being_edited.classList.contains("paragraph_input")) { + editorLog("found paragraph_input"); + nature_of_the_change = "replace"; + var paragraph_content = object_being_edited.innerHTML; + // editorLog("paragraph_content from innerHTML", paragraph_content); + paragraph_content = paragraph_content.trim(); + + var cursor_location = object_being_edited.selectionStart; + + editorLog("cursor_location", cursor_location, "out of", paragraph_content.length, "paragraph_content", paragraph_content); + + var parent_and_location = [object_being_edited.getAttribute("data-parent_id"), object_being_edited.getAttribute("data-parent_component")]; + editorLog("parent_and_location", parent_and_location); + editorLog("of ", object_being_edited); + + var prev_id = object_being_edited.getAttribute("data-source_id"); + editorLog("prev_id", prev_id); + editorLog("which contains", internalSource[prev_id]); + + // need to replace the below by split_paragraphs + + // does the textbox contain more than one paragraph? + var paragraph_content_list = paragraph_content.split("
(.*?)<;>/g, function (match, newid) {
+ if (newid.startsWith("{")) {
+ newid = newid.slice(1,-1);
+ if (newid in output_structure) {
+ return output_structure[newid]
+ } else { // don't want to return 'undefined'
+ return ""
+ }
+ } else if (newid.startsWith("(")) {
+ var this_piece = newid.slice(1,-1);
+ var this_fcn;
+ [this_fcn, this_piece] = this_piece.split(",");
+ return process_value_from_source(this_fcn, this_piece, the_object)
+ } else {
+ if (newid in the_object) {
+ return the_object[newid]
+ } else {
+ return ""
+ }
+ }
+ });
+ editorLog(" attr_val", attr_val);
+ if (attr_val && !attr_val.includes('""')) {
+ output_attributes_values.push(attr_val)
+ }
+ }
+
+ editorLog("output_structure", output_tag, "is", output_structure);
+ editorLog("output_attributes_values", output_attributes_values);
+ editorLog("output_structure.pieces", output_structure.pieces);
+ for (var j=0; j < output_structure.pieces.length; ++j) {
+ var this_piece_output = "";
+ var [this_piece, this_tag] = output_structure.pieces[j];
+ editorLog("output_structure", output_structure);
+ // when this_piece is provisional, then this_tag is actually the key for the required content
+ editorLog(j, "this_piece", this_piece, "this_tag", this_tag, "output_tag", output_tag);
+ if (this_piece.startsWith("{")) {
+ this_piece = this_piece.slice(1,-1);
+ this_piece_output += output_from_source(the_object, objectStructure[this_piece][format], format);
+ editorLog("wrapping in bracketed tag", this_tag);
+ the_answer += wrap_tag(this_tag, this_piece_output, [])
+ } else if (this_piece.startsWith("%")) {
+ // need to distinguish between the case where this object exists,
+ // and when it does not exist and we want a placeholder
+ this_piece = this_piece.slice(1,-1);
+ editorLog("% % % % % % % % % ", this_piece, "this_tag", this_tag, "the_object", the_object);
+ editorLog("% % % % % % % % % ", the_object[this_piece]);
+ editorLog("% % % % % % % % % ", the_object[this_tag]);
+ if (the_object[this_tag]) {
+ // var sub_object = {};
+
+// Object.assign(sub_object, the_object);
+
+ // sub_object['type-contained'] = this_tag;
+ // editorLog("sub_object", sub_object);
+ // this_piece_output = output_from_source(sub_object, objectStructure[this_piece][format], format);
+ this_piece_output = expand_condensed_source_html(the_object[this_tag],"html?");
+ // this_piece_output = output_from_source(sub_object, objectStructure[this_piece][format], format);
+ the_answer += this_piece_output;
+ editorLog("this piece exists", this_piece, "this_piece_output", this_piece_output)
+ } else {
+ editorLog("making placeholder for", this_piece);
+ the_answer += wrap_tag("div", "", ['class="placeholder ' + this_piece + '"', 'data-parent_id="' + the_object['xml:id'] + '"', 'data-has="' + this_piece + '"', 'tabindex="-1"', 'data-editable="123456"', 'data-placeholder=""'])
+ }
+ } else if (this_piece.startsWith("(")) {
+ editorLog("whole this_piece", this_piece);
+ this_piece = this_piece.slice(1,-1);
+ var this_fcn;
+ [this_fcn, this_piece] = this_piece.split(",");
+ var this_content = process_value_from_source(this_fcn, this_piece, the_object)
+ editorLog(j, "parenthesized content", this_content, "this_piece", this_piece, "XX", this_tag)
+ the_answer += wrap_tag(this_tag, this_content, [])
+ } else if (this_piece in the_object) {
+ this_piece_output = output_from_text(the_object[this_piece], format);
+ if (format == "pretext" && output_tag == "md" && this_piece == "content") {
+ // convert \cr to mrow
+ this_piece_output = this_piece_output.replace(/\s*\\cr\b\s*/g, "\n';
+ return opening_tag + spacemath_to_tex(the_object["content"]) + closing_tag
+ } else if (["md","mdn"].includes(sourcetag) && is_inner == "edit") {
+ var opening_tag = '';
+ this_content = the_object["content"].replace(/<&>(.*?)<;>/g,expand_condensed_src_edit);
+ this_content = this_content.replace("MROWsepARATOR", "\n yyyy \n");
+ return opening_tag + this_content + closing_tag
+ } else if (["mrow"].includes(sourcetag) && is_inner == "edit") {
+ var opening_tag = '';
+ return opening_tag + "MROW" + spacemath_to_tex(the_object["content"]) + closing_tag
+ } else if (sourcetag == "xref" && is_inner == "edit") {
+ // here we are assuming the tag is 'm'
+ var opening_tag = '';
+ return opening_tag + the_object["ref"] + closing_tag
+ } else {
+ html_of_this_object = output_from_id("", the_id, "html");
+ editorLog("html_of_this_object", html_of_this_object);
+ the_html_objects.push(html_of_this_object);
+
+ }
+
+ editorLog(" RRRR returning the_html_objects", the_html_objects);
+
+// the_html_objects = the_html_objects.replace("MROWsepARATOR", "\n\\cr\n");
+ return the_html_objects
+}
+
+function insert_html_version(these_changes) {
+
+ var nature_of_the_change = these_changes[0];
+ var location_of_change = these_changes[1];
+ var possibly_changed_ids_and_entry = these_changes[2];
+
+ editorLog("nature_of_the_change", nature_of_the_change);
+ editorLog("location_of_change", location_of_change);
+ editorLog("possibly_changed_ids_and_entry", possibly_changed_ids_and_entry);
+
+ if (!possibly_changed_ids_and_entry.length) {
+ editorLog("nothing to change");
+ // return ""
+ }
+ // we make HTML version of the objects with ids possibly_changed_ids_and_entry,
+ // and then insert those into the page.
+
+// here is where we detect deleting?
+// or is that after this function is done?
+ if (nature_of_the_change != "replace") {
+ editorLog("should be replace, since it is the edit form we are replacing");
+ }
+
+ var object_as_html = "";
+ var this_object_id, this_object_entry, this_object_oldornew, this_object;
+
+ editorLog(" there are", possibly_changed_ids_and_entry.length, "items to process");
+
+ for (var j=0; j < possibly_changed_ids_and_entry.length; ++j) {
+ this_object_id = possibly_changed_ids_and_entry[j][0];
+ this_object_entry = possibly_changed_ids_and_entry[j][1];
+ this_object_oldornew = possibly_changed_ids_and_entry[j][2];
+ editorLog("j=", j, "this thing", possibly_changed_ids_and_entry[j]);
+ this_object = internalSource[this_object_id];
+ editorLog(j, "this_object", this_object);
+ if (tag_type(this_object["sourcetag"]) == "p" || this_object["sourcetag"] == "li" || tag_type(this_object["sourcetag"]) == "md") {
+
+ var this_new_object = html_from_internal_id(this_object_id);
+ editorLog("inserting",this_new_object,"before",location_of_change);
+ location_of_change.insertAdjacentHTML('beforebegin', this_new_object[0]);
+ object_as_html = document.getElementById(this_object_id);
+
+ } else if (this_object_entry == "title") {
+ var object_as_html = document.createElement('span');
+ object_as_html.setAttribute("class", "title");
+ object_as_html.setAttribute('data-editable', 20);
+ object_as_html.setAttribute('tabindex', -1);
+ // next line should apply a transform to the source
+ object_as_html.innerHTML = this_object[this_object_entry];
+ editorLog("inserting",object_as_html,"before",location_of_change);
+ // location_of_change is the .header . We want it to be the .title
+ location_of_change = location_of_change.querySelector("#actively_editing");
+ editorLog("now location_of_change",location_of_change);
+ location_of_change.insertAdjacentElement('beforebegin', object_as_html);
+ } else if (this_object_entry == "caption") {
+ console.log("Error: don't know what to do with 'caption'")
+ } else if (this_object_entry == "image") {
+ editorLog("image, this_object", this_object);
+ var this_new_object = html_from_internal_id(this_object_id);
+ editorLog("inserting",this_new_object,"before",location_of_change);
+ location_of_change.insertAdjacentHTML('beforebegin', this_new_object[0]);
+ object_as_html = document.getElementById(this_object_id);
+
+ } else {
+ editorLog("trouble making", this_object);
+ }
+ MathJax.typesetPromise();
+// MathJax.Hub.Queue(['Typeset', MathJax.Hub, this_object_id]);
+ }
+ location_of_change.remove();
+
+ editorLog("returning from insert html version", object_as_html);
+ // call mathjax, in case the new content contains math
+ return object_as_html // the most recently added object, which we may want to
+ // do something, like add an editing menu
+} // insert html version
+
+function save_edits() {
+
+ var currentState = internalSource;
+
+ editorLog("saving", currentState);
+ localStorage.setObject("savededits", currentState);
+ return "";
+}
+
+function previous_editing() {
+ var old_internal_source = localStorage.getObject("savededits");
+ return (old_internal_source || "")
+}
+
+function local_editing_action(e) {
+ editorLog("in local editing action for" ,e.code);
+ var most_recent_edit;
+ if (e.code == "Escape" || e.code == "Enter") {
+ editorLog("I saw a Rettttt");
+ if (document.activeElement.getAttribute('data-component') == "title" ||
+ document.activeElement.getAttribute('data-component') == "caption") {
+ editorLog("probably saving a ", document.activeElement.getAttribute('data-component'));
+ e.preventDefault();
+ these_changes = assemble_internal_version_changes(document.activeElement);
+ final_added_object = insert_html_version(these_changes);
+ most_recent_edit = ongoing_editing_actions.pop();
+ recent_editing_actions.unshift(most_recent_edit);
+ editorLog("most_recent_edit should be title change", most_recent_edit);
+ editorLog("final_added_object", final_added_object);
+ this_char = "";
+ prev_char = "";
+ save_edits();
+
+ // .title is in a .heading, and neither have an id
+ make_current_editing_tree_from_id(final_added_object.parentElement.parentElement.id);
+ edit_menu_from_current_editing("entering");
+
+// editing_input_image
+ } else if (e.code == "Escape" || (prev_char.code == "Enter" && prev_prev_char.code == "Enter") || document.getElementById("editing_input_image")) {
+ editorLog("need to save");
+editorLog(" HHH current_editing", current_editing, "with active element", document.activeElement);
+
+ e.preventDefault();
+ this_char = "";
+ prev_char = "";
+ these_changes = assemble_internal_version_changes(document.activeElement);
+ editorLog(" CCC these_changes", these_changes);
+ editorLog(" CCC0 these_changes[0]", these_changes[0]);
+ editorLog("ongoing_editing_actions", ongoing_editing_actions);
+ editorLog("actively_editing", document.getElementById("actively_editing"));
+editorLog(" III current_editing", current_editing, current_editing["tree"][current_editing["level"]]);
+ previous_added_object = final_added_object;
+ final_added_object = insert_html_version(these_changes);
+ editorLog("final_added_object, previous_added_object", final_added_object, previous_added_object);
+editorLog(" LLL current_editing", current_editing, current_editing["tree"][current_editing["level"]]);
+ editorLog("the final_added_object", final_added_object);
+ editorLog("the actively_editing", document.getElementById("actively_editing"));
+ editorLog("OO", ongoing_editing_actions.length, " ongoing_editing_actions", ongoing_editing_actions);
+/*
+ editorLog("ongoing_editing_actions[0]", ongoing_editing_actions[0]);
+ editorLog("ongoing_editing_actions[0][2]", ongoing_editing_actions[0][2]);
+*/
+ // maybe this next if only handles when we delete by removing the letters in a p?
+ if (these_changes[0] == "empty") {
+ editorLog("NN", ongoing_editing_actions.length, " ongoing_editing_actions", ongoing_editing_actions);
+ editorLog("ongoing_editing_actions[0]", ongoing_editing_actions[0]);
+ editorLog("ongoing_editing_actions[0][2]", ongoing_editing_actions[0][2]);
+ editorLog(" going to delete", these_changes[2][0]);
+ // this is sort-of a hack to detext the end of inserting li
+ if (ongoing_editing_actions.length == 2 &&
+ ongoing_editing_actions[1][0] == "empty" &&
+ ongoing_editing_actions[1][1] == "p" &&
+ ongoing_editing_actions[0][0] == "new" &&
+ ongoing_editing_actions[0][1] == "li") {
+ ongoing_editing_actions.pop(); // content was empty, so there is no editing action
+ ongoing_editing_actions.pop();
+ delete_by_id(these_changes[2][0][0], "newempty");
+ current_editing["location"][current_editing["level"]] -= 1
+ final_added_object = previous_added_object; // this approach makes the updating of current_editing moot?
+ } else {
+ delete_by_id(these_changes[2][0][0], "empty");
+ }
+ editorLog("MM", ongoing_editing_actions.length, " ongoing_editing_actions", ongoing_editing_actions);
+ for (var j=0; jcopy to clipboard\n';
+hlmenu_contents += 'delete highlight\n';
+hlmenu_contents += 'dismiss menu';
+hlmenu.innerHTML = hlmenu_contents;
+document.body.appendChild(hlmenu);
+
+var all_highlights = localStorage.getObject("all_highlights");
+if (!all_highlights) {
+ console.log("no highlights on this page",all_highlights);
+ all_highlights= {};
+} else {
+ console.log("highlights already",all_highlights);
+}
+
+console.log("all_highlights.keys()", Object.keys(all_highlights));
+console.log("waiting for MathJax");
+MathJax.Hub.Register.StartupHook("End",function () {
+ // need to wait for MathJax, because MathJax changes the number of nodes in a paragraph
+ console.log("MathJax is done");
+ display_all_highlights(all_highlights, Object.keys(all_highlights), 0);
+});
+
+
+/*
+for (var key in all_highlights) {
+ var this_key = key;
+ var these_highlights = all_highlights[key];
+ console.log("adding highlights to", key);
+// await display_highlights_on(key, all_highlights[key], 0)
+ for (var i=0; i< these_highlights.length; ++i) {
+ hl = these_highlights[i];
+ console.log("inserting highlight",i,"which is",hl, "on", key);
+ // display_one_highlight(key, hl);
+//fails because
+ setTimeout(function() { display_one_highlight(this_key, hl)}, i*2000);
+
+ }
+}
+*/
+
+function index_of_child(child) {
+ var i = 0;
+ while( (child = child.previousSibling) != null )
+ {i++ }
+ return i
+}
+
+function increment_id(list_of_things_with_ids) { // assume ids are of the form xxxxNN with N a digit and x a non-digit
+ console.log("incrementing id on", list_of_things_with_ids);
+ if (list_of_things_with_ids.length == 0) {
+ return 0
+ }
+
+ id_start = list_of_things_with_ids[0]["id"].replace(/^(.*?)[0-9]+$/, "$1");
+ current_endings = [];
+ for (var i=0; i < list_of_things_with_ids.length; ++i) {
+ current_endings.push(list_of_things_with_ids[i]["id"].replace(/^.*?([0-9]+)$/, "$1"));
+ }
+ console.log("existing id endings", current_endings);
+ current_max = Math.max(...current_endings);
+ return id_start + (parseInt(current_max) + 1)
+}
+
+function enclosing_p_or_li(obj) {
+ console.log("obj.tagName", obj.tagName, "ggg",obj);
+ if (!obj) {
+ console.log("problem with previous object");
+ return null
+ }
+ else if (obj.tagName == 'P' || obj.tagName == 'LI') {
+ return obj
+ }
+ return enclosing_p_or_li(obj.parentNode)
+}
+
+// If you just loop ofer the highlights to add them,
+// you end up with a race condition because each highlight changes
+// the structure of the paragraph.
+async function display_one_highlight(parent_id, hl) {
+ var the_parent = document.getElementById(parent_id);
+ if (!the_parent) {
+ console.log("this id not on this page:", parent_id);
+ return
+ }
+ console.log("setting", hl, "on", parent_id);
+ var st_node_ind = hl['start_nn'];
+ var st_offset = hl['start_offset'];
+ var end_node_ind = hl['end_nn'];
+ var end_offset = hl['end_offset'];
+ console.log("st_node_ind", st_node_ind, "st_offset", st_offset, "end_node_ind", end_node_ind, "end_offset", end_offset);
+ // other error checks: same parent
+ if (st_offset < 0 || st_node_ind > the_parent.childNodes.length || end_node_ind > the_parent.childNodes.length || st_offset > the_parent.childNodes[st_node_ind].textContent.length || end_offset < 0 || end_offset > the_parent.childNodes[end_node_ind].textContent.length) {
+ console.log("highlight data inconsistent with paragraph structure that contains", the_parent.childNodes.length, "nodes");
+ return
+ }
+
+ let this_range = document.createRange();
+ console.log("setting this_range.setStart", the_parent.childNodes[st_node_ind], "with offset", st_offset, "out of", the_parent.childNodes[st_node_ind].textContent.length);
+ this_range.setStart(the_parent.childNodes[st_node_ind], st_offset);
+ this_range.setEnd(the_parent.childNodes[end_node_ind], end_offset);
+ var inside_part = document.createElement("span")
+ inside_part.classList.add("hl");
+ inside_part.id = hl['id'];
+ console.log("inside_part", inside_part, "going inside this_range",this_range);
+ console.log("in the_parent",the_parent);
+ this_range.surroundContents(inside_part);
+ return;
+}
+
+//var display_highlights_on = function(parent_id, highlights_on, ind) {
+async function display_highlights_on(parent_id, highlights_on, ind) {
+ console.log("display_highlights_on", parent_id, "xxxx", ind, "out of", highlights_on.length);
+ if (ind < highlights_on.length) {
+ console.log("about to display one highlight, number", ind, "on", parent_id);
+ await display_one_highlight(parent_id, highlights_on[ind]);
+ ++ind;
+ await display_highlights_on(parent_id, highlights_on, ind)
+ }
+ return;
+}
+
+async function display_all_highlights(every_highlight, hl_p_keys, i) {
+ console.log("making hl on", hl_p_keys[i]);
+ if (i < hl_p_keys.length) {
+ await display_highlights_on(hl_p_keys[i], every_highlight[hl_p_keys[i]], 0);
+ ++i;
+ await display_all_highlights(every_highlight, hl_p_keys, i)
+ }
+ return;
+}
+
+var DELAY = 500, clicks = 0, timer = null;
+$("p[id], li[id]").on("click", function(e) {
+ clicks++; //count clicks
+
+ if(clicks === 1) {
+
+ if (e.target.classList.contains("hl")) {
+ modifyhighlight(e);
+ clicks = 0;
+ } else {
+ timer = setTimeout(function() {
+ newhighlight()
+ clicks = 0; //after action performed, reset counter
+ }, DELAY);
+
+ }
+
+
+ } else if (clicks === 2) {
+ timer2 = setTimeout(function() {
+ clearTimeout(timer);
+ // alert("Double Click");
+ clicks = 0;
+ }, DELAY/2);
+ } else {
+ clearTimeout(timer); //prevent single-click action
+ clearTimeout(timer2); //prevent double-click action
+ // alert("Triple Click"); //perform triple-click action
+ clicks = 0; //after action performed, reset counter
+ }
+});
+
+function save_highlights() {
+ hl_data = {"action": "save", "user": uname, "pw": emanu, "bookID": bodyID, "type": "highlights", "hl": JSON.stringify(all_highlights)}
+ $.ajax({
+ url: "https://aimath.org/cgi-bin/u/highlights.py",
+ type: "post",
+ data: JSON.stringify(hl_data),
+ dataType: "json",
+ success: function(data) {
+ console.log("something", data, "back from highlight");
+ // alert(data);
+ },
+ error: function(errMsg) {
+ console.log("seems to be an error?",errMsg);
+ // alert("Error\n" + errMsg);
+ }
+ });
+
+ console.log("just ajax sent", JSON.stringify(reading_questions_object));
+}
+
+function newhighlight() {
+ var this_selection = window.getSelection();
+ console.log("UUUUUUUUUUUUUUUUUUUUUUUUUUU");
+ console.log("selection", this_selection, "as string", this_selection.toString(), "length", this_selection.toString().length);
+ if(this_selection.toString().length >= 3) {
+ console.log("this_selection", this_selection);
+ console.log("this_selection parentNode", this_selection.parentNode);
+
+ num_selected_ranges = this_selection.rangeCount;
+ console.log("this_selection.rangeCount", this_selection.rangeCount);
+ console.log("this_selection.getRangeAt(0)", this_selection.getRangeAt(0));
+ console.log("this_selection.getRangeAt(num_selected_ranges)", this_selection.getRangeAt(num_selected_ranges-1));
+ console.log("this_selection.getRangeAt(0).startContainer", this_selection.getRangeAt(0).startContainer);
+ console.log("this_selection.getRangeAt(0).endContainer", this_selection.getRangeAt(0).endContainer);
+ console.log("this_selection.getRangeAt(-1).startContainer", this_selection.getRangeAt(num_selected_ranges-1).startContainer);
+ console.log("this_selection.getRangeAt(-1).endContainer", this_selection.getRangeAt(num_selected_ranges-1).endContainer);
+ console.log("start equals end", this_selection.getRangeAt(0).startContainer == this_selection.getRangeAt(0).endContainer);
+ console.log("this_selection.getRangeAt(0).startContainer.parent", this_selection.getRangeAt(0).startContainer.parentNode);
+ console.log("this_selection.getRangeAt(0).endContainer.parent", this_selection.getRangeAt(0).endContainer.parentNode);
+ starting_parent = enclosing_p_or_li(this_selection.getRangeAt(0).startContainer);
+ starting_parent_id = starting_parent.id;
+ ending_parent_id = enclosing_p_or_li(this_selection.getRangeAt(num_selected_ranges-1).endContainer).id;
+ console.log("starting parent", enclosing_p_or_li(this_selection.getRangeAt(0).startContainer));
+ console.log("starting_parent.childNodes", starting_parent.childNodes);
+ console.log("starting_parent.childNodes.length", starting_parent.childNodes.length);
+ console.log("ending parent", enclosing_p_or_li(this_selection.getRangeAt(0).endContainer));
+ console.log("index of starting node", index_of_child(this_selection.getRangeAt(0).startContainer));
+ console.log("which is", starting_parent.childNodes[index_of_child(this_selection.getRangeAt(0).startContainer)]);
+ console.log("index of ending node", index_of_child(this_selection.getRangeAt(num_selected_ranges-1).endContainer));
+ console.log("which is", starting_parent.childNodes[index_of_child(this_selection.getRangeAt(num_selected_ranges-1).endContainer)]);
+ console.log("XXXXXXXXXXXXXXXXXXXXXXX");
+ starting_node = this_selection.getRangeAt(0);
+ starting_node_container = starting_node.startContainer;
+ starting_node_number = index_of_child(starting_node_container);
+ starting_node_offset = starting_node.startOffset;
+ console.log("starting_node", starting_node, "starting_node_container", starting_node_container);
+ console.log("starting_parent.childNodes[0]", starting_parent.childNodes[0]);
+ ending_node = this_selection.getRangeAt(num_selected_ranges-1);
+ ending_node_container = ending_node.endContainer;
+ console.log("ending_node", ending_node, "ending_node_container", ending_node_container);
+ ending_node_number = index_of_child(ending_node_container);
+ ending_node_offset = ending_node.endOffset;
+ console.log("selection starts at character number", starting_node.startOffset, "in node number", index_of_child(starting_node), "of node", starting_node.startContainer, "within", starting_node.startContainer.parentNode,"which is", starting_node);
+ console.log("selection ends at character number", ending_node.endOffset, "in node number", index_of_child(ending_node_container), "of node", ending_node.endContainer, "within", ending_node.endContainer.parentNode, "which is", ending_node);
+
+// let this_range = document.createRange();
+// this_range.setStart(starting_parent.childNodes[starting_node_number], starting_node_offset);
+// this_range.setEnd(document.getElementById(starting_parent_id).childNodes[ending_node_number], ending_node_offset);
+// test_inside_part=document.createElement("span")
+// test_inside_part.classList.add("gggg");
+// this_range.surroundContents(test_inside_part);
+ console.log("num_selected_ranges", num_selected_ranges, "starting_parent_id", starting_parent_id, "ending_parent_id", ending_parent_id);
+ this_selection.empty();
+ console.log("starting_parent_id", starting_parent_id, "ending_parent_id", ending_parent_id);
+ if (starting_parent_id != ending_parent_id) {
+ alert("Highlights must be within\none paragraph or list item.");
+ return ""
+ }
+ if (starting_parent != starting_node_container.parentNode) {
+ starting_node_number = index_of_child(starting_node_container.parentNode) - 1;
+ console.log("new starting node",starting_node_number, " which is", starting_parent.childNodes[starting_node_number]);
+ starting_node_offset = starting_parent.childNodes[starting_node_number].length;
+ }
+ if (starting_parent != ending_node_container.parentNode) {
+ ending_node_number = index_of_child(ending_node_container.parentNode) + 1;
+ console.log("new edngin node",ending_node_number, " which is", starting_parent.childNodes[ending_node_number]);
+ ending_node_offset = 0;
+ }
+ console.log("starting_parent eq st cont parent", starting_parent == starting_node_container.parentNode, "starting_parent eq end cont parent", starting_parent == ending_node_container.parentNode);
+// display_one_highlight(starting_parent_id, starting_node_number, starting_node_offset, ending_node_number, ending_node_offset);
+// console.log("this_range", this_range);
+ this_highlight = {"start_nn": starting_node_number,
+ "start_offset": starting_node_offset,
+ "end_nn": ending_node_number,
+ "end_offset": ending_node_offset};
+ if (starting_parent_id in all_highlights) {
+ console.log("the starting_parent_id", starting_parent_id, "is already in all_highlights", all_highlights);
+ new_id = increment_id(all_highlights[starting_parent_id]);
+ this_highlight['id'] = new_id;
+ all_highlights[starting_parent_id].push(this_highlight)
+ } else {
+ this_highlight['id'] = starting_parent_id + "-" + "hl" + 1;
+ all_highlights[starting_parent_id] = [this_highlight]
+ }
+ display_one_highlight(starting_parent_id, this_highlight);
+ localStorage.setObject("all_highlights", all_highlights);
+
+ if (uname != "guest" && role=="student") {
+ console.log("saving highlights");
+ save_highlights();
+ }
+ console.log("all_highlights", all_highlights);
+ return "";
+ }
+}
+
+function modifyhighlight(e) {
+ this_hl = e.target;
+ console.log("clicked hl", this_hl.id);
+
+ var x = e.clientX, y = e.clientY;
+ console.log("x", x, "y", y);
+ document.getElementById("hlmenu").style.top = (y - 10 + $(window).scrollTop()) + 'px';
+ document.getElementById("hlmenu").style.left = (x + 20) + 'px';
+ document.getElementById("hlmenu").style.display = 'block';
+ document.getElementsByClassName("hlcopy")[0].setAttribute("data-hlid", this_hl.id);
+ document.getElementsByClassName("hldelete")[0].setAttribute("data-hlid", this_hl.id);
+// tooltipSpan.style.left = (x + 20) + 'px';
+
+ var parent_id = this_hl.id.replace(/^(.*)-[^\-]*$/, "$1");
+ var number_of_this_highlight = this_hl.id.slice(-1);
+ var these_highlights = all_highlights[parent_id];
+ var this_highlight = these_highlights[number_of_this_highlight-1];
+ console.log("parent id", parent_id, "nunber",number_of_this_highlight);
+ var num_child_nodes = this_hl.childNodes.length;
+ console.log("which has", this_hl.childNodes.length, "child nodes");
+ for (var i=0; i < num_child_nodes; ++i) {
+ console.log(i, "node is", this_hl.childNodes[i])
+ }
+ console.log("highlights on this item",all_highlights[parent_id], "of which we clicked", these_highlights[number_of_this_highlight - 1],
+"number", number_of_this_highlight, "out of", these_highlights.length );
+ for (var i=0; i
Word PTX PDF
";
+ icon_list += '' + "" + icons_on_this_page[j][0] + ": ";
+ icon_list += '' + next_icon + '';
+ } else {
+ icon_list += '' + next_icon + '';
+ }
+ prev_icon = next_icon;
+ }
+ icon_list += '';
+
+ icon_legend_for_this_page.setAttribute('class', 'iconlegend');
+ icon_legend_for_this_page.innerHTML = icon_list
+ document.body.appendChild(icon_legend_for_this_page);
+
+} // if logged in as instructor
diff --git a/_static/pretext/js/lib/jquery.espy.min.js b/_static/pretext/js/lib/jquery.espy.min.js
new file mode 100644
index 00000000..31cffd1a
--- /dev/null
+++ b/_static/pretext/js/lib/jquery.espy.min.js
@@ -0,0 +1,195 @@
+
+(function(b, u, v) {
+ function x(b, f, e) {
+ b = (b + "").match(/^(-?[0-9]+)(%)?$/);
+ if (!b) return !1;
+ var c = parseInt(b[1], 10);
+ b[2] && (c *= f / 100);
+ return 0 > c ? f + c + (e || 0) : c
+ }
+
+ function y(k, f) {
+ function e() {
+ function b() {
+ g = +new Date;
+ f.apply(e, t);
+ c && (c = clearTimeout(c))
+ }
+ var e = this,
+ q = +new Date - g,
+ t = arguments;
+ c && (c = clearTimeout(c));
+ q > k ? b() : c = setTimeout(b, k - q)
+ }
+ var c, g = 0;
+ b.guid && (e.guid = f.guid = f.guid || b.guid++);
+ return e
+ }
+ b.Espy = function(k, f, e) {
+ function c(a, d) {
+ b.isPlainObject(a) && (d = a, a = null);
+ b.extend(t.prototype, d);
+ null !== a && (w = a)
+ }
+
+ function g(a) {
+ if (a =
+ q(a)) {
+ var d = a.$el.offset()[a.settings.horizontal ? "left" : "top"] - p.offset[a.settings.horizontal ? "left" : "top"],
+ h = a.$el[a.settings.horizontal ? "outerWidth" : "outerHeight"]();
+ b.extend(a, {
+ start: d,
+ elSize: h,
+ end: d + h
+ })
+ }
+ }
+
+ function r(a) {
+ // console.log("r(a) with a = ", a);
+ if (a === v) b.each(m, r);
+ else if (a = q(a)) {
+ var d = p[a.settings.horizontal ? "width" : "height"],
+ h = x(a.settings.size, d),
+ d = p[a.settings.horizontal ? "left" : "top"] + x(a.settings.offset, d, -h),
+ c = d + h,
+ h = a.settings.contain ? d <= a.start && c >= a.end ? "inside" : d + h / 2 > a.start + a.elSize / 2 ? a.settings.horizontal ? "left" :
+ "up" : a.settings.horizontal ? "right" : "down" : d > a.start && d < a.end || c > a.start && c < a.end || d <= a.start && c >= a.start || d <= a.end && c >= a.end ? "inside" : d > a.end ? a.settings.horizontal ? "left" : "up" : a.settings.horizontal ? "right" : "down";
+ a.state !== h && (a.state = h, "function" === typeof w && w.call(a.el, "inside" === h, h), "function" === typeof a.callback && a.callback.call(a.el, "inside" === h, h))
+ }
+ }
+
+ function s(a) {
+ if (m.hasOwnProperty(a)) return a;
+ if (b.isPlainObject(a) && m.hasOwnProperty(a.id)) return a.id;
+ a = b(a)[0];
+ var d = !1;
+ b.each(m, function(b,
+ c) {
+ c.el === a && (d = b)
+ });
+ return d
+ }
+
+ // console.log("nothing yet");
+ function q(a) {
+ return (a = s(a)) ? m[a] : !1
+ }
+ "function" !== typeof f && (e = f, f = 0);
+ // console.log("k was", k);
+ var t = function(a) {
+ b.extend(this, a)
+ },
+ u = function(a, d, c, e) {
+ this.id = a;
+ this.el = d;
+ this.$el = b(d);
+ this.callback = c;
+ this.settings = new t(e);
+ this.configure = function(a, d) {
+ b.isPlainObject(a) && (d = a, a = null);
+ b.extend(this.settings, d);
+ null !== a && (this.callback = a)
+ }
+ },
+ n = this,
+ l = b(k);
+ // console.log("l", l, "l==window", l[0]==window);
+ k = b.fn.espy.defaults;
+ // console.log("k is", k);
+ var w, m = {},
+ z = 0;
+ // because window.offset() is not defined in jQuery 3 (why?!?!?!),
+ // we have to treat that as a special case (DF 1/28/19)
+ if (l[0]==window) { offSET = { top: 0, left: 0 } }
+ else { offSET = l.offset() }
+ var p = {
+ top: l.scrollTop(),
+ left: l.scrollLeft(),
+ width: l.innerWidth(),
+ height: l.innerHeight(),
+ offset: offSET
+/*
+ offset: l.offset() || {
+ top: 0,
+ left: 0
+ }
+*/
+ };
+ // console.log("p", p);
+ c(f, b.extend({}, k, e));
+ n.add = function(a, d, c) {
+ b.isPlainObject(d) && (c = d, d = 0);
+ b(a).each(function(a, b) {
+ var e = s(b) || "s" + z++;
+ m[e] = new u(e, b, d, c);
+ g(e);
+ r(e)
+ })
+ };
+ n.configure = function(a, d, e) {
+ "function" === typeof a ? (d = a, a = null, b.isPlainObject(d) && (e = d, d = null)) : b.isPlainObject(a) ? (e = a, d = a = null) : b.isPlainObject(d) && (e = d, d = null);
+ null === a ? (c(d, e), b.each(m, function(a, b) {
+ g(b)
+ })) : b(a).each(function(a, b) {
+ var c = q(b);
+ c && (c.configure(d, e), g(b))
+ })
+ };
+ n.reload = function(a) {
+ a === v ? b.each(m, function() {
+ g(this.id)
+ }) :
+ b(a).each(function(a, b) {
+ var c = s(b);
+ c && (g(c), r(c))
+ })
+ };
+ n.remove = function(a) {
+ b(a).each(function(a, b) {
+ var c = s(b);
+ c && delete m[c]
+ })
+ };
+ n.destroy = function() {
+ l.off(".espy");
+ m = {};
+ n = v
+ };
+ n.resize = function() {
+ b.each(m, function() {
+ this.reloadOnResize && g(this)
+ });
+ p.width = l.innerWidth();
+ p.height = l.innerHeight();
+ r()
+ };
+ l.on("scroll.espy", y(k.delay, function() {
+ p.top = l.scrollTop();
+ p.left = l.scrollLeft();
+ r()
+ }));
+ l.on("resize.espy", y(k.delay, function() {
+ n.resize()
+ }))
+ };
+ b.fn.espy = function(k, f) {
+ var e, c;
+ e = f && f.context || u;
+ var g = b.data(e,
+ "espy") || b.data(e, "espy", new b.Espy(e));
+ "string" !== typeof k ? g.add(this, k, f) : (e = k, c = Array.prototype.slice.call(arguments), c[0] = this, "function" === typeof g[e] && g[e].apply(g, c));
+ return this
+ };
+ b.fn.espy.defaults = {
+ delay: 100,
+ context: window,
+ horizontal: 0,
+ offset: 0,
+ size: "100%",
+ contain: 0,
+ reloadOnResize: !0
+ }
+})(jQuery, window);
+
+
diff --git a/_static/pretext/js/lib/jquery.min.js b/_static/pretext/js/lib/jquery.min.js
new file mode 100644
index 00000000..4d9b3a25
--- /dev/null
+++ b/_static/pretext/js/lib/jquery.min.js
@@ -0,0 +1,2 @@
+/*! jQuery v3.3.1 | (c) JS Foundation and other contributors | jquery.org/license */
+!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return"function"==typeof t&&"number"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement("script");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[c.call(e)]||"object":typeof e}var b="3.3.1",w=function(e,t){return new w.fn.init(e,t)},T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;w.fn=w.prototype={jquery:"3.3.1",constructor:w,length:0,toArray:function(){return o.call(this)},get:function(e){return null==e?o.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=w.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return w.each(this,e)},map:function(e){return this.pushStack(w.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(o.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n","
"],col:[2,"
"],tr:[2,"","
"],td:[3,"
"],_default:[0,"",""]};ge.optgroup=ge.option,ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td;function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&N(e,t)?w.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n","