Skip to content

Commit 9f5c826

Browse files
authored
1.8.0
1.8.0
2 parents f4a3ec2 + d55d1d4 commit 9f5c826

17 files changed

+6941
-357
lines changed

about.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<h1 align="center">
2+
<a href="https://codeit.codes"><img src="/icons/app-favicon.png" height="100" width="100"></a>
3+
<br>
4+
Codeit
5+
</h1>
6+
<p align="center">
7+
<h3 align="center">
8+
Mobile code editor connected to Git
9+
</h3>
10+
</p>
11+
12+
<p align="center">
13+
<a href="https://codeit.codes"><img src="/icons/social/tryit.svg" width="32" height="26"></a>
14+
<a href="https://discord.gg/47RFy3Vfmg"><img src="/icons/social/discordapp.svg" width="26" height="26"></a>
15+
<a href="https://twitter.com/codeitcodes"><img src="/icons/social/twitter.svg" width="36" height="26"></a>
16+
</p>
17+
18+
<h2>Features</h2>
19+
<ul>
20+
<li>Uses blazing-fast web APIs. <a href="#details">More technical details below.</a></li>
21+
<li>Framework-free. Only library is PrismJS, for syntax highlighting.</li>
22+
<li>PWA support. Weighs 70% less than regular apps, can be installed and works offline.</li>
23+
<li>Autosaving down to the character helps you pick up right where you left off. Code, scroll and caret positions, and location in your repos.</li>
24+
<li>Supports 275 lanugages. Most common languages are preloaded by default, with uncommon languages loaded dynamically.</li>
25+
<li>Codeit is built for Chrome on Android, Windows, macOS and Linux, as well as Safari on iOS.</li>
26+
</ul>
27+
28+
<h2 id="details">Technical details</h2>
29+
30+
<h3>The Codeit Editor</h3>
31+
32+
The editor utilizes:
33+
34+
<ul>
35+
36+
<li>The <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contenteditable"><code>contenteditable</code> API</a>, to enable editing the actual highlighted HTML. Compare this to other code editors, such as Visual Studio Code, Atom, or CodeMirror, which use an invisible overlaid textarea on top of the highlighted HTML, and constantly synchronize the textarea and DOM. Codeit's approach might be more preformant, as no synchronizing between textarea and DOM is required.</li>
37+
38+
<li>The <a href="https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver"><code>MutationObserver</code> API</a>, to quickly detect changes in the DOM without an event listener. Changes from JavaScript will be detected automatically by the editor, without the need to run an <code>update</code> function.</li>
39+
40+
<li>The <a href="https://developer.mozilla.org/en-US/docs/Web/API/Range"><code>Range</code> API</a>, for optimized parsing of the DOM. Using the <code>contenteditable</code> API could have included a caveat, as by default, the browser reparses the entire DOM after every change. However, using the Range API has been proven succesful to optimize DOM parsing by directing the browser to parse only what has actually changed.</li>
41+
42+
</ul>
43+
44+
The editor is <a href="/lib">fully standalone</a>, and is a library by itself. It includes multiple custom <a href="/lib">plugins</a> and <a href="https://github.com/PrismJS/prism/tree/master/themes">themes</a>.
45+
46+
<h3>Security</h3>
47+
48+
When you log in to Git, Codeit recives an authuntication token from your Git hosting provider.
49+
This token is saved on your device and is used to read and commit code.
50+
51+
When you edit a file, Codeit saves a local copy of the file on your device.
52+
When you commit an edited file, it's local copy is deleted.
53+
54+
<h3>Privacy</h3>
55+
56+
We don't use cookies and don't collect any personal data.
57+
58+
To install Codeit, we ask for the bare minimum. If cookies are disabled, your browser will block Codeit from installing a Service Worker, which is absolutely necessary for the app to function. For this reason, we ask you enable cookies on the Codeit site.
59+
60+
<h2>Special Thanks</h2>
61+
Codeit's logo was created by <a href="https://twitter.com/sandorqi">@sandorqi</a>.

bottomfloat.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function updateFloat() {
88
saveSidebarStateLS();
99

1010
// show bottom floater
11-
bottomFloat.classList.remove('hidden');
11+
bottomWrapper.classList.remove('hidden');
1212

1313
// if selected file is modified, show flag
1414
if (modifiedFiles[selectedFile.sha] &&
@@ -30,17 +30,22 @@ function updateFloat() {
3030

3131
// open sidebar when clicked on button
3232
sidebarOpen.addEventListener('click', () => {
33+
34+
// if bottom float isn't expanded
35+
if (liveView.children.length == 0) {
36+
37+
toggleSidebar(true);
38+
saveSidebarStateLS();
3339

34-
toggleSidebar(true);
35-
saveSidebarStateLS();
40+
let selectedEl = fileWrapper.querySelector('.item.selected');
3641

37-
let selectedEl = fileWrapper.querySelector('.item.selected');
42+
if (selectedEl) {
3843

39-
if (selectedEl) {
40-
41-
// scroll to selected file
42-
selectedEl.scrollIntoViewIfNeeded();
44+
// scroll to selected file
45+
selectedEl.scrollIntoViewIfNeeded();
4346

47+
}
48+
4449
}
4550

4651
})
@@ -99,13 +104,13 @@ if (isMobile) {
99104
if (st > lastScrollTop) {
100105

101106
// hide bottom float
102-
bottomFloat.classList.add('hidden');
107+
bottomWrapper.classList.add('hidden');
103108

104109
// if scrolled to bottom of codeit
105110
if ((st + cd.offsetHeight) >= cd.scrollHeight) {
106111

107112
// show bottom float
108-
bottomFloat.classList.remove('hidden');
113+
bottomWrapper.classList.remove('hidden');
109114

110115
}
111116

@@ -115,7 +120,7 @@ if (isMobile) {
115120
if ((lastScrollTop - st) > 20) {
116121

117122
// show bottom float
118-
bottomFloat.classList.remove('hidden');
123+
bottomWrapper.classList.remove('hidden');
119124

120125
}
121126

codedrop.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,21 @@ function getFileLang(src) {
1515

1616
src = src.replaceAll('\n', '');
1717

18-
var extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1];
18+
const extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1];
1919
return EXTENSIONS[extension] || extension;
2020

2121
}
2222

23+
function splitFileName(src) {
24+
25+
src = src.replaceAll('\n', '');
26+
27+
const extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1];
28+
return [src.replace(('.' + extension), ''), '.' + extension];
29+
30+
}
31+
32+
2333
function processFile(file) {
2434

2535
const reader = new FileReader();

file.js

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -104,34 +104,45 @@ function updateModFileScrollPos(sha, scrollPos) {
104104
// store the updated file under old sha as key
105105
// and store the updated file under new sha as key
106106
// in modifiedFiles object for 1 minute after commit
107-
function onFileEclipsedInCache(oldSha, newSha) {
107+
function onFileEclipsedInCache(oldSha, newSha, newFile) {
108108

109109
// if file element under old sha exists in HTML,
110110
// update it to the new sha
111111
const fileEl = fileWrapper.querySelector('.file[sha="' + oldSha + '"]');
112112
if (fileEl) setAttr(fileEl, 'sha', newSha);
113113

114114

115-
// store the updated file under old sha as key
115+
let fileToUpdate;
116116

117-
// find the eclipsed file
118-
let fileToUpdate = modifiedFiles[oldSha];
117+
// if old sha exists
118+
if (oldSha) {
119119

120-
fileToUpdate.sha = newSha;
121-
fileToUpdate.caretPos = [0, 0];
122-
fileToUpdate.eclipsed = true;
123-
124-
// if file to update is selected
125-
if (selectedFile.sha === oldSha) {
120+
// store the updated file under old sha as key
121+
122+
// find the eclipsed file
123+
fileToUpdate = modifiedFiles[oldSha];
124+
125+
fileToUpdate.sha = newSha;
126+
fileToUpdate.caretPos = [0, 0];
127+
fileToUpdate.eclipsed = true;
128+
129+
// if file to update is selected
130+
if (selectedFile.sha === oldSha) {
131+
132+
// update its content
133+
// to the selected file contents
134+
updateModFileContent(oldSha, selectedFile.content);
135+
136+
// update selected file sha to the new sha
137+
selectedFile.sha = newSha;
138+
139+
updateSelectedFileLS();
140+
141+
}
126142

127-
// update its content
128-
// to the selected file contents
129-
updateModFileContent(oldSha, selectedFile.content);
143+
} else {
130144

131-
// update selected file sha to the new sha
132-
selectedFile.sha = newSha;
133-
134-
updateSelectedFileLS();
145+
fileToUpdate = newFile;
135146

136147
}
137148

@@ -147,9 +158,14 @@ function onFileEclipsedInCache(oldSha, newSha) {
147158
// set 1 minute timeout to remove updated files
148159
window.setTimeout(() => {
149160

150-
// remove the updated file under old sha as key
151-
// from modifiedFiles
152-
deleteModFile(oldSha);
161+
// if old sha exists
162+
if (oldSha) {
163+
164+
// remove the updated file under old sha as key
165+
// from modifiedFiles
166+
deleteModFile(oldSha);
167+
168+
}
153169

154170
// if not edited updated file under new sha as key
155171
// while in timeout (file is still eclipsed)
@@ -170,14 +186,22 @@ function setTimeoutForEclipsedFiles() {
170186

171187
const eclipsedFiles = Object.values(modifiedFiles).filter(file => file.eclipsed);
172188

189+
// run on all eclipsed files
173190
eclipsedFiles.forEach(file => {
174191

175-
// set 1 minute timeout to remove updated files
192+
// set 1 minute timeout to remove eclipsed file
176193
window.setTimeout(() => {
177194

178-
// remove the updated file under old sha as key
179-
// from modifiedFiles
180-
deleteModFile(file.sha);
195+
// if not edited eclipsed file
196+
// while in timeout (file is still eclipsed)
197+
if (modifiedFiles[file.sha] &&
198+
modifiedFiles[file.sha].eclipsed) {
199+
200+
// remove the eclipsed file
201+
// from modifiedFiles
202+
deleteModFile(file.sha);
203+
204+
}
181205

182206
}, 65 * 1000); // 65s
183207

@@ -199,6 +223,9 @@ function getLatestVersion(item) {
199223

200224
function followTrail(crumb) {
201225

226+
if(typeof(modifiedFiles[crumb]) == 'undefined') //@@
227+
return null;
228+
202229
// if version sha matches its key
203230
// (it dosen't point to another version)
204231
if (modifiedFiles[crumb].sha === crumb) {
@@ -210,7 +237,14 @@ function getLatestVersion(item) {
210237

211238
// version sha points to another version,
212239
// follow the trail
213-
return followTrail(modifiedFiles[crumb].sha);
240+
let ret = followTrail(modifiedFiles[crumb].sha);
241+
242+
if(ret == null){
243+
// No file with this sha was found in modifiedFiles, return the file with latest bread crumb: //@@
244+
return modifiedFiles[crumb];
245+
}else{
246+
return ret;
247+
}
214248

215249
}
216250

0 commit comments

Comments
 (0)