Skip to content

Commit

Permalink
Cleanup and some bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
probablykasper committed Nov 2, 2017
1 parent 563df77 commit 3ef33f1
Show file tree
Hide file tree
Showing 12 changed files with 486 additions and 107 deletions.
4 changes: 1 addition & 3 deletions chrome-extension/extension/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<title>Taskler</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="todo.css">
<!-- chrome extension-->
</head>
<body>
<div class="chrome-extension">
Expand All @@ -30,7 +29,7 @@
<path d="M0 0h24v24H0z" fill="none"></path>
<path d="M12,3.3V0L7.6,4.4L12,8.7V5.5c3.6,0,6.5,2.9,6.5,6.5c0,1.1-0.3,2.1-0.8,3.1l1.6,1.6c0.9-1.3,1.4-2.9,1.4-4.6 C20.7,7.2,16.8,3.3,12,3.3z M12,18.5c-3.6,0-6.5-2.9-6.5-6.5c0-1.1,0.3-2.1,0.8-3.1L4.6,7.4C3.8,8.7,3.3,10.3,3.3,12 c0,4.8,3.9,8.7,8.7,8.7V24l4.4-4.4L12,15.3V18.5z"></path>
</svg>
<div class="tooltip">Sync your tasks</div>
<div class="tooltip">Sync your tasks (Beta)</div>
</div>
<div class="bg"></div>
<div class="container">
Expand All @@ -47,7 +46,6 @@ <h2>How to get your personal access token</h2>
<button tabindex="-1" class="save-personal-access-token">SAVE</button>
</div>
</div>
<script src="tinygql.min.js"></script>
<script src="todo.js"></script>
</body>
</html>
1 change: 0 additions & 1 deletion chrome-extension/extension/tinygql.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion chrome-extension/extension/todo.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 24 additions & 14 deletions chrome-extension/extension/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,6 @@ window.xhr = function(req, options) {
};
}

function savePersonalAccessToken(paToken) {
localStorage.setItem("personalAccessToken", paToken);
personalAccessToken = paToken;
gist = null;
localStorage.removeItem("gist");
reloadTasks();
}
function updateGistId(id) {
localStorage.setItem("gistId", id);
gistId = id;
Expand Down Expand Up @@ -311,7 +304,7 @@ function save(saveGist = true) {
}
}

(function sync() {
(function syncDialog() {
var svg = document.querySelector(".sync svg");
var dialog = document.querySelector(".sync-dialog");
var personalAccessTokenInput = dialog.querySelector("input.personal-access-token");
Expand All @@ -322,24 +315,41 @@ function save(saveGist = true) {
var saveButton = dialog.querySelector("button.save-personal-access-token");
saveButton.addEventListener("click", function() {
console.log("saving access token");
savePersonalAccessToken(personalAccessTokenInput.value);
dialog.classList.remove("visible");
// save personal access token
personalAccessToken = personalAccessTokenInput.value;
localStorage.setItem("personalAccessToken", personalAccessToken);
gistId = null;
gistDate = null;
localStorage.removeItem("gistId");
localStorage.removeItem("gistDate");
dialog.classList.add("saving");
reloadTasks(function() {
dialog.classList.remove("saving");
dialog.classList.remove("visible");
});
});
})();

reloadTasks();
function reloadTasks() {
function reloadTasks(callback) {
if (personalAccessToken) {
if (gistId) {
findGist(personalAccessToken, gistId, gistFound);
findGist(personalAccessToken, gistId, function(content, updatedAt) {
gistFound(content, updatedAt);
if (callback) callback();
});
} else {
findGistId(personalAccessToken, function(id) {
if (id) {
findGist(personalAccessToken, id, gistFound);
findGist(personalAccessToken, id, function(content, updatedAt) {
gistFound(content, updatedAt);
if (callback) callback();
});
} else {
createGist(personalAccessToken, function(id, updatedAt) {
updateGistId(id);
updateGistDate(id, updatedAt);
if (callback) callback();
});
}
});
Expand Down Expand Up @@ -383,7 +393,6 @@ function findGist(paToken, gistId, callback) {
});
}

// fc395703130a46c1ed7f9fe323adf8a85aa0743d
function createGist(paToken, callback) {
var req = {
description: "Gist that enables syncing Taskler tasks",
Expand Down Expand Up @@ -425,6 +434,7 @@ function findGistId(paToken, callback) {
for (var i = 0; i < gists.length; i++) {
if (gists[i].files[getFilename(paToken)]) {
callback(gists[i].id);
return;
}
}
callback(false);
Expand Down
Loading

0 comments on commit 3ef33f1

Please sign in to comment.