<commit_before>extends layout

block content
  h1(style="text-align: center")= title
  hr
  br

  .btn-group.btn-group-justified(role='group', aria-label='...')
    .btn-group(role='group')
      a.btn.btn-default(type='button', href="/") Manage users
    .btn-group(role='group')
      a.btn.btn-default(type='button', href="/manageBadges") Manage badges
    .btn-group(role='group')
      a.btn.btn-default(type='button', href="/manageRewards") Manage rewards
    .btn-group(role='group')
      a.btn.btn-default(type='button', href="/showLeaderboard") Show leaderboard
    
  h2 Rewards
  table.table.table-striped.table-responsive
    thead
      th #
      th Name
      th Description
      th Image
      th Category
      th Actions
    tbody
      each reward in rewards
        tr
          td= reward.id
          td= reward.name
          td= reward.description
          td
            img(src="#{reward.image}", width="50px")
          td= reward.category
          td
            a(href="#" onclick="edit(#{reward.id})") Edit
            span  -  
            a(href="/reward/#{reward.id}/delete") Delete


  br
  img(id="test" class="col-md-2 col-md-offset-2" src="https://git.reviewboard.kde.org/media/uploaded/files/2015/07/18/a70d8ab6-1bbf-4dcc-b11f-524c2f56b14a__picture_default_cover.jpg")
  form#testform(class="col-md-5")
    .form-group
      label(for='name') Name
      input#name.form-control(type='text', placeholder='Name')
    .form-group
      label(for='description') Description
      input#description.form-control(type='text', placeholder='Description')
    .form-group
      label(for='image') Image
      input#image.form-control(type='text', placeholder='Image url')
    .form-group
      label(for='category') Category
      input#category.form-control(type='text', placeholder='Category')
    a#submit.btn.btn-default(type='submit' onclick="submit()") Add
    span  
    a#cancel.btn.btn-default(type='submit' style="display:none;" onclick="ResetForm()") Cancel

  script.
    var isEdition;
    var rewardId;

    ResetForm();

    function IsValidImageUrl(url) {
        if(url === "")
          url = "no-url-valid";

        $("<img>", {
            src: url,
            error: function() { 
              $('#test').attr('src', 'https://git.reviewboard.kde.org/media/uploaded/files/2015/07/18/a70d8ab6-1bbf-4dcc-b11f-524c2f56b14a__picture_default_cover.jpg');
            },
            load: function() { 
              $('#test').attr('src', url);
            }
        });
    }

    function ResetForm() {
        $('#name').val("");
        $('#description').val("");
        $('#image').val("");
        IsValidImageUrl("");
        $('#category').val("");
        $('#cancel').hide();
        $('#submit').text('Add');

        isEdition = false;
    }

    function submit() {
      var name = $('#name').val();
      var description = $('#description').val();
      var image = $('#image').val();
      var category = $('#category').val();

      var dataTest = {
            name: name,
            description: description,
            image: image,
            category: category
          };

      $.ajax({
        type: (isEdition ? "PUT" : "POST"),
        url: "http://localhost:8080/MoussaRaser/api/badges/" + (isEdition ? rewardId : "") + "/?apiKey=" + API_KEY,
        contentType:"application/json; charset=utf-8",
        dataType:"json",
        data: JSON.stringify(dataTest),
        success: function(data) {<commit_msg>Update manage-rewards.jade<commit_after>extends layout

block content
  h1(style="text-align: center")= title
  hr
  br

  .btn-group.btn-group-justified(role='group', aria-label='...')
    .btn-group(role='group')
      a.btn.btn-default(type='button', href="/") Manage users
    .btn-group(role='group')
      a.btn.btn-default(type='button', href="/manageBadges") Manage badges
    .btn-group(role='group')
      a.btn.btn-default(type='button', href="/manageRewards") Manage rewards
    .btn-group(role='group')
      a.btn.btn-default(type='button', href="/showLeaderboard") Show leaderboard
    
  h2 Rewards
  table.table.table-striped.table-responsive
    thead
      th #
      th Name
      th Description
      th Image
      th Category
      th Actions
    tbody
      each reward in rewards
        tr
          td= reward.id
          td= reward.name
          td= reward.description
          td
            img(src="#{reward.image}", width="50px")
          td= reward.category
          td
            a(href="#" onclick="edit(#{reward.id})") Edit
            span  -  
            a(href="/reward/#{reward.id}/delete") Delete


  br
  img(id="test" class="col-md-2 col-md-offset-2" src="https://git.reviewboard.kde.org/media/uploaded/files/2015/07/18/a70d8ab6-1bbf-4dcc-b11f-524c2f56b14a__picture_default_cover.jpg")
  form#testform(class="col-md-5")
    .form-group
      label(for='name') Name
      input#name.form-control(type='text', placeholder='Name')
    .form-group
      label(for='description') Description
      input#description.form-control(type='text', placeholder='Description')
    .form-group
      label(for='image') Image
      input#image.form-control(type='text', placeholder='Image url')
    .form-group
      label(for='category') Category
      input#category.form-control(type='text', placeholder='Category')
    a#submit.btn.btn-default(type='submit' onclick="submit()") Add
    span  
    a#cancel.btn.btn-default(type='submit' style="display:none;" onclick="ResetForm()") Cancel

  script.
    var isEdition;
    var rewardId;

    ResetForm();

    function IsValidImageUrl(url) {
        if(url === "")
          url = "no-url-valid";

        $("<img>", {
            src: url,
            error: function() { 
              $('#test').attr('src', 'https://git.reviewboard.kde.org/media/uploaded/files/2015/07/18/a70d8ab6-1bbf-4dcc-b11f-524c2f56b14a__picture_default_cover.jpg');
            },
            load: function() { 
              $('#test').attr('src', url);
            }
        });
    }

    function ResetForm() {
        $('#name').val("");
        $('#description').val("");
        $('#image').val("");
        IsValidImageUrl("");
        $('#category').val("");
        $('#cancel').hide();
        $('#submit').text('Add');

        isEdition = false;
    }

    function submit() {
      var name = $('#name').val();
      var description = $('#description').val();
      var image = $('#image').val();
      var category = $('#category').val();

      var dataTest = {
            name: name,
            description: description,
            image: image,
            category: category
          };

      $.ajax({
        type: (isEdition ? "PUT" : "POST"),
        url: "http://localhost:8080/MoussaRaser/api/badges/" + (isEdition ? rewardId : "") + "?apiKey=" + API_KEY,
        contentType:"application/json; charset=utf-8",
        dataType:"json",
        data: JSON.stringify(dataTest),
        success: function(data) {
{'fraction_non_alphanumeric': 0.17395654659805604, 'fraction_numerical': 0.017152658662092625, 'mean_word_length': 2.3655603655603654, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3947633', 'n_tokens_mistral': 2244, 'n_tokens_neox': 2171, 'n_words': 361}