Added github contributors to options page

This commit is contained in:
sghsri
2020-08-23 23:11:01 -05:00
parent b2d46c186e
commit 908241fd67
6 changed files with 362 additions and 232 deletions

View File

@@ -1,37 +1,55 @@
var manifestData = chrome.runtime.getManifest();
$("#version").text(manifestData.version);
chrome.storage.sync.get('options', function(data){
if(data.options){
console.log(data.options);
Object.keys(data.options).forEach(key => {
let enabled = data.options[key];
$('#options_container').append(Template.Options.options_row(key, enabled));
});
}
chrome.storage.sync.get("options", function (data) {
if (data.options) {
console.log(data.options);
Object.keys(data.options).forEach(key => {
let enabled = data.options[key];
$("#options_container").append(Template.Options.options_row(key, enabled));
});
}
});
$("body").on("click","button",function(){
let key = $(this).attr('id');
let old_status = $(this).val() === 'true';
let new_status = !old_status;
chrome.runtime.sendMessage({
command: "setOptionsValue",
key: key,
value: new_status
}, function (response) {
console.log(response.value);
toggle(key, response.value)
updateAllTabsCourseList();
});
$("body").on("click", "button", function () {
let key = $(this).attr("id");
let old_status = $(this).val() === "true";
let new_status = !old_status;
chrome.runtime.sendMessage(
{
command: "setOptionsValue",
key: key,
value: new_status,
},
function (response) {
console.log(response.value);
toggle(key, response.value);
updateAllTabsCourseList();
}
);
});
$.get("https://api.github.com/repos/sghsri/UT-Registration-Plus/stats/contributors", data => {
data = data.sort((a, b) => b.total - a.total);
console.log("data", data);
for (var contributorData of data) {
$.get(`https://api.github.com/users/${contributorData.author.login}`, userData => {
let fullData = { ...contributorData, ...userData };
let { login, avatar_url, html_url, name } = fullData;
$("#contributor-list").append(Template.Options.contributor_card(login, name, avatar_url, html_url));
});
}
});
$("body").on("click", ".contributor-card", function () {
console.log("hello world");
window.open($(this).data("url"), "_blank");
});
function toggle(key, value) {
let button_text = value ? "Turn Off": "Turn On";
let button_color = value ? Colors.closed : Colors.open ;
$(`#${key}`).text(button_text);
$(`#${key}`).css("background", button_color);
$(`#${key}`).val(value);
let button_text = value ? "Turn Off" : "Turn On";
let button_color = value ? Colors.closed : Colors.open;
$(`#${key}`).text(button_text);
$(`#${key}`).css("background", button_color);
$(`#${key}`).val(value);
}