add_audio_kind.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. {% extends "dbadmin_base.html" %}
  2. {% import "bootstrap/wtf.html" as wtf %}
  3. {% block title %}Larigira - DB add audio "{{kind}}" {%endblock%}
  4. {% block scripts %}
  5. {{super()}}
  6. <script type="text/javascript">
  7. function check_suggestion(el) {
  8. val = $(el).val();
  9. datalist = $(document.getElementById($(el).attr('list')));
  10. values = $('option', datalist).map(function(i, x) { return $(x).attr('value'); });
  11. if($.inArray(val, values) != -1) {
  12. $(el).closest('div.form-group').removeClass('has-warning has-feedback');
  13. $('.not-in-datalist', $(el).parent()).remove()
  14. } else {
  15. $(el).closest('div.form-group').addClass('has-warning has-feedback');
  16. if($('.not-in-datalist', $(el).parent()).length === 0) {
  17. $(el).parent().append($('<span class="not-in-datalist glyphicon glyphicon-warning-sign form-control-feedback"/>'))
  18. $(el).parent().append($('<span/>')
  19. .addClass('help-block not-in-datalist')
  20. .text('Warning: larigira is not sure this path is correct'));
  21. }
  22. }
  23. }
  24. $(function() {
  25. $('input[list]').each(function(i, el) {
  26. check_suggestion(el);
  27. })
  28. });
  29. $('form').on('change keyup', 'input[list]', function(evt) {
  30. check_suggestion(evt.target);
  31. });
  32. </script>
  33. {%endblock scripts %}
  34. {% block content %}
  35. {% if form.errors %}
  36. <div class="alert alert-danger">
  37. <strong>There were some error in your form;</strong> please fix them, then
  38. resubmit
  39. </div>
  40. {% endif %}
  41. {% for category in suggestions %}
  42. <datalist id="dl-suggested-{{category}}">
  43. {% for fname in suggestions[category] %}
  44. <option value="{{fname}}">
  45. {% endfor %}
  46. </datalist>
  47. {% endfor %}
  48. <div class="container-fluid">
  49. {{wtf.quick_form(form)}}
  50. </div>
  51. {% endblock content %}
  52. {# vim: set ts=2 sw=2 noet: #}