Spostate le funzioni di update tag
This commit is contained in:
parent
67d6831948
commit
3a7c880edf
1 changed files with 36 additions and 0 deletions
36
www/js/tag.update.js
Normal file
36
www/js/tag.update.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
function aggiornaTagsToPosts(id, tagId) {
|
||||
FONTE.dbHandler.executeSql('INSERT INTO xm24_tags_to_posts VALUES (?,?)', [id, tagId], function (resultSet) {
|
||||
console.log('resultSet.insertId: ' + resultSet.insertId);
|
||||
console.log('resultSet.rowsAffected: ' + resultSet.rowsAffected);
|
||||
}, function (error) {
|
||||
console.log('INSERT error: ' + error.message);
|
||||
//feedback
|
||||
$("#aggiorna").attr("src", "./image/aggiorna.png");
|
||||
});
|
||||
}
|
||||
|
||||
function aggiornaTags(pagenum) {
|
||||
var jsonurl = weburl + "wp-json/wp/v2/tags?per_page=100&page=" + pagenum;
|
||||
$.ajax({
|
||||
dataType: "json"
|
||||
, url: jsonurl
|
||||
, success: function (data, status, xhr) {
|
||||
var totalPages = parseInt(xhr.getResponseHeader("X-WP-TotalPages"));
|
||||
$.each(data, function (key, val) {
|
||||
var name = val.name;
|
||||
var slug = val.slug;
|
||||
var id = val.id;
|
||||
var blob = JSON.stringify(val);
|
||||
FONTE.dbHandler.executeSql('INSERT INTO xm24_tags VALUES (?,?,?)', [id, slug, blob], function (resultSet) {
|
||||
console.log('resultSet.insertId: ' + resultSet.insertId);
|
||||
console.log('resultSet.rowsAffected: ' + resultSet.rowsAffected);
|
||||
}, function (error) {
|
||||
console.log('INSERT error: ' + error.message);
|
||||
});
|
||||
});
|
||||
pagenum += 1
|
||||
if (pagenum <= totalPages) aggiornaTags(pagenum)
|
||||
}
|
||||
, error: JSONErrorHandler
|
||||
});
|
||||
};
|
Loading…
Reference in a new issue