diff --git a/build.sh b/build.sh index 1944927..1b98897 100755 --- a/build.sh +++ b/build.sh @@ -20,7 +20,7 @@ copyDevFunction() prepareChromeFunction() { echo "Preparing manifest.json for Chrome" - sed -i -e '28,32d;19d;35d' ./dev/manifest.json + sed -i -e '27,31d;35d' ./dev/manifest.json } packageChromeFunction() diff --git a/js/popup.js b/js/popup.js index 9db624c..3c2a4e0 100644 --- a/js/popup.js +++ b/js/popup.js @@ -51,27 +51,32 @@ function fetchGeoLocation() { }); } +function compileHtml(html, obj, clip) { + for (var prop in obj) { + html = html.replace(new RegExp(clip + prop + clip, 'g'), obj[prop] ? obj[prop] : ''); + } + return html; +} + function triggerView() { - var infosHtml = _.template($('#ipGeoLocationView').html()); - compiledInfosHtml = infosHtml({ - gl: geoIpV4 ? geoIpV4.toJSON() : new GeoLocation(), - gl6: geoIpV6 ? geoIpV6.toJSON() : new GeoLocation6() - }); + var infosHtml = $('#ipGeoLocationView').html(); + var gIPv4 = (geoIpV4 ? geoIpV4.toJSON() : new GeoLocation().toJSON()); + var gIPv6 = (geoIpV6 ? geoIpV6.toJSON() : new GeoLocation6().toJSON()); + compiledInfosHtml = compileHtml(infosHtml, gIPv4.geoLocation, 'T'); + compiledInfosHtml = compileHtml(compiledInfosHtml, gIPv4.browser, 'T'); + compiledInfosHtml = compileHtml(compiledInfosHtml, gIPv6.geoLocation, 'T6'); + compiledInfosHtml = compileHtml(compiledInfosHtml, gIPv6.browser, 'T6'); $('#ipLocationInfo').html(compiledInfosHtml); if (geoIpV4 && geoIpV4.toJSON().geoLocation && geoIpV4.toJSON().geoLocation.latitude != 0) { - var mapHtml = _.template($('#ipGeoMapView').html()); - compiledMapHtml = mapHtml({ - gl: geoIpV4.toJSON() - }); + var mapHtml = $('#ipGeoMapView').html(); + compiledMapHtml = compileHtml(mapHtml, geoIpV4.toJSON().geoLocation, 'T'); $('#mapIPV4').html(compiledMapHtml); } - if(geoIpV6 && geoIpV6.toJSON().geoLocation && geoIpV6.toJSON().geoLocation.latitude != 0) { - var mapHtml = _.template($('#ipGeoMapView').html()); - compiledMapHtml = mapHtml({ - gl: geoIpV6.toJSON() - }); + if (geoIpV6 && geoIpV6.toJSON().geoLocation && geoIpV6.toJSON().geoLocation.latitude != 0) { + var mapHtml = $('#ipGeoMapView').html(); + compiledMapHtml = compileHtml(mapHtml, geoIpV6.toJSON().geoLocation, 'T'); $('#mapIPV6').html(compiledMapHtml); } } diff --git a/manifest.json b/manifest.json index 474fa98..9eeca72 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "IP Address & Geolocation", - "version": "2.0.3", + "version": "2.1.0", "manifest_version": 2, "icons": { "16": "img/icon16.png", @@ -23,7 +23,7 @@ "default_popup": "popup.html", "default_title": "IP Address & Geolocation" }, - "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", + "content_security_policy": "script-src 'self'; object-src 'self'", "applications": { "gecko": { "id": "ipgeolocator@aykutcevik.com" diff --git a/popup.html b/popup.html index ec2e5d4..e2c705d 100644 --- a/popup.html +++ b/popup.html @@ -50,7 +50,7 @@

IP Address & Geolocation

@@ -67,33 +67,33 @@

IP Address & Geolocation

IP - <%- gl.geoLocation ? gl.geoLocation.ipAddress : null %> - <%- gl6.geoLocation ? gl6.geoLocation.ipAddress : null %> + TipAddressT + T6ipAddressT6 City - <%- gl.geoLocation ? gl.geoLocation.city : null %> - <%- gl6.geoLocation ? gl6.geoLocation.city : null %> + TcityT + T6cityT6 Country - <%- gl.geoLocation ? gl.geoLocation.countryName : null %> - <%- gl6.geoLocation ? gl6.geoLocation.countryName : null %> + TcountryNameT + T6countryNameT6 Continent - <%- gl.geoLocation ? gl.geoLocation.continent : null %> - <%- gl6.geoLocation ? gl6.geoLocation.continent : null %> + TcontinentT + T6continentT6 Timezone - <%- gl.geoLocation ? gl.geoLocation.timezone : null %> - <%- gl6.geoLocation ? gl6.geoLocation.timezone : null %> + TtimezoneT + T6timezoneT6 User agent - <%- gl.geoLocation ? gl.browser.userAgent : null %> - <%- gl6.geoLocation ? gl6.browser.userAgent : null %> + TuserAgentT + T6userAgentT6