Populate POI Database
by salitrapraveen
HTML
<div id="progress">
0 %
</div>
<div id="output">
Done: 0/Unkown
</div>
CSS
body {
font-family: helvetica;
}
#progress {
width: 160px;
height: 60px;
background: #111;
color: #fff;
font-size: 24px;
line-height: 60px;
border-radius: 4px;
margin: 10px auto;
padding: 4px;
text-align: center;
}
#output {
margin: 20px auto;
width: 560px;
padding: 4px;
box-shadow: 0 0 10px #ccc;
font-size: 16px;
color: #222;
text-align: center;
}
JavaScript
(function($) {
var tasks = [],
settings = {
sleep: undefined
},
numberOfTasks = 0,
numberOfExecutedTasks = -1,
isRefresh = true;
methods = {
schedule: function(task) {
if ($.isFunction(task)) {
tasks.push(function(cb) {
task();
cb();
});
numberOfTasks++;
}
else {
$.error('Parameter is not a function');
}
},
schedulerSetup: function(options) {
$.extend(settings, settings, options);
},
schedulerNext: function() {
var nextTask;
numberOfExecutedTasks++; //This is not very accurate if the sleep is set, not a big deal though
if (tasks.length > 0) {
nextTask = tasks.shift();
(settings.sleep) ? setTimeout(function() {
nextTask($.schedulerNext);
}, settings.sleep) : nextTask($.schedulerNext);
}
},
schedulerProgress: function() {
if(numberOfExecutedTasks > 0){
return (numberOfExecutedTasks * 100 / numberOfTasks).toFixed(3);
}
else{
return 0;
}
}
};
$.schedule = methods.schedule;
$.schedulerSetup = methods.schedulerSetup;
$.schedulerNext = methods.schedulerNext;
$.schedulerProgress = methods.schedulerProgress;
})(jQuery);
$(function() {
var defaults = {
baseURL: 'http://ec2-107-21-118-28.compute-1.amazonaws.com:8080/ubuntu/',
baseYQLURL: 'http://query.yahooapis.com/v1/public/yql?callback=?&format=json&q=',
getCitiesServlet: 'GetCities',
populatePOIServelt: 'PopulatePOI',
getTypesServlet: 'GetTypeList',
startFrom: 14000,
endTo: 14020,
minPopulation: 1000,
maxNumberOfResults: 50,
...