Skip to content

Commit

Permalink
Gulp task and TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosLongarela committed Nov 12, 2019
1 parent 708f0a4 commit c2d6a6c
Show file tree
Hide file tree
Showing 34 changed files with 131 additions and 104 deletions.
7 changes: 3 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"chrome": true
},
"extends": [
"eslint:recommended",
"wordpress"
],
"eslint:recommended"
],
"parserOptions": {
"sourceType": "module"
},
Expand Down Expand Up @@ -272,4 +271,4 @@
"yield-star-spacing": "error",
"yoda": "off"
}
}
}
22 changes: 11 additions & 11 deletions __src/typescript/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/* eslint-disable no-unused-vars */
var utils = {
/* eslint-enable no-unused-vars */
translator: function( html ) {
translator: function( html: any ) {
'use strict';

/**
Expand All @@ -35,7 +35,7 @@ var utils = {
length,
attrs_to_check = ['title', 'alt', 'placeholder', 'value', 'href'];

function replacer( text : string ) {
function replacer( text: string ) {
return text.replace(/\{\{([\s\S]*?)\}\}/gm, function( str, g1 ) {
return chrome.i18n.getMessage( g1.trim() ) || str;
});
Expand All @@ -49,7 +49,7 @@ var utils = {
});
}

if ( html.nodeType === 3 ) { //text node
if ( 3 === html.nodeType ) { //text node
html.data = replacer( html.data );
} else {
for ( i = 0, length = html.childNodes.length; i < length; i++ ) {
Expand All @@ -58,7 +58,7 @@ var utils = {
}
}, // /translator.

ajax: function( url : string, fn ) {
ajax: function( url: string, fn: any ) {
'use strict';

var request = new XMLHttpRequest();
Expand All @@ -75,7 +75,7 @@ var utils = {
request.send();
}, // /ajax.

set_menu: function( active_item ) {
set_menu: function( active_item: string ): void {
'use strict';

var html_menu = '';
Expand Down Expand Up @@ -124,19 +124,19 @@ var utils = {
this.show_div( 'notice' );
}, // /url_not_valid.

show_div: function( div_id ) {
show_div: function( div_id: string ) {
'use strict';

document.getElementById( div_id ).style.display = 'block';
}, // /show_div.

hide_div: function( div_id ) {
hide_div: function( div_id: string ) {
'use strict';

document.getElementById( div_id ).style.display = 'none';
}, // /hide_div.

show_hide_div: function( div_id ) {
show_hide_div: function( div_id: string ) {
'use strict';

if ( document.getElementById( div_id ).style.display === 'none' ) {
Expand All @@ -151,10 +151,10 @@ var utils = {

data_style.height = 'auto';
data_style.overflow = 'auto';
data_style.opacity = 1;
data_style.opacity = '1';
}, // /show_data_div.

copy_text: function( div_id ) {
copy_text: function( div_id: string ) {
'use strict';

var self = this;
Expand All @@ -172,7 +172,7 @@ var utils = {
}, 4000 );
}, // /copy_text.

extract_hostname: function( url ) {
extract_hostname: function( url: string ) {
'use strict';

var hostname;
Expand Down
10 changes: 5 additions & 5 deletions __src/typescript/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
document.addEventListener( 'DOMContentLoaded', function() {
'use strict';

function show_tab_data_home( tab ) {
function show_tab_data_home( tab: any ) {
var html, https_img, https_txt;

html = '';
Expand Down Expand Up @@ -46,7 +46,7 @@ document.addEventListener( 'DOMContentLoaded', function() {
utils.ajax( 'https://tabernawp.com/wp-total-tools/api/?url=' + encodeURI( tab.url ), info_api_url );
}

function info_api_url( response ) {
function info_api_url( response: any ) {
var html;

html = '';
Expand All @@ -63,7 +63,7 @@ document.addEventListener( 'DOMContentLoaded', function() {
}

if ( response.namelookup_time ) {
html += '<p>' + chrome.i18n.getMessage( 'msg_dns_lookup' ) + ': <strong>' + ( response.namelookup_time * 1000 ).toFixed(2) + ' ms</strong></p>';
html += '<p>' + chrome.i18n.getMessage( 'msg_dns_lookup' ) + ': <strong>' + ( response.namelookup_time * 1000 ).toFixed(2) + ' ms</strong></p>';
}

if ( response.connect_time ) {
Expand All @@ -83,7 +83,7 @@ document.addEventListener( 'DOMContentLoaded', function() {
}

if ( response.compress ) {
html += '<p>' + chrome.i18n.getMessage( 'msg_compress' ) + ': <strong class="ok">' + response.compress + '</strong></p>';
html += '<p>' + chrome.i18n.getMessage( 'msg_compress' ) + ': <strong class="ok">' + response.compress + '</strong></p>';
} else {
html += '<p>' + chrome.i18n.getMessage( 'msg_compress' ) + ': <span class="fail">' + chrome.i18n.getMessage( 'msg_no' ) + '</span></p>';
}
Expand All @@ -109,4 +109,4 @@ document.addEventListener( 'DOMContentLoaded', function() {

utils.show_data_div(); // Show principal content.

} );
} );
8 changes: 4 additions & 4 deletions __src/typescript/wpo.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
document.addEventListener( 'DOMContentLoaded', function() {
'use strict';

var items_wpo = document.getElementsByClassName( 'item_wpo' );
var fieldset_wpo = document.getElementsByClassName( 'wpo_fieldset' );
var items_wpo: any = document.getElementsByClassName( 'item_wpo' );
var fieldset_wpo: any = document.getElementsByClassName( 'wpo_fieldset' );

function show_section_wpo() {
for ( var i = 0; i < fieldset_wpo.length; i++ ) {
Expand All @@ -11,7 +11,7 @@ document.addEventListener( 'DOMContentLoaded', function() {
utils.show_div( 'target_' + this.id );
}

function show_tabs_buttons( tab ) {
function show_tabs_buttons( tab: any ) {
var current_url = tab.url;
var encoded_current_url = encodeURI( current_url );
var current_domain = utils.extract_hostname( current_url );
Expand Down Expand Up @@ -108,4 +108,4 @@ document.addEventListener( 'DOMContentLoaded', function() {

utils.show_data_div(); // Show principal content.

} );
} );
1 change: 1 addition & 0 deletions css/maps/styles.min.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c2d6a6c

Please sign in to comment.