Fossil
Check-in [b7f70ffc]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Further simplification of the javascript loading code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | refactor-js-handling
Files: files | file ages | folders
SHA3-256: b7f70ffc14489d7fd320f96b6f4905f13ea712f5dd05f90babc6fab188eb1666
User & Date: drh 2020-07-31 21:57:18
Context
2020-07-31
22:04
Simplify the internal interfaces used for injecting built-in Javascript files onto a web page. (check-in: 036a9d5c user: drh tags: trunk)
21:57
Further simplification of the javascript loading code. (Closed-Leaf check-in: b7f70ffc user: drh tags: refactor-js-handling)
21:47
Replace various style_emit_script...() calls with builtin_request_js(). (check-in: 699a977c user: drh tags: refactor-js-handling)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/fileedit.c.

1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966

1967

1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
  style_emit_script_fossil_bootstrap(0);
  append_diff_javascript(1);
  builtin_request_js("fossil.fetch.js");
  builtin_request_js("fossil.dom.js");
  builtin_request_js("fossil.tabs.js");
  builtin_request_js("fossil.confirmer.js");
  builtin_request_js("fossil.storage.js");
  builtin_fulfill_js_requests();

  /*
  ** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
  ** used for dynamically toggling certain UI components on and off.
  ** Must come before fossil.page.fileedit.js.

  */

  ajax_emit_js_preview_modes(1);

  style_emit_script_builtin(0, "fossil.page.fileedit.js");
  if(blob_size(&endScript)>0){
    style_emit_script_tag(0,0);
    CX("\n(function(){\n");
    CX("try{\n%b}\n"
       "catch(e){"
       "fossil.error(e); console.error('Exception:',e);"
       "}\n",







<




|
>

>


|







1954
1955
1956
1957
1958
1959
1960

1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
  style_emit_script_fossil_bootstrap(0);
  append_diff_javascript(1);
  builtin_request_js("fossil.fetch.js");
  builtin_request_js("fossil.dom.js");
  builtin_request_js("fossil.tabs.js");
  builtin_request_js("fossil.confirmer.js");
  builtin_request_js("fossil.storage.js");


  /*
  ** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
  ** used for dynamically toggling certain UI components on and off.
  ** Must come before fossil.page.fileedit.js and after the fetches
  ** above.
  */
  builtin_fulfill_js_requests();
  ajax_emit_js_preview_modes(1);

  builtin_request_js("fossil.page.fileedit.js");
  if(blob_size(&endScript)>0){
    style_emit_script_tag(0,0);
    CX("\n(function(){\n");
    CX("try{\n%b}\n"
       "catch(e){"
       "fossil.error(e); console.error('Exception:',e);"
       "}\n",

Changes to src/forum.c.

759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
*/
static void forum_emit_page_js(){
  static int once = 0;
  if(0==once){
    once = 1;
    builtin_request_js("forum.js");
    style_emit_script_fossil_bootstrap(0);
    style_emit_script_dom(0);
    style_emit_script_builtin(0, "fossil.page.forumpost.js");
  }
}

/*
** WEBPAGE: forumpost
**
** Show a single forum posting. The posting is shown in context with







|
|







759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
*/
static void forum_emit_page_js(){
  static int once = 0;
  if(0==once){
    once = 1;
    builtin_request_js("forum.js");
    style_emit_script_fossil_bootstrap(0);
    builtin_request_js("fossil.dom.js");
    builtin_request_js("fossil.page.forumpost.js");
  }
}

/*
** WEBPAGE: forumpost
**
** Show a single forum posting. The posting is shown in context with

Changes to src/style.c.

1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
....
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
    */
    CX("window.fossil.page = {"
       "name:\"%T\""
       "};\n", g.zPath);
    CX("})();\n");
    /* The remaining fossil object bootstrap code is not dependent on
    ** C-runtime state... */
    if(asInline){
      CX("%s\n", builtin_text("fossil.bootstrap.js"));
    }
    style_emit_script_tag(1,0);
    if(asInline==0){
      style_emit_script_builtin(0, "fossil.bootstrap.js");
    }
  }
}

/*
** If passed 0 as its first argument, it emits a script opener tag
** with this request's nonce. If passed non-0 it emits a script
** closing tag. Mnemonic for remembering the order in which to pass 0
................................................................................
    }else{
      CX("<script nonce='%s'>", style_nonce());
    }
  }else{
    CX("</script>\n");
  }
}

/*
** Emits a script tag which uses content from a builtin script file.
**
** If asInline is true, it is emitted directly as an opening tag, the
** content of the zName builtin file, and a closing tag.
**
** If it is false, a script tag loading it via
** src=builtin/{{zName}}?cache=XYZ is emitted, where XYZ is a
** build-time-dependent cache-buster value.
*/
void style_emit_script_builtin(int asInline, char const * zName){
  if(asInline){
    style_emit_script_tag(0,0);
    CX("%s", builtin_text(zName));
    style_emit_script_tag(1,0);
  }else{
    char * zFullName = mprintf("builtin/%s",zName);
    const char * zHash = fossil_exe_id();
    CX("<script src='%R/%T?cache=%.8s'></script>\n",
       zFullName, zHash);
    fossil_free(zFullName);
  }
}







<
<
<

<
|
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
1465
1466
1467
1468
1469
1470
1471



1472

1473

1474
1475
1476
1477
1478
1479
1480
....
1499
1500
1501
1502
1503
1504
1505
























    */
    CX("window.fossil.page = {"
       "name:\"%T\""
       "};\n", g.zPath);
    CX("})();\n");
    /* The remaining fossil object bootstrap code is not dependent on
    ** C-runtime state... */



    style_emit_script_tag(1,0);

    builtin_request_js("fossil.bootstrap.js");

  }
}

/*
** If passed 0 as its first argument, it emits a script opener tag
** with this request's nonce. If passed non-0 it emits a script
** closing tag. Mnemonic for remembering the order in which to pass 0
................................................................................
    }else{
      CX("<script nonce='%s'>", style_nonce());
    }
  }else{
    CX("</script>\n");
  }
}