Fossil SCM

cosmetic internal tweaks.

stephan 2020-05-06 05:21 fileedit-ajaxify
Commit bb71f9ecd2f064ba2707b05067ae0b2da5b911961325a5844cf48596c1530c0c
--- src/fossil.bootstrap.js
+++ src/fossil.bootstrap.js
@@ -79,19 +79,22 @@
7979
If the 2nd argument is an array, each encoded element is appended
8080
to that array and tgtArray is returned. The above object would be
8181
appended as ['a','=','1','&','b','=','2']. This form is used for
8282
building up parameter lists before join('')ing the array to create
8383
the result string.
84
+
85
+ If passed a truthy 3rd argument, it does not really encode each
86
+ component - it simply concatenates them together.
8487
*/
85
- F.encodeUrlArgs = function(obj,tgtArray){
88
+ F.encodeUrlArgs = function(obj,tgtArray,fakeEncode){
8689
if(!obj) return '';
87
- const a = (tgtArray instanceof Array) ? tgtArray : [];
90
+ const a = (tgtArray instanceof Array) ? tgtArray : [],
91
+ enc = fakeEncode ? (x)=>x : encodeURIComponent;
8892
let k, i = 0;
8993
for( k in obj ){
9094
if(i++) a.push('&');
91
- a.push(encodeURIComponent(k),
92
- '=',encodeURIComponent(obj[k]));
95
+ a.push(enc(k),'=',enc(obj[k]));
9396
}
9497
return a===tgtArray ? a : a.join('');
9598
};
9699
/**
97100
repoUrl( repoRelativePath [,urlParams] )
98101
--- src/fossil.bootstrap.js
+++ src/fossil.bootstrap.js
@@ -79,19 +79,22 @@
79 If the 2nd argument is an array, each encoded element is appended
80 to that array and tgtArray is returned. The above object would be
81 appended as ['a','=','1','&','b','=','2']. This form is used for
82 building up parameter lists before join('')ing the array to create
83 the result string.
 
 
 
84 */
85 F.encodeUrlArgs = function(obj,tgtArray){
86 if(!obj) return '';
87 const a = (tgtArray instanceof Array) ? tgtArray : [];
 
88 let k, i = 0;
89 for( k in obj ){
90 if(i++) a.push('&');
91 a.push(encodeURIComponent(k),
92 '=',encodeURIComponent(obj[k]));
93 }
94 return a===tgtArray ? a : a.join('');
95 };
96 /**
97 repoUrl( repoRelativePath [,urlParams] )
98
--- src/fossil.bootstrap.js
+++ src/fossil.bootstrap.js
@@ -79,19 +79,22 @@
79 If the 2nd argument is an array, each encoded element is appended
80 to that array and tgtArray is returned. The above object would be
81 appended as ['a','=','1','&','b','=','2']. This form is used for
82 building up parameter lists before join('')ing the array to create
83 the result string.
84
85 If passed a truthy 3rd argument, it does not really encode each
86 component - it simply concatenates them together.
87 */
88 F.encodeUrlArgs = function(obj,tgtArray,fakeEncode){
89 if(!obj) return '';
90 const a = (tgtArray instanceof Array) ? tgtArray : [],
91 enc = fakeEncode ? (x)=>x : encodeURIComponent;
92 let k, i = 0;
93 for( k in obj ){
94 if(i++) a.push('&');
95 a.push(enc(k),'=',enc(obj[k]));
 
96 }
97 return a===tgtArray ? a : a.join('');
98 };
99 /**
100 repoUrl( repoRelativePath [,urlParams] )
101
--- src/fossil.page.fileedit.js
+++ src/fossil.page.fileedit.js
@@ -126,11 +126,11 @@
126126
E('#r-link').setAttribute(
127127
'href',
128128
F.repoUrl('info/'+rev)
129129
);
130130
E('#r-label').innerText = rev;
131
- const purlArgs = F.encodeUrlArgs({file, r:rShort});
131
+ const purlArgs = F.encodeUrlArgs({file, r:rShort},false,true);
132132
const purl = F.repoUrl('fileedit',purlArgs);
133133
const e = E('#permalink');
134134
e.innerText='fileedit?'+purlArgs;
135135
e.setAttribute('href',purl);
136136
return this;
@@ -180,12 +180,14 @@
180180
target = this.e.tabs.preview.querySelector(
181181
'#fileedit-tab-preview-wrapper'
182182
),
183183
self = this;
184184
const updateView = function(c){
185
- if(c) target.innerHTML = c;
186
- else D.clearElement(target);
185
+ D.clearElement(target);
186
+ if('string'===typeof c){
187
+ target.innerHTML = c;
188
+ }
187189
F.message('Updated preview.');
188190
if(switchToTab) self.tabs.switchToTab(self.e.tabs.preview);
189191
};
190192
if(!content){
191193
updateView('');
192194
--- src/fossil.page.fileedit.js
+++ src/fossil.page.fileedit.js
@@ -126,11 +126,11 @@
126 E('#r-link').setAttribute(
127 'href',
128 F.repoUrl('info/'+rev)
129 );
130 E('#r-label').innerText = rev;
131 const purlArgs = F.encodeUrlArgs({file, r:rShort});
132 const purl = F.repoUrl('fileedit',purlArgs);
133 const e = E('#permalink');
134 e.innerText='fileedit?'+purlArgs;
135 e.setAttribute('href',purl);
136 return this;
@@ -180,12 +180,14 @@
180 target = this.e.tabs.preview.querySelector(
181 '#fileedit-tab-preview-wrapper'
182 ),
183 self = this;
184 const updateView = function(c){
185 if(c) target.innerHTML = c;
186 else D.clearElement(target);
 
 
187 F.message('Updated preview.');
188 if(switchToTab) self.tabs.switchToTab(self.e.tabs.preview);
189 };
190 if(!content){
191 updateView('');
192
--- src/fossil.page.fileedit.js
+++ src/fossil.page.fileedit.js
@@ -126,11 +126,11 @@
126 E('#r-link').setAttribute(
127 'href',
128 F.repoUrl('info/'+rev)
129 );
130 E('#r-label').innerText = rev;
131 const purlArgs = F.encodeUrlArgs({file, r:rShort},false,true);
132 const purl = F.repoUrl('fileedit',purlArgs);
133 const e = E('#permalink');
134 e.innerText='fileedit?'+purlArgs;
135 e.setAttribute('href',purl);
136 return this;
@@ -180,12 +180,14 @@
180 target = this.e.tabs.preview.querySelector(
181 '#fileedit-tab-preview-wrapper'
182 ),
183 self = this;
184 const updateView = function(c){
185 D.clearElement(target);
186 if('string'===typeof c){
187 target.innerHTML = c;
188 }
189 F.message('Updated preview.');
190 if(switchToTab) self.tabs.switchToTab(self.e.tabs.preview);
191 };
192 if(!content){
193 updateView('');
194

Keyboard Shortcuts

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