var update_zip_json = function () { // Skip if not done if (!this.loader.is_done()) return; // Remove if (this.zip.get_file_count() > this.loader.images.length) { this.zip.remove_file(this.zip.get_file_count() - 1); } // Skip if (this.zip_info_json_mode == constants.JSON_OMIT) return; // Settings var images = this.loader.images, gal_info = this.loader.gal_info, date = new Date(gal_info.date_uploaded), tab_mode, json_info, img, obj, i; if (this.zip_info_json_mode == constants.JSON_READABLE_2SPACE) { tab_mode = 2; } else if (this.zip_info_json_mode == constants.JSON_READABLE_4SPACE) { tab_mode = 4; } else if (this.zip_info_json_mode == constants.JSON_READABLE_TABS) { tab_mode = "\t"; } // Create json_info = { gallery_info: { title: gal_info.title, title_original: gal_info.title_original, category: gal_info.category, tags: gal_info.tags, language: gal_info.language, translated: gal_info.translated, favorite_category: null, upload_date: [ date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), ], source: { site: API.get_site(), gid: gal_info.gallery.gid, token: gal_info.gallery.token, parent_gallery: gal_info.parent, newer_versions: gal_info.newer_versions, }, }, image_api_key: (images.length > 0 && images[0].info) ? images[0].info.navigation.api_key : null, image_info: [], }; // Set info if (gal_info.favorites.category >= 0 && gal_info.favorites.category_title !== null) { json_info.gallery_info.favorite_category = { id: gal_info.favorites.category, title: gal_info.favorites.category_title, }; } // Set images for (i = 0; i < images.length; ++i) { img = images[i].info; obj = { image_key: img.navigation.key_current, direct_id: img.navigation.direct_id, width: images[i].used.data.width, height: images[i].used.data.height, original_filename: img.image.filename, }; json_info.image_info.push(obj); } // Add to file this.zip.add_file(ZipCreator.string_to_array(JSON.stringify(json_info, null, tab_mode)), this.zip_info_json_name); // Done if (this.zip_blob !== null) { create_zip.call(this); } };