Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch misc-js-experiments Excluding Merge-Ins
This is equivalent to a diff from 1f4143ba28 to 3f08a9d200
|
2020-08-25
| ||
| 07:00 | The fossil.XYZ.js-using pages now include all of those APIs when running in bundled JS mode, as that provides far lower aggregate over-the-wire and HTTP request counts. Added ? popup help buttons in wikiedit/fileedit to replace title-attribute hoverhelp (popup positioning can still be improved, though). ... (check-in: 34f7fd72c6 user: stephan tags: trunk) | |
| 06:18 | Lots of tweaking to the "help buttonlet" popup position. Something to improve some rainy day. ... (Closed-Leaf check-in: 3f08a9d200 user: stephan tags: misc-js-experiments) | |
|
2020-08-24
| ||
| 23:24 | Merge miscellanous auxiliary defenses and security enhancements. This check-in is not needed to fix any problems that are not already fixed in version 2.12.1. It merely provides additional defense in depth. ... (check-in: f741baa6be user: drh tags: trunk) | |
| 22:46 | Improved cross-page caching of wikiedit/fileedit bundle, reducing those pages to a single request of 10-13k once cache is warm. Fixed non-bundled JS distribution of fileedit and wikiedit. ... (check-in: 20c50cd1e5 user: stephan tags: misc-js-experiments) | |
| 22:45 | Adjust 'fossil merge' command to use CR/LF line endings for conflict markings if both files being merged already use such line ending type. ... (check-in: 60ecf5d9ed user: marciogabe tags: merge-crlf-bom) | |
| 20:49 | Experimentally added '?' help buttons in wikiedit. Experimentally emit all fossil.XYZ APIs, rather than selected ones, to test whether that reduces overall transmission together with caching. DOM init-time timing workarounds to get confirmer buttons to pin their sizes properly. ... (check-in: 9edbb7eab1 user: stephan tags: misc-js-experiments) | |
| 20:24 | Changed how fossil.confirmer pinSize option computes element width to be more robust in the face of CSS 'auto' width values. ... (check-in: 1f4143ba28 user: stephan tags: trunk) | |
| 12:35 | For Hash or Wiki interwiki hyperlinks in Fossil Wiki without an alternative display, elide the initial interwiki tag from the display. ... (check-in: 2d1a493d9c user: drh tags: trunk) | |
Changes to src/ajax.c.
| ︙ | ︙ | |||
39 40 41 42 43 44 45 | ** Emits JS code which initializes the ** fossil.page.previewModes object to a map of AJAX_RENDER_xxx values ** and symbolic names for use by client-side scripts. ** ** If addScriptTag is true then the output is wrapped in a SCRIPT tag ** with the current nonce, else no SCRIPT tag is emitted. ** | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
** Emits JS code which initializes the
** fossil.page.previewModes object to a map of AJAX_RENDER_xxx values
** and symbolic names for use by client-side scripts.
**
** If addScriptTag is true then the output is wrapped in a SCRIPT tag
** with the current nonce, else no SCRIPT tag is emitted.
**
** Requires that builtin_emit_script_fossil_bootstrap() has already been
** called in order to initialize the window.fossil.page object.
*/
void ajax_emit_js_preview_modes(int addScriptTag){
if(addScriptTag){
style_emit_script_tag(0,0);
CX("\n");
}
|
| ︙ | ︙ | |||
129 130 131 132 133 134 135 |
safe_html_context(DOCSRC_FILE);
wiki_render_by_mimetype(pContent, zMime);
break;
default:{
const char *zContent = blob_str(pContent);
if(AJAX_PREVIEW_LINE_NUMBERS & flags){
output_text_with_line_numbers(zContent, blob_size(pContent),
| | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
safe_html_context(DOCSRC_FILE);
wiki_render_by_mimetype(pContent, zMime);
break;
default:{
const char *zContent = blob_str(pContent);
if(AJAX_PREVIEW_LINE_NUMBERS & flags){
output_text_with_line_numbers(zContent, blob_size(pContent),
zName, "on", 0);
}else{
const char *zExt = strrchr(zName,'.');
if(zExt && zExt[1]){
CX("<pre><code class='language-%s'>%h</code></pre>",
zExt+1, zContent);
}else{
CX("<pre>%h</pre>", zContent);
|
| ︙ | ︙ |
Changes to src/attach.c.
| ︙ | ︙ | |||
615 616 617 618 619 620 621 |
blob_zero(&attach);
if( fShowContent ){
const char *z;
content_get(ridSrc, &attach);
blob_to_utf8_no_bom(&attach, 0);
z = blob_str(&attach);
if( zLn ){
| | | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 |
blob_zero(&attach);
if( fShowContent ){
const char *z;
content_get(ridSrc, &attach);
blob_to_utf8_no_bom(&attach, 0);
z = blob_str(&attach);
if( zLn ){
output_text_with_line_numbers(z, blob_size(&attach), zName, zLn, 1);
}else{
@ <pre>
@ %h(z)
@ </pre>
}
}else if( strncmp(zMime, "image/", 6)==0 ){
int sz = db_int(0, "SELECT size FROM blob WHERE rid=%d", ridSrc);
|
| ︙ | ︙ |
Changes to src/builtin.c.
| ︙ | ︙ | |||
256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
if( strcmp(zMode, "bundled")==0 ){
builtin.eDelivery = JS_BUNDLED;
}else if( !bSilent ){
fossil_fatal("unknown javascript delivery mode \"%s\" - should be"
" one of: inline separate bundled", zMode);
}
}
/*
** The caller wants the Javascript file named by zFilename to be
** included in the generated page. Add the file to the queue of
** requested javascript resources, if it is not there already.
**
** The current implementation queues the file to be included in the
| > > > > > > > > | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
if( strcmp(zMode, "bundled")==0 ){
builtin.eDelivery = JS_BUNDLED;
}else if( !bSilent ){
fossil_fatal("unknown javascript delivery mode \"%s\" - should be"
" one of: inline separate bundled", zMode);
}
}
/*
** Returns the current JS delivery mode: one of JS_INLINE,
** JS_SEPARATE, JS_BUNDLED.
*/
int builtin_get_js_delivery_mode(void){
return builtin.eDelivery;
}
/*
** The caller wants the Javascript file named by zFilename to be
** included in the generated page. Add the file to the queue of
** requested javascript resources, if it is not there already.
**
** The current implementation queues the file to be included in the
|
| ︙ | ︙ | |||
557 558 559 560 561 562 563 |
*/
int builtin_vtab_register(sqlite3 *db){
int rc = sqlite3_create_module(db, "builtin", &builtinVtabModule, 0);
return rc;
}
/* End of the builtin virtual table
******************************************************************************/
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 |
*/
int builtin_vtab_register(sqlite3 *db){
int rc = sqlite3_create_module(db, "builtin", &builtinVtabModule, 0);
return rc;
}
/* End of the builtin virtual table
******************************************************************************/
/*
** The first time this is called, it emits code to install and
** bootstrap the window.fossil object, using the built-in file
** fossil.bootstrap.js (not to be confused with bootstrap.js).
**
** Subsequent calls are no-ops.
**
** It emits 2 parts:
**
** 1) window.fossil core object, some of which depends on C-level
** runtime data. That part of the script is always emitted inline. If
** addScriptTag is true then it is wrapped in its own SCRIPT tag, else
** it is assumed that the caller already opened a tag.
**
** 2) Emits the static fossil.bootstrap.js using builtin_request_js().
*/
void builtin_emit_script_fossil_bootstrap(int addScriptTag){
static int once = 0;
if(0==once++){
char * zName;
/* Set up the generic/app-agnostic parts of window.fossil
** which require C-level state... */
if(addScriptTag!=0){
style_emit_script_tag(0,0);
}
CX("(function(){\n");
CX(/*MSIE NodeList.forEach polyfill, courtesy of Mozilla:
https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#Polyfill
*/
"if(window.NodeList && !NodeList.prototype.forEach){"
"NodeList.prototype.forEach = Array.prototype.forEach;"
"}\n");
CX("if(!window.fossil) window.fossil={};\n"
"window.fossil.version = %!j;\n"
/* fossil.rootPath is the top-most CGI/server path,
** including a trailing slash. */
"window.fossil.rootPath = %!j+'/';\n",
get_version(), g.zTop);
/* fossil.config = {...various config-level options...} */
CX("window.fossil.config = {");
zName = db_get("project-name", "");
CX("projectName: %!j,\n", zName);
fossil_free(zName);
zName = db_get("short-project-name", "");
CX("shortProjectName: %!j,\n", zName);
fossil_free(zName);
zName = db_get("project-code", "");
CX("projectCode: %!j,\n", zName);
fossil_free(zName);
CX("/* Length of UUID hashes for display purposes. */");
CX("hashDigits: %d, hashDigitsUrl: %d,\n",
hash_digits(0), hash_digits(1));
CX("editStateMarkers: {"
"/*Symbolic markers to denote certain edit states.*/"
"isNew:'[+]', isModified:'[*]', isDeleted:'[-]'},\n");
CX("confirmerButtonTicks: 3 "
"/*default fossil.confirmer tick count.*/\n");
CX("};\n"/* fossil.config */);
#if 0
/* Is it safe to emit the CSRF token here? Some pages add it
** as a hidden form field. */
if(g.zCsrfToken[0]!=0){
CX("window.fossil.csrfToken = %!j;\n",
g.zCsrfToken);
}
#endif
/*
** fossil.page holds info about the current page. This is also
** where the current page "should" store any of its own
** page-specific state, and it is reserved for that purpose.
*/
CX("window.fossil.page = {"
"name:\"%T\""
"};\n", g.zPath);
CX("})();\n");
if(addScriptTag!=0){
style_emit_script_tag(1,0);
}
/* The remaining window.fossil bootstrap code is not dependent on
** C-runtime state... */
builtin_request_js("fossil.bootstrap.js");
}
}
/*
** Convenience wrapper which calls builtin_request_js() for a series
** of builtin scripts named fossil.NAME.js. The first time it is
** called, it also calls builtin_emit_script_fossil_bootstrap() to
** initialize the window.fossil JS API. The first argument is the NAME
** part of the first API to emit. All subsequent arguments must be
** strings of the NAME part of additional fossil.NAME.js files,
** followed by a NULL argument to terminate the list.
**
** e.g. pass it ("fetch", "dom", "tabs", 0) to load those 3
** APIs. Do not forget the trailing 0!
*/
void builtin_emit_fossil_js_apis( const char * zApi, ... ) {
static int once = 0;
const char *zArg;
char * zName;
va_list vargs;
if(0==once++){
builtin_emit_script_fossil_bootstrap(1);
}
zName = mprintf("fossil.%s.js", zApi);
builtin_request_js(zName);
fossil_free(zName);
va_start(vargs,zApi);
while( (zArg = va_arg (vargs, const char *))!=0 ){
zName = mprintf("fossil.%s.js", zArg);
builtin_request_js(zName);
fossil_free(zName);
}
va_end(vargs);
}
/*
** If builtin_get_js_delivery_mode() returns JS_BUNDLED then this
** function emits, via builtin_request_js(), all JS fossil.XYZ APIs
** which are not strictly specific to a single page, and then calls
** builtin_fulfill_js_requests(). The idea is that we can get better
** bundle caching and reduced HTTP requests by including all JS,
** rather than creating separate bundles on a per-page basis. It then
** returns true. As a special case, if this is called more than once
** in bundled mode, subsequent calls are a no-op.
**
** If the current JS delivery mode is *not* JS_BUNDLED then this
** function is a no-op and returns false.
**
** Minor caveat: the purpose of emitting all of the fossil.XYZ JS APIs
** at once is to reduce over-the-wire transfers by enabling cross-page
** caching, but if there are other JS scripts pending via
** builtin_request_js() when this is called then they will be included
** in the JS request emitted by this routine, resulting in a different
** script URL than if they were not included. Thus, if a given page
** has its own scripts to install via builtin_request_js(), they
** should, if possible, be delayed until after this is called OR the
** page should call builtin_fulfill_js_requests() to flush the request
** queue before calling this routine.
*/
int builtin_bundle_all_fossil_js_apis(void){
static int bundled = 0;
if(JS_BUNDLED == builtin_get_js_delivery_mode()){
if(!bundled){
bundled = 1;
builtin_emit_fossil_js_apis("dom", "fetch",
"storage", "tabs",
"confirmer", "popupwidget",
"copybutton", "numbered-lines",
0);
builtin_fulfill_js_requests();
}
return 1;
}else{
return 0;
}
}
|
Changes to src/default.css.
| ︙ | ︙ | |||
1098 1099 1100 1101 1102 1103 1104 |
font-size: 175%;
}
.font-size-200 {
font-size: 200%;
}
/**
| | | | | | > | 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 |
font-size: 175%;
}
.font-size-200 {
font-size: 200%;
}
/**
.input-with-label is intended to be a wrapper element which contain
both a LABEL tag and an INPUT or SELECT control. The wrapper is
"necessary", as opposed to placing the INPUT in the LABEL, so that
we can include multiple INPUT elements (e.g. a set of radio
buttons). Note that these elements must sometimes be BLOCK elements
(e.g. DIV) so that certain nesting constructs are legal.
*/
.input-with-label {
border: 1px inset #808080;
border-radius: 0.25em;
padding: 0.25em 0.4em;
margin: 0 0.5em;
display: inline-block;
|
| ︙ | ︙ | |||
1291 1292 1293 1294 1295 1296 1297 |
color: black;
}
blockquote.file-content {
/* file content block in the /file page */
margin: 0 1em;
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 |
color: black;
}
blockquote.file-content {
/* file content block in the /file page */
margin: 0 1em;
}
/**
Circular "help" buttons intended to be placed to the right of
another element and hold text text for it. These get initialized
automatically at page startup via fossil.popupwidget.js. All child
content gets moved out of the DOM and shown in a popup when they
are clicked. They may be SPAN elements if their children are all
inline elements, otherwise they must be DIVs (block elements)
so that nesting of block elements is legal.
*/
.help-buttonlet {
display: inline-block;
min-width: 1rem;
max-width: 1rem;
min-height: 1rem;
max-height: 1rem;
font-size: 0.9em;
border-radius: 0.5rem;
background-color: rgba(54, 54, 255,1);
color: rgb(255, 255, 255);
cursor: pointer;
font-family: monspace;
text-align: center;
margin: 0 0 0 0.35em;
border-width: 1px;
border-style: outset;
font-weight: 700;
overflow: hidden;
}
.help-buttonlet::before {
content: "?";
}
/**
We really want to hide all help text via CSS but CSS cannot select
TEXT nodes. Thus we move them out of the way programmatically
during initialization.
*/
.help-buttonlet > *{}
/**
CSS class for PopupWidget which wraps .help-buttonlet content.
They also have class fossil-tooltip. We need an overly-exact
selector here to be certain that this class's style overrides
that of fossil-tooltip.
*/
.fossil-tooltip.help-buttonlet-content {
cursor: default;
text-align: left;
border-style: outset;
box-shadow: 0em 0em 0.2em 0.2em rgba(0,0,0,0.40);
}
|
Changes to src/fileedit.c.
| ︙ | ︙ | |||
1703 1704 1705 1706 1707 1708 1709 |
{
CX("<div id='fileedit-tab-content' "
"data-tab-parent='fileedit-tabs' "
"data-tab-label='File Content' "
"class='hidden'"
">");
CX("<div class='flex-container flex-row child-gap-small'>");
| > | > > | | > | | 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 |
{
CX("<div id='fileedit-tab-content' "
"data-tab-parent='fileedit-tabs' "
"data-tab-label='File Content' "
"class='hidden'"
">");
CX("<div class='flex-container flex-row child-gap-small'>");
CX("<div class='input-with-label'>"
"<button class='fileedit-content-reload confirmer' "
">Discard & Reload</button>"
"<div class='help-buttonlet'>"
"Reload the file from the server, discarding "
"any local edits. To help avoid accidental loss of "
"edits, it requires confirmation (a second click) within "
"a few seconds or it will not reload."
"</div>"
"</div>");
style_select_list_int("select-font-size",
"editor_font_size", "Editor font size",
NULL/*tooltip*/,
100,
"100%", 100, "125%", 125,
"150%", 150, "175%", 175,
"200%", 200, NULL);
|
| ︙ | ︙ | |||
1744 1745 1746 1747 1748 1749 1750 |
** the text editor with their own. */
"data-f-preview-via='_postPreview' "
/* ^^^ fossil.page[methodName](content, callback) */
"data-f-preview-to='#fileedit-tab-preview-wrapper' "
/* ^^^ dest elem ID */
">Refresh</button>");
/* Toggle auto-update of preview when the Preview tab is selected. */
| > > | < | < > | | > > | 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 |
** the text editor with their own. */
"data-f-preview-via='_postPreview' "
/* ^^^ fossil.page[methodName](content, callback) */
"data-f-preview-to='#fileedit-tab-preview-wrapper' "
/* ^^^ dest elem ID */
">Refresh</button>");
/* Toggle auto-update of preview when the Preview tab is selected. */
CX("<div class='input-with-label'>"
"<input type='checkbox' value='1' "
"id='cb-preview-autorefresh' checked>"
"<label for='cb-preview-autorefresh'>Auto-refresh?</label>"
"<div class='help-buttonlet'>"
"If on, the preview will automatically "
"refresh (if needed) when this tab is selected."
"</div>"
"</div>");
/* Default preview rendering mode selection... */
previewRenderMode = zFileMime
? ajax_render_mode_for_mimetype(zFileMime)
: AJAX_RENDER_GUESS;
style_select_list_int("select-preview-mode",
"preview_render_mode",
|
| ︙ | ︙ | |||
1977 1978 1979 1980 1981 1982 1983 |
"is unspecified and may differ across environments. When "
"committing or force-reloading a file, local edits to that "
"file/check-in combination are discarded.</li>");
CX("</ul>");
}
CX("</div>"/*#fileedit-tab-help*/);
| | | | < > > | 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 |
"is unspecified and may differ across environments. When "
"committing or force-reloading a file, local edits to that "
"file/check-in combination are discarded.</li>");
CX("</ul>");
}
CX("</div>"/*#fileedit-tab-help*/);
if(!builtin_bundle_all_fossil_js_apis()){
builtin_emit_fossil_js_apis("fetch", "dom", "tabs", "confirmer",
"storage", "popupwidget", 0);
}
/*
** 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 after window.fossil has been intialized and before
** fossil.page.fileedit.js. Potential TODO: move this into the
** window.fossil bootstrapping so that we don't have to "fulfill"
** the JS multiple times.
*/
ajax_emit_js_preview_modes(1);
builtin_request_js("sbsdiff.js");
builtin_request_js("fossil.page.fileedit.js");
builtin_fulfill_js_requests();
{
/* Dynamically populate the editor, display any error in the err
** blob, and/or switch to tab #0, where the file selector
** lives. The extra C scopes here correspond to JS-level scopes,
** to improve grokability. */
|
| ︙ | ︙ |
Changes to src/forum.c.
| ︙ | ︙ | |||
802 803 804 805 806 807 808 |
style_submenu_checkbox("unf", "Unformatted", 0, 0);
style_submenu_checkbox("hist", "History", 0, 0);
/* Display the thread. */
forum_display_thread(froot, fpid, mode, bUnf, bHist);
/* Emit Forum Javascript. */
| | | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 |
style_submenu_checkbox("unf", "Unformatted", 0, 0);
style_submenu_checkbox("hist", "History", 0, 0);
/* Display the thread. */
forum_display_thread(froot, fpid, mode, bUnf, bHist);
/* Emit Forum Javascript. */
builtin_emit_script_fossil_bootstrap(1);
builtin_request_js("forum.js");
builtin_request_js("fossil.dom.js");
builtin_request_js("fossil.page.forumpost.js");
/* Emit the page style. */
style_footer();
}
|
| ︙ | ︙ |
Changes to src/fossil.bootstrap.js.
1 2 3 4 5 6 7 8 9 |
"use strict";
(function () {
/* CustomEvent polyfill, courtesy of Mozilla:
https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
*/
if(typeof window.CustomEvent === "function") return false;
window.CustomEvent = function(event, params) {
if(!params) params = {bubbles: false, cancelable: false, detail: null};
const evt = document.createEvent('CustomEvent');
| | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
"use strict";
(function () {
/* CustomEvent polyfill, courtesy of Mozilla:
https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
*/
if(typeof window.CustomEvent === "function") return false;
window.CustomEvent = function(event, params) {
if(!params) params = {bubbles: false, cancelable: false, detail: null};
const evt = document.createEvent('CustomEvent');
evt.initCustomEvent( event, !!params.bubbles, !!params.cancelable, params.detail );
return evt;
};
})();
(function(global){
/* Bootstrapping bits for the global.fossil object. Must be loaded
after style.c:builtin_emit_script_fossil_bootstrap() has
initialized that object.
*/
const F = global.fossil;
/**
Returns the current time in something approximating
ISO-8601 format.
|
| ︙ | ︙ | |||
326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
Convenience wrapper which adds an onload event listener to the
window object. Returns this.
*/
F.onPageLoad = function(callback){
window.addEventListener('load', callback, false);
return this;
};
/**
Assuming name is a repo-style filename, this function returns
a shortened form of that name:
.../LastDirectoryPart/FilenamePart
| > > > > > > > > | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
Convenience wrapper which adds an onload event listener to the
window object. Returns this.
*/
F.onPageLoad = function(callback){
window.addEventListener('load', callback, false);
return this;
};
/**
Convenience wrapper which adds a DOMContentLoadedevent listener
to the window object. Returns this.
*/
F.onDOMContentLoaded = function(callback){
window.addEventListener('DOMContentLoaded', callback, false);
return this;
};
/**
Assuming name is a repo-style filename, this function returns
a shortened form of that name:
.../LastDirectoryPart/FilenamePart
|
| ︙ | ︙ |
Changes to src/fossil.numbered-lines.js.
1 2 3 4 5 6 7 8 9 10 |
(function callee(arg){
/*
JS counterpart of info.c:output_text_with_line_numbers()
which ties an event handler to the line numbers to allow
selection of individual lines or ranges.
Requires: fossil.bootstrap, fossil.dom, fossil.popupwidget,
fossil.copybutton
*/
var tbl = arg || document.querySelectorAll('table.numbered-lines');
| < | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
(function callee(arg){
/*
JS counterpart of info.c:output_text_with_line_numbers()
which ties an event handler to the line numbers to allow
selection of individual lines or ranges.
Requires: fossil.bootstrap, fossil.dom, fossil.popupwidget,
fossil.copybutton
*/
var tbl = arg || document.querySelectorAll('table.numbered-lines');
if(tbl && !arg){
if(tbl.length>1){ /* multiple query results: recurse */
tbl.forEach( (t)=>callee(t) );
return;
}else{/* single query result */
tbl = tbl[0];
}
}
if(!tbl) return /* no matching elements */;
const F = window.fossil, D = F.dom;
const tdLn = tbl.querySelector('td.line-numbers');
const lineState = {
urlArgs: (window.location.search||'?')
.replace(/&?\budc=[^&]*/,'') /* "update display prefs cookie" */
.replace(/&?\bln=[^&]*/,'') /* inbound line number/range */
.replace('?&','?'),
|
| ︙ | ︙ |
Changes to src/fossil.page.fileedit.js.
| ︙ | ︙ | |||
462 463 464 465 466 467 468 |
e:{/*DOM element(s)*/},
init: function(domInsertPoint/*insert widget BEFORE this element*/){
const wrapper = D.addClass(
D.attr(D.div(),'id','fileedit-stash-selector'),
'input-with-label'
);
const sel = this.e.select = D.select();
| | > > > > > > > > | | | < < < < < > > | 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
e:{/*DOM element(s)*/},
init: function(domInsertPoint/*insert widget BEFORE this element*/){
const wrapper = D.addClass(
D.attr(D.div(),'id','fileedit-stash-selector'),
'input-with-label'
);
const sel = this.e.select = D.select();
const btnClear = this.e.btnClear = D.button("Discard Edits"),
btnHelp = D.append(
D.addClass(D.div(), "help-buttonlet"),
'Locally-edited files. Timestamps are the last local edit time. ',
'Only the ',P.config.defaultMaxStashSize,' most recent files ',
'are retained. Saving or reloading a file removes it from this list. ',
D.append(D.code(),F.storage.storageImplName()),
' = ',F.storage.storageHelpDescription()
);
D.append(wrapper, "Local edits (",
D.append(D.code(),
F.storage.storageImplName()),
"):",
btnHelp, sel, btnClear);
F.helpButtonlets.setup(btnHelp);
D.option(D.disable(sel), "(empty)");
F.page.addEventListener('fileedit-stash-updated',(e)=>this.updateList(e.detail));
F.page.addEventListener('fileedit-file-loaded',(e)=>this.updateList($stash, e.detail));
sel.addEventListener('change',function(e){
const opt = this.selectedOptions[0];
if(opt && opt._finfo) P.loadFile(opt._finfo);
});
if(F.storage.isTransient()){/*Warn if our storage is particularly transient...*/
D.append(wrapper, D.append(
D.addClass(D.span(),'warning'),
"Warning: persistent storage is not available, "+
"so uncomitted edits will not survive a page reload."
));
}
domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint);
P.tabs.switchToTab(1/*DOM visibility workaround*/);
F.confirmer(btnClear, {
/* must come after insertion into the DOM for the pinSize option to work. */
pinSize: true,
confirmText: "DISCARD all local edits?",
onconfirm: function(e){
if(P.finfo){
const stashed = P.getStashedFinfo(P.finfo);
P.clearStash();
if(stashed) P.loadFile(/*reload after discarding edits*/);
}else{
P.clearStash();
}
},
ticks: F.config.confirmerButtonTicks
});
D.addClass(this.e.btnClear,'hidden' /* must not be set until after confirmer is set up!*/);
$stash._fireStashEvent(/*read the page-load-time stash*/);
P.tabs.switchToTab(0/*DOM visibility workaround*/);
delete this.init;
},
/**
Regenerates the edit selection list.
*/
updateList: function f(stasher,theFinfo){
if(!f.compare){
|
| ︙ | ︙ | |||
652 653 654 655 656 657 658 |
selectPreviewMode: E('#select-preview-mode select'),
selectHtmlEmsWrap: E('#select-preview-html-ems'),
selectEolWrap: E('#select-eol-style'),
selectEol: E('#select-eol-style select[name=eol]'),
selectFontSizeWrap: E('#select-font-size'),
selectDiffWS: E('select[name=diff_ws]'),
cbLineNumbersWrap: E('#cb-line-numbers'),
| | | 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
selectPreviewMode: E('#select-preview-mode select'),
selectHtmlEmsWrap: E('#select-preview-html-ems'),
selectEolWrap: E('#select-eol-style'),
selectEol: E('#select-eol-style select[name=eol]'),
selectFontSizeWrap: E('#select-font-size'),
selectDiffWS: E('select[name=diff_ws]'),
cbLineNumbersWrap: E('#cb-line-numbers'),
cbAutoPreview: E('#cb-preview-autorefresh'),
previewTarget: E('#fileedit-tab-preview-wrapper'),
manifestTarget: E('#fileedit-manifest'),
diffTarget: E('#fileedit-tab-diff-wrapper'),
cbIsExe: E('input[type=checkbox][name=exec_bit]'),
cbManifest: E('input[type=checkbox][name=include_manifest]'),
editStatus: E('#fileedit-edit-status'),
tabs:{
|
| ︙ | ︙ | |||
735 736 737 738 739 740 741 742 743 744 745 746 747 748 |
);
diffButtons.querySelector('button.unified').addEventListener(
"click",(e)=>P.diff(false), false
);
P.e.btnCommit.addEventListener(
"click",(e)=>P.commit(), false
);
F.confirmer(P.e.btnReload, {
pinSize: true,
confirmText: "Really reload, losing edits?",
onconfirm: (e)=>P.unstashContent().loadFile(),
ticks: F.config.confirmerButtonTicks
});
E('#comment-toggle').addEventListener(
| > | 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 |
);
diffButtons.querySelector('button.unified').addEventListener(
"click",(e)=>P.diff(false), false
);
P.e.btnCommit.addEventListener(
"click",(e)=>P.commit(), false
);
P.tabs.switchToTab(1/*DOM visibility workaround*/);
F.confirmer(P.e.btnReload, {
pinSize: true,
confirmText: "Really reload, losing edits?",
onconfirm: (e)=>P.unstashContent().loadFile(),
ticks: F.config.confirmerButtonTicks
});
E('#comment-toggle').addEventListener(
|
| ︙ | ︙ |
Changes to src/fossil.page.wikiedit.js.
1 2 3 4 5 6 |
(function(F/*the fossil object*/){
"use strict";
/**
Client-side implementation of the /wikiedit app. Requires that
the fossil JS bootstrapping is complete and that several fossil
JS APIs have been installed: fossil.fetch, fossil.dom,
| | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
(function(F/*the fossil object*/){
"use strict";
/**
Client-side implementation of the /wikiedit app. Requires that
the fossil JS bootstrapping is complete and that several fossil
JS APIs have been installed: fossil.fetch, fossil.dom,
fossil.tabs, fossil.storage, fossil.confirmer, fossil.popupwidget.
Custom events which can be listened for via
fossil.page.addEventListener():
- Event 'wiki-page-loaded': passes on information when it
loads a wiki (whether from the network or its internal local-edit
cache), in the form of an "winfo" object:
|
| ︙ | ︙ | |||
555 556 557 558 559 560 561 |
sel)
);
D.attr(sel, 'size', 12);
D.option(D.disable(D.clearElement(sel)), "Loading...");
/** Set up filter checkboxes for the various types
of wiki pages... */
| | | 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 |
sel)
);
D.attr(sel, 'size', 12);
D.option(D.disable(D.clearElement(sel)), "Loading...");
/** Set up filter checkboxes for the various types
of wiki pages... */
const fsFilter = D.addClass(D.fieldset("Page types"),"page-types-list"),
fsFilterBody = D.div(),
filters = ['normal', 'branch/...', 'tag/...', 'checkin/...']
;
D.append(fsFilter, fsFilterBody);
D.addClass(fsFilterBody, 'flex-container', 'flex-column', 'stretch');
// Add filters by page type...
|
| ︙ | ︙ | |||
595 596 597 598 599 600 601 |
lbl = D.attr(D.append(D.label(),
getEditMarker(getEditMarker.DELETED,false),
'deleted'),
'for', cbId),
cb = D.attr(D.input('checkbox'), 'id', cbId);
cb.checked = false;
D.addClass(parentElem,'hide-deleted');
| | > > | > | > > | 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 |
lbl = D.attr(D.append(D.label(),
getEditMarker(getEditMarker.DELETED,false),
'deleted'),
'for', cbId),
cb = D.attr(D.input('checkbox'), 'id', cbId);
cb.checked = false;
D.addClass(parentElem,'hide-deleted');
D.attr(lbl);
const deletedTip = F.helpButtonlets.create(
D.span(),
'Fossil considers empty pages to be "deleted" in some contexts.'
);
D.append(fsFilterBody, D.append(
D.span(), cb, lbl, deletedTip
));
cb.addEventListener(
'change',
function(ev){
if(ev.target.checked) D.removeClass(parentElem,'hide-deleted');
else D.addClass(parentElem,'hide-deleted');
},
false);
|
| ︙ | ︙ | |||
680 681 682 683 684 685 686 |
P.stashWidget = {
e:{/*DOM element(s)*/},
init: function(domInsertPoint/*insert widget BEFORE this element*/){
const wrapper = D.addClass(
D.attr(D.div(),'id','wikiedit-stash-selector'),
'input-with-label'
);
| | | > > > > > > > > | | < < < < | 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
P.stashWidget = {
e:{/*DOM element(s)*/},
init: function(domInsertPoint/*insert widget BEFORE this element*/){
const wrapper = D.addClass(
D.attr(D.div(),'id','wikiedit-stash-selector'),
'input-with-label'
);
const sel = this.e.select = D.select(),
btnClear = this.e.btnClear = D.button("Discard Edits"),
btnHelp = D.append(
D.addClass(D.div(), "help-buttonlet"),
'Locally-edited wiki pages. Timestamps are the last local edit time. ',
'Only the ',P.config.defaultMaxStashSize,' most recent pages ',
'are retained. Saving or reloading a file removes it from this list. ',
D.append(D.code(),F.storage.storageImplName()),
' = ',F.storage.storageHelpDescription()
);
D.append(wrapper, "Local edits (",
D.append(D.code(),
F.storage.storageImplName()),
"):",
btnHelp, sel, btnClear);
F.helpButtonlets.setup(btnHelp);
D.option(D.disable(sel), "(empty)");
P.addEventListener('wiki-stash-updated',(e)=>this.updateList(e.detail));
P.addEventListener('wiki-page-loaded',(e)=>this.updateList($stash, e.detail));
sel.addEventListener('change',function(e){
const opt = this.selectedOptions[0];
if(opt && opt._winfo) P.loadPage(opt._winfo);
});
|
| ︙ | ︙ | |||
833 834 835 836 837 838 839 |
document.body.classList.add('wikiedit');
P.base = {tag: E('base'), wikiUrl: F.repoUrl('wiki')};
P.base.originalHref = P.base.tag.href;
P.e = { /* various DOM elements we work with... */
taEditor: E('#wikiedit-content-editor'),
btnReload: E("#wikiedit-tab-content button.wikiedit-content-reload"),
btnSave: E("button.wikiedit-save"),
| | < < | | 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 |
document.body.classList.add('wikiedit');
P.base = {tag: E('base'), wikiUrl: F.repoUrl('wiki')};
P.base.originalHref = P.base.tag.href;
P.e = { /* various DOM elements we work with... */
taEditor: E('#wikiedit-content-editor'),
btnReload: E("#wikiedit-tab-content button.wikiedit-content-reload"),
btnSave: E("button.wikiedit-save"),
btnSaveClose: E("button.wikiedit-save-close"),
selectMimetype: E('select[name=mimetype]'),
selectFontSizeWrap: E('#select-font-size'),
// selectDiffWS: E('select[name=diff_ws]'),
cbAutoPreview: E('#cb-preview-autorefresh'),
previewTarget: E('#wikiedit-tab-preview-wrapper'),
diffTarget: E('#wikiedit-tab-diff-wrapper'),
editStatus: E('#wikiedit-edit-status'),
tabContainer: E('#wikiedit-tabs'),
tabs:{
pageList: E('#wikiedit-tab-pages'),
content: E('#wikiedit-tab-content'),
|
| ︙ | ︙ | |||
868 869 870 871 872 873 874 |
P.tabs.addEventListener(
/* Set up some before-switch-to tab event tasks... */
'before-switch-to', function(ev){
const theTab = ev.detail, btnSlot = theTab.querySelector('.save-button-slot');
if(btnSlot){
/* Several places make sense for a save button, so we'll
move that button around to those tabs where it makes sense. */
| | | | 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 |
P.tabs.addEventListener(
/* Set up some before-switch-to tab event tasks... */
'before-switch-to', function(ev){
const theTab = ev.detail, btnSlot = theTab.querySelector('.save-button-slot');
if(btnSlot){
/* Several places make sense for a save button, so we'll
move that button around to those tabs where it makes sense. */
btnSlot.parentNode.insertBefore( P.e.btnSave.parentNode, btnSlot );
btnSlot.parentNode.insertBefore( P.e.btnSaveClose.parentNode, btnSlot );
P.updateSaveButton();
}
if(theTab===P.e.tabs.preview){
P.baseHrefForWiki();
if(P.previewNeedsUpdate && P.e.cbAutoPreview.checked) P.preview();
}else if(theTab===P.e.tabs.diff){
/* Work around a weird bug where the page gets wider than
|
| ︙ | ︙ | |||
956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 |
delete P.winfo;
P.updatePageTitle();
F.message("Discarded new page ["+w.name+"].");
}
};
if(P.config.useConfirmerButtons.reload){
F.confirmer(P.e.btnReload, {
pinSize: true,
confirmText: "Really reload, losing edits?",
onconfirm: doReload,
ticks: F.config.confirmerButtonTicks
});
}else{
P.e.btnReload.addEventListener('click', doReload, false);
}
if(P.config.useConfirmerButtons.save){
F.confirmer(P.e.btnSave, {
pinSize: true,
confirmText: "Really save changes?",
onconfirm: ()=>doSave(),
ticks: F.config.confirmerButtonTicks
});
F.confirmer(P.e.btnSaveClose, {
| > > | 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 |
delete P.winfo;
P.updatePageTitle();
F.message("Discarded new page ["+w.name+"].");
}
};
if(P.config.useConfirmerButtons.reload){
P.tabs.switchToTab(1/*DOM visibility workaround*/);
F.confirmer(P.e.btnReload, {
pinSize: true,
confirmText: "Really reload, losing edits?",
onconfirm: doReload,
ticks: F.config.confirmerButtonTicks
});
}else{
P.e.btnReload.addEventListener('click', doReload, false);
}
if(P.config.useConfirmerButtons.save){
P.tabs.switchToTab(1/*DOM visibility workaround*/);
F.confirmer(P.e.btnSave, {
pinSize: true,
confirmText: "Really save changes?",
onconfirm: ()=>doSave(),
ticks: F.config.confirmerButtonTicks
});
F.confirmer(P.e.btnSaveClose, {
|
| ︙ | ︙ | |||
1067 1068 1069 1070 1071 1072 1073 |
if(!winfo.version && winfo.type!=='sandbox'){
F.message('You are editing a new, unsaved page:',winfo.name);
}
P.updatePageTitle().updateSaveButton(/* b/c save() routes through here */);
},
false
);
| | > > > > > > | 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 |
if(!winfo.version && winfo.type!=='sandbox'){
F.message('You are editing a new, unsaved page:',winfo.name);
}
P.updatePageTitle().updateSaveButton(/* b/c save() routes through here */);
},
false
);
/* These init()s need to come after P's event handlers are registered.
The tab-switching is a workaround for the pinSize option of the confirmer widgets:
it does not work if the confirmer button being initialized is in a hidden
part of the DOM :/. */
P.tabs.switchToTab(0);
WikiList.init( P.e.tabs.pageList.firstElementChild );
P.tabs.switchToTab(1);
P.stashWidget.init(P.e.tabs.content.lastElementChild);
P.tabs.switchToTab(0);
//P.$wikiList = WikiList/*only for testing/debugging*/;
}/*F.onPageLoad()*/);
/**
Returns true if fossil.page.winfo is set, indicating that a page
has been loaded, else it reports an error and returns false.
|
| ︙ | ︙ |
Changes to src/fossil.popupwidget.js.
| ︙ | ︙ | |||
262 263 264 265 266 267 268 269 |
displays for twice as long as a normal toast.
*/
error: function(/*...*/){
return toastImpl('error',2,arguments);
}
}/*F.toast*/;
})(window.fossil);
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
displays for twice as long as a normal toast.
*/
error: function(/*...*/){
return toastImpl('error',2,arguments);
}
}/*F.toast*/;
F.helpButtonlets = {
/**
Initializes one or more "help buttonlets". It may be passed any of:
- A string: CSS selector (multiple matches are legal)
- A single DOM element.
- A forEach-compatible container of DOM elements.
- No arguments, which is equivalent to passing the string
".help-buttonlet:not(.processed)".
Passing the same element(s) more than once is a no-op: during
initialization, each elements get the class'processed' added to
it, and any elements with that class are skipped.
All child nodes of a help buttonlet are removed from the button
during initialization and stashed away for use in a PopupWidget
when the botton is clicked.
*/
setup: function f(){
if(!f.hasOwnProperty('clickHandler')){
f.clickHandler = function fch(ev){
if(!fch.popup){
fch.popup = new F.PopupWidget({
cssClass: ['fossil-tooltip', 'help-buttonlet-content'],
refresh: function(){
}
});
fch.popup.e.style.maxWidth = '80%'/*of body*/;
const hide = ()=>fch.popup.hide();
fch.popup.e.addEventListener('click', hide, false);
document.body.addEventListener('click', hide, true);
document.body.addEventListener('keydown', function(ev){
if(fch.popup.isShown() && 27===ev.which){
fch.popup.hide();
}
}, true);
}
D.append(D.clearElement(fch.popup.e), ev.target.$helpContent);
var popupRect = ev.target.getClientRects()[0];
var x = popupRect.left, y = popupRect.top;
if(x<0) x = 0;
if(y<0) y = 0;
/* Shift the help around a bit to "better" fit the
screen. However, fch.popup.e.getClientRects() is empty
until the popup is shown, so we have to show it,
calculate the resulting size, then move and/or resize it.
This algorithm/these heuristics can certainly be improved
upon. Just be careful to mess only with the X coordinate
and the width. The browser will try to keep the widget
from being truncated off-screen on the right, shifting it
to the left if needed, and we cannot generically be sure
that an enforced fully on-screen size will actually fit
the current help text.
*/
fch.popup.show(x, y);
x = popupRect.left, y = popupRect.top;
popupRect = fch.popup.e.getBoundingClientRect();
const rectBody = document.body.getClientRects()[0];
if(popupRect.right > rectBody.right){
x -= (popupRect.right - rectBody.right);
}
if(x + popupRect.width > rectBody.right){
x = rectBody.x + (rectBody.width*0.1);
fch.popup.e.style.minWidth = '70%';
}else{
fch.popup.e.style.removeProperty('min-width');
x -= popupRect.width/2;
}
if(x<0) x = 0;
//console.debug("dimensions",x,y, popupRect, rectBody);
fch.popup.show(x, y);
};
f.foreachElement = function(e){
if(e.classList.contains('processed')) return;
e.classList.add('processed');
e.$helpContent = [];
/* We have to move all child nodes out of the way because we
cannot hide TEXT nodes via CSS (which cannot select TEXT
nodes). We have to do it in two steps to avoid invaliding
the list during traversal. */
e.childNodes.forEach((ch)=>e.$helpContent.push(ch));
e.$helpContent.forEach((ch)=>ch.remove());
e.addEventListener('click', f.clickHandler, false);
};
}/*static init*/
var elems;
if(!arguments.length){
arguments[0] = '.help-buttonlet:not(.processed)';
arguments.length = 1;
}
if(arguments.length){
if('string'===typeof arguments[0]){
elems = document.querySelectorAll(arguments[0]);
}else if(arguments[0] instanceof HTMLElement){
elems = [arguments[0]];
}else if(arguments[0].forEach){/* assume DOM element list or array */
elems = arguments[0];
}
}
if(elems) elems.forEach(f.foreachElement);
},
/**
Sets up the given element as a "help buttonlet", adding the CSS
class help-buttonlet to it. Any (optional) arguments after the
first are appended to the element using fossil.dom.append(), so
that they become the content for the buttonlet's popup help.
The element is then passed to this.setup() before it
is returned from this function.
*/
create: function(elem/*...body*/){
D.addClass(elem, 'help-buttonlet');
if(arguments.length>1){
const args = Array.prototype.slice.call(arguments,1);
D.append(elem, args);
}
this.setup(elem);
return elem;
}
}/*helpButtonlets*/;
F.onDOMContentLoaded( ()=>F.helpButtonlets.setup() );
})(window.fossil);
|
Changes to src/fossil.storage.js.
| ︙ | ︙ | |||
133 134 135 136 137 138 139 140 141 142 143 |
and sessionStorage are unavailable. */
isTransient: ()=>$storageHolder!==$storage,
/** Returns a symbolic name for the current storage mechanism. */
storageImplName: function(){
if($storage===window.localStorage) return 'localStorage';
else if($storage===window.sessionStorage) return 'sessionStorage';
else return 'transient';
}
};
})(window.fossil);
| > > > > > > > > > > > > > > > | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
and sessionStorage are unavailable. */
isTransient: ()=>$storageHolder!==$storage,
/** Returns a symbolic name for the current storage mechanism. */
storageImplName: function(){
if($storage===window.localStorage) return 'localStorage';
else if($storage===window.sessionStorage) return 'sessionStorage';
else return 'transient';
},
/**
Returns a brief help text string for the currently-selected
storage type.
*/
storageHelpDescription: function(){
return {
localStorage: "Browser-local persistent storage with an "+
"unspecified long-term lifetime (survives closing the browser, "+
"but maybe not a browser upgrade).",
sessionStorage: "Storage local to this browser tab, "+
"lost if this tab is closed.",
"transient": "Transient storage local to this invocation of this page."
}[this.storageImplName()];
}
};
})(window.fossil);
|
Changes to src/info.c.
| ︙ | ︙ | |||
2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 | ** the X part of a "language-X" CSS class on the generated CODE block. ** ** zLn is the ?ln= parameter for the HTTP query. If there is an argument, ** then highlight that line number and scroll to it once the page loads. ** If there are two line numbers, highlight the range of lines. ** Multiple ranges can be highlighed by adding additional line numbers ** separated by a non-digit character (also not one of [-,.]). */ void output_text_with_line_numbers( const char *z, int nZ, const char *zName, | > > > > > > > | > > | 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 |
** the X part of a "language-X" CSS class on the generated CODE block.
**
** zLn is the ?ln= parameter for the HTTP query. If there is an argument,
** then highlight that line number and scroll to it once the page loads.
** If there are two line numbers, highlight the range of lines.
** Multiple ranges can be highlighed by adding additional line numbers
** separated by a non-digit character (also not one of [-,.]).
**
** If includeJS is true then the JS code associated with line
** numbering is also emitted, else it is not. If this routine is
** called multiple times in a single app run, the JS is emitted only
** once. Note that when using this routine to emit Ajax responses, the
** JS should be not be included, as it will not get imported properly
** into the response's rendering.
*/
void output_text_with_line_numbers(
const char *z,
int nZ,
const char *zName,
const char *zLn,
int includeJS
){
int iStart, iEnd; /* Start and end of region to highlight */
int n = 0; /* Current line number */
int i = 0; /* Loop index */
int iTop = 0; /* Scroll so that this line is on top of screen. */
int nLine = 0; /* content line count */
int nSpans = 0; /* number of distinct zLn spans */
const char *zExt = file_extension(zName);
static int emittedJS = 0; /* emitted shared JS yet? */
Stmt q;
iStart = iEnd = atoi(zLn);
db_multi_exec(
"CREATE TEMP TABLE lnos(iStart INTEGER PRIMARY KEY, iEnd INTEGER)");
if( iStart>0 ){
do{
|
| ︙ | ︙ | |||
2113 2114 2115 2116 2117 2118 2119 |
if(zExt && *zExt){
cgi_printf("<code class='language-%h'>",zExt);
}else{
cgi_append_content("<code>", -1);
}
cgi_printf("%z", htmlize(z, nZ));
CX("</code></pre></td></tr></tbody></table>\n");
| > > | | | > | | > > | 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 |
if(zExt && *zExt){
cgi_printf("<code class='language-%h'>",zExt);
}else{
cgi_append_content("<code>", -1);
}
cgi_printf("%z", htmlize(z, nZ));
CX("</code></pre></td></tr></tbody></table>\n");
if(includeJS && !emittedJS){
emittedJS = 1;
if( db_int(0, "SELECT EXISTS(SELECT 1 FROM lnos)") ){
builtin_request_js("scroll.js");
}
if(!builtin_bundle_all_fossil_js_apis()){
builtin_emit_fossil_js_apis("dom", "copybutton", "popupwidget",
"numbered-lines", 0);
}
}
}
/*
** COMMAND: test-line-numbers
**
** Usage: %fossil test-line-numbers FILE ?LN-SPEC?
**
|
| ︙ | ︙ | |||
2142 2143 2144 2145 2146 2147 2148 |
}
db_find_and_open_repository(0,0);
zFilename = g.argv[2];
fossil_print("%s %s\n", zFilename, zLn);
blob_read_from_file(&content, zFilename, ExtFILE);
output_text_with_line_numbers(blob_str(&content), blob_size(&content),
| | | 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 |
}
db_find_and_open_repository(0,0);
zFilename = g.argv[2];
fossil_print("%s %s\n", zFilename, zLn);
blob_read_from_file(&content, zFilename, ExtFILE);
output_text_with_line_numbers(blob_str(&content), blob_size(&content),
zFilename, zLn, 0);
blob_reset(&content);
fossil_print("%b\n", cgi_output_blob());
}
/*
** WEBPAGE: artifact
** WEBPAGE: file
|
| ︙ | ︙ | |||
2454 2455 2456 2457 2458 2459 2460 |
"SELECT name FROM mlink, filename"
" WHERE filename.fnid=mlink.fnid"
" AND mlink.fid=%d",
rid);
zExt = zFileName ? file_extension(zFileName) : 0;
if( zLn ){
output_text_with_line_numbers(z, blob_size(&content),
| | | 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 |
"SELECT name FROM mlink, filename"
" WHERE filename.fnid=mlink.fnid"
" AND mlink.fid=%d",
rid);
zExt = zFileName ? file_extension(zFileName) : 0;
if( zLn ){
output_text_with_line_numbers(z, blob_size(&content),
zFileName, zLn, 1);
}else if( zExt && zExt[1] ){
@ <pre>
@ <code class="language-%s(zExt)">%h(z)</code>
@ </pre>
}else{
@ <pre>
@ %h(z)
|
| ︙ | ︙ |
Changes to src/style.c.
| ︙ | ︙ | |||
1228 1229 1230 1231 1232 1233 1234 | ** the optional value for the checkbox. zTip is an optional tooltip, ** which gets set as the "title" attribute of the outermost ** element. If isChecked is true, the checkbox gets the "checked" ** attribute set, else it is not. ** ** Resulting structure: ** | | | | | | 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 |
** the optional value for the checkbox. zTip is an optional tooltip,
** which gets set as the "title" attribute of the outermost
** element. If isChecked is true, the checkbox gets the "checked"
** attribute set, else it is not.
**
** Resulting structure:
**
** <div class='input-with-label' title={{zTip}} id={{zWrapperId}}>
** <input type='checkbox' name={{zFieldName}} value={{zValue}}
** id='A RANDOM VALUE'
** {{isChecked ? " checked : ""}}/>
** <label for='ID OF THE INPUT FIELD'>{{zLabel}}</label>
** </div>
**
** zLabel, and zValue are required. zFieldName, zWrapperId, and zTip
** are may be NULL or empty.
**
** Be sure that the input-with-label CSS class is defined sensibly, in
** particular, having its display:inline-block is useful for alignment
** purposes.
*/
void style_labeled_checkbox(const char * zWrapperId,
const char *zFieldName, const char * zLabel,
const char * zValue, int isChecked,
const char * zTip){
char * zLabelID = style_next_input_id();
CX("<div class='input-with-label'");
if(zTip && *zTip){
CX(" title='%h'", zTip);
}
if(zWrapperId && *zWrapperId){
CX(" id='%s'",zWrapperId);
}
CX("><input type='checkbox' id='%s' ", zLabelID);
if(zFieldName && *zFieldName){
CX("name='%s' ",zFieldName);
}
CX("value='%T'%s/>",
zValue ? zValue : "", isChecked ? " checked" : "");
CX("<label for='%s'>%h</label></div>", zLabelID, zLabel);
fossil_free(zLabelID);
}
/*
** Outputs a SELECT list from a compile-time list of integers.
** The vargs must be a list of (const char *, int) pairs, terminated
** with a single NULL. Each pair is interpreted as...
|
| ︙ | ︙ | |||
1294 1295 1296 1297 1298 1299 1300 | ** zLabel is an optional string to use as a "label" for the element ** (see below). ** ** zTooltip is an optional value for the SELECT's title attribute. ** ** The structure of the emitted HTML is: ** | | | | | 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 |
** zLabel is an optional string to use as a "label" for the element
** (see below).
**
** zTooltip is an optional value for the SELECT's title attribute.
**
** The structure of the emitted HTML is:
**
** <div class='input-with-label' title={{zToolTip}} id={{zWrapperId}}>
** <label for='SELECT ELEMENT ID'>{{zLabel}}</label>
** <select id='RANDOM ID' name={{zFieldName}}>...</select>
** </div>
**
** Example:
**
** style_select_list_int("my-grapes", "my_grapes", "Grapes",
** "Select the number of grapes",
** atoi(PD("my_field","0")),
** "", 1, "2", 2, "Three", 3,
** NULL);
**
*/
void style_select_list_int(const char * zWrapperId,
const char *zFieldName, const char * zLabel,
const char * zToolTip, int selectedVal,
... ){
char * zLabelID = style_next_input_id();
va_list vargs;
va_start(vargs,selectedVal);
CX("<div class='input-with-label'");
if(zToolTip && *zToolTip){
CX(" title='%h'",zToolTip);
}
if(zWrapperId && *zWrapperId){
CX(" id='%s'",zWrapperId);
}
CX(">");
|
| ︙ | ︙ | |||
1345 1346 1347 1348 1349 1350 1351 |
CX("%s", zOption);
}else{
CX("%d",v);
}
CX("</option>\n");
}
CX("</select>\n");
| | | 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 |
CX("%s", zOption);
}else{
CX("%d",v);
}
CX("</option>\n");
}
CX("</select>\n");
CX("</div>\n");
va_end(vargs);
fossil_free(zLabelID);
}
/*
** The C-string counterpart of style_select_list_int(), this variant
** differs only in that its variadic arguments are C-strings in pairs
|
| ︙ | ︙ | |||
1380 1381 1382 1383 1384 1385 1386 |
char * zLabelID = style_next_input_id();
va_list vargs;
va_start(vargs,zSelectedVal);
if(!zSelectedVal){
zSelectedVal = __FILE__/*some string we'll never match*/;
}
| | | 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 |
char * zLabelID = style_next_input_id();
va_list vargs;
va_start(vargs,zSelectedVal);
if(!zSelectedVal){
zSelectedVal = __FILE__/*some string we'll never match*/;
}
CX("<div class='input-with-label'");
if(zToolTip && *zToolTip){
CX(" title='%h'",zToolTip);
}
if(zWrapperId && *zWrapperId){
CX(" id='%s'",zWrapperId);
}
CX(">");
|
| ︙ | ︙ | |||
1409 1410 1411 1412 1413 1414 1415 |
CX("%s", zLabel);
}else{
CX("%h",zVal);
}
CX("</option>\n");
}
CX("</select>\n");
| | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 |
CX("%s", zLabel);
}else{
CX("%h",zVal);
}
CX("</option>\n");
}
CX("</select>\n");
CX("</div>\n");
va_end(vargs);
fossil_free(zLabelID);
}
/*
** 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
** or 1 as the first argument to this function: 0 comes before 1.
**
** If passed 0 as its first argument and a non-NULL/non-empty zSrc,
|
| ︙ | ︙ | |||
1528 1529 1530 1531 1532 1533 1534 |
}else{
CX("<script nonce='%s'>", style_nonce());
}
}else{
CX("</script>\n");
}
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1443 1444 1445 1446 1447 1448 1449 |
}else{
CX("<script nonce='%s'>", style_nonce());
}
}else{
CX("</script>\n");
}
}
|
Changes to src/style.fileedit.css.
| ︙ | ︙ | |||
218 219 220 221 222 223 224 225 |
white-space: nowrap;
}
body.fileedit #fileedit-edit-status span.links > *::before {
content: "[";
}
body.fileedit #fileedit-edit-status span.links > *::after {
content: "]";
}
| > > > > > > > > > | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
white-space: nowrap;
}
body.fileedit #fileedit-edit-status span.links > *::before {
content: "[";
}
body.fileedit #fileedit-edit-status span.links > *::after {
content: "]";
}
/* JS selection of line numbers cannot work in preview mode,
so disable the UI indications which imply that it does
something... */
body.fileedit table.numbered-lines td.line-numbers > span {
cursor: unset;
}
body.fileedit table.numbered-lines td.line-numbers > span:hover {
background-color: inherit;
}
|
Changes to src/style.wikiedit.css.
| ︙ | ︙ | |||
182 183 184 185 186 187 188 |
margin: 0.25em;
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: baseline;
}
body.wikiedit #wikiedit-stash-selector select {
| | > > > > > | | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
margin: 0.25em;
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: baseline;
}
body.wikiedit #wikiedit-stash-selector select {
margin: 0 1em 0 0.5em;
height: initial;
font-family: monospace;
flex: 10 1 auto;
}
body.wikiedit fieldset.page-types-list > div > span {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
}
|
Changes to src/wiki.c.
| ︙ | ︙ | |||
1160 1161 1162 1163 1164 1165 1166 |
{
CX("<div id='wikiedit-tab-content' "
"data-tab-parent='wikiedit-tabs' "
"data-tab-label='Editor' "
"class='hidden'"
">");
CX("<div class='flex-container flex-row child-gap-small'>");
| | | > | | > | | > > > > > > | > > | | > > | | 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 |
{
CX("<div id='wikiedit-tab-content' "
"data-tab-parent='wikiedit-tabs' "
"data-tab-label='Editor' "
"class='hidden'"
">");
CX("<div class='flex-container flex-row child-gap-small'>");
CX("<div class='input-with-label'>"
"<label>Mime type</label>");
mimetype_option_menu(0);
CX("</div>");
style_select_list_int("select-font-size",
"editor_font_size", "Editor font size",
NULL/*tooltip*/,
100,
"100%", 100, "125%", 125,
"150%", 150, "175%", 175,
"200%", 200, NULL);
CX("<div class='input-with-label'>"
"<button class='wikiedit-save'>"
"Save</button>"
"</div>" /*will get moved around dynamically*/);
CX("<div class='input-with-label'>"
"<button class='wikiedit-save-close'>"
"Save & Close</button>"
"<div class='help-buttonlet'>"
"Save edits to this page and returns to the wiki page viewer."
"</div>"
"</div>" /*will get moved around dynamically*/);
CX("<span class='save-button-slot'></span>");
CX("<div class='input-with-label'>"
"<button class='wikiedit-content-reload' "
">Discard & Reload</button>"
"<div class='help-buttonlet'>"
"Reload the file from the server, discarding "
"any local edits. To help avoid accidental loss of "
"edits, it requires confirmation (a second click) within "
"a few seconds or it will not reload."
"</div>"
"</div>");
CX("</div>");
CX("<div class='flex-container flex-column stretch'>");
CX("<textarea name='content' id='wikiedit-content-editor' "
"class='wikiedit' rows='25'>");
CX("</textarea>");
CX("</div>"/*textarea wrapper*/);
CX("</div>"/*#tab-file-content*/);
|
| ︙ | ︙ | |||
1211 1212 1213 1214 1215 1216 1217 |
** the text editor with their own. */
"data-f-preview-via='_postPreview' "
/* ^^^ fossil.page[methodName](content, callback) */
"data-f-preview-to='#wikiedit-tab-preview-wrapper' "
/* ^^^ dest elem ID */
">Refresh</button>");
/* Toggle auto-update of preview when the Preview tab is selected. */
| > > | < | < > | | > > | 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 |
** the text editor with their own. */
"data-f-preview-via='_postPreview' "
/* ^^^ fossil.page[methodName](content, callback) */
"data-f-preview-to='#wikiedit-tab-preview-wrapper' "
/* ^^^ dest elem ID */
">Refresh</button>");
/* Toggle auto-update of preview when the Preview tab is selected. */
CX("<div class='input-with-label'>"
"<input type='checkbox' value='1' "
"id='cb-preview-autorefresh' checked>"
"<label for='cb-preview-autorefresh'>Auto-refresh?</label>"
"<div class='help-buttonlet'>"
"If on, the preview will automatically "
"refresh (if needed) when this tab is selected."
"</div>"
"</div>");
CX("<span class='save-button-slot'></span>");
CX("</div>"/*.wikiedit-options*/);
CX("<div id='wikiedit-tab-preview-wrapper'></div>");
CX("</div>"/*#wikiedit-tab-preview*/);
}
/****** Diff tab ******/
|
| ︙ | ︙ | |||
1268 1269 1270 1271 1272 1273 1274 1275 |
"the repo with endless test runs. Any attempt to save the "
"sandbox page will fail.</p>");
CX("<h2>Wiki Name Rules</h2>");
well_formed_wiki_name_rules();
CX("</div>"/*#wikiedit-tab-save*/);
}
builtin_request_js("sbsdiff.js");
| > > > > < | | 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 |
"the repo with endless test runs. Any attempt to save the "
"sandbox page will fail.</p>");
CX("<h2>Wiki Name Rules</h2>");
well_formed_wiki_name_rules();
CX("</div>"/*#wikiedit-tab-save*/);
}
if(!builtin_bundle_all_fossil_js_apis()){
builtin_emit_fossil_js_apis("fetch", "dom", "tabs", "confirmer",
"storage", "popupwidget", 0);
}
builtin_request_js("sbsdiff.js");
builtin_request_js("fossil.page.wikiedit.js");
builtin_fulfill_js_requests();
/* Dynamically populate the editor... */
style_emit_script_tag(0,0);
{
/* Render the current page list to save us an XHR request
during page initialization. This must be OUTSIDE of
an onPageLoad() handler or else it does not get applied
|
| ︙ | ︙ |