Fossil SCM

Further simplification of the javascript loading code.

drh 2020-07-31 21:57 refactor-js-handling
Commit b7f70ffc14489d7fd320f96b6f4905f13ea712f5dd05f90babc6fab188eb1666
3 files changed +4 -3 +2 -2 +1 -30
+4 -3
--- src/fileedit.c
+++ src/fileedit.c
@@ -1956,20 +1956,21 @@
19561956
builtin_request_js("fossil.fetch.js");
19571957
builtin_request_js("fossil.dom.js");
19581958
builtin_request_js("fossil.tabs.js");
19591959
builtin_request_js("fossil.confirmer.js");
19601960
builtin_request_js("fossil.storage.js");
1961
- builtin_fulfill_js_requests();
19621961
19631962
/*
19641963
** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
19651964
** used for dynamically toggling certain UI components on and off.
1966
- ** Must come before fossil.page.fileedit.js.
1965
+ ** Must come before fossil.page.fileedit.js and after the fetches
1966
+ ** above.
19671967
*/
1968
+ builtin_fulfill_js_requests();
19681969
ajax_emit_js_preview_modes(1);
19691970
1970
- style_emit_script_builtin(0, "fossil.page.fileedit.js");
1971
+ builtin_request_js("fossil.page.fileedit.js");
19711972
if(blob_size(&endScript)>0){
19721973
style_emit_script_tag(0,0);
19731974
CX("\n(function(){\n");
19741975
CX("try{\n%b}\n"
19751976
"catch(e){"
19761977
--- src/fileedit.c
+++ src/fileedit.c
@@ -1956,20 +1956,21 @@
1956 builtin_request_js("fossil.fetch.js");
1957 builtin_request_js("fossil.dom.js");
1958 builtin_request_js("fossil.tabs.js");
1959 builtin_request_js("fossil.confirmer.js");
1960 builtin_request_js("fossil.storage.js");
1961 builtin_fulfill_js_requests();
1962
1963 /*
1964 ** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
1965 ** used for dynamically toggling certain UI components on and off.
1966 ** Must come before fossil.page.fileedit.js.
 
1967 */
 
1968 ajax_emit_js_preview_modes(1);
1969
1970 style_emit_script_builtin(0, "fossil.page.fileedit.js");
1971 if(blob_size(&endScript)>0){
1972 style_emit_script_tag(0,0);
1973 CX("\n(function(){\n");
1974 CX("try{\n%b}\n"
1975 "catch(e){"
1976
--- src/fileedit.c
+++ src/fileedit.c
@@ -1956,20 +1956,21 @@
1956 builtin_request_js("fossil.fetch.js");
1957 builtin_request_js("fossil.dom.js");
1958 builtin_request_js("fossil.tabs.js");
1959 builtin_request_js("fossil.confirmer.js");
1960 builtin_request_js("fossil.storage.js");
 
1961
1962 /*
1963 ** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
1964 ** used for dynamically toggling certain UI components on and off.
1965 ** Must come before fossil.page.fileedit.js and after the fetches
1966 ** above.
1967 */
1968 builtin_fulfill_js_requests();
1969 ajax_emit_js_preview_modes(1);
1970
1971 builtin_request_js("fossil.page.fileedit.js");
1972 if(blob_size(&endScript)>0){
1973 style_emit_script_tag(0,0);
1974 CX("\n(function(){\n");
1975 CX("try{\n%b}\n"
1976 "catch(e){"
1977
+2 -2
--- src/forum.c
+++ src/forum.c
@@ -761,12 +761,12 @@
761761
static int once = 0;
762762
if(0==once){
763763
once = 1;
764764
builtin_request_js("forum.js");
765765
style_emit_script_fossil_bootstrap(0);
766
- style_emit_script_dom(0);
767
- style_emit_script_builtin(0, "fossil.page.forumpost.js");
766
+ builtin_request_js("fossil.dom.js");
767
+ builtin_request_js("fossil.page.forumpost.js");
768768
}
769769
}
770770
771771
/*
772772
** WEBPAGE: forumpost
773773
--- src/forum.c
+++ src/forum.c
@@ -761,12 +761,12 @@
761 static int once = 0;
762 if(0==once){
763 once = 1;
764 builtin_request_js("forum.js");
765 style_emit_script_fossil_bootstrap(0);
766 style_emit_script_dom(0);
767 style_emit_script_builtin(0, "fossil.page.forumpost.js");
768 }
769 }
770
771 /*
772 ** WEBPAGE: forumpost
773
--- src/forum.c
+++ src/forum.c
@@ -761,12 +761,12 @@
761 static int once = 0;
762 if(0==once){
763 once = 1;
764 builtin_request_js("forum.js");
765 style_emit_script_fossil_bootstrap(0);
766 builtin_request_js("fossil.dom.js");
767 builtin_request_js("fossil.page.forumpost.js");
768 }
769 }
770
771 /*
772 ** WEBPAGE: forumpost
773
+1 -30
--- src/style.c
+++ src/style.c
@@ -1467,17 +1467,12 @@
14671467
"name:\"%T\""
14681468
"};\n", g.zPath);
14691469
CX("})();\n");
14701470
/* The remaining fossil object bootstrap code is not dependent on
14711471
** C-runtime state... */
1472
- if(asInline){
1473
- CX("%s\n", builtin_text("fossil.bootstrap.js"));
1474
- }
14751472
style_emit_script_tag(1,0);
1476
- if(asInline==0){
1477
- style_emit_script_builtin(0, "fossil.bootstrap.js");
1478
- }
1473
+ builtin_request_js("fossil.bootstrap.js");
14791474
}
14801475
}
14811476
14821477
/*
14831478
** If passed 0 as its first argument, it emits a script opener tag
@@ -1506,29 +1501,5 @@
15061501
}
15071502
}else{
15081503
CX("</script>\n");
15091504
}
15101505
}
1511
-
1512
-/*
1513
-** Emits a script tag which uses content from a builtin script file.
1514
-**
1515
-** If asInline is true, it is emitted directly as an opening tag, the
1516
-** content of the zName builtin file, and a closing tag.
1517
-**
1518
-** If it is false, a script tag loading it via
1519
-** src=builtin/{{zName}}?cache=XYZ is emitted, where XYZ is a
1520
-** build-time-dependent cache-buster value.
1521
-*/
1522
-void style_emit_script_builtin(int asInline, char const * zName){
1523
- if(asInline){
1524
- style_emit_script_tag(0,0);
1525
- CX("%s", builtin_text(zName));
1526
- style_emit_script_tag(1,0);
1527
- }else{
1528
- char * zFullName = mprintf("builtin/%s",zName);
1529
- const char * zHash = fossil_exe_id();
1530
- CX("<script src='%R/%T?cache=%.8s'></script>\n",
1531
- zFullName, zHash);
1532
- fossil_free(zFullName);
1533
- }
1534
-}
15351506
--- src/style.c
+++ src/style.c
@@ -1467,17 +1467,12 @@
1467 "name:\"%T\""
1468 "};\n", g.zPath);
1469 CX("})();\n");
1470 /* The remaining fossil object bootstrap code is not dependent on
1471 ** C-runtime state... */
1472 if(asInline){
1473 CX("%s\n", builtin_text("fossil.bootstrap.js"));
1474 }
1475 style_emit_script_tag(1,0);
1476 if(asInline==0){
1477 style_emit_script_builtin(0, "fossil.bootstrap.js");
1478 }
1479 }
1480 }
1481
1482 /*
1483 ** If passed 0 as its first argument, it emits a script opener tag
@@ -1506,29 +1501,5 @@
1506 }
1507 }else{
1508 CX("</script>\n");
1509 }
1510 }
1511
1512 /*
1513 ** Emits a script tag which uses content from a builtin script file.
1514 **
1515 ** If asInline is true, it is emitted directly as an opening tag, the
1516 ** content of the zName builtin file, and a closing tag.
1517 **
1518 ** If it is false, a script tag loading it via
1519 ** src=builtin/{{zName}}?cache=XYZ is emitted, where XYZ is a
1520 ** build-time-dependent cache-buster value.
1521 */
1522 void style_emit_script_builtin(int asInline, char const * zName){
1523 if(asInline){
1524 style_emit_script_tag(0,0);
1525 CX("%s", builtin_text(zName));
1526 style_emit_script_tag(1,0);
1527 }else{
1528 char * zFullName = mprintf("builtin/%s",zName);
1529 const char * zHash = fossil_exe_id();
1530 CX("<script src='%R/%T?cache=%.8s'></script>\n",
1531 zFullName, zHash);
1532 fossil_free(zFullName);
1533 }
1534 }
1535
--- src/style.c
+++ src/style.c
@@ -1467,17 +1467,12 @@
1467 "name:\"%T\""
1468 "};\n", g.zPath);
1469 CX("})();\n");
1470 /* The remaining fossil object bootstrap code is not dependent on
1471 ** C-runtime state... */
 
 
 
1472 style_emit_script_tag(1,0);
1473 builtin_request_js("fossil.bootstrap.js");
 
 
1474 }
1475 }
1476
1477 /*
1478 ** If passed 0 as its first argument, it emits a script opener tag
@@ -1506,29 +1501,5 @@
1501 }
1502 }else{
1503 CX("</script>\n");
1504 }
1505 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1506

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button