Skip to content

Commit

Permalink
Merge pull request #5 from c3ho/issue-1
Browse files Browse the repository at this point in the history
Added hotkey to save and wrote a save function
  • Loading branch information
evlnyng committed Sep 24, 2019
2 parents 5da855e + 0b5f90d commit 56b52cf
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion index.html
Expand Up @@ -56,9 +56,47 @@ <h1 id ="title" style="color: black;" contenteditable></h1>
<div id="summary" contenteditable></div>
</div>
<script src="https://unpkg.com/filer/dist/filer.min.js"></script>
<script src="https://unpkg.com/hotkeys-js/dist/hotkeys.min.js"></script>
<script>
const fs = new Filer.FileSystem();

//ctrl+q to save current window
hotkeys('ctrl+q', function(){
save();
alert('Save key pressed!');
})

//save function to be used as part of save hotkey
var save = function(){
fs.writeFile('/title', document.querySelector('#title').innerHTML, function(err) {
if(err) {
console.log(err);
throw err;
}
});

fs.writeFile('/main', document.querySelector('#main').innerHTML, function(err) {
if(err) {
console.log(err);
throw err;
}
});

fs.writeFile('/cues', document.querySelector('#cues').innerHTML, function(err) {
if(err) {
console.log(err);
throw err;
}
});

fs.writeFile('/summary', document.querySelector('#summary').innerHTML, function(err) {
if(err) {
console.log(err);
throw err;
}
});
alert('Document saved!')
}
window.addEventListener('DOMContentLoaded', (event) => {
fs.readFile('/title', 'utf8', (err, data) => {
if(err) {
Expand Down Expand Up @@ -126,7 +164,6 @@ <h1 id ="title" style="color: black;" contenteditable></h1>
});
}, 1000);


</script>
</body>
</html>

0 comments on commit 56b52cf

Please sign in to comment.