diff --git a/content/modal.html b/content/modal.html index d1c1802..0195e7f 100644 --- a/content/modal.html +++ b/content/modal.html @@ -1,6 +1,7 @@ \ No newline at end of file + diff --git a/src/gas-api.js b/src/gas-api.js index 3a279e7..d53c694 100644 --- a/src/gas-api.js +++ b/src/gas-api.js @@ -11,7 +11,7 @@ function pull(code) { } const name = match[1]; const type = match[2]; - + if (!code.gas[file]) { return () => gasCreateFile(name, type) .then(() => { @@ -20,7 +20,8 @@ function pull(code) { } else { return () => gasUpdateFile(name, code.github[file]); } - }); + }) + .filter(n => n != undefined); const delete_promises = changed.filter(f => !code.github[f]) .map((file) => { @@ -37,7 +38,7 @@ function pull(code) { showAlert("Nothing to do", LEVEL_WARN); return; } - + getGasContext() .then(() => { return Promise.all(update_promises.map(f => f())) @@ -206,4 +207,4 @@ function gasDeleteFile(file) { reject(new Error('Update file failed')); }); }); -} \ No newline at end of file +} diff --git a/src/gas-hub.js b/src/gas-hub.js index 3d14579..661e255 100644 --- a/src/gas-hub.js +++ b/src/gas-hub.js @@ -7,7 +7,7 @@ const LEVEL_WARN = "info"; const LEVEL_INFO = "promo"; const observer = new MutationObserver((e) => { observer.disconnect(); - $('.github-alert').remove(); + $('.github-alert').remove(); }); $(() => { @@ -80,14 +80,14 @@ function initLoginContent() { $('#login').hover(() => { $('#login').addClass('goog-toolbar-menu-button-hover'); }, () => { - $('#login').removeClass('goog-toolbar-menu-button-hover'); + $('#login').removeClass('goog-toolbar-menu-button-hover'); }); $('#login').click(() => { if (chrome.runtime.openOptionsPage) { chrome.runtime.openOptionsPage(); } else { window.open(chrome.runtime.getURL('options/options.html')); - } + } }); chrome.runtime.sendMessage({ cmd: "tab" }); }); @@ -99,7 +99,7 @@ function initPageEvent() { ['repo', 'branch'].forEach((type) => { const container = $(`.${type}-menu`); const button = $(`#${type}Select`); - if (!container.is(event.target) + if (!container.is(event.target) && !button.is(event.target) && container.has(event.target).length === 0 && button.has(event.target).length == 0) { @@ -203,8 +203,8 @@ function initPageEvent() { break; default: return; - } - context[type] = content; + } + context[type] = content; const bindName = `bind${type.capitalize()}`; Object.assign(context[bindName], { [context.id] : content }); chrome.storage.sync.set({ [bindName]: context[bindName] }, () => { @@ -265,6 +265,10 @@ function showDiff(code, type) { return gasFiles.indexOf(e) < 0; }) .concat(gasFiles) + .filter((file) => { + const match = file.match(/(.*?)\.(gs|html)$/); + return match && match[1] && match[2]; + }) .reduce((diff, file) => { let mode = null; if (!oldCode[file]) { @@ -279,7 +283,7 @@ function showDiff(code, type) { if (mode) { diffArr.splice(1, 0, mode); } - fileDiff = diffArr.join('\n'); + fileDiff = diffArr.join('\n'); return diff + fileDiff; }, ""); @@ -331,7 +335,7 @@ function showDiff(code, type) { function updateRepo(repos) { $('.repo-menu').empty().append('
Create new repo
'); $('.repo-menu').append('
Using Gist
'); - + repos.forEach((repo) => { let content = `
${repo.name}
` $('.repo-menu').append(content); @@ -442,4 +446,4 @@ function showAlert(message, level=LEVEL_INFO) { String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); -} \ No newline at end of file +}