<%# 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 <http://www.gnu.org/licenses/>.
%>
<div id="error" title="error"></div>

<div>
    <button disabled id="reload_photos" type="button">reload photos</button>
    <select disabled id="show_license">
        <option <% unless @user.show_license %>selected <% end %>value="">show photos with any license</option>
        <% @licenses.each do |license| %>
            <option <% if license == @user.show_license %>selected <% end %>value="<%= license.id %>"><%= license.name %></option>
        <% end %>
    </select>
    <select disabled id="show_privacy">
        <% @show_privacies.each do |show_privacy, name| %>
            <option <% if show_privacy == @user.show_privacy %>selected <% end %>value="<%= show_privacy %>"><%= name %></option>
        <% end %>
    </select>
    <select disabled id="show_ignored">
        <% @show_ignoreds.each do |show_ignored, name| %>
            <option <% if show_ignored == @user.show_ignored %>selected <% end %>value="<%= show_ignored %>"><%= name %></option>
        <% end %>
    </select>
</div>

<div grid id="photos">
    <div class="spinner"></div>
</div>

<div>
    <select disabled id="select_license">
        <option value="" selected>select license</option>
        <% @licenses.each do |license| %>
            <option value="<%= license.id %>"><%= license.name %></option>
        <% end %>
    </select>
    <button disabled id="apply_license" type="button">apply license</button>
    <span id="license_link"></span> to <span id="selected_count">0</span> <span id="selected_noun">photos</span>
</div>

<script>
var licenses = <%= @licenses.to_json %>;
</script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
<script src="/js/app.js"></script>