1
1
/*
2
- * uget-chrome-wrapper is an extension to integrate uGet Download manager
3
- * with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
4
- *
5
- * Copyright (C) 2016 Gobinath
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- */
2
+ * uget-chrome-wrapper is an extension to integrate uGet Download manager
3
+ * with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
4
+ *
5
+ * Copyright (C) 2016 Gobinath
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
20
21
21
function saveChanges ( ) {
22
- var keywords = document . getElementById ( "keywords" ) . value ;
23
- var interrupt = document . getElementById ( 'chk-interrupt' ) . checked ;
22
+ var keywords = document . getElementById ( "keywords" ) . value ;
23
+ var interrupt = document . getElementById ( 'chk-interrupt' ) . checked ;
24
24
25
- localStorage [ "uget-keywords" ] = keywords ;
25
+ localStorage [ "uget-keywords" ] = keywords ;
26
26
27
- chrome . runtime . getBackgroundPage ( function ( backgroundPage ) {
28
- backgroundPage . updateKeywords ( keywords ) ;
29
- backgroundPage . setInterruptDownload ( interrupt , true ) ;
30
- } ) ;
27
+ chrome . runtime . getBackgroundPage ( function ( backgroundPage ) {
28
+ backgroundPage . updateKeywords ( keywords ) ;
29
+ backgroundPage . setInterruptDownload ( interrupt , true ) ;
30
+ } ) ;
31
31
32
- window . close ( ) ;
33
- }
34
-
35
- function updateInfo ( info ) {
36
- document . getElementById ( 'info' ) . innerHTML = info ;
32
+ window . close ( ) ;
37
33
}
38
34
39
35
// When the popup HTML has loaded
40
36
window . addEventListener ( 'load' , function ( evt ) {
41
- chrome . runtime . getBackgroundPage ( function ( backgroundPage ) {
42
- // alert('hi');
43
- document . getElementById ( 'info' ) . innerHTML = backgroundPage . getInfo ( ) ;
44
- } ) ;
37
+ // Show the system status
38
+ chrome . runtime . getBackgroundPage ( function ( backgroundPage ) {
39
+ var message = backgroundPage . getInfo ( ) . replace ( / < [ ^ > ] * > ? / g, '' ) ;
40
+ var label = 'error' ;
41
+ if ( message . toLowerCase ( ) . startsWith ( "info" ) ) {
42
+ label = 'info' ;
43
+ } else if ( message . toLowerCase ( ) . startsWith ( "warn" ) ) {
44
+ label = 'warn' ;
45
+ }
46
+ document . getElementById ( label ) . innerHTML = message ;
47
+ } ) ;
45
48
46
49
var interrupt = ( localStorage [ "uget-interrupt" ] == "true" ) ;
47
- document . getElementById ( 'save' ) . addEventListener ( 'click' , saveChanges ) ;
48
- document . getElementById ( 'keywords' ) . value = localStorage [ "uget-keywords" ] ;
49
- document . getElementById ( 'chk-interrupt' ) . checked = interrupt ;
50
- } ) ;
50
+ document . getElementById ( 'save' ) . addEventListener ( 'click' , saveChanges ) ;
51
+ document . getElementById ( 'keywords' ) . value = localStorage [ "uget-keywords" ] ;
52
+ document . getElementById ( 'chk-interrupt' ) . checked = interrupt ;
53
+ } ) ;
0 commit comments