Skip to content

Commit

Permalink
未选中及无可下载提示
Browse files Browse the repository at this point in the history
  • Loading branch information
YanhuiJessica committed Mar 22, 2022
1 parent 71f48fa commit 2badddc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
5 changes: 4 additions & 1 deletion popup/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div id="download">
<div id="non-course" style="display: block;">
未选中课程页面
</div>
<div id="download" style="display: none;">
<table>
<thead>
<tr>
Expand Down
28 changes: 18 additions & 10 deletions popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@ function onError(error) {
console.log(`Error: ${error}`);
}

var uploads;
var uploads,
nonCourse = document.getElementById('non-course'),
divDl = document.getElementById('download');
window.addEventListener('load', function() {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {from: 'popup', subject: 'getUploads'},
function(response) {
uploads = response.uploads;
nonCourse.style.display = 'none';
divDl.style.display = 'block';
if (uploads.length === 0) {
divDl.innerHTML = '当前课程没有可下载的课件';
} else {
var tb = document.getElementById('uploads');
if (tb.innerHTML.length == 0) {
for (let u in uploads) {
var tr = document.createElement('tr');
tr.innerHTML = `
<td><input type="radio" name="courseware" value="${u}" /></td>
<td>${uploads[u].name}</td>
<td></td>
`;
tb.appendChild(tr);
if (tb.innerHTML.length == 0) {
for (let u in uploads) {
var tr = document.createElement('tr');
tr.innerHTML = `
<td><input type="radio" name="courseware" value="${u}" /></td>
<td>${uploads[u].name}</td>
<td></td>
`;
tb.appendChild(tr);
}
}
}
});
Expand Down

0 comments on commit 2badddc

Please sign in to comment.