Skip to content

Commit 89951f2

Browse files
committed
Extension: add installed text on the first run if necessary.
1 parent caa9709 commit 89951f2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

js/app.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,19 @@ $('.stars').each(function(idx, element){
699699
}
700700
});
701701

702+
function setInstalledText() {
703+
var button = $('#extension-button');
704+
if(button && button.hasClass('is-installed')) {
705+
button.find('.button-text').text('Already installed');
706+
}
707+
}
708+
709+
setInstalledText();
710+
// The is-installed class is added by the extension. It is unspecified when
711+
// this is done. So check again in a second or so.
712+
setTimeout(setInstalledText, 1000);
713+
714+
// chrome.webstore.install can only be called from standard event handlers.
702715
document.getElementById('extension-button').addEventListener('click', function(event) {
703716
var button = $(event.target);
704717
if(button.hasClass('is-installed')) {
@@ -743,9 +756,13 @@ document.getElementById('extension-button').addEventListener('click', function(e
743756
openInWindow();
744757
});
745758
} catch(e) {
759+
button.removeClass('is-installed');
760+
button.find('.button-text').text('Add to chrome');
746761
openInWindow();
747762
}
748763
} else {
764+
button.removeClass('is-installed');
765+
button.find('.button-text').text('Add to chrome');
749766
openInWindow();
750767
}
751768
});

0 commit comments

Comments
 (0)