<commit_before><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Recharge</title>
  <link rel="stylesheet" type="text/css" media="screen" href="/app.css" />
  <link rel="shortcut icon" href="/favicon.ico" />
  <script type="text/javascript" src="/jquery-1.4.4.min.js"></script>
  <script type="text/javascript" src="/jquery-ui-1.8.7.min.js"></script>
  <script type="text/javascript" src="/app.js"></script>
  <script>
    $(function() {
      $("#copy").popover({trigger: 'manual', placement: 'above', offset: 10});

      var cookie_name = location.pathname.replace(/\//g, '_');
      if ($.cookie(cookie_name)) {
        $.cookie(cookie_name, null, {path: '/'});
        $(".page-header")
          .attr("rel", "popover")
          .attr("title", "Leg dir ein Lesezeichen an!")
          .attr("data-content", "Unter dieser festen Adresse wird dein Kalender verfügbar bleiben."
              + "Leg dir am besten ein Lesezeichen an, damit du ihn wiederfindest.")
          .popover({trigger: 'manual', placement: 'below', offset: -60})
          .popover('show');
      }

      if (window.location.hash === '#moved') {
        window.location.hash = "";
        history.pushState('', document.title, window.location.pathname);
        $(".page-header")
          .attr("rel", "popover")
          .attr("title", "Wir sind umgezogen")
          .attr("data-content", "<NAME> hat eine neue Heimat bei recharge.wendtswelt.de gefunden."
              + " Bitte denk dran, deine Lesezeichen zu aktualisieren.")
          .popover({trigger: 'manual', placement: 'below', offset: -60})
          .popover('show');
      }

      $("body").click(function() {
        $("[rel=popover]").each(function() { $(this).popover('hide') });
      });

      <% if show_link_to_ical_export? %>
      ZeroClipboard.setMoviePath('/ZeroClipboard.swf');
      var clip = new ZeroClipboard.Client();
      clip.setText("<%= calendar_url %>");
      clip.glue('copy');
      clip.addEventListener('onMouseOver', function() { $("#copy").popover('show'); });
      clip.addEventListener('onMouseOut', function() { $("#copy").popover('hide'); });
      clip.addEventListener('onComplete', function() { $("#copy").popover('hide'); });
      <% end %>

      var mark_vacation = function(fn) {
        return function() {
          fn.apply(this, arguments);
          update_count();
        }
      };
      var highlight_between_ids = function(from, to) {
        sorted_ids = [parseInt(from, 10), parseInt(to, 10)].sort();
        $(".vacation_drag").removeClass("vacation_drag");
        for(id = sorted_ids[0]; id <= sorted_ids[1]; id += 1) {
          $("#"+id).addClass("vacation_drag");
        }
      };
      var update_count = function() {
        var count = $(".vacation,.vacation_drag").not(".holiday.active").length;
        $("#count").text(count);
        if (count == 0) {
          $("#save").attr('disabled', 'disabled');
        } else {
          $("#save").attr('disabled', '');
          if (count == 1) {
            $(".calendar").addClass('flash');
          }
        }
      };
      var dragging;
      $("td").draggable({
        opacity: 0.7,
        helper: "clone",
        appendTo: 'body',
        start: function(event, ui) {
          dragging = $(this);
          ui.helper.removeClass("friday").removeClass("monday");
        },
        stop: mark_vacation(function() {
          $(".vacation_drag").removeClass("vacation_drag").addClass("vacation");
        })
      });
      $("td").droppable({
          hoverClass: 'drophover',
          over: mark_vacation(function() {
            highlight_between_ids($(".drophover").attr("id"), $(dragging).attr("id"));
          }),
          drop: mark_vacation(function() {
            $(".vacation_drag").removeClass("vacation_drag").addClass("vacation");
          })
      });
      $("td").click(mark_vacation(function(e) {
        if (e.shiftKey && $(this).hasClass("holiday")) {
          $(this).toggleClass("active");
        } else {
          $(this).toggleClass("vacation");
        }
      }));
      $("#region").change(function() {
        var region = $("#region option:selected").attr("name");
        $.ajax({
          url: "/holidays/"+region+"/<%= year %>",
          dataType: 'json',
          success: function(json) {
            $(".holiday").removeClass("holiday active").removeAttr("title");
            $.each(json, function(date, name) {
              $("#"+date).addClass("holiday active").attr("title", name);
            });
            update_count();
          }
        });
      });
      $("#save").click(function() {
        $.ajax({
          type: 'POST',
          dataType: 'json',
          data: {
            vacation: {
              <%= year %>: $.makeArray($(".vacation").map(function() {
                return $(this).attr("id");
              }))
            },
            holidays: {
              <%= year %>: $.makeArray($(".holiday.active").map(function() {
                return $(this).attr("id");
              }))
            },
            _csrf: "<%= csrf_token %>"
          },
          success: function(data) {
            location.href = data.url;
          },
          error: function(jqXHR, textStatus, errorThrown) {
            $("#save")
              .attr("rel", "popover")
              .attr("title", "Speichern fehlgeschlagen")
              .attr("data-content", "Da hat etwas nicht geklappt. Bitte versuch es später erneut.")
              .popover({trigger: 'manual', placement: 'above', offset: 10})
              .popover("show");
          }
        });
      });
      update_count();
    });
  </script>
</head>
<body>
  <div class="container">
    <div class="content">
      <div class="page-header">
        <h1>Recharge <small>— zählt deine Urlaubstage, damit du es nicht machen musst!</small></h1>
        <div id="icon" class="offset12" style="position: absolute; top:3px;">
         <div class="calendar animated">
          <span class="weekday"><%= year %></span>
          <span id="count">9</span>
         </div>
        </div>
      </div>
      <div class="row">
        <div class="span16">
          <span class="label success">Los geht's:</span>
          Klick deine Urlaubstage für <%= year %> einfach an.
          <label for="region">Feiertage anzeigen für:</label>
          <select id="region">
            <option name="de_by">Bayern</option>
            <option name="de_bw">Baden-Württemberg</option>
            <option name="de" selected="selected">Berlin</option>
            <option name="de_bb">Brandenburg</option>
            <option name="de">Bremen</option>
            <option name="de">Hamburg</option>
            <option name="de_he">Hessen</option>
            <option name="de_mv">Mecklenburg-Vorpommern</option>
            <option name="de">Niedersachsen</option>
            <option name="de_nw">Nordrhein-Westfalen</option>
            <option name="de_rp">Rheinland-Pfalz</option>
            <option name="de_sn">Sachsen</option>
            <option name="de_st">Sachsen-Anhalt</option>
            <option name="de_sl">Saarland</option>
            <option name="de">Schleswig-Holstein</option>
            <option name="de_th">Thüringen</option>
          </select>
        </div>
      </div>
      <div class="row">
        <div class="span16">
          <%= calendar_for(year, vacation, holidays) %>
        </div>
      </div>
      <div class="row">
        <div class="span2">
          <%= link_to_previous_year(year) %>
        </div>
        <div class="span3 offset4">
          <button id="save" class="btn success"><%= button_label %></button>
        </div>
        <div class="span4">
          <%= link_to_icalendar_export %>
        </div>
        <div class="span2 offset1">
          <%= link_to_next_year(year) %>
        </div>
      </div>
      <div class="row">
        <div class="span15 offset1">
          Recharge von <a href="http://twitter.com/awendt">André</a> &#183;
          Kalender-Icon in CSS von <a href="http://usw-usf.de/featured/iphone-calendar-icon-mit-css3/">Henning</a>
        </div>
      </div>
    </div>
  </div> <!-- /container -->
  <a href="http://github.com/awendt/recharge"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
</body>
</html><commit_msg>Indicate AJAX action when saving calendars<commit_after><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Recharge</title>
  <link rel="stylesheet" type="text/css" media="screen" href="/app.css" />
  <link rel="shortcut icon" href="/favicon.ico" />
  <script type="text/javascript" src="/jquery-1.4.4.min.js"></script>
  <script type="text/javascript" src="/jquery-ui-1.8.7.min.js"></script>
  <script type="text/javascript" src="/app.js"></script>
  <script>
    $(function() {
      $("#copy").popover({trigger: 'manual', placement: 'above', offset: 10});

      var cookie_name = location.pathname.replace(/\//g, '_');
      if ($.cookie(cookie_name)) {
        $.cookie(cookie_name, null, {path: '/'});
        $(".page-header")
          .attr("rel", "popover")
          .attr("title", "Leg dir ein Lesezeichen an!")
          .attr("data-content", "Unter dieser festen Adresse wird dein Kalender verfügbar bleiben."
              + "Leg dir am besten ein Lesezeichen an, damit du ihn wiederfindest.")
          .popover({trigger: 'manual', placement: 'below', offset: -60})
          .popover('show');
      }

      if (window.location.hash === '#moved') {
        window.location.hash = "";
        history.pushState('', document.title, window.location.pathname);
        $(".page-header")
          .attr("rel", "popover")
          .attr("title", "Wir sind umgezogen")
          .attr("data-content", "Dein Urlaubskalender hat eine neue Heimat bei recharge.wendtswelt.de gefunden."
              + " Bitte denk dran, deine Lesezeichen zu aktualisieren.")
          .popover({trigger: 'manual', placement: 'below', offset: -60})
          .popover('show');
      }

      $("body").click(function() {
        $("[rel=popover]").each(function() { $(this).popover('hide') });
      });

      <% if show_link_to_ical_export? %>
      ZeroClipboard.setMoviePath('/ZeroClipboard.swf');
      var clip = new ZeroClipboard.Client();
      clip.setText("<%= calendar_url %>");
      clip.glue('copy');
      clip.addEventListener('onMouseOver', function() { $("#copy").popover('show'); });
      clip.addEventListener('onMouseOut', function() { $("#copy").popover('hide'); });
      clip.addEventListener('onComplete', function() { $("#copy").popover('hide'); });
      <% end %>

      var mark_vacation = function(fn) {
        return function() {
          fn.apply(this, arguments);
          update_count();
        }
      };
      var highlight_between_ids = function(from, to) {
        sorted_ids = [parseInt(from, 10), parseInt(to, 10)].sort();
        $(".vacation_drag").removeClass("vacation_drag");
        for(id = sorted_ids[0]; id <= sorted_ids[1]; id += 1) {
          $("#"+id).addClass("vacation_drag");
        }
      };
      var update_count = function() {
        var count = $(".vacation,.vacation_drag").not(".holiday.active").length;
        $("#count").text(count);
        if (count == 0) {
          $("#save").attr('disabled', 'disabled');
        } else {
          $("#save").attr('disabled', '');
          if (count == 1) {
            $(".calendar").addClass('flash');
          }
        }
      };
      var dragging;
      $("td").draggable({
        opacity: 0.7,
        helper: "clone",
        appendTo: 'body',
        start: function(event, ui) {
          dragging = $(this);
          ui.helper.removeClass("friday").removeClass("monday");
        },
        stop: mark_vacation(function() {
          $(".vacation_drag").removeClass("vacation_drag").addClass("vacation");
        })
      });
      $("td").droppable({
          hoverClass: 'drophover',
          over: mark_vacation(function() {
            highlight_between_ids($(".drophover").attr("id"), $(dragging).attr("id"));
          }),
          drop: mark_vacation(function() {
            $(".vacation_drag").removeClass("vacation_drag").addClass("vacation");
          })
      });
      $("td").click(mark_vacation(function(e) {
        if (e.shiftKey && $(this).hasClass("holiday")) {
          $(this).toggleClass("active");
        } else {
          $(this).toggleClass("vacation");
        }
      }));
      $("#region").change(function() {
        var region = $("#region option:selected").attr("name");
        $.ajax({
          url: "/holidays/"+region+"/<%= year %>",
          dataType: 'json',
          success: function(json) {
            $(".holiday").removeClass("holiday active").removeAttr("title");
            $.each(json, function(date, name) {
              $("#"+date).addClass("holiday active").attr("title", name);
            });
            update_count();
          }
        });
      });
      $("#save").click(function() {
        $(this).attr('disabled', 'disabled').text('Speichern...');
        $.ajax({
          type: 'POST',
          dataType: 'json',
          data: {
            vacation: {
              <%= year %>: $.makeArray($(".vacation").map(function() {
                return $(this).attr("id");
              }))
            },
            holidays: {
              <%= year %>: $.makeArray($(".holiday.active").map(function() {
                return $(this).attr("id");
              }))
            },
            _csrf: "<%= csrf_token %>"
          },
          success: function(data) {
            location.href = data.url;
          },
          error: function(jqXHR, textStatus, errorThrown) {
            $("#save")
              .attr("rel", "popover")
              .attr("title", "Speichern fehlgeschlagen")
              .attr("data-content", "Da hat etwas nicht geklappt. Bitte versuch es später erneut.")
              .popover({trigger: 'manual', placement: 'above', offset: 10})
              .popover("show");
          }
        });
      });
      update_count();
    });
  </script>
</head>
<body>
  <div class="container">
    <div class="content">
      <div class="page-header">
        <h1>Recharge <small>— zählt deine Urlaubstage, damit du es nicht machen musst!</small></h1>
        <div id="icon" class="offset12" style="position: absolute; top:3px;">
         <div class="calendar animated">
          <span class="weekday"><%= year %></span>
          <span id="count">9</span>
         </div>
        </div>
      </div>
      <div class="row">
        <div class="span16">
          <span class="label success">Los geht's:</span>
          Klick deine Urlaubstage für <%= year %> einfach an.
          <label for="region">Feiertage anzeigen für:</label>
          <select id="region">
            <option name="de_by">Bayern</option>
            <option name="de_bw">Baden-Württemberg</option>
            <option name="de" selected="selected">Berlin</option>
            <option name="de_bb">Brandenburg</option>
            <option name="de">Bremen</option>
            <option name="de">Hamburg</option>
            <option name="de_he">Hessen</option>
            <option name="de_mv">Mecklenburg-Vorpommern</option>
            <option name="de">Niedersachsen</option>
            <option name="de_nw">Nordrhein-Westfalen</option>
            <option name="de_rp">Rheinland-Pfalz</option>
            <option name="de_sn">Sachsen</option>
            <option name="de_st">Sachsen-Anhalt</option>
            <option name="de_sl">Saarland</option>
            <option name="de">Schleswig-Holstein</option>
            <option name="de_th">Thüringen</option>
          </select>
        </div>
      </div>
      <div class="row">
        <div class="span16">
          <%= calendar_for(year, vacation, holidays) %>
        </div>
      </div>
      <div class="row">
        <div class="span2">
          <%= link_to_previous_year(year) %>
        </div>
        <div class="span3 offset4">
          <button id="save" class="btn success"><%= button_label %></button>
        </div>
        <div class="span4">
          <%= link_to_icalendar_export %>
        </div>
        <div class="span2 offset1">
          <%= link_to_next_year(year) %>
        </div>
      </div>
      <div class="row">
        <div class="span15 offset1">
          Recharge von <a href="http://twitter.com/awendt">André</a> &#183;
          Kalender-Icon in CSS von <a href="http://usw-usf.de/featured/iphone-calendar-icon-mit-css3/">Henning</a>
        </div>
      </div>
    </div>
  </div> <!-- /container -->
  <a href="http://github.com/awendt/recharge"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
</body>
</html>
{'fraction_non_alphanumeric': 0.19052668787557442, 'fraction_numerical': 0.00671615411806292, 'mean_word_length': 2.2016220294228592, 'pattern_counts': {'":': 0, '<': 250, '<?xml version=': 0, '>': 248, 'https://': 0, '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': '1304367', 'n_tokens_mistral': 5307, 'n_tokens_neox': 5177, 'n_words': 923}