Removed jQuery dependency from Chrome driver

main
Elbert Alias 12 years ago
parent 4fbcf1c5ab
commit 2fac8bb5b5

@ -1,5 +1,13 @@
$(function() { document.addEventListener('DOMContentLoaded', function() {
$('[data-i18n]').each(function() { var
$(this).html(chrome.i18n.getMessage($(this).attr('data-i18n'))); i, value,
}); d = document
nodes = d.getElementsByTagName('*')
;
for ( i = 0; i < nodes.length; i ++ ) {
if ( attr = nodes[i].dataset.i18n ) {
nodes[i].innerHTML = chrome.i18n.getMessage(attr);
}
}
}); });

@ -1,15 +1,17 @@
$(function() { document.addEventListener('DOMContentLoaded', function() {
var d = document;
var options = { var options = {
opts: defaults, opts: defaults,
init: function() { init: function() {
options.load(); options.load();
$('#github' ).click(function() { window.open(wappalyzer.config.githubURL); }); d.getElementById('github' ).addEventListener('click', function() { window.open(wappalyzer.config.githubURL); });
$('#twitter' ).click(function() { window.open(wappalyzer.config.twitterURL); }); d.getElementById('twitter' ).addEventListener('click', function() { window.open(wappalyzer.config.twitterURL); });
$('#wappalyzer').click(function() { window.open(wappalyzer.config.websiteURL + '?utm_source=chrome&utm_medium=extension&utm_campaign=extensions'); }); d.getElementById('wappalyzer').addEventListener('click', function() { window.open(wappalyzer.config.websiteURL + '?utm_source=chrome&utm_medium=extension&utm_campaign=extensions'); });
$('#options-save').click(options.save); d.getElementById('options-save').addEventListener('click', options.save);
}, },
load: function() { load: function() {
@ -20,29 +22,32 @@ $(function() {
} }
if ( parseInt(options.opts.autoAnalyzeHeaders) ) { if ( parseInt(options.opts.autoAnalyzeHeaders) ) {
$('#option-auto-analyze-headers').attr('checked', 'checked'); d.getElementById('option-auto-analyze-headers').setAttribute('checked', 'checked');
} }
if ( parseInt(options.opts.upgradeMessage) ) { if ( parseInt(options.opts.upgradeMessage) ) {
$('#option-upgrade-message').attr('checked', 'checked'); d.getElementById('option-upgrade-message').setAttribute('checked', 'checked');
} }
if ( parseInt(options.opts.tracking) ) { if ( parseInt(options.opts.tracking) ) {
$('#option-tracking').attr('checked', 'checked'); d.getElementById('option-tracking').setAttribute('checked', 'checked');
} }
}, },
save: function() { save: function() {
options.opts.autoAnalyzeHeaders = $('#option-auto-analyze-headers').is(':checked') ? 1 : 0; options.opts.autoAnalyzeHeaders = d.getElementById('option-auto-analyze-headers').checked ? 1 : 0;
options.opts.upgradeMessage = $('#option-upgrade-message' ).is(':checked') ? 1 : 0; options.opts.upgradeMessage = d.getElementById('option-upgrade-message' ).checked ? 1 : 0;
options.opts.tracking = $('#option-tracking' ).is(':checked') ? 1 : 0; options.opts.tracking = d.getElementById('option-tracking' ).checked ? 1 : 0;
for ( option in options.opts ) { for ( option in options.opts ) {
localStorage[option] = options.opts[option]; localStorage[option] = options.opts[option];
} }
document.getElementById('options-saved').style.display = 'inline';
setTimeout(function(){document.getElementById('options-saved').style.display = 'none';},2000);
d.getElementById('options-saved').style.display = 'inline';
setTimeout(function(){
d.getElementById('options-saved').style.display = 'none';
}, 2000);
} }
}; };

@ -1,20 +1,27 @@
(function() { document.addEventListener('DOMContentLoaded', function() {
var
d = document,
analyzeHeaders = d.getElementById('analyze-headers'),
detectedApps = d.getElementById('detected-apps')
;
var popup = { var popup = {
pollHeaders: null, pollHeaders: null,
init: function() { init: function() {
$('#options').click(function() { d.getElementById('options').addEventListener('click', function() {
window.open(chrome.extension.getURL('options.html')); open(chrome.extension.getURL('options.html'));
}); });
$('#analyze-headers').text(chrome.i18n.getMessage('analyzeHeaders')).removeAttr('disabled'); analyzeHeaders.innerHTML = chrome.i18n.getMessage('analyzeHeaders');
analyzeHeaders.removeAttribute('disabled');
chrome.tabs.getSelected(null, function(tab) { chrome.tabs.getSelected(null, function(tab) {
if ( tab.url.match(/https?:\/\//) ) { if ( tab.url.match(/https?:\/\//) ) {
$('#detected-apps').html('<div class="empty">' + chrome.i18n.getMessage('noAppsDetected') + '</div>'); detectedApps.innerHTML = '<div class="empty">' + chrome.i18n.getMessage('noAppsDetected') + '</div>';
$('#analyze-headers').click(function() { analyzeHeaders.addEventListener('click', function() {
$(this).attr('disabled', 'disabled'); analyzeHeaders.setAttribute('disabled', 'disabled');
chrome.extension.sendRequest({ id: 'fetch_headers', tab: tab }); chrome.extension.sendRequest({ id: 'fetch_headers', tab: tab });
@ -22,12 +29,12 @@
}); });
if ( parseInt(localStorage['autoAnalyzeHeaders']) ) { if ( parseInt(localStorage['autoAnalyzeHeaders']) ) {
$('#analyze-headers').click(); analyzeHeaders.click();
} }
} else { } else {
$('#detected-apps').html('<div class="empty">' + chrome.i18n.getMessage('nothingToDo') + '</div>'); detectedApps.innerHTML = '<div class="empty">' + chrome.i18n.getMessage('nothingToDo') + '</div>';
$('#analyze-headers').attr('disabled', 'disabled'); analyzeHeaders.setAttribute('disabled', 'disabled');
} }
}); });
@ -41,12 +48,12 @@
if ( popup.pollHeaders != null ) { if ( popup.pollHeaders != null ) {
clearTimeout(popup.pollHeaders); clearTimeout(popup.pollHeaders);
$('#analyze-headers').text(chrome.i18n.getMessage('analyzeHeadersDone')); analyzeHeaders.innerHTML = chrome.i18n.getMessage('analyzeHeadersDone');
} }
} }
if ( response.tabCache.count > 0 ) { if ( response.tabCache.count > 0 ) {
$('#detected-apps').html(''); detectedApps.innerHTML = '';
response.tabCache.appsDetected.map(function(appName) { response.tabCache.appsDetected.map(function(appName) {
html = html =
@ -67,13 +74,13 @@
'</a>' + '</a>' +
'</div>'; '</div>';
$('#detected-apps').append(html); detectedApps.innerHTML = detectedApps.innerHTML + html;
}); });
} }
}); });
}); });
} }
} };
$(function() { popup.init(); }); popup.init();
})(); });

Loading…
Cancel
Save