2
2
var mainContent = document . querySelector ( '#mainContent' ) ;
3
3
4
4
//Get data from the syncStorage
5
- chrome . storage . sync . get ( [ "language" , "theCode" , "theme" , "fontPt" ] , function ( localStorage ) {
6
- mainContent . language = localStorage . language || '--' ;
7
- mainContent . code = localStorage . theCode || '' ;
8
- mainContent . theme = localStorage . theme || 'light' ;
9
- mainContent . fontPt = localStorage . fontPt || 14 ;
10
-
11
-
12
- } ) ;
13
- mainContent . addEventListener ( 'template-bound' , function ( ) {
14
-
5
+ chrome . storage . sync . get (
6
+ [ 'language' , 'theCode' , 'theme' , 'fontPt' ] ,
7
+ function ( localStorage ) {
8
+ mainContent . language = localStorage . language || '--' ;
9
+ mainContent . code = localStorage . theCode || '' ;
10
+ mainContent . theme = localStorage . theme || 'light' ;
11
+ mainContent . fontPt = localStorage . fontPt || 14 ;
12
+ } ) ;
13
+ mainContent . addEventListener ( 'template-bound' , function ( ) {
15
14
//Set the font-size
16
15
mainContent . ptChange ( ) ;
17
16
18
17
//Now that the template is bound update the code in the textArea
19
- mainContent . $ . taCode . value = mainContent . code ;
20
- mainContent . $ . agTa . update ( mainContent . $ . taCode ) ; //Update the autoGrowArea;
18
+ // mainContent.$.codeValue = mainContent.code;
19
+ // mainContent.$.agTa.update(mainContent.$.taCode); //Update the autoGrowArea;
21
20
22
21
//Add a change listener to the textArea
23
22
mainContent . $ . taCode . addEventListener ( 'input' , function ( ) {
@@ -30,18 +29,18 @@ mainContent.addEventListener('template-bound', function(){
30
29
} ) ;
31
30
32
31
//Find the label of the selected language to set it on the paper-dropdown-menu
33
- var mnItems = document . querySelectorAll ( 'paper-item' ) ;
34
- [ ] . some . call ( mnItems , function ( mnItem ) {
35
- if ( mnItem . dataset . value == mainContent . language ) {
32
+ var mnItems = document . querySelectorAll ( 'paper-item' ) ;
33
+ [ ] . some . call ( mnItems , function ( mnItem ) {
34
+ if ( mnItem . dataset . value == mainContent . language ) {
36
35
//Item found, update the selectedItem to change the label
37
- mainContent . $ . pdmLanguage . selectedItemLabel = mnItem . innerText ;
36
+ mainContent . $ . pdmLanguage . selectedItemLabel = mnItem . innerText ;
38
37
return true ;
39
38
}
40
39
return false ;
41
40
} ) ;
42
41
43
42
//Select the theme on the slider
44
- mainContent . $ . ptbTheme . checked = ( mainContent . theme == 'dark' ) ;
43
+ mainContent . $ . ptbTheme . checked = ( mainContent . theme == 'dark' ) ;
45
44
46
45
//Set the theme and lang on all the components
47
46
setThemeAndLang ( ) ;
@@ -50,7 +49,7 @@ mainContent.addEventListener('template-bound', function(){
50
49
mainContent . validateForSlides ( ) ;
51
50
} ) ;
52
51
53
- var setThemeAndLang = function ( ) {
52
+ var setThemeAndLang = function ( ) {
54
53
//Change the classes on the prettyprint element accordingly
55
54
document . body . className = 'theme-' + mainContent . theme ;
56
55
@@ -62,12 +61,12 @@ var setThemeAndLang = function(){
62
61
/*if (mainContent.lang != '--') {
63
62
mainContent.$.destination.className += ' lang-' + mainContent.lang;
64
63
}*/
65
- }
64
+ } ;
66
65
67
- mainContent . languageSelected = function ( selMenu ) {
66
+ mainContent . languageSelected = function ( selMenu ) {
68
67
//Changed selected language, update the value and store
69
- if ( selMenu . detail . isSelected ) {
70
- mainContent . language = selMenu . detail . item . dataset . value ;
68
+ if ( selMenu . detail . isSelected ) {
69
+ mainContent . language = selMenu . detail . item . dataset . value ;
71
70
chrome . storage . sync . set ( { 'language' : mainContent . language } , function ( ) {
72
71
//Nothing to do
73
72
} ) ;
@@ -76,13 +75,13 @@ mainContent.languageSelected = function(selMenu){
76
75
setThemeAndLang ( ) ;
77
76
}
78
77
79
- }
78
+ } ;
80
79
81
- mainContent . chTheme = function ( ) {
80
+ mainContent . chTheme = function ( ) {
82
81
//if checked theme is dark, otherwise light
83
- if ( mainContent . $ . ptbTheme . checked ) {
82
+ if ( mainContent . $ . ptbTheme . checked ) {
84
83
mainContent . theme = 'dark' ;
85
- } else {
84
+ } else {
86
85
mainContent . theme = 'light' ;
87
86
}
88
87
chrome . storage . sync . set ( { 'theme' : mainContent . theme } , function ( ) {
@@ -92,13 +91,13 @@ mainContent.chTheme = function(){
92
91
//Set the theme and lang
93
92
setThemeAndLang ( ) ;
94
93
95
- }
94
+ } ;
96
95
97
- var ptToPx = function ( valPt ) {
98
- return ( 16 / 12 ) * valPt ; //return the font-size in px from the ptValue
99
- }
96
+ var ptToPx = function ( valPt ) {
97
+ return ( 16 / 12 ) * valPt ; //return the font-size in px from the ptValue
98
+ } ;
100
99
101
- mainContent . ptChange = function ( ) {
100
+ mainContent . ptChange = function ( ) {
102
101
//TODO:Validate the value before saving it and using it to calculate the px value
103
102
104
103
chrome . storage . sync . set ( { 'fontPt' : mainContent . fontPt } , function ( ) {
@@ -116,9 +115,9 @@ mainContent.ptChange = function(){
116
115
var preElement = mainContent . $ . destination . shadowRoot . querySelector ( 'pre' ) ;
117
116
preElement . style . fontSize = fontPx ;
118
117
119
- }
118
+ } ;
120
119
121
- mainContent . selPrettyCode = function ( sender ) {
120
+ mainContent . selPrettyCode = function ( sender ) {
122
121
//Get the pre element inside the prettyfy-element
123
122
var preElement = sender . currentTarget . shadowRoot . querySelector ( 'pre' ) ;
124
123
@@ -130,30 +129,30 @@ mainContent.selPrettyCode = function(sender){
130
129
selection . removeAllRanges ( ) ;
131
130
selection . addRange ( range ) ;
132
131
133
- }
132
+ } ;
134
133
135
- mainContent . validateForSlides = function ( ) {
136
- var divW = document . querySelector ( " #slidesWarnings" ) ;
134
+ mainContent . validateForSlides = function ( ) {
135
+ var divW = document . querySelector ( ' #slidesWarnings' ) ;
137
136
var warn = [ ] ;
138
137
139
138
var MAX_LINES = 20 ;
140
139
if ( ( mainContent . code . match ( / \n / g) || [ ] ) . length >= MAX_LINES ) {
141
- warn . push ( 'More than ' + MAX_LINES + ' lines of code will be hard to read on a slide.' ) ;
140
+ warn . push ( 'More than ' + MAX_LINES +
141
+ ' lines of code will be hard to read on a slide.' ) ;
142
142
}
143
143
144
144
var lines = mainContent . code . split ( '\n' ) || [ ] ;
145
145
var MAX_LINE_LENGTH = 80 ;
146
146
for ( var i = 0 ; i < lines . length ; i ++ ) {
147
147
if ( lines [ i ] . length > MAX_LINE_LENGTH ) {
148
- warn . push ( 'Line ' + ( i + 1 ) + ' has more than ' + MAX_LINE_LENGTH + ' characters!' ) ;
148
+ warn . push ( 'Line ' + ( i + 1 ) + ' has more than ' +
149
+ MAX_LINE_LENGTH + ' characters!' ) ;
149
150
}
150
151
}
151
- if ( warn . length > 0 ) {
152
+ if ( warn . length > 0 ) {
152
153
divW . innerHTML = warn . join ( '<br>' ) ;
153
- } else {
154
- divW . innerHTML = 'Perfect code for slides' ;
154
+ } else {
155
+ divW . innerHTML = 'Perfect code for slides' ;
155
156
}
156
- }
157
-
158
-
157
+ } ;
159
158
0 commit comments