Skip to content

Commit 2badddc

Browse files
committed
未选中及无可下载提示
1 parent 71f48fa commit 2badddc

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

popup/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css">
88
</head>
99
<body>
10-
<div id="download">
10+
<div id="non-course" style="display: block;">
11+
未选中课程页面
12+
</div>
13+
<div id="download" style="display: none;">
1114
<table>
1215
<thead>
1316
<tr>

popup/popup.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,30 @@ function onError(error) {
22
console.log(`Error: ${error}`);
33
}
44

5-
var uploads;
5+
var uploads,
6+
nonCourse = document.getElementById('non-course'),
7+
divDl = document.getElementById('download');
68
window.addEventListener('load', function() {
79
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
810
chrome.tabs.sendMessage(tabs[0].id, {from: 'popup', subject: 'getUploads'},
911
function(response) {
1012
uploads = response.uploads;
13+
nonCourse.style.display = 'none';
14+
divDl.style.display = 'block';
15+
if (uploads.length === 0) {
16+
divDl.innerHTML = '当前课程没有可下载的课件';
17+
} else {
1118
var tb = document.getElementById('uploads');
12-
if (tb.innerHTML.length == 0) {
13-
for (let u in uploads) {
14-
var tr = document.createElement('tr');
15-
tr.innerHTML = `
16-
<td><input type="radio" name="courseware" value="${u}" /></td>
17-
<td>${uploads[u].name}</td>
18-
<td></td>
19-
`;
20-
tb.appendChild(tr);
19+
if (tb.innerHTML.length == 0) {
20+
for (let u in uploads) {
21+
var tr = document.createElement('tr');
22+
tr.innerHTML = `
23+
<td><input type="radio" name="courseware" value="${u}" /></td>
24+
<td>${uploads[u].name}</td>
25+
<td></td>
26+
`;
27+
tb.appendChild(tr);
28+
}
2129
}
2230
}
2331
});

0 commit comments

Comments
 (0)