/* flickrlicense -- A thingy to update Flickr photo licenses * Copyright (C) 2017 Douglas Thrift * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ $(function() { var errorTag = $('#error'); var reloadPhotosTag = $('#reload_photos'); var showLicenseTag = $('#show_license'); var showLicenseVal = showLicenseTag.val(); var showPrivacyTag = $('#show_privacy'); var showPrivacyVal = showPrivacyTag.val(); var showIgnoredTag = $('#show_ignored'); var showIgnoredVal = showIgnoredTag.val(); var photosTag = $('#photos'); var selectLicenseTag = $('#select_license'); var applyLicenseTag = $('#apply_license'); var licenseLinkTag = $('#license_link'); function controlsDisabled(disabled) { reloadPhotosTag.prop('disabled', disabled); showLicenseTag.prop('disabled', disabled); showPrivacyTag.prop('disabled', disabled); showIgnoredTag.prop('disabled', disabled); selectLicenseTag.prop('disabled', disabled); photosTag.find('.photo button').prop('disabled', disabled); } function filterPhotos() { photosTag.children('.photo').each(function(index, element) { var photoTag = $(element); var show = true; if (showLicenseVal != '' && !photoTag.hasClass('license-' + showLicenseVal)) { show = false; } if (showPrivacyVal != 'all' && !photoTag.hasClass(showPrivacyVal)) { show = false; } if (showIgnoredVal != 'true' && photoTag.hasClass('ignored')) { show = false; } if (show) { photoTag.show(); } else { photoTag.hide(); } }); } function reloadPhotos(params = {}, path = '/photos/1') { controlsDisabled(true); $.getJSON(path, params, function(data) { photosTag.children('.spinner').remove(); for (let photo of data.photos) { let privacy; let privacyTag = $(''); if (photo.public) { privacy = 'public'; privacyTag.text('public'); } else if (photo.friend && photo.family) { privacy = 'friends_family'; privacyTag.text('friends&family'); } else if (photo.friend) { privacy = 'friends'; privacyTag.text('friends'); } else if (photo.family) { privacy = 'family'; privacyTag.text('family'); } else { privacy = 'private'; privacyTag.text('private'); } let photoTag = $('
').addClass('license-' + photo.license).addClass(privacy).data('photo', photo); let ignoreTag = $('