| | @@ -88,14 +88,10 @@ |
| 88 | 88 | |
| 89 | 89 | /* |
| 90 | 90 | ** Flags for various javascript files needed prior to </body> |
| 91 | 91 | */ |
| 92 | 92 | static int needHrefJs = 0; /* href.js */ |
| 93 | | -static int needSortJs = 0; /* sorttable.js */ |
| 94 | | -static int needGraphJs = 0; /* graph.js */ |
| 95 | | -static int needCopyBtnJs = 0; /* copybtn.js */ |
| 96 | | -static int needAccordionJs = 0; /* accordion.js */ |
| 97 | 93 | |
| 98 | 94 | /* |
| 99 | 95 | ** Extra JS added to the end of the file. |
| 100 | 96 | */ |
| 101 | 97 | static Blob blobOnLoad = BLOB_INITIALIZER; |
| | @@ -484,11 +480,11 @@ |
| 484 | 480 | zBtnFmt/*works-like:"%h%s%h%h%d"*/, |
| 485 | 481 | zTargetId,zText,zTargetId,zTargetId,cchLength); |
| 486 | 482 | } |
| 487 | 483 | } |
| 488 | 484 | free(zText); |
| 489 | | - style_copybutton_control(); |
| 485 | + builtin_request_js("copybtn.js"); |
| 490 | 486 | return zResult; |
| 491 | 487 | } |
| 492 | 488 | |
| 493 | 489 | /* |
| 494 | 490 | ** Return a random nonce that is stored in static space. For a particular |
| | @@ -694,66 +690,17 @@ |
| 694 | 690 | |
| 695 | 691 | /* |
| 696 | 692 | ** Indicate that the table-sorting javascript is needed. |
| 697 | 693 | */ |
| 698 | 694 | void style_table_sorter(void){ |
| 699 | | - needSortJs = 1; |
| 700 | | -} |
| 701 | | - |
| 702 | | -/* |
| 703 | | -** Indicate that the accordion javascript is needed. |
| 704 | | -*/ |
| 705 | | -void style_accordion(void){ |
| 706 | | - needAccordionJs = 1; |
| 707 | | -} |
| 708 | | - |
| 709 | | -/* |
| 710 | | -** Indicate that the timeline graph javascript is needed. |
| 711 | | -*/ |
| 712 | | -void style_graph_generator(void){ |
| 713 | | - needGraphJs = 1; |
| 714 | | -} |
| 715 | | - |
| 716 | | -/* |
| 717 | | -** Indicate that the copy button javascript is needed. |
| 718 | | -*/ |
| 719 | | -void style_copybutton_control(void){ |
| 720 | | - needCopyBtnJs = 1; |
| 721 | | -} |
| 722 | | - |
| 723 | | -/* |
| 724 | | -** Generate code to load a single javascript file |
| 725 | | -*/ |
| 726 | | -void style_load_one_js_file(const char *zFile){ |
| 727 | | - @ <script src='%R/builtin/%s(zFile)?id=%S(fossil_exe_id())'></script> |
| 728 | | -} |
| 729 | | - |
| 730 | | -/* |
| 731 | | -** All extra JS files to load. |
| 732 | | -*/ |
| 733 | | -static const char *azJsToLoad[4]; |
| 734 | | -static int nJsToLoad = 0; |
| 735 | | - |
| 736 | | -/* |
| 737 | | -** Register a new JS file to load at the end of the document. |
| 738 | | -*/ |
| 739 | | -void style_load_js(const char *zName){ |
| 740 | | - int i; |
| 741 | | - for(i=0; i<nJsToLoad; i++){ |
| 742 | | - if( fossil_strcmp(zName, azJsToLoad[i])==0 ) return; |
| 743 | | - } |
| 744 | | - if( nJsToLoad>=sizeof(azJsToLoad)/sizeof(azJsToLoad[0]) ){ |
| 745 | | - fossil_panic("too many JS files"); |
| 746 | | - } |
| 747 | | - azJsToLoad[nJsToLoad++] = zName; |
| 695 | + builtin_request_js("sorttable.js"); |
| 748 | 696 | } |
| 749 | 697 | |
| 750 | 698 | /* |
| 751 | 699 | ** Generate code to load all required javascript files. |
| 752 | 700 | */ |
| 753 | 701 | static void style_load_all_js_files(void){ |
| 754 | | - int i; |
| 755 | 702 | if( needHrefJs ){ |
| 756 | 703 | int nDelay = db_get_int("auto-hyperlink-delay",0); |
| 757 | 704 | int bMouseover = db_get_boolean("auto-hyperlink-mouseover",0); |
| 758 | 705 | @ <script id='href-data' type='application/json'>\ |
| 759 | 706 | @ {"delay":%d(nDelay),"mouseover":%d(bMouseover)}</script> |
| | @@ -762,43 +709,20 @@ |
| 762 | 709 | @ function debugMsg(msg){ |
| 763 | 710 | @ var n = document.getElementById("debugMsg"); |
| 764 | 711 | @ if(n){n.textContent=msg;} |
| 765 | 712 | @ } |
| 766 | 713 | if( needHrefJs ){ |
| 714 | + @ /* href.js */ |
| 767 | 715 | cgi_append_content(builtin_text("href.js"),-1); |
| 768 | 716 | } |
| 769 | | - if( needSortJs ){ |
| 770 | | - cgi_append_content(builtin_text("sorttable.js"),-1); |
| 771 | | - } |
| 772 | | - if( needGraphJs ){ |
| 773 | | - cgi_append_content(builtin_text("graph.js"),-1); |
| 774 | | - } |
| 775 | | - if( needCopyBtnJs ){ |
| 776 | | - cgi_append_content(builtin_text("copybtn.js"),-1); |
| 777 | | - } |
| 778 | | - if( needAccordionJs ){ |
| 779 | | - cgi_append_content(builtin_text("accordion.js"),-1); |
| 780 | | - } |
| 781 | | - for(i=0; i<nJsToLoad; i++){ |
| 782 | | - cgi_append_content(builtin_text(azJsToLoad[i]),-1); |
| 783 | | - } |
| 784 | 717 | if( blob_size(&blobOnLoad)>0 ){ |
| 785 | 718 | @ window.onload = function(){ |
| 786 | 719 | cgi_append_content(blob_buffer(&blobOnLoad), blob_size(&blobOnLoad)); |
| 787 | 720 | cgi_append_content("\n}\n", -1); |
| 788 | 721 | } |
| 789 | 722 | @ </script> |
| 790 | | -} |
| 791 | | - |
| 792 | | -/* |
| 793 | | -** Extra JS to run after all content is loaded. |
| 794 | | -*/ |
| 795 | | -void style_js_onload(const char *zFormat, ...){ |
| 796 | | - va_list ap; |
| 797 | | - va_start(ap, zFormat); |
| 798 | | - blob_vappendf(&blobOnLoad, zFormat, ap); |
| 799 | | - va_end(ap); |
| 723 | + builtin_fulfill_js_requests(); |
| 800 | 724 | } |
| 801 | 725 | |
| 802 | 726 | /* |
| 803 | 727 | ** Draw the footer at the bottom of the page. |
| 804 | 728 | */ |
| | @@ -916,11 +840,11 @@ |
| 916 | 840 | @ </div> |
| 917 | 841 | if( nSubmenuCtrl ){ |
| 918 | 842 | cgi_query_parameters_to_hidden(); |
| 919 | 843 | cgi_tag_query_parameter(0); |
| 920 | 844 | @ </form> |
| 921 | | - style_load_one_js_file("menu.js"); |
| 845 | + builtin_request_js("menu.js"); |
| 922 | 846 | } |
| 923 | 847 | } |
| 924 | 848 | |
| 925 | 849 | zAd = style_adunit_text(&mAdFlags); |
| 926 | 850 | if( (mAdFlags & ADUNIT_RIGHT_OK)!=0 ){ |
| | @@ -1543,17 +1467,12 @@ |
| 1543 | 1467 | "name:\"%T\"" |
| 1544 | 1468 | "};\n", g.zPath); |
| 1545 | 1469 | CX("})();\n"); |
| 1546 | 1470 | /* The remaining fossil object bootstrap code is not dependent on |
| 1547 | 1471 | ** C-runtime state... */ |
| 1548 | | - if(asInline){ |
| 1549 | | - CX("%s\n", builtin_text("fossil.bootstrap.js")); |
| 1550 | | - } |
| 1551 | 1472 | style_emit_script_tag(1,0); |
| 1552 | | - if(asInline==0){ |
| 1553 | | - style_emit_script_builtin(0, "fossil.bootstrap.js"); |
| 1554 | | - } |
| 1473 | + builtin_request_js("fossil.bootstrap.js"); |
| 1555 | 1474 | } |
| 1556 | 1475 | } |
| 1557 | 1476 | |
| 1558 | 1477 | /* |
| 1559 | 1478 | ** If passed 0 as its first argument, it emits a script opener tag |
| | @@ -1582,99 +1501,5 @@ |
| 1582 | 1501 | } |
| 1583 | 1502 | }else{ |
| 1584 | 1503 | CX("</script>\n"); |
| 1585 | 1504 | } |
| 1586 | 1505 | } |
| 1587 | | - |
| 1588 | | -/* |
| 1589 | | -** Emits a script tag which uses content from a builtin script file. |
| 1590 | | -** |
| 1591 | | -** If asInline is true, it is emitted directly as an opening tag, the |
| 1592 | | -** content of the zName builtin file, and a closing tag. |
| 1593 | | -** |
| 1594 | | -** If it is false, a script tag loading it via |
| 1595 | | -** src=builtin/{{zName}}?cache=XYZ is emitted, where XYZ is a |
| 1596 | | -** build-time-dependent cache-buster value. |
| 1597 | | -*/ |
| 1598 | | -void style_emit_script_builtin(int asInline, char const * zName){ |
| 1599 | | - if(asInline){ |
| 1600 | | - style_emit_script_tag(0,0); |
| 1601 | | - CX("%s", builtin_text(zName)); |
| 1602 | | - style_emit_script_tag(1,0); |
| 1603 | | - }else{ |
| 1604 | | - char * zFullName = mprintf("builtin/%s",zName); |
| 1605 | | - const char * zHash = fossil_exe_id(); |
| 1606 | | - CX("<script src='%R/%T?cache=%.8s'></script>\n", |
| 1607 | | - zFullName, zHash); |
| 1608 | | - fossil_free(zFullName); |
| 1609 | | - } |
| 1610 | | -} |
| 1611 | | - |
| 1612 | | -/* |
| 1613 | | -** The first time this is called it emits the JS code from the |
| 1614 | | -** built-in file fossil.fossil.js. Subsequent calls are no-ops. |
| 1615 | | -** |
| 1616 | | -** If passed a true value, it emits the contents directly |
| 1617 | | -** to the page output, else it emits a script tag with a |
| 1618 | | -** src=builtin/... to load the script. |
| 1619 | | -** |
| 1620 | | -** Note that this code relies on that loaded via |
| 1621 | | -** style_emit_script_fossil_bootstrap() but it does not call that |
| 1622 | | -** routine. |
| 1623 | | -*/ |
| 1624 | | -void style_emit_script_fetch(int asInline){ |
| 1625 | | - static int once = 0; |
| 1626 | | - if(0==once++){ |
| 1627 | | - style_emit_script_builtin(asInline, "fossil.fetch.js"); |
| 1628 | | - } |
| 1629 | | -} |
| 1630 | | - |
| 1631 | | -/* |
| 1632 | | -** The first time this is called it emits the JS code from the |
| 1633 | | -** built-in file fossil.dom.js. Subsequent calls are no-ops. |
| 1634 | | -** |
| 1635 | | -** If passed a true value, it emits the contents directly |
| 1636 | | -** to the page output, else it emits a script tag with a |
| 1637 | | -** src=builtin/... to load the script. |
| 1638 | | -** |
| 1639 | | -** Note that this code relies on that loaded via |
| 1640 | | -** style_emit_script_fossil_bootstrap(), but it does not call that |
| 1641 | | -** routine. |
| 1642 | | -*/ |
| 1643 | | -void style_emit_script_dom(int asInline){ |
| 1644 | | - static int once = 0; |
| 1645 | | - if(0==once++){ |
| 1646 | | - style_emit_script_builtin(asInline, "fossil.dom.js"); |
| 1647 | | - } |
| 1648 | | -} |
| 1649 | | - |
| 1650 | | -/* |
| 1651 | | -** The first time this is called, it calls style_emit_script_dom(), |
| 1652 | | -** passing it the given asInline value, and emits the JS code from the |
| 1653 | | -** built-in file fossil.tabs.js. Subsequent calls are no-ops. |
| 1654 | | -** |
| 1655 | | -** If passed a true value, it emits the contents directly |
| 1656 | | -** to the page output, else it emits a script tag with a |
| 1657 | | -** src=builtin/... to load the script. |
| 1658 | | -*/ |
| 1659 | | -void style_emit_script_tabs(int asInline){ |
| 1660 | | - static int once = 0; |
| 1661 | | - if(0==once++){ |
| 1662 | | - style_emit_script_dom(asInline); |
| 1663 | | - style_emit_script_builtin(asInline, "fossil.tabs.js"); |
| 1664 | | - } |
| 1665 | | -} |
| 1666 | | - |
| 1667 | | -/* |
| 1668 | | -** The first time this is called it emits the JS code from the |
| 1669 | | -** built-in file fossil.confirmer.js. Subsequent calls are no-ops. |
| 1670 | | -** |
| 1671 | | -** If passed a true value, it emits the contents directly |
| 1672 | | -** to the page output, else it emits a script tag with a |
| 1673 | | -** src=builtin/... to load the script. |
| 1674 | | -*/ |
| 1675 | | -void style_emit_script_confirmer(int asInline){ |
| 1676 | | - static int once = 0; |
| 1677 | | - if(0==once++){ |
| 1678 | | - style_emit_script_builtin(asInline, "fossil.confirmer.js"); |
| 1679 | | - } |
| 1680 | | -} |
| 1681 | 1506 | |