@@ -30,26 +30,30 @@ $(window).on('load', function() {
30
30
* Handles click event on </> buttons for code conversion
31
31
*/
32
32
$ ( '.detected__app-convert' ) . click ( function ( e ) {
33
+ trackButton ( e ) ;
33
34
e . preventDefault ( ) ;
34
35
e . stopPropagation ( ) ;
35
36
console . log ( "Converting code for: " + $ ( this ) . data ( 'type' ) )
36
37
convertApp ( $ ( this ) . data ( 'type' ) ) ;
37
38
} ) ;
38
39
39
40
$ ( '.settings-button' ) . click ( function ( e ) {
41
+ trackButton ( e ) ;
40
42
e . preventDefault ( ) ;
41
43
e . stopPropagation ( ) ;
42
44
console . log ( "Clicked settings button" ) ;
43
45
$ ( ".settings-dropdown" ) . css ( "display" , "block" ) ;
44
46
} ) ;
45
47
46
48
$ ( '.feedback-button' ) . click ( function ( e ) {
49
+ trackButton ( e ) ;
47
50
e . preventDefault ( ) ;
48
51
e . stopPropagation ( ) ;
49
52
window . open ( "https://github.com/ampproject/amp-readiness/issues/new" ) ;
50
53
} ) ;
51
54
52
55
$ ( '#license-button' ) . click ( function ( e ) {
56
+ trackButton ( e ) ;
53
57
if ( chrome . runtime . openOptionsPage ) {
54
58
chrome . runtime . openOptionsPage ( ) ;
55
59
} else {
@@ -58,6 +62,7 @@ $(window).on('load', function() {
58
62
} ) ;
59
63
60
64
$ ( '.back-button' ) . click ( function ( e ) {
65
+ trackButton ( e ) ;
61
66
e . preventDefault ( ) ;
62
67
e . stopPropagation ( ) ;
63
68
$ ( '.container' ) . show ( ) ;
@@ -137,7 +142,10 @@ $(window).on('load', function() {
137
142
$ ( '.converter-tabs' ) . append ( "<div id='" + hash + "'></div>" ) ;
138
143
} ) ;
139
144
145
+
140
146
$ ( '.converter-tabs' ) . tabs ( ) ;
147
+
148
+
141
149
142
150
$ ( '.ui-tabs-tab' ) . click ( function ( e ) {
143
151
var appName = $ ( this ) . first ( ) . text ( ) ;
@@ -153,11 +161,12 @@ function convertApp(app) {
153
161
if ( ! $ ( '.converter-tabs #' + appHash ) . is ( ':empty' ) ) {
154
162
console . log ( "already generated snippet!" ) ;
155
163
} else {
156
- var template , content = null ;
164
+ var template , content , link = null ;
157
165
var result = [ ] ;
158
166
// Loop through regexes
159
167
content = convertableApps [ app ] . content ;
160
168
template = convertableApps [ app ] . template ;
169
+ link = convertableApps [ app ] . link ;
161
170
//We will revisit code completion later
162
171
// var expressions = typeof convertableApps[app].regex === "string" ? [convertableApps[app].regex] : convertableApps[app].regex;
163
172
// // Check for matches on the first regex
@@ -186,10 +195,12 @@ function convertApp(app) {
186
195
// }
187
196
console . log ( template ) ;
188
197
console . log ( content ) ;
198
+ console . log ( link ) ;
189
199
190
200
renderedHTML = renderAppConversionHtml ( template , app ) ;
191
201
var html = content ? '<p class="converted-content">' + content + '</p>' : '' ;
192
- html += '<pre><code class="language-html">' + renderedHTML + '</code></pre>' ;
202
+ html = '<pre><code class="language-html">' + renderedHTML + '</code></pre>' ;
203
+ html += '<p class="converted-content">More documentation available <a target="_blank" href="' + link + '">here<a/></p>' ;
193
204
194
205
$ ( '.converter-tabs #' + appHash ) . prepend ( html ) ;
195
206
}
@@ -217,9 +228,9 @@ function convertApp(app) {
217
228
// function renderAppConversionHtml(html, result, app) {
218
229
function renderAppConversionHtml ( html , app ) {
219
230
if ( convertableApps [ app ] . type === "amp-analytics" ) {
220
- html = "// Add this to <head>\n" +
231
+ html = "<!-- Add this to <head> -- >\n" +
221
232
"<script async custom-element=\"amp-analytics\" src=\"https://cdn.ampproject.org/v0/amp-analytics-0.1.js\"></script>\n" +
222
- "// Add this to <body>\n" +
233
+ "<!-- Add this to <body> -- >\n" +
223
234
html ;
224
235
}
225
236
// if (result != null) {
@@ -237,7 +248,6 @@ function renderAppConversionHtml(html, app) {
237
248
function replaceDomWhenReady ( dom ) {
238
249
if ( / c o m p l e t e | i n t e r a c t i v e | l o a d e d / . test ( document . readyState ) ) {
239
250
replaceDom ( dom ) ;
240
-
241
251
} else {
242
252
document . addEventListener ( 'DOMContentLoaded' , ( ) => {
243
253
replaceDom ( dom ) ;
@@ -643,7 +653,18 @@ _gaq.push(['_setAccount', 'UA-58015925-3']);
643
653
_gaq . push ( [ '_trackPageview' ] ) ;
644
654
645
655
( function ( ) {
646
- var ga = document . createElement ( 'script' ) ; ga . type = 'text/javascript' ; ga . async = true ;
656
+ var ga = document . createElement ( 'script' ) ;
657
+ ga . type = 'text/javascript' ;
658
+ ga . async = true ;
647
659
ga . src = 'https://ssl.google-analytics.com/ga.js' ;
648
- var s = document . getElementsByTagName ( 'script' ) [ 0 ] ; s . parentNode . insertBefore ( ga , s ) ;
649
- } ) ( ) ;
660
+ var s = document . getElementsByTagName ( 'script' ) [ 0 ] ;
661
+ s . parentNode . insertBefore ( ga , s ) ;
662
+ } ) ( ) ;
663
+
664
+ function trackButton ( e ) {
665
+ console . log ( e ) ;
666
+ if ( e . target . className === "detected__app-convert" ) {
667
+ _gaq . push ( [ '_trackEvent' , "Conversion Button for " + e . target . dataset . type , 'clicked' ] ) ;
668
+ } else
669
+ _gaq . push ( [ '_trackEvent' , "UI Button " + e . target . className , 'clicked' ] ) ;
670
+ } ;
0 commit comments