@@ -10,6 +10,11 @@ let $tbConvertedTime = $('#tb-convertedtime');
1010
1111const PROCESSING = 'processing ...' ;
1212
13+ const ORIGINAL_CSS = 0 ;
14+ const SMALL_CSS = 1 ;
15+
16+ let cssFlag = ORIGINAL_CSS ;
17+
1318function selectFile ( )
1419{
1520 $uploadResult . text ( '' ) ;
@@ -54,6 +59,42 @@ function generateResult(msg)
5459 $tbConvertedTime . text ( json . ConvertedTime ) ;
5560}
5661
62+ function loadCSSFile ( fileName ) {
63+ var fileRef = document . createElement ( 'link' )
64+ fileRef . setAttribute ( 'rel' , 'stylesheet' )
65+ fileRef . setAttribute ( 'type' , 'text/css' )
66+ fileRef . setAttribute ( 'href' , fileName )
67+ document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( fileRef ) ;
68+ }
69+
70+ function removeCSSFile ( fileName ) {
71+ var allItems = document . getElementsByTagName ( 'link' ) ;
72+ for ( var i = 0 ; i < allItems . length ; i ++ ) {
73+ var item = allItems [ i ] ;
74+ if ( ! item ) continue ;
75+ var attribute = item . getAttribute ( 'href' ) ;
76+ if ( ! attribute ) continue ;
77+ if ( attribute . indexOf ( fileName ) == - 1 ) continue ;
78+
79+ item . parentNode . removeChild ( allItems [ i ] ) ;
80+ }
81+ }
82+
83+ function toggleCSS ( )
84+ {
85+ if ( cssFlag == SMALL_CSS ) {
86+ removeCSSFile ( 'web/style_small.css' ) ;
87+ loadCSSFile ( 'web/style_ori.css' ) ;
88+ cssFlag = ORIGINAL_CSS ;
89+ } else {
90+ removeCSSFile ( 'web/style_ori.css' ) ;
91+ loadCSSFile ( 'web/style_small.css' ) ;
92+ cssFlag = SMALL_CSS ;
93+ }
94+
95+ return ;
96+ }
97+
5798function uploadFile ( )
5899{
59100 if ( $inputName [ 0 ] . files . length == 0 ) {
@@ -94,4 +135,4 @@ function uploadFile()
94135 generateResult ( message ) ;
95136 }
96137 } ) ;
97- }
138+ }
0 commit comments