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 }); } function myJsonPostByTagList(idTag, div) { $.mobile.loading('show'); var tagid = parseInt(idTag); FONTE.dbHandler.executeSql("SELECT * FROM xm24_tags_to_posts WHERE tagid = ?;", [tagid], function (resultSet) { var items = []; var finishCounter = 0; for (var i = 0; i < resultSet.rows.length; i++) { var val = resultSet.rows.item(i); FONTE.dbHandler.executeSql("SELECT * FROM xm24_posts WHERE id = ? ORDER BY title COLLATE NOCASE ASC;", [val.id], function (resultSetPost) { finishCounter++; for (var n = 0; n < resultSetPost.rows.length; n++) { var val = JSON.parse(resultSetPost.rows.item(n).post); var id = val.id; var time = val.modified; var title = val.title.rendered; var url = val.guid.rendered; var splitTime = time.split("T"); var cleanTime = splitTime[0]; //key mi dice l'indice' items.push({ item: "
  • " + title + "
    " + cleanTime + "
  • ", title: title }); } // fallo solo quando items รจ stato riempito if (finishCounter >= resultSet.rows.length - 1) { $(div).empty(); $("