Skip to content

Commit

Permalink
✅Now able to close recently opened files
Browse files Browse the repository at this point in the history
✅fixed error of files not being read
  • Loading branch information
John4650-hub committed Sep 17, 2023
1 parent 6cb3f33 commit f023486
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.TK }}
with:
tag_name: ${{ github.run_number }}
release_name: ${{ github.event.repository.name }} v5.0.3 #release
release_name: ${{ github.event.repository.name }} v5.0.4 #release

- name: upload Release Apk
id: upload_release_assets
Expand Down
2 changes: 1 addition & 1 deletion clean.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#rm -r www/js
rm -r www/js
rm main.py sample.txt
6 changes: 5 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

P1="www/js/components/tabs/changeLog.js"
P2=".github/workflows/build.yml"
P3="sample.txt"
def read_file(path):
'''
return file content
Expand All @@ -15,7 +16,8 @@ def write_file(path,new_content):
write content to file
'''
with open(path,'w',encoding='utf-8') as file_handle:
return file_handle.write(new_content)
file_handle.write(new_content)
file_handle.close()


content = read_file(P1)
Expand All @@ -39,3 +41,5 @@ def write_file(path,new_content):
pos2 = content_2.find(' #release')
newUpdate = content_2.replace(content_2[pos2-6:pos2],version)
write_file(P2,newUpdate)

write_file(P3,INFO)
5 changes: 2 additions & 3 deletions routines.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
python main.py
txt=$(cat sample.txt)
git add .
git commit -m "
Added file path to recently opened files incase both of the file have the same names.
Fix: Removed repeated addition of already open file to recently opened file."
git commit -m "$txt"
git push

39 changes: 2 additions & 37 deletions sample.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,2 @@
,{version:'v5.0.1 (lts)',info: 'just trying to do some clean up
'}let log = [{
version: 'v5.0.0 (latest)',
info: `Added tab for recently edited files
implemented saving of setting
`
}, {
version: 'v 4.0.7',
info: `Added new paste in textarea,
support for new language,
Added about section`
}
]

export default function changeLogTab(_par) {
let parentElm = document.querySelector(_par);
let listGroup = makeElm('div')
insertAttr(['class=container'], listGroup)
let listElm = makeElm('ul')
insertAttr(['class=list-group'], listElm)
parentElm.appendChild(listElm)
let version, listItem,title,inform;
for (let i = 0; i < log.length; i++)
{
version = makeElm('li');
title = makeElm('h2')
version.appendChild(title)
title.innerText = log[i].version
inform = makeElm('p')
inform.innerText=log[i].info
insertAttr(['class=list-group-item'],version)
version.appendChild(inform)
listElm.appendChild(version)
parentElm.appendChild(version);
}

}
✅Now able to close recently opened files
✅fixed error of files not being read
8 changes: 4 additions & 4 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ <h5 class="offcanvas-title text-white" id="fileSystemCanvasLabel">FILE SYSTEM</h
</div>
</div>
<!--Recent opened files-->
<div class="offcanvas offcanvas-top bg-light" id="recentlyOpened" aria-labelledby="recentFiles">
<div class="offcanvas-header">
<div class="offcanvas offcanvas-top bg-dark rounded-bottom h-50 text-light" id="recentlyOpened" aria-labelledby="recentFiles">
<div class="offcanvas-header h-25">
<h5 id="recentFiles">Recent files</h5>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
<button type="button" class="btn btn-dark text-reset" data-bs-dismiss="offcanvas" aria-label="Close"><i class="fa fa-window-close text-danger"></i></button>
</div>
<div class="offcanvas-body">
<ul class="list-group list-group-flush mh-50 bg-transparent" id="recent_file"></ul>
<ul class="containerlist-group list-group-flush mh-50 bg-transparent" id="recent_file"></ul>

</div>
</div>
Expand Down
42 changes: 31 additions & 11 deletions www/js/components/main_FileEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,33 +109,53 @@ export async function onDeviceReady() {

}, () => { console.log('failed to save file'); });
}
let recents = []

function addRecentlyOpenedFile(name, url, ext) {
let openedFile = makeElm('li')
let fPath = makeElm('p')
insertAttr(['class=fs-6 fw-light fst-italic'], fPath)
insertAttr(['class=fs-6 fw-light fst-italic mb-0'], fPath)
fPath.innerText = url
openedFile.appendChild(fPath)
insertAttr(['class=list-group-item bg-transparent border-bottom border-dark'], openedFile)
let row = makeElm('div')
insertAttr(['class=row border-bottom border-white',`id=${url}`],row)
insertAttr(['class=col-10 list-group-item bg-transparent border-0 h-25'], openedFile)
let closeBtn = makeElm('button')
closeBtn.innerHTML = '<i class="fa fa-minus-circle text-danger"></i>'

insertAttr(['class=btn btn-dark col-2 fs-2 h-25 align-middle','type=button',`id=${url}row`], closeBtn)
closeBtn.addEventListener('click', function() {
let rid = this.getAttribute('id')
let ridlen = rid.length
let i_d = rid.slice(0,ridlen-3)
let recentElmId= recents.indexOf(i_d)
let myRow = document.getElementById(i_d)
myRow.remove()
this.remove()
recents.splice(recentElmId,1)
})
openedFile.innerText = name
openedFile.addEventListener('click', function() {
workWithFile(url)
window.aceEditor.session.setMode(`ace/mode/${ext}`)
})

let recents = document.querySelectorAll('#recent_file li p')
let foundMatch = false
for (let i = 0; i < recents.length; i++) {
if (recents[i].innerText == url) {
foundMatch=true
if (recents[i] == url) {
console.log('match')
foundMatch = true
break
} else {
foundMatch=false
foundMatch = false
}
}
if (foundMatch==false){
recentFilesTab.appendChild(openedFile)
}
if (foundMatch == false) {
recentFilesTab.appendChild(row)

row.appendChild(openedFile)
row.appendChild(closeBtn)
openedFile.appendChild(fPath)
recents.push(url)
}
}
}, () => { console.log('failed to load file system'); });
}
2 changes: 2 additions & 0 deletions www/js/components/tabs/changeLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ let log = [{
✅Added Comments
`},{version:'v5.0.2',info: `✅Just fixed recent files
`},{version:'v5.0.3',info: `✅Bug fix
`},{version:'v5.0.4',info: `✅Now able to close recently opened files
✅fixed error of files not being read
`}
]

Expand Down
2 changes: 1 addition & 1 deletion www/libs/bootstrap-treeview.min.js

Large diffs are not rendered by default.

0 comments on commit f023486

Please sign in to comment.