Skip to content

Commit

Permalink
* During the big merge I noticed some code was duplicated in userCoun…
Browse files Browse the repository at this point in the history
…try.js

Refs matomo-org#4019
  • Loading branch information
mattab committed Jun 30, 2013
1 parent a93ef90 commit 28b9f12
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 73 deletions.
2 changes: 2 additions & 0 deletions plugins/UserCountry/Controller.php
Expand Up @@ -191,6 +191,8 @@ public function updateGeoIPLinks()
if ($info !== false) {
echo Piwik_Common::json_encode($info);
return;
} else {
echo 1;
}
} catch (Exception $ex) {
echo Piwik_Common::json_encode(array('error' => $ex->getMessage()));
Expand Down
94 changes: 21 additions & 73 deletions plugins/UserCountry/javascripts/userCountry.js
Expand Up @@ -139,63 +139,8 @@ $(document).ready(function () {
.on('click', '#update-geoip-links', function () {
$('#geoipdb-update-info-error').hide();

var currentDownloading = null,
updateGeoIPSuccess = function (response) {
if (response && response.error) {
$('#geoip-progressbar-container').hide();
$('#geoipdb-update-info-error').html(response.error).show();
}
else if (response && response.to_download) {
var continuing = currentDownloading == response.to_download;
currentDownloading = response.to_download;

// show progress bar w/ message
$('#geoip-updater-progressbar').progressbar('option', 'value', 1);
$('#geoip-updater-progressbar-label').html(response.to_download_label);
$('#geoip-progressbar-container').show();

// start/continue download
downloadNextChunk(
'downloadMissingGeoIpDb', 'geoipdb-update-info', 'geoip-updater-progressbar',
continuing, {key: response.to_download}, updateGeoIPSuccess);
}
else {
$('#geoipdb-update-info-error').hide();
$('#geoip-updater-progressbar-label').html('');
$('#geoip-progressbar-container').hide();

// fade in/out Done message
$('#done-updating-updater').fadeIn(1000, function () {
setTimeout(function () {
$('#done-updating-updater').fadeOut(1000);
}, 3000);
});
}
};

// setup the auto-updater
var ajaxRequest = new ajaxHelper();
ajaxRequest.addParams({
period: $('#geoip-update-period-cell>input:checked').val()
}, 'get');
ajaxRequest.addParams({
module: 'UserCountry',
action: 'updateGeoIPLinks',
token_auth: piwik.token_auth,
loc_db: $('#geoip-location-db').val(),
isp_db: $('#geoip-isp-db').val(),
org_db: $('#geoip-org-db').val()
}, 'post');
ajaxRequest.setCallback(updateGeoIPSuccess);
ajaxRequest.send(false);
});
});

$('body').on('click', '#update-geoip-links', function () {
$('#geoipdb-update-info-error').hide();

var currentDownloading = null,
updateGeoIPSuccess = function (response) {
var currentDownloading = null;
var updateGeoIPSuccess = function (response) {
if (response && response.error) {
$('#geoip-progressbar-container').hide();
$('#geoipdb-update-info-error').html(response.error).show();
Expand Down Expand Up @@ -228,19 +173,22 @@ $(document).ready(function () {
}
};

// setup the auto-updater
var ajaxRequest = new ajaxHelper();
ajaxRequest.addParams({
period: $('#geoip-update-period-cell').find('>input:checked').val()
}, 'get');
ajaxRequest.addParams({
module: 'UserCountry',
action: 'updateGeoIPLinks',
loc_db: $('#geoip-location-db').val(),
isp_db: $('#geoip-isp-db').val(),
org_db: $('#geoip-org-db').val()
}, 'post');
ajaxRequest.setCallback(updateGeoIPSuccess);
ajaxRequest.send(false);
}
);
// setup the auto-updater
var ajaxRequest = new ajaxHelper();
var periodSelected = $('#geoip-update-period-cell>input:checked').val();
ajaxRequest.addParams({
period: periodSelected
}, 'get');
ajaxRequest.addParams({
module: 'UserCountry',
action: 'updateGeoIPLinks',
token_auth: piwik.token_auth,
loc_db: $('#geoip-location-db').val(),
isp_db: $('#geoip-isp-db').val(),
org_db: $('#geoip-org-db').val()
}, 'post');
ajaxRequest.setCallback(updateGeoIPSuccess);
ajaxRequest.send(false);
}
);
});

0 comments on commit 28b9f12

Please sign in to comment.