<commit_before>/*
!! DO NOT USE ANY OF THIS CODE, ITS ONLY FOR OUR DOCS PAGE !!
 _             _
(_)           (_)
 _  ___  _ __  _  ___
| |/ _ \| '_ \| |/ __|
| | (_) | | | | | (__
|_|\___/|_| |_|_|\___|

*/

(function(){

  /* Header menu toggle for mobile */
  $("#menu-toggle").click(function(e) {
      e.preventDefault();
      $(this).toggleClass("active");
  });

  /* Fixed left menu */
  var fixedMenu = $('.docked-menu');
  var activeId;
  if(fixedMenu.length) {
    $(document.body).scrollspy({ target: '.docked-menu', offset: 300 });

    var fixedMenuTop = fixedMenu.offset().top;
    var menuTopPadding = 20;
    fixedMenu.css({
      top: menuTopPadding + 'px'
    });

    function docScroll() {
      if(window.scrollY + menuTopPadding > fixedMenuTop) {
        fixedMenu
          .css({
            width: fixedMenu.width() + 'px'
          })
          .addClass("fixed-menu");
      } else {
        fixedMenu
          .removeClass("fixed-menu")
          .css({
            width: 'auto'
          });
        if(window.scrollY < 200) {
          $('.active').removeClass(".active");
        }
      }
    }
    $(window).resize(function(){
      fixedMenu
          .removeClass("fixed-menu")
          .css({
            width: 'auto'
          });
      docScroll();
    });
    $(window).scroll(docScroll);
  }

  /* Fixed device preview on the docs page */
  var devicePreview = $('.device-preview');
  if(devicePreview.length) {
    var docContent = $('.main-content');
    var orgDeviceTop = devicePreview.offset().top;
    var $defaultScreen = devicePreview.find('.default-screen');

    function onScroll() {
      if(window.scrollY > orgDeviceTop) {
        if( !devicePreview.hasClass('fixed-preview') ) {
          devicePreview
            .css({
              left: Math.round(devicePreview.offset().left) + 'px'
            })
            .addClass("fixed-preview");
          }
      } else {
        if( devicePreview.hasClass('fixed-preview') ) {
          devicePreview
            .removeClass("fixed-preview")
            .css({
              left: 'auto'
            });
        }
      }

    }
    $(window).resize(function(){
      devicePreview
          .removeClass("fixed-preview")
          .css({
            left: 'auto'
          });
      onScroll();
    });
    $(window).scroll(onScroll);
    onScroll();

    function scrollSpyChange(e) {
      if(smoothScrollingTo) return false;

      var id;
      if(e.target.children.length > 1) {
        // this is a top level nav link
        var activeSublinks = $(e.target).find('.active');
        if(!activeSublinks.length) {
          // no children are active for this top level link
          id = e.target.children[0].hash;
        }
      } else if(e.target.children.length === 1) {
        // this is a sub nav link
        id = e.target.children[0].hash;
      }

      if(id) {
        setTimeout(function(){
          previewSection(id);
        });
      }
    }
    fixedMenu.on('activate.bs.scrollspy', scrollSpyChange);

    var defaultScreen = devicePreview.find('.default-screen');
    function previewSection(id, doNotSetHistory) {
      var activeSection = $(id);
      if(!activeSection.length) return;

      var title = activeSection.find('h1,h2,h3').first();
      var newTitle = "Ionic Components";
      activeId = activeSection.attr('id');
      if(title.length) {
        newTitle = title.text() + " - " + newTitle;
      }
      document.title = newTitle;

      docContent.find('.active').removeClass('active');
      activeSection.addClass("active");

      if(!doNotSetHistory && window.history.replaceState) {
        window.history.replaceState({}, newTitle, "#" + activeId);
      }

      devicePreview.find('.active-preview').removeClass('active-preview');
      var docExample = activeSection.find('.doc-example');
      if( docExample.length ) {
        // this
        var exampleId = 'example-' + activeId;
        var examplePreview = $('#' + exampleId);
        if(examplePreview.length) {
          // preview has already been added
          examplePreview.addClass('active-preview');
        } else {
          // create a new example preview
          devicePreview.append( '
' + docExample.html() + '
' );
          setTimeout(function(){
            $('#' + exampleId)
              .addClass('active-preview')
              .find('a').click(function(){
                return false;
              });
          });
        }

      } else {
        defaultScreen.addClass('active-preview');
      }
    }

    var firstSection = docContent.find('.docs-section').first();
    if(firstSection.length) {
      previewSection( '#' + firstSection[0].id, true );
    }

  }

  // Smooth Scrolling
  var smoothScrollingTo;
  $(function() {
    $('a[href*=#]:not([href=#])').click(function() {
      if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
        var target = $(this.hash);
        target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
        if (target.length) {
          smoothScrollingTo = '#' + target.attr('id');
          $('html,body').animate({ scrollTop: target.offset().top }, 100, 'swing',
            function() {
              previewSection(smoothScrollingTo);
              smoothScrollingTo = undefined;
            });
          return false;
        }
      }
    });
  });

})();
<commit_msg>fix getting-started left menu<commit_after>/*
!! DO NOT USE ANY OF THIS CODE, ITS ONLY FOR OUR DOCS PAGE !!
 _             _
(_)           (_)
 _  ___  _ __  _  ___
| |/ _ \| '_ \| |/ __|
| | (_) | | | | | (__
|_|\___/|_| |_|_|\___|

*/

(function(){

  /* Header menu toggle for mobile */
  $("#menu-toggle").click(function(e) {
      e.preventDefault();
      $(this).toggleClass("active");
  });

  /* Fixed left menu */
  var fixedMenu = $('.docked-menu');
  var activeId;
  if(fixedMenu.length) {
    $(document.body).scrollspy({ target: '.docked-menu', offset: 300 });

    var fixedMenuTop = fixedMenu.offset().top;
    var menuTopPadding = 20;
    fixedMenu.css({
      top: menuTopPadding + 'px'
    });

    function docScroll() {
      if(window.scrollY + menuTopPadding > fixedMenuTop) {
        fixedMenu
          .css({
            width: fixedMenu.width() + 'px'
          })
          .addClass("fixed-menu");
      } else {
        fixedMenu
          .removeClass("fixed-menu")
          .css({
            width: 'auto'
          });
        if(window.scrollY < 200) {
          $('.active').removeClass(".active");
        }
      }
    }
    $(window).resize(function(){
      fixedMenu
          .removeClass("fixed-menu")
          .css({
            width: 'auto'
          });
      docScroll();
    });
    $(window).scroll(docScroll);
  }

  /* Fixed device preview on the docs page */
  var devicePreview = $('.device-preview');
  if(devicePreview.length) {
    var docContent = $('.main-content');
    var orgDeviceTop = devicePreview.offset().top;
    var $defaultScreen = devicePreview.find('.default-screen');

    function onScroll() {
      if(window.scrollY > orgDeviceTop) {
        if( !devicePreview.hasClass('fixed-preview') ) {
          devicePreview
            .css({
              left: Math.round(devicePreview.offset().left) + 'px'
            })
            .addClass("fixed-preview");
          }
      } else {
        if( devicePreview.hasClass('fixed-preview') ) {
          devicePreview
            .removeClass("fixed-preview")
            .css({
              left: 'auto'
            });
        }
      }

    }
    $(window).resize(function(){
      devicePreview
          .removeClass("fixed-preview")
          .css({
            left: 'auto'
          });
      onScroll();
    });
    $(window).scroll(onScroll);
    onScroll();

    function scrollSpyChange(e) {
      if(smoothScrollingTo || !docContent) return;

      var id;
      if(e.target.children.length > 1) {
        // this is a top level nav link
        var activeSublinks = $(e.target).find('.active');
        if(!activeSublinks.length) {
          // no children are active for this top level link
          id = e.target.children[0].hash;
        }
      } else if(e.target.children.length === 1) {
        // this is a sub nav link
        id = e.target.children[0].hash;
      }

      if(id) {
        setTimeout(function(){
          previewSection(id);
        });
      }
    }
    fixedMenu.on('activate.bs.scrollspy', scrollSpyChange);

    var defaultScreen = devicePreview.find('.default-screen');
    function previewSection(id, doNotSetHistory) {
      var activeSection = $(id);
      if(!activeSection.length) return;

      var title = activeSection.find('h1,h2,h3').first();
      var newTitle = "Ionic Components";
      activeId = activeSection.attr('id');
      if(title.length) {
        newTitle = title.text() + " - " + newTitle;
      }
      document.title = newTitle;

      docContent.find('.active').removeClass('active');
      activeSection.addClass("active");

      if(!doNotSetHistory && window.history.replaceState) {
        window.history.replaceState({}, newTitle, "#" + activeId);
      }

      devicePreview.find('.active-preview').removeClass('active-preview');
      var docExample = activeSection.find('.doc-example');
      if( docExample.length ) {
        // this
        var exampleId = 'example-' + activeId;
        var examplePreview = $('#' + exampleId);
        if(examplePreview.length) {
          // preview has already been added
          examplePreview.addClass('active-preview');
        } else {
          // create a new example preview
          devicePreview.append( '
' + docExample.html() + '
' );
          setTimeout(function(){
            $('#' + exampleId)
              .addClass('active-preview')
              .find('a').click(function(){
                return false;
              });
          });
        }

      } else {
        defaultScreen.addClass('active-preview');
      }
    }

    var firstSection = docContent.find('.docs-section').first();
    if(firstSection.length) {
      previewSection( '#' + firstSection[0].id, true );
    }

  }

  // Smooth Scrolling
  var smoothScrollingTo;
  $(function() {
    $('a[href*=#]:not([href=#])').click(function() {
      if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
        var target = $(this.hash);
        target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
        if (target.length) {
          smoothScrollingTo = '#' + target.attr('id');
          $('html,body').animate({ scrollTop: target.offset().top }, 100, 'swing',
            function() {
              if(docContent) {
                previewSection(smoothScrollingTo);
              }
              smoothScrollingTo = undefined;
            });
          return false;
        }
      }
    });
  });

})();
<|endoftext|>


<commit_before>//configuration object

var config = {
    title:"Vanuatu Cyclone Pam 3W",
    description:"
Click the graphs or map to interact.
Date: 25/03/2015 - Contact: Simon Johnson
Source: MapAction
",
    data:"data/data.json",
    whoFieldName:"organisation",
    whatFieldName:"activity",
    whereFieldName:"adm2_code",
    statusFieldName:"status",
    geo:"data/vanuatu.geojson",
    joinAttribute:"adm2code",
    colors:['#81d4fa','#4fc3f7','#29b6f6','#03a9f4','#039be5','#0288d1','#0277bd','#01579b']
};

//function to generate the 3W component
//data is the whole 3W Excel data set
//geom is geojson file

function generate3WComponent(config,data,geom){

    $('#title').html(config.title);
    $('#description').html(config.description);

    var whoChart = dc.rowChart('#hdx-3W-who');
    var whatChart = dc.rowChart('#hdx-3W-what');
    var whereChart = dc.leafletChoroplethChart('#hdx-3W-where');
    var statusChart = dc.rowChart('#hdx-3W-status');

    var cf = crossfilter(data);

    var whoDimension = cf.dimension(function(d){ return d[config.whoFieldName]; });
    var whatDimension = cf.dimension(function(d){ return d[config.whatFieldName]; });
    var whereDimension = cf.dimension(function(d){ return d[config.whereFieldName]; });
    var statusDimension = cf.dimension(function(d){ return d[config.statusFieldName]; });

    var whoGroup = whoDimension.group();
    var whatGroup = whatDimension.group();
    var whereGroup = whereDimension.group();
    var statusGroup = statusDimension.group();
    var all = cf.groupAll();

    whoChart.width($('#hdx-3W-who').width()).height(510)
            .dimension(whoDimension)
            .group(whoGroup)
            .elasticX(true)
            .data(function(group) {
                return group.top(20);
            })
            .labelOffsetY(13)
            .colors(config.colors)
            .colorDomain([0,7])
            .colorAccessor(function(d, i){return 3;})
            .xAxis().ticks(5);

    whatChart.width($('#hdx-3W-what').width()).height(250)
            .dimension(whatDimension)
            .group(whatGroup)
            .elasticX(true)
            .data(function(group) {
                return group.top(15);
            })
            .labelOffsetY(13)
            .colors(config.colors)
            .colorDomain([0,7])
            .colorAccessor(function(d, i){return 3;})
            .xAxis().ticks(5);

    statusChart.width($('#hdx-3W-status').width()).height(160)
            .dimension(statusDimension)
            .group(statusGroup)
            .elasticX(true)
            .data(function(group) {
                return group.top(15);
            })
            .labelOffsetY(13)
            .colors(config.colors)
            .colorDomain([0,7])
            .colorAccessor(function(d, i){return 3;})
            .xAxis().ticks(5);

    dc.dataCount('#count-info')
            .dimension(cf)
            .group(all);

    whereChart.width($('#hxd-3W-where').width()).height(400)
            .dimension(whereDimension)
            .group(whereGroup)
            .center([-17.050,168.3000])
            .zoom(6)
            .geojson(geom)
            .colors(['#CCCCCC', config.colors[3]])
            .colorDomain([0, 1])
            .colorAccessor(function (d) {
                if(d>0){
                    return 1;
                } else {
                    return 0;
                }
            })
            .featureKeyAccessor(function(feature){
                return feature.properties[config.joinAttribute];
            });

    dc.renderAll();

    var g = d3.selectAll('#hdx-3W-who').select('svg').append('g');

    g.append('text')
        .attr('class', 'x-axis-label')
        .attr('text-anchor', 'middle')
        .attr('x', $('#hdx-3W-who').width()/2)
        .attr('y', 520)
        .text('Activities');

    var g = d3.selectAll('#hdx-3W-what').select('svg').append('g');

    g.append('text')
        .attr('class', 'x-axis-label')
        .attr('text-anchor', 'middle')
        .attr('x', $('#hdx-3W-what').width()/2)
        .attr('y', 250)
        .text('Activities');

    var g = d3.selectAll('#hdx-3W-status').select('svg').append('g');

    g.append('text')
        .attr('class', 'x-axis-label')
        .attr('text-anchor', 'middle')
        .attr('x', $('#hdx-3W-status').width()/2)
        .attr('y', 160)
        .text('Activities');

}

//load 3W data

var dataCall = $.ajax({
    type: 'GET',
    url: config.data,
    dataType: 'json',
});

//load geometry

var geomCall = $.ajax({
    type: 'GET',
    url: config.geo,
    dataType: 'json'
});

//when both ready construct 3W

$.when(dataCall, geomCall).then(function(dataArgs, geomArgs){
    var geom = geomArgs[0];
    geom.features.forEach(function(e){
        e.properties[config.joinAttribute] = String(e.properties[config.joinAttribute]);
    });
    generate3WComponent(config,dataArgs[0],geom);
});

<commit_msg>axis label tweak<commit_after>//configuration object

var config = {
    title:"Vanuatu Cyclone Pam 3W",
    description:"
Click the graphs or map to interact.
Date: 25/03/2015 - Contact: Simon Johnson
Source: MapAction
",
    data:"data/data.json",
    whoFieldName:"organisation",
    whatFieldName:"activity",
    whereFieldName:"adm2_code",
    statusFieldName:"status",
    geo:"data/vanuatu.geojson",
    joinAttribute:"adm2code",
    colors:['#81d4fa','#4fc3f7','#29b6f6','#03a9f4','#039be5','#0288d1','#0277bd','#01579b']
};

//function to generate the 3W component
//data is the whole 3W Excel data set
//geom is geojson file

function generate3WComponent(config,data,geom){

    $('#title').html(config.title);
    $('#description').html(config.description);

    var whoChart = dc.rowChart('#hdx-3W-who');
    var whatChart = dc.rowChart('#hdx-3W-what');
    var whereChart = dc.leafletChoroplethChart('#hdx-3W-where');
    var statusChart = dc.rowChart('#hdx-3W-status');

    var cf = crossfilter(data);

    var whoDimension = cf.dimension(function(d){ return d[config.whoFieldName]; });
    var whatDimension = cf.dimension(function(d){ return d[config.whatFieldName]; });
    var whereDimension = cf.dimension(function(d){ return d[config.whereFieldName]; });
    var statusDimension = cf.dimension(function(d){ return d[config.statusFieldName]; });

    var whoGroup = whoDimension.group();
    var whatGroup = whatDimension.group();
    var whereGroup = whereDimension.group();
    var statusGroup = statusDimension.group();
    var all = cf.groupAll();

    whoChart.width($('#hdx-3W-who').width()).height(510)
            .dimension(whoDimension)
            .group(whoGroup)
            .elasticX(true)
            .data(function(group) {
                return group.top(20);
            })
            .labelOffsetY(13)
            .colors(config.colors)
            .colorDomain([0,7])
            .colorAccessor(function(d, i){return 3;})
            .xAxis().ticks(5);

    whatChart.width($('#hdx-3W-what').width()).height(250)
            .dimension(whatDimension)
            .group(whatGroup)
            .elasticX(true)
            .data(function(group) {
                return group.top(15);
            })
            .labelOffsetY(13)
            .colors(config.colors)
            .colorDomain([0,7])
            .colorAccessor(function(d, i){return 3;})
            .xAxis().ticks(5);

    statusChart.width($('#hdx-3W-status').width()).height(160)
            .dimension(statusDimension)
            .group(statusGroup)
            .elasticX(true)
            .data(function(group) {
                return group.top(15);
            })
            .labelOffsetY(13)
            .colors(config.colors)
            .colorDomain([0,7])
            .colorAccessor(function(d, i){return 3;})
            .xAxis().ticks(5);

    dc.dataCount('#count-info')
            .dimension(cf)
            .group(all);

    whereChart.width($('#hxd-3W-where').width()).height(400)
            .dimension(whereDimension)
            .group(whereGroup)
            .center([-17.050,168.3000])
            .zoom(6)
            .geojson(geom)
            .colors(['#CCCCCC', config.colors[3]])
            .colorDomain([0, 1])
            .colorAccessor(function (d) {
                if(d>0){
                    return 1;
                } else {
                    return 0;
                }
            })
            .featureKeyAccessor(function(feature){
                return feature.properties[config.joinAttribute];
            });

    dc.renderAll();

    var g = d3.selectAll('#hdx-3W-who').select('svg').append('g');

    g.append('text')
        .attr('class', 'x-axis-label')
        .attr('text-anchor', 'middle')
        .attr('x', $('#hdx-3W-who').width()/2)
        .attr('y', 510)
        .text('Activities');

    var g = d3.selectAll('#hdx-3W-what').select('svg').append('g');

    g.append('text')
        .attr('class', 'x-axis-label')
        .attr('text-anchor', 'middle')
        .attr('x', $('#hdx-3W-what').width()/2)
        .attr('y', 250)
        .text('Activities');

    var g = d3.selectAll('#hdx-3W-status').select('svg').append('g');

    g.append('text')
        .attr('class', 'x-axis-label')
        .attr('text-anchor', 'middle')
        .attr('x', $('#hdx-3W-status').width()/2)
        .attr('y', 160)
        .text('Activities');

}

//load 3W data

var dataCall = $.ajax({
    type: 'GET',
    url: config.data,
    dataType: 'json',
});

//load geometry

var geomCall = $.ajax({
    type: 'GET',
    url: config.geo,
    dataType: 'json'
});

//when both ready construct 3W

$.when(dataCall, geomCall).then(function(dataArgs, geomArgs){
    var geom = geomArgs[0];
    geom.features.forEach(function(e){
        e.properties[config.joinAttribute] = String(e.properties[config.joinAttribute]);
    });
    generate3WComponent(config,dataArgs[0],geom);
});

<|endoftext|>


<commit_before>(function ($){
  var app = $.app;

  function Skin() {}

  function init(){
    var width = ($(document).width()>1280 ? $(document).width() : 1280);
    $('body').css('width', width);

    var playlistHeight =
      $('#search_column').height() - $('#player_wrapper').height() + 10;
    $('#playlist_wrapper').css('height', playlistHeight);

    var playerColumnWidth = $('#player_column').width()-
      ($('#player_skin').width()+$('#player_wrapper').width()+50);
    $('#song_info').children().css('width', playerColumnWidth);
    $('.title').css('width', playerColumnWidth-55);

    $('input[name=search]')
      .width($('#search_column').width()-$('#addall').width()-40);

    $.app.canvas = $('#seeker').get(0);
    $.app.ctx = $.app.canvas.getContext('2d');
    google.search.Search.getBranding('google_branding');
    $('.gsc-branding-text', '#google_branding')
      .text('Artworks powered by ')
      .css({'font-size' : '11px', 'text-align' : 'right'});

    $('#addmusic').click(function () {
      $('input[name=actual_addmusic]').click();
    });
  }

  function showHomeScreen(){
    $('#player_container').hide();
    $('#home_screen').show();
  }

  function showPlayerScreen(){
    $('#player_container').show();
    $('#home_screen').hide();
    $.app.player.init($('#player_column'));
    $.app.Storage.load();
    $.app.Playlist.loadPlaylist();
    $.app.mainColumn.init();
    $.app.Cache.init();
  }

  app.Skin = Skin;
  app.Skin.init = init;
  app.Skin.showHomeScreen = showHomeScreen;
  app.Skin.showPlayerScreen = showPlayerScreen;

})(jQuery);
<commit_msg>fadeIn effects for player container<commit_after>(function ($){
  var app = $.app;

  function Skin() {}

  function init(){
    var width = ($(document).width()>1280 ? $(document).width() : 1280);
    $('body').css('width', width);

    var playlistHeight =
      $('#search_column').height() - $('#player_wrapper').height() + 10;
    $('#playlist_wrapper').css('height', playlistHeight);

    var playerColumnWidth = $('#player_column').width()-
      ($('#player_skin').width()+$('#player_wrapper').width()+50);
    $('#song_info').children().css('width', playerColumnWidth);
    $('.title').css('width', playerColumnWidth-55);

    $('input[name=search]')
      .width($('#search_column').width()-$('#addall').width()-40);

    $.app.canvas = $('#seeker').get(0);
    $.app.ctx = $.app.canvas.getContext('2d');
    google.search.Search.getBranding('google_branding');
    $('.gsc-branding-text', '#google_branding')
      .text('Artworks powered by ')
      .css({'font-size' : '11px', 'text-align' : 'right'});

    $('#addmusic').click(function () {
      $('input[name=actual_addmusic]').click();
    });
  }

  function showHomeScreen(){
    $('#player_container').hide();
    $('#home_screen').fadeIn();
  }

  function showPlayerScreen(){
    $('#home_screen').hide();
    $('#player_container').fadeIn();
    $.app.player.init($('#player_column'));
    $.app.Storage.load();
    $.app.Playlist.loadPlaylist();
    $.app.mainColumn.init();
    $.app.Cache.init();
  }

  app.Skin = Skin;
  app.Skin.init = init;
  app.Skin.showHomeScreen = showHomeScreen;
  app.Skin.showPlayerScreen = showPlayerScreen;

})(jQuery);
<|endoftext|>


<commit_before>var audio = undefined;

function parseQuery(q)
{
  var stage1 = q.slice(1).split("&");

  var stage2 = [];
  var stage3 = {};
  for(var i=0;i<stage1.length;++i)
  {
    stage2[i] = stage1[i].split("=");
    stage3[stage2[i][0]] = stage2[i][1];
  }

  return stage3;
}

var query = parseQuery(window.location.hash);

if(query.lang == "scottish")
{
  var head  = document.getElementsByTagName('head')[0];
  var link  = document.createElement('link');
  link.rel  = 'stylesheet';
  link.type = 'text/css';
  link.href = '/css/lang/Scot.css';
  link.media = 'all';
  head.appendChild(link);

  var audio = document.createElement("audio");
  audio.src = "audio/lang/SCOTscotlandforever.mp3";
  audio.loop = true;
  audio.play();

  var div = document.createElement("div");
  div.innerHTML = ''
  document.body.appendChild(div);
}
  else if(query.lang == "us")
{
  var head  = document.getElementsByTagName('head')[0];
  var link  = document.createElement('link');
  link.rel  = 'stylesheet';
  link.type = 'text/css';
  link.href = '/css/lang/us.css';
  link.media = 'all';
  head.appendChild(link);

  var div = document.createElement("div");
  div.innerHTML = ''
  document.body.appendChild(div);
  var source = [];
  source[0] = "audio/lang/USBrother/Brother1.mp3";
  source[1] = "audio/lang/USBrother/Brother2.mp3";
  source[2] = "audio/lang/USBrother/Brother3.mp3";
  source[3] = "audio/lang/USBrother/Brother4.mp3";
  source[4] = "audio/lang/USBrother/Brother5.mp3";
  source[5] = "audio/lang/USBrother/Brother6.mp3";
  source[6] = "audio/lang/USBrother/Brother7.mp3";
  source[7] = "audio/lang/USBrother/Brother8.mp3";
  source[8] = "audio/lang/USBrother/Brother9.mp3";
  source[9] = "audio/lang/USBrother/Brother10.mp3";
  source[10] = "audio/lang/USBrother/Brother11.mp3";
  source[11] = "audio/lang/USBrother/Brother12.mp3";
  source[12] = "audio/lang/USBrother/Brother13.mp3";
  var audio = [];
  for(var i=0;i<10;++i)
  {
    audio[i] = document.createElement("audio");
    audio[i].src = source[i];
    audio[i].pause();
  }

  var hoverfunc = function(){
    audio[Math.floor(Math.random()*13)].play();
  };

  document.getElementById("first").onmouseover = hoverfunc;
}

<commit_msg>Update tags.js<commit_after>var audio = undefined;

function parseQuery(q)
{
  var stage1 = q.slice(1).split("&");

  var stage2 = [];
  var stage3 = {};
  for(var i=0;i<stage1.length;++i)
  {
    stage2[i] = stage1[i].split("=");
    stage3[stage2[i][0]] = stage2[i][1];
  }

  return stage3;
}

var query = parseQuery(window.location.hash);

if(query.lang == "scottish")
{
  var head  = document.getElementsByTagName('head')[0];
  var link  = document.createElement('link');
  link.rel  = 'stylesheet';
  link.type = 'text/css';
  link.href = '/css/lang/Scot.css';
  link.media = 'all';
  head.appendChild(link);

  var audio = document.createElement("audio");
  audio.src = "audio/lang/SCOTscotlandforever.mp3";
  audio.loop = true;
  audio.play();

  var div = document.createElement("div");
  div.innerHTML = ''
  document.body.appendChild(div);
}
  else if(query.lang == "us")
{
  var head  = document.getElementsByTagName('head')[0];
  var link  = document.createElement('link');
  link.rel  = 'stylesheet';
  link.type = 'text/css';
  link.href = '/css/lang/us.css';
  link.media = 'all';
  head.appendChild(link);

  var div = document.createElement("div");
  div.innerHTML = ''
  document.body.appendChild(div);
  var source = [];
  source[0] = "audio/lang/USBrother/Brother1.mp3";
  source[1] = "audio/lang/USBrother/Brother2.mp3";
  source[2] = "audio/lang/USBrother/Brother3.mp3";
  source[3] = "audio/lang/USBrother/Brother4.mp3";
  source[4] = "audio/lang/USBrother/Brother5.mp3";
  source[5] = "audio/lang/USBrother/Brother6.mp3";
  source[6] = "audio/lang/USBrother/Brother7.mp3";
  source[7] = "audio/lang/USBrother/Brother8.mp3";
  source[8] = "audio/lang/USBrother/Brother9.mp3";
  source[9] = "audio/lang/USBrother/Brother10.mp3";
  source[10] = "audio/lang/USBrother/Brother11.mp3";
  source[11] = "audio/lang/USBrother/Brother12.mp3";
  source[12] = "audio/lang/USBrother/Brother13.mp3";
  var audio = [];
  for(var i=0;i<13;++i)
  {
    audio[i] = document.createElement("audio");
    audio[i].src = source[i];
    audio[i].pause();
  }

  var hoverfunc = function(){
    audio[Math.floor(Math.random()*13)].play();
  };

  document.getElementById("first").onmouseover = hoverfunc;
}

<|endoftext|>


<commit_before>var audio = undefined;

function parseQuery(q)
{
  var stage1 = q.slice(1).split("&");

  var stage2 = [];
  var stage3 = {};
  for(var i=0;i<stage1.length;++i)
  {
    stage2[i] = stage1[i].split("=");
    stage3[stage2[i][0]] = stage2[i][1];
  }

  return stage3;
}

var query = parseQuery(window.location.search);

if(query.lang == "scottish")
{
  var head  = document.getElementsByTagName('head')[0];
  var link  = document.createElement('link');
  link.rel  = 'stylesheet';
  link.type = 'text/css';
  link.href = '/css/lang/Scot.css';
  link.media = 'all';
  head.appendChild(link);

  var audio = document.createElement("audio");
  audio.src = "audio/scot.mp3";
  audio.loop = true;
  audio.play();

  var div = document.createElement("div");
  div.innerHTML = ''
  document.body.appendChild(div);
}
  else if(query.lang == "us")
{
  var head  = document.getElementsByTagName('head')[0];
  var link  = document.createElement('link');
  link.rel  = 'stylesheet';
  link.type = 'text/css';
  link.href = '/css/lang/us.css';
  link.media = 'all';
  head.appendChild(link);

  var source = [];
  source[0] = "";
  source[1] = "";
  source[2] = "";
  source[3] = "";
  source[4] = "";
  source[5] = "";
  source[6] = "";
  source[7] = "";
  source[8] = "";
  source[9] = "";

  var audio = [];
  for(var i=0;i<10;++i)
  {
    audio[i] = document.createElement("audio");
    audio[i].src = source[i];
    audio[i].pause();

  var hoverfunc = function(){
    audio[Math.random()*10].play();
  }

  document.getElementById("name").onmouseover = hoverfunc;
}

<commit_msg>Update tags.js<commit_after>var audio = undefined;

function parseQuery(q)
{
  var stage1 = q.slice(1).split("&");

  var stage2 = [];
  var stage3 = {};
  for(var i=0;i<stage1.length;++i)
  {
    stage2[i] = stage1[i].split("=");
    stage3[stage2[i][0]] = stage2[i][1];
  }

  return stage3;
}

var query = parseQuery(window.location.search);

if(query.lang == "scottish")
{
  var head  = document.getElementsByTagName('head')[0];
  var link  = document.createElement('link');
  link.rel  = 'stylesheet';
  link.type = 'text/css';
  link.href = '/css/lang/Scot.css';
  link.media = 'all';
  head.appendChild(link);

  var audio = document.createElement("audio");
  audio.src = "audio/scot.mp3";
  audio.loop = true;
  audio.play();

  var div = document.createElement("div");
  div.innerHTML = ''
  document.body.appendChild(div);
}
  else if(query.lang == "us")
{
  var head  = document.getElementsByTagName('head')[0];
  var link  = document.createElement('link');
  link.rel  = 'stylesheet';
  link.type = 'text/css';
  link.href = '/css/lang/us.css';
  link.media = 'all';
  head.appendChild(link);

  var source = [];
  source[0] = "";
  source[1] = "";
  source[2] = "";
  source[3] = "";
  source[4] = "";
  source[5] = "";
  source[6] = "";
  source[7] = "";
  source[8] = "";
  source[9] = "";

  var audio = [];
  for(var i=0;i<10;++i)
  {
    audio[i] = document.createElement("audio");
    audio[i].src = source[i];
    audio[i].pause();
  }

  var hoverfunc = function(){
    audio[Math.random()*10].play();
  }

  document.getElementById("name").onmouseover = hoverfunc;
}

<|endoftext|>


<commit_before>$.ajax({
  url: "http://thoughtatwork.cias.rit.edu/img/team/",
  success: function(data){
     $(data).find("a:contains(.jpg)").each(function(){
        // will loop through

        //img URL
        var images = $(this).attr("href");
        var imagesFull = "img/team/"+images

        //keys for string
        var urlString = "'https://taw.imgix.net/team/";
        var urlString2 = "'https://taw.imgix.net/team2/";
		var endString = "'";
		var sizeString = "?h=628&w=418";
        //img2
        var images2 = images.replace(/1/g, '2');

        //first name
		var start_pos = images.indexOf('');
		var end_pos = images.indexOf('_',start_pos);
		var firstName = images.substring(start_pos,end_pos)
		firstName = firstName.replace('!', ' ');

		//last name
		var start_pos = images.indexOf('_') + 1;
		var end_pos = images.indexOf('1',start_pos) - 1;
		var lastName = images.substring(start_pos,end_pos)

		//major
		var start_pos = images.indexOf('1_') + 2;
		var end_pos = images.indexOf('.jpg',start_pos);
		var majorRaw = images.substring(start_pos,end_pos)
		var major = majorRaw.replace(/_/g, ' ');

		//$( "#teamOut" ).append("
"+firstName+"
");

		/*$( "#teamOut" ).append('

'+firstName+'
'+lastName+'

'+major+'

');*/

		//test code for team image hovers
		$( "#teamOut" ).append('
' +
			'\n
'+firstName+'
'+lastName+'

'+major+'

');
     });

	$('#teamOut > h2').css('text-transform', 'capitalize');
  }
});
<commit_msg>test team2<commit_after>$.ajax({
  url: "http://thoughtatwork.cias.rit.edu/",
  success: function(data){
     $(data).find("a:contains(.jpg)").each(function(){
        // will loop through

        //img URL
        var images = $(this).attr("href");
        var imagesFull = "img/team/"+images

        //keys for string
        var urlString = "'https://taw.imgix.net/team/";
        var urlString2 = "'https://taw.imgix.net/team2/";
		var endString = "'";
		var sizeString = "?h=628&w=418";
        //img2
        var images2 = images.replace(/1/g, '2');

        //first name
		var start_pos = images.indexOf('');
		var end_pos = images.indexOf('_',start_pos);
		var firstName = images.substring(start_pos,end_pos)
		firstName = firstName.replace('!', ' ');

		//last name
		var start_pos = images.indexOf('_') + 1;
		var end_pos = images.indexOf('1',start_pos) - 1;
		var lastName = images.substring(start_pos,end_pos)

		//major
		var start_pos = images.indexOf('1_') + 2;
		var end_pos = images.indexOf('.jpg',start_pos);
		var majorRaw = images.substring(start_pos,end_pos)
		var major = majorRaw.replace(/_/g, ' ');

		//$( "#teamOut" ).append("
"+firstName+"
");

		/*$( "#teamOut" ).append('

'+firstName+'
'+lastName+'

'+major+'

');*/

		//test code for team image hovers
		$( "#teamOut" ).append('
' +
			'\n
'+firstName+'
'+lastName+'

'+major+'

');
     });

	$('#teamOut > h2').css('text-transform', 'capitalize');
  }
});
<|endoftext|>


<commit_before>//console.log('Hello World');
//alert('Hello again');
// Game props

gameProps = {
    Ndots:10,
    seed:1
};

dot = {
    ind:1,
    size:2,
    col:'red'

};

function addCircle(dot, parent){
    svgns = "http://www.w3.org/2000/svg";
    e = document.createElementNS(svgns,'circle');
    e.setAttribute('cx', '50');
    e.setAttribute('cy', '50');
    e.setAttribute('r', '25');
    e.setAttribute('fill', 'purple');
    parent.appendChild(e);
    return e;
}

circleSpec = [
    { x: 10 ,
      y: 20 ,
      c: "green"
    },
    { x: 100,
      y: 200,
      c: "blue"
    }
]

function placeCircles(circSpec) {
    // something
}
<commit_msg>fn skeleton<commit_after>//console.log('Hello World');
//alert('Hello again');
// Game props

gameProps = {
    Ndots:10,
    seed:1
};

dot = {
    ind:1,
    size:2,
    col:'red'

};

function addCircle(dot, parent){
    svgns = "http://www.w3.org/2000/svg";
    e = document.createElementNS(svgns,'circle');
    e.setAttribute('cx', '50');
    e.setAttribute('cy', '50');
    e.setAttribute('r', '25');
    e.setAttribute('fill', 'purple');
    parent.appendChild(e);
    return e;
}

circleSpec = [
    { x: 10 ,
      y: 20 ,
      c: "green"
    },
    { x: 100,
      y: 200,
      c: "blue"
    }
];

function placeCircles(circSpec) {
    // something
}
<|endoftext|>


<commit_before>function Tile(position, value) {
  this.x                = position.x;
  this.y                = position.y;
  this.value            = value;

  this.previousPosition = null;
  this.mergedFrom       = null; // Tracks tiles that merged together
}

Tile.prototype.savePosition = function () {
  this.previousPosition = { x: this.x, y: this.y };
};

Tile.prototype.updatePosition = function (position) {
  this.x = position.x;
  this.y = position.y;
};
<commit_msg>dev update<commit_after>function Tile(position, value) {
  this.x                = position.x;
  this.y                = position.y;
  this.value            = value || 4;

  this.previousPosition = null;
  this.mergedFrom       = null; // Tracks tiles that merged together
}

Tile.prototype.savePosition = function () {
  this.previousPosition = { x: this.x, y: this.y };
};

Tile.prototype.updatePosition = function (position) {
  this.x = position.x;
  this.y = position.y;
};
<|endoftext|>


<commit_before>/*
 * StatusNet - a distributed open-source microblogging tool
 * Copyright (C) 2008, StatusNet, Inc.
 *
 * 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/>.
 *
 * @category  UI interaction
 * @package   StatusNet
 * @author    Sarven Capadisli <csarven@status.net>
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2009 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link      http://status.net/
 */

$(document).ready(function(){
    if ($('body.user_in').length > 0) {
        if ($('#'+SN.C.S.NoticeDataText).length) {
            if (maxLength > 0) {
                $('#'+SN.C.S.NoticeDataText).bind('keyup', function(e) {
                    SN.U.Counter();
                });
                // run once in case there's something in there
                SN.U.Counter();
            }

            $('#'+SN.C.S.NoticeDataText).bind('keydown', function(e) {
                SN.U.SubmitOnReturn(e, $('#'+SN.C.S.FormNotice));
            });

            if($('body')[0].id != 'conversation') {
                $('#'+SN.C.S.NoticeDataText).focus();
            }
        }

        $('.form_user_subscribe').each(function() { SN.U.FormXHR($(this)); });
        $('.form_user_unsubscribe').each(function() { SN.U.FormXHR($(this)); });
        $('.form_favor').each(function() { SN.U.FormXHR($(this)); });
        $('.form_disfavor').each(function() { SN.U.FormXHR($(this)); });
        $('.form_group_join').each(function() { SN.U.FormXHR($(this)); });
        $('.form_group_leave').each(function() { SN.U.FormXHR($(this)); });
        $('.form_user_nudge').each(function() { SN.U.FormXHR($(this)); });

        SN.U.FormNoticeXHR();

        SN.U.NoticeReply();

        SN.U.NoticeDataAttach();
    }

    SN.U.NoticeAttachments();
});

var SN = { // StatusNet
    C: { // Config
        I: { // Init
            CounterBlackout: false,
            MaxLength: 140,
            PatternUsername: /^[0-9a-zA-Z\-_.]*$/,
            HTTP20x30x: [200, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307]
        },

        S: { // Selector
            Disabled: 'disabled',
            Warning: 'warning',
            Error: 'error',
            Success: 'success',
            Processing: 'processing',
            CommendResult: 'command_result',
            FormNotice: 'form_notice',
            NoticeDataText: 'notice_data-text',
            NoticeTextCount: 'notice_text-count',
            NoticeInReplyTo: 'notice_in-reply-to',
            NoticeDataAttach: 'notice_data-attach',
            NoticeDataAttachSelected: 'notice_data-attach_selected',
            NoticeActionSubmit: 'notice_action-submit',
        }
    },

    U: { // Utils
        SubmitOnReturn: function(event, el) {
            if (event.keyCode == 13 || event.keyCode == 10) {
                el.submit();
                event.preventDefault();
                event.stopPropagation();
                $('#'+SN.U.NoticeDataText).blur();
                $('body').focus();
                return false;
            }
            return true;
        },

        Counter: function() {
            if (typeof(maxLength) == "undefined") {
                 maxLength = SN.C.I.MaxLength;
            }

            if (maxLength <= 0) {
                return;
            }

            var remaining = maxLength - $('#'+SN.C.S.NoticeDataText).val().length;
            var counter = $('#'+SN.C.S.NoticeTextCount);

            if (remaining.toString() != counter.text()) {
                if (!SN.C.I.CounterBlackout || remaining == 0) {
                    if (counter.text() != String(remaining)) {
                        counter.text(remaining);
                    }
                    if (remaining < 0) {
                        $('#'+SN.C.S.FormNotice).addClass(SN.C.S.Warning);
                    } else {
                        $('#'+SN.C.S.FormNotice).removeClass(SN.C.S.Warning);
                    }
                    // Skip updates for the next 500ms.
                    // On slower hardware, updating on every keypress is unpleasant.
                    if (!SN.C.I.CounterBlackout) {
                        SN.C.I.CounterBlackout = true;
                        window.setTimeout(SN.U.ClearCounterBlackout, 500);
                    }
                }
            }
        },

        ClearCounterBlackout: function() {
            // Allow keyup events to poke the counter again
            SN.C.I.CounterBlackout = false;
            // Check if the string changed since we last looked
            SN.U.Counter(null);
        },

        FormXHR: function(f) {
            f.bind('submit', function(e) {
                form_id = $(this)[0].id;
                $.ajax({
                    type: 'POST',
                    url: $(this)[0].action,
                    data: $(this).serialize() + '&ajax=1',
                    beforeSend: function(xhr) {
                        $('#'+form_id).addClass(SN.C.S.Processing);
                        $('#'+form_id+' .submit').addClass(SN.C.S.Disabled);
                        $('#'+form_id+' .submit').attr(SN.C.S.Disabled, SN.C.S.Disabled);
                    },
                    error: function (xhr, textStatus, errorThrown) {
                        alert(errorThrown || textStatus);
                    },
                    success: function(data, textStatus) {
                        if ($('form', data)[0].length > 0) {
                            form_new = $('form', data)[0];
                            $('#'+form_id).replaceWith(document._importNode(form_new, true));
                            $('#'+form_new.id).each(function() { SN.U.FormXHR($(this)); });
                        }
                        else {
                            $('#'+form_id).replaceWith(document._importNode($('p', data)[0], true));
                        }
                    }
                });
                return false;
            });
        },

        FormNoticeXHR: function() {
            $('#'+SN.C.S.FormNotice).append('<input type="hidden" name="ajax" value="1"/>');
            $('#'+SN.C.S.FormNotice).ajaxForm({
                timeout: '60000',
                dataType: 'xml',
                beforeSend: function(xhr) {
                    if ($('#'+SN.C.S.NoticeDataText)[0].value.length === 0) {
                        $('#'+SN.C.S.FormNotice).addClass(SN.C.S.Warning);
                        return false;
                    }
                    $('#'+SN.C.S.FormNotice).addClass(SN.C.S.Processing);
                    $('#'+SN.C.S.NoticeActionSubmit).addClass(SN.C.S.Disabled);
                    $('#'+SN.C.S.NoticeActionSubmit).attr(SN.C.S.Disabled, SN.C.S.Disabled);
                    return true;
                },
                error: function (xhr, textStatus, errorThrown) {
                    $('#'+SN.C.S.FormNotice).removeClass(SN.C.S.Processing);
                    $('#'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled);
                    $('#'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled, SN.C.S.Disabled);
                    if (textStatus == 'timeout') {
                        alert ('Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists');
                    }
                    else {
                        if ($('.'+SN.C.S.Error, xhr.responseXML).length > 0) {
                            $('#'+SN.C.S.FormNotice).append(document._importNode($('.'+SN.C.S.Error, xhr.responseXML)[0], true));
                        }
                        else {
                            if(jQuery.inArray(parseInt(xhr.status), SN.C.I.HTTP20x30x) < 0) {
                                alert('Sorry! We had trouble sending your notice ('+xhr.status+' '+xhr.statusText+'). Please report the problem to the site administrator if this happens again.');
                            }
                            else {
                                SN.C.I.NoticeDataText.val('');
                                SN.U.Counter();
                            }
                        }
                    }
                },
                success: function(data, textStatus) {
                    if ($('#'+SN.C.S.Error, data).length > 0) {
                        var result = document._importNode($('p', data)[0], true);
                        alert(result.textContent || result.innerHTML);
                    }
                    else {
                        if($('body')[0].id == 'bookmarklet') {
                            self.close();
                        }
                        if ($('#'+SN.C.S.CommandResult, data).length > 0) {
                            var result = document._importNode($('p', data)[0], true);
                            alert(result.textContent || result.innerHTML);
                        }
                        else {
                             notice = $('li', data)[0];
                             if ($('#'+notice.id).length === 0) {
                                var notice_irt_value = $('#'+SN.C.S.NoticeInReplyTo).val();
                                var notice_irt = '#notices_primary #notice-'+notice_irt_value;
                                if($('body')[0].id == 'conversation') {
                                    if(notice_irt_value.length > 0 && $(notice_irt+' .notices').length < 1) {
                                        $(notice_irt).append('

');
                                    }
                                    $($(notice_irt+' .notices')[0]).append(document._importNode(notice, true));
                                }
                                else {
                                    $("#notices_primary .notices").prepend(document._importNode(notice, true));
                                }
                                $('#'+notice.id).css({display:'none'});
                                $('#'+notice.id).fadeIn(2500);
                                SN.U.NoticeAttachments();
                                SN.U.NoticeReply();
                             }
                        }
                        $('#'+SN.C.S.NoticeDataText).val('');
                        $('#'+SN.C.S.NoticeDataAttach).val('');
                        $('#'+SN.C.S.NoticeInReplyTo).val('');
                        SN.U.Counter();
                    }
                },
                complete: function(xhr, textStatus) {
                    $('#'+SN.C.S.FormNotice).removeClass(SN.C.S.Processing);
                    $('#'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled);
                    $('#'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled);
                }
            });
        },

        NoticeReply: function() {
            if ($('#'+SN.C.S.NoticeDataText).length > 0 && $('#content .notice_reply').length > 0) {
                $('#content .notice').each(function() {
                    var notice = $(this)[0];
                    $($('.notice_reply', notice)[0]).click(function() {
                        var nickname = ($('.author .nickname', notice).length > 0) ? $($('.author .nickname', notice)[0]) : $('.author .nickname.uid');
                        SN.U.NoticeReplySet(nickname.text(), $($('.notice_id', notice)[0]).text());
                        return false;
                    });
                });
            }
        },

        NoticeReplySet: function(nick,id) {
            if (nick.match(SN.C.I.PatternUsername)) {
                var text = $('#'+SN.C.S.NoticeDataText);
                if (text.length) {
                    replyto = '@' + nick + ' ';
                    text.val(replyto + text.val().replace(RegExp(replyto, 'i'), ''));
                    $('#'+SN.C.S.FormNotice+' input#'+SN.C.S.NoticeInReplyTo).val(id);
                    if (text.get(0).setSelectionRange) {
                        var len = text.val().length;
                        text.get(0).setSelectionRange(len,len);
                        text.get(0).focus();
                    }
                    return false;
                }
            }
            return true;
        },

        NoticeAttachments: function() {
            $.fn.jOverlay.options = {
                method : 'GET',
                data : '',
                url : '',
                color : '#000',
                opacity : '0.6',
                zIndex : 99,
                center : false,
                imgLoading : $('address .url')[0].href+'theme/base/images/illustrations/illu_progress_loading-01.gif',
                bgClickToClose : true,
                success : function() {
                    $('#jOverlayContent').append('<button>×</button>');
                    $('#jOverlayContent button').click($.closeOverlay);
                },
                timeout : 0,
                autoHide : true,
                css : {'max-width':'542px', 'top':'5%', 'left':'32.5%'}
            };

            $('#content .notice a.attachment').click(function() {
                $().jOverlay({url: $('address .url')[0].href+'attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'});
                return false;
            });

            var t;
            $("body:not(#shownotice) #content .notice a.thumbnail").hover(
                function() {
                    var anchor = $(this);
                    $("a.thumbnail").children('img').hide();
                    anchor.closest(".entry-title").addClass('ov');

                    if (anchor.children('img').length == 0) {
                        t = setTimeout(function() {
                            $.get($('address .url')[0].href+'attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) {
                                anchor.append(data);
                            });
                        }, 500);
                    }
                    else {
                        anchor.children('img').show();
                    }
                },
                function() {
                    clearTimeout(t);
                    $("a.thumbnail").children('img').hide();
                    $(this).closest(".entry-title").removeClass('ov');
                }
            );
        },

        NoticeDataAttach: function() {
            NDA = $('#'+SN.C.S.NoticeDataAttach);
            NDA.change(function() {
                S = '
'+$(this).val()+' <button>×</button>
';
                NDAS = $('#'+SN.C.S.NoticeDataAttachSelected);
                (NDAS.length > 0) ? NDAS.replaceWith(S) : $('#'+SN.C.S.FormNotice).append(S);
                $('#'+SN.C.S.NoticeDataAttachSelected+' button').click(function(){
                    $('#'+SN.C.S.NoticeDataAttachSelected).remove();
                    NDA.val('');
                });
            });
        }
    }
}
<commit_msg>Remove attachment view after XHR notice submit<commit_after>/*
 * StatusNet - a distributed open-source microblogging tool
 * Copyright (C) 2008, StatusNet, Inc.
 *
 * 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/>.
 *
 * @category  UI interaction
 * @package   StatusNet
 * @author    Sarven Capadisli <csarven@status.net>
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2009 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link      http://status.net/
 */

$(document).ready(function(){
    if ($('body.user_in').length > 0) {
        if ($('#'+SN.C.S.NoticeDataText).length) {
            if (maxLength > 0) {
                $('#'+SN.C.S.NoticeDataText).bind('keyup', function(e) {
                    SN.U.Counter();
                });
                // run once in case there's something in there
                SN.U.Counter();
            }

            $('#'+SN.C.S.NoticeDataText).bind('keydown', function(e) {
                SN.U.SubmitOnReturn(e, $('#'+SN.C.S.FormNotice));
            });

            if($('body')[0].id != 'conversation') {
                $('#'+SN.C.S.NoticeDataText).focus();
            }
        }

        $('.form_user_subscribe').each(function() { SN.U.FormXHR($(this)); });
        $('.form_user_unsubscribe').each(function() { SN.U.FormXHR($(this)); });
        $('.form_favor').each(function() { SN.U.FormXHR($(this)); });
        $('.form_disfavor').each(function() { SN.U.FormXHR($(this)); });
        $('.form_group_join').each(function() { SN.U.FormXHR($(this)); });
        $('.form_group_leave').each(function() { SN.U.FormXHR($(this)); });
        $('.form_user_nudge').each(function() { SN.U.FormXHR($(this)); });

        SN.U.FormNoticeXHR();

        SN.U.NoticeReply();

        SN.U.NoticeDataAttach();
    }

    SN.U.NoticeAttachments();
});

var SN = { // StatusNet
    C: { // Config
        I: { // Init
            CounterBlackout: false,
            MaxLength: 140,
            PatternUsername: /^[0-9a-zA-Z\-_.]*$/,
            HTTP20x30x: [200, 201, 202, 203, 204, 205, 206, 300, 301, 302, 303, 304, 305, 306, 307]
        },

        S: { // Selector
            Disabled: 'disabled',
            Warning: 'warning',
            Error: 'error',
            Success: 'success',
            Processing: 'processing',
            CommendResult: 'command_result',
            FormNotice: 'form_notice',
            NoticeDataText: 'notice_data-text',
            NoticeTextCount: 'notice_text-count',
            NoticeInReplyTo: 'notice_in-reply-to',
            NoticeDataAttach: 'notice_data-attach',
            NoticeDataAttachSelected: 'notice_data-attach_selected',
            NoticeActionSubmit: 'notice_action-submit',
        }
    },

    U: { // Utils
        SubmitOnReturn: function(event, el) {
            if (event.keyCode == 13 || event.keyCode == 10) {
                el.submit();
                event.preventDefault();
                event.stopPropagation();
                $('#'+SN.U.NoticeDataText).blur();
                $('body').focus();
                return false;
            }
            return true;
        },

        Counter: function() {
            if (typeof(maxLength) == "undefined") {
                 maxLength = SN.C.I.MaxLength;
            }

            if (maxLength <= 0) {
                return;
            }

            var remaining = maxLength - $('#'+SN.C.S.NoticeDataText).val().length;
            var counter = $('#'+SN.C.S.NoticeTextCount);

            if (remaining.toString() != counter.text()) {
                if (!SN.C.I.CounterBlackout || remaining == 0) {
                    if (counter.text() != String(remaining)) {
                        counter.text(remaining);
                    }
                    if (remaining < 0) {
                        $('#'+SN.C.S.FormNotice).addClass(SN.C.S.Warning);
                    } else {
                        $('#'+SN.C.S.FormNotice).removeClass(SN.C.S.Warning);
                    }
                    // Skip updates for the next 500ms.
                    // On slower hardware, updating on every keypress is unpleasant.
                    if (!SN.C.I.CounterBlackout) {
                        SN.C.I.CounterBlackout = true;
                        window.setTimeout(SN.U.ClearCounterBlackout, 500);
                    }
                }
            }
        },

        ClearCounterBlackout: function() {
            // Allow keyup events to poke the counter again
            SN.C.I.CounterBlackout = false;
            // Check if the string changed since we last looked
            SN.U.Counter(null);
        },

        FormXHR: function(f) {
            f.bind('submit', function(e) {
                form_id = $(this)[0].id;
                $.ajax({
                    type: 'POST',
                    url: $(this)[0].action,
                    data: $(this).serialize() + '&ajax=1',
                    beforeSend: function(xhr) {
                        $('#'+form_id).addClass(SN.C.S.Processing);
                        $('#'+form_id+' .submit').addClass(SN.C.S.Disabled);
                        $('#'+form_id+' .submit').attr(SN.C.S.Disabled, SN.C.S.Disabled);
                    },
                    error: function (xhr, textStatus, errorThrown) {
                        alert(errorThrown || textStatus);
                    },
                    success: function(data, textStatus) {
                        if ($('form', data)[0].length > 0) {
                            form_new = $('form', data)[0];
                            $('#'+form_id).replaceWith(document._importNode(form_new, true));
                            $('#'+form_new.id).each(function() { SN.U.FormXHR($(this)); });
                        }
                        else {
                            $('#'+form_id).replaceWith(document._importNode($('p', data)[0], true));
                        }
                    }
                });
                return false;
            });
        },

        FormNoticeXHR: function() {
            $('#'+SN.C.S.FormNotice).append('<input type="hidden" name="ajax" value="1"/>');
            $('#'+SN.C.S.FormNotice).ajaxForm({
                timeout: '60000',
                dataType: 'xml',
                beforeSend: function(xhr) {
                    if ($('#'+SN.C.S.NoticeDataText)[0].value.length === 0) {
                        $('#'+SN.C.S.FormNotice).addClass(SN.C.S.Warning);
                        return false;
                    }
                    $('#'+SN.C.S.FormNotice).addClass(SN.C.S.Processing);
                    $('#'+SN.C.S.NoticeActionSubmit).addClass(SN.C.S.Disabled);
                    $('#'+SN.C.S.NoticeActionSubmit).attr(SN.C.S.Disabled, SN.C.S.Disabled);
                    return true;
                },
                error: function (xhr, textStatus, errorThrown) {
                    $('#'+SN.C.S.FormNotice).removeClass(SN.C.S.Processing);
                    $('#'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled);
                    $('#'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled, SN.C.S.Disabled);
                    if (textStatus == 'timeout') {
                        alert ('Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists');
                    }
                    else {
                        if ($('.'+SN.C.S.Error, xhr.responseXML).length > 0) {
                            $('#'+SN.C.S.FormNotice).append(document._importNode($('.'+SN.C.S.Error, xhr.responseXML)[0], true));
                        }
                        else {
                            if(jQuery.inArray(parseInt(xhr.status), SN.C.I.HTTP20x30x) < 0) {
                                alert('Sorry! We had trouble sending your notice ('+xhr.status+' '+xhr.statusText+'). Please report the problem to the site administrator if this happens again.');
                            }
                            else {
                                SN.C.I.NoticeDataText.val('');
                                SN.U.Counter();
                            }
                        }
                    }
                },
                success: function(data, textStatus) {
                    if ($('#'+SN.C.S.Error, data).length > 0) {
                        var result = document._importNode($('p', data)[0], true);
                        alert(result.textContent || result.innerHTML);
                    }
                    else {
                        if($('body')[0].id == 'bookmarklet') {
                            self.close();
                        }
                        if ($('#'+SN.C.S.CommandResult, data).length > 0) {
                            var result = document._importNode($('p', data)[0], true);
                            alert(result.textContent || result.innerHTML);
                        }
                        else {
                             notice = $('li', data)[0];
                             if ($('#'+notice.id).length == 0) {
                                var notice_irt_value = $('#'+SN.C.S.NoticeInReplyTo).val();
                                var notice_irt = '#notices_primary #notice-'+notice_irt_value;
                                if($('body')[0].id == 'conversation') {
                                    if(notice_irt_value.length > 0 && $(notice_irt+' .notices').length < 1) {
                                        $(notice_irt).append('

');
                                    }
                                    $($(notice_irt+' .notices')[0]).append(document._importNode(notice, true));
                                }
                                else {
                                    $("#notices_primary .notices").prepend(document._importNode(notice, true));
                                }
                                $('#'+notice.id).css({display:'none'});
                                $('#'+notice.id).fadeIn(2500);
                                SN.U.NoticeAttachments();
                                SN.U.NoticeReply();
                             }
                        }
                        $('#'+SN.C.S.NoticeDataText).val('');
                        $('#'+SN.C.S.NoticeDataAttach).val('');
                        $('#'+SN.C.S.NoticeInReplyTo).val('');
                        $('#'+SN.C.S.NoticeDataAttachSelected).remove();
                        SN.U.Counter();
                    }
                },
                complete: function(xhr, textStatus) {
                    $('#'+SN.C.S.FormNotice).removeClass(SN.C.S.Processing);
                    $('#'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled);
                    $('#'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled);
                }
            });
        },

        NoticeReply: function() {
            if ($('#'+SN.C.S.NoticeDataText).length > 0 && $('#content .notice_reply').length > 0) {
                $('#content .notice').each(function() {
                    var notice = $(this)[0];
                    $($('.notice_reply', notice)[0]).click(function() {
                        var nickname = ($('.author .nickname', notice).length > 0) ? $($('.author .nickname', notice)[0]) : $('.author .nickname.uid');
                        SN.U.NoticeReplySet(nickname.text(), $($('.notice_id', notice)[0]).text());
                        return false;
                    });
                });
            }
        },

        NoticeReplySet: function(nick,id) {
            if (nick.match(SN.C.I.PatternUsername)) {
                var text = $('#'+SN.C.S.NoticeDataText);
                if (text.length) {
                    replyto = '@' + nick + ' ';
                    text.val(replyto + text.val().replace(RegExp(replyto, 'i'), ''));
                    $('#'+SN.C.S.FormNotice+' input#'+SN.C.S.NoticeInReplyTo).val(id);
                    if (text.get(0).setSelectionRange) {
                        var len = text.val().length;
                        text.get(0).setSelectionRange(len,len);
                        text.get(0).focus();
                    }
                    return false;
                }
            }
            return true;
        },

        NoticeAttachments: function() {
            $.fn.jOverlay.options = {
                method : 'GET',
                data : '',
                url : '',
                color : '#000',
                opacity : '0.6',
                zIndex : 99,
                center : false,
                imgLoading : $('address .url')[0].href+'theme/base/images/illustrations/illu_progress_loading-01.gif',
                bgClickToClose : true,
                success : function() {
                    $('#jOverlayContent').append('<button>×</button>');
                    $('#jOverlayContent button').click($.closeOverlay);
                },
                timeout : 0,
                autoHide : true,
                css : {'max-width':'542px', 'top':'5%', 'left':'32.5%'}
            };

            $('#content .notice a.attachment').click(function() {
                $().jOverlay({url: $('address .url')[0].href+'attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'});
                return false;
            });

            var t;
            $("body:not(#shownotice) #content .notice a.thumbnail").hover(
                function() {
                    var anchor = $(this);
                    $("a.thumbnail").children('img').hide();
                    anchor.closest(".entry-title").addClass('ov');

                    if (anchor.children('img').length == 0) {
                        t = setTimeout(function() {
                            $.get($('address .url')[0].href+'attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) {
                                anchor.append(data);
                            });
                        }, 500);
                    }
                    else {
                        anchor.children('img').show();
                    }
                },
                function() {
                    clearTimeout(t);
                    $("a.thumbnail").children('img').hide();
                    $(this).closest(".entry-title").removeClass('ov');
                }
            );
        },

        NoticeDataAttach: function() {
            NDA = $('#'+SN.C.S.NoticeDataAttach);
            NDA.change(function() {
                S = '
'+$(this).val()+' <button>×</button>
';
                NDAS = $('#'+SN.C.S.NoticeDataAttachSelected);
                (NDAS.length > 0) ? NDAS.replaceWith(S) : $('#'+SN.C.S.FormNotice).append(S);
                $('#'+SN.C.S.NoticeDataAttachSelected+' button').click(function(){
                    $('#'+SN.C.S.NoticeDataAttachSelected).remove();
                    NDA.val('');
                });
            });
        }
    }
}
<|endoftext|>


<commit_before>var xeit = (function () {
    "use strict";

    function parse($doc, html) {
        if ($('#XEIViewer').length || html.indexOf('XEIViewer') > -1) {
            return {
                func: 'init',
                opts: { plugin: 'SoftForum' },
                args: [
                    html,
                    $('param[name="smime_header"]').val(),
                    $('param[name="smime_body"]').val(),
                    $('param[name="info_msg"]').val(),
                    $('param[name="ui_option"]').val(),
                    $('param[name="ui_desc"]').val()
                ]
            };
        } else if (html.indexOf('IniMasPlugin') > -1) {
            //HACK: IE에서만 동작하는 activeControl() (function.js) 이슈 회피.
            var body = html.replace(
                /activeControl\(([\s]*['"])/,
                "var activeControl = function (a, b, c) {" +
                    "var d = document.createElement('div');" +
                    "d.innerHTML = \"<OBJECT ID='IniMasPluginObj'>\" + a;" +
                    "d.firstChild.innerHTML = b + c;" +
                    "document.getElementById('embedControl').appendChild(d);" +
                "}($1"
            ).replace(
                /^[\s\S]*<body.*?>|<\/body>[\s\S]*$/ig,
                ''
            );
            $doc.empty().append($.parseHTML(body, true));

            return {
                func: 'init',
                opts: { plugin: 'IniTech' },
                args: [
                    html,
                    $('param[name="IniSMContents"]').val(),
                    $('param[name="Question"]').val(),
                    $('param[name="AttachedFile"]').val()
                ]
            };
        } else if (html.indexOf('IniCrossMailObj') > -1) {
            return {
                func: 'init',
                opts: { plugin: 'IniTech' },
                args: [
                    html,
                    $('param[name="IniSMContents"]').val(),
                    $('param[name="Question"]').val(),
                    $('param[name="AttachedFile"]').val(),
                    $('param[name="OptData"]').val()
                ]
            };
        } else if ($('#JXCEAL').length) {
            return {
                func: 'init',
                opts: { plugin: 'Soft25' },
                args: [
                    html,
                    $('#JSEncContents').val()
                ]
            };
        } else if ($('#MailDec').length) {
            return {
                func: 'init',
                opts: { plugin: 'Natingtel' },
                args: [
                    html,
                    $('param[name="DocumentMail"]').val()
                ]
            };
        } else {
            return {
                func: 'init',
                opts: { plugin: 'Vendor' },
                args: []
            }
        }
    }

    function check(html) {
        //HACK: <object> 태그의 상위 노드로써 DOM에 임시로 추가하여 query 수행.
        var $doc = $('<div>', { id: 'Xeit-temp' }).hide().appendTo($('body')).append($.parseHTML(html));
        var info = parse($doc, html);
        $doc.remove();
        return info;
    }

    var worker = new Worker('js/worker.js');
    function work(func, opts, args, success, failure) {
        var messageHandler = function (e) {
            if (e.data.func == func) {
                success(e.data.resp);
                removeHandlers();
            }
        };
        worker.addEventListener('message', messageHandler);

        var errorHandler = function (e) {
            failure(e);
            removeHandlers();
        };
        worker.addEventListener('error', errorHandler);

        function removeHandlers() {
            worker.removeEventListener('message', messageHandler);
            worker.removeEventListener('error', errorHandler);
        }

        worker.postMessage({
            func: func,
            opts: opts,
            args: args
        });
    }

    return {
        init: function (html, success, failure) {
            var info = check(html);
            work(info.func, info.opts, info.args, success, failure);
        },

        load: function (password, success, failure) {
            work('load', {}, [password], success, failure);
        }
    };
})();
<commit_msg>Improve detection of mails from Softforum and IniTech (#54)<commit_after>var xeit = (function () {
    "use strict";

    function parse($doc, html) {
        if ($('#XEIViewer').length || (html.indexOf('PrintObjectTag') > -1 && html.indexOf('XEIViewer') > -1)) {
            return {
                func: 'init',
                opts: { plugin: 'SoftForum' },
                args: [
                    html,
                    $('param[name="smime_header"]').val(),
                    $('param[name="smime_body"]').val(),
                    $('param[name="info_msg"]').val(),
                    $('param[name="ui_option"]').val(),
                    $('param[name="ui_desc"]').val()
                ]
            };
        } else if ($('#IniMasPluginObj').length || (html.indexOf('activeControl') > -1 && html.indexOf('IniMasPlugin') > -1)) {
            //HACK: IE에서만 동작하는 activeControl() (function.js) 이슈 회피.
            var body = html.replace(
                /activeControl\(([\s]*['"])/,
                "var activeControl = function (a, b, c) {" +
                    "var d = document.createElement('div');" +
                    "d.innerHTML = \"<OBJECT ID='IniMasPluginObj'>\" + a;" +
                    "d.firstChild.innerHTML = b + c;" +
                    "document.getElementById('embedControl').appendChild(d);" +
                "}($1"
            ).replace(
                /^[\s\S]*<body.*?>|<\/body>[\s\S]*$/ig,
                ''
            );
            $doc.empty().append($.parseHTML(body, true));

            return {
                func: 'init',
                opts: { plugin: 'IniTech' },
                args: [
                    html,
                    $('param[name="IniSMContents"]').val(),
                    $('param[name="Question"]').val(),
                    $('param[name="AttachedFile"]').val()
                ]
            };
        } else if ($('#IniCrossMailObj').length) {
            return {
                func: 'init',
                opts: { plugin: 'IniTech' },
                args: [
                    html,
                    $('param[name="IniSMContents"]').val(),
                    $('param[name="Question"]').val(),
                    $('param[name="AttachedFile"]').val(),
                    $('param[name="OptData"]').val()
                ]
            };
        } else if ($('#JXCEAL').length) {
            return {
                func: 'init',
                opts: { plugin: 'Soft25' },
                args: [
                    html,
                    $('#JSEncContents').val()
                ]
            };
        } else if ($('#MailDec').length) {
            return {
                func: 'init',
                opts: { plugin: 'Natingtel' },
                args: [
                    html,
                    $('param[name="DocumentMail"]').val()
                ]
            };
        } else {
            return {
                func: 'init',
                opts: { plugin: 'Vendor' },
                args: []
            }
        }
    }

    function check(html) {
        //HACK: <object> 태그의 상위 노드로써 DOM에 임시로 추가하여 query 수행.
        var $doc = $('<div>', { id: 'Xeit-temp' }).hide().appendTo($('body')).append($.parseHTML(html));
        var info = parse($doc, html);
        $doc.remove();
        return info;
    }

    var worker = new Worker('js/worker.js');
    function work(func, opts, args, success, failure) {
        var messageHandler = function (e) {
            if (e.data.func == func) {
                success(e.data.resp);
                removeHandlers();
            }
        };
        worker.addEventListener('message', messageHandler);

        var errorHandler = function (e) {
            failure(e);
            removeHandlers();
        };
        worker.addEventListener('error', errorHandler);

        function removeHandlers() {
            worker.removeEventListener('message', messageHandler);
            worker.removeEventListener('error', errorHandler);
        }

        worker.postMessage({
            func: func,
            opts: opts,
            args: args
        });
    }

    return {
        init: function (html, success, failure) {
            var info = check(html);
            work(info.func, info.opts, info.args, success, failure);
        },

        load: function (password, success, failure) {
            work('load', {}, [password], success, failure);
        }
    };
})();
<|endoftext|>


<commit_before>'use strict';

var React                 = require('react-native');
var Icon                  = require('react-native-vector-icons/Ionicons');
var BackgroundGeolocation = require('react-native-background-geolocation');
var SettingsService       = require('./SettingsService');

SettingsService.init('iOS');

var mapRef = 'mapRef';

var {
  AsyncStorage,
  StyleSheet,
  MapView,
  AppStateIOS,
  Text,
  TextInput,
  View,
  SwitchIOS,
  Navigator,
  NavButton,
  TouchableHighlight
} = React;

var Map = React.createClass({

  getInitialState() {
    var me = this;

    AsyncStorage.getItem("state")
    .then((values) => {
      if (values !== null){
        values = JSON.parse(values);
        values.isStationary = true;
        me.setState(values);
        if (values.isEnabled) {
          me.onToggleEnabled(values.isEnabled);
        }
      }
    })
    .catch((error) => console.error("- error: ", error.message))
    .done();

    AppStateIOS.addEventListener('change', this.onAppStateChange);

    this.bgGeo = BackgroundGeolocation;

    // Fetch bg-geo settings.
    SettingsService.getValues(function(values) {

      // Configure Background Geolocation.
      me.bgGeo.configure(values);

      me.bgGeo.getState(function(s) {
        console.log('----------- getState: ', s);
      }, function(error) {
        console.log('----------- ERROR: getState: ', error);
      });
      me.bgGeo.getOdometer(function(v) {
        console.log('------------- getOdometer: ', v);
      });
      me.bgGeo.resetOdometer(function(v) {
        console.log('------------- resetOdometer: ', v);
      });

      me.bgGeo.getCurrentPosition({}, function(location) {
        console.log('------------- getCurrentPosition: ', JSON.stringify(location));
        me.bgGeo.addGeofence({
          identifier: 'Home',
          latitude: location.coords.latitude,
          longitude: location.coords.longitude,
          radius: 200,
          notifyOnExit: true
        }, function(v) {
          console.log('----------- addGeofence success');
          me.bgGeo.getGeofences(function(rs) {
            console.log('----------- geofences: ', JSON.stringify(rs));
          }, function(error) {
            console.log('----------- ERROR: getGeofences: ', error);
          });
        }, function(error) {
          console.log('----------- ERROR: addGefence');
        });
      }, function(error) {
        console.warn('------------ getCurrentPosition error: ', error);
      });
      me.bgGeo.on('geofence', function(geofence) {
        console.log('----------- Event: geofence: ', JSON.stringify(geofence));
        me.bgGeo.removeGeofence(geofence.identifier, function(v) {
          console.log('---------------- removeGeofence SUCCESS');
          me.bgGeo.getGeofences(function(rs) {
            console.log('------------ getGeofences: ', JSON.stringify(rs));
          });
        }, function(error) {
          conosle.log('---------------- ERROR: removeGeofence');
        });
      })
      me.bgGeo.getState(function(state) {
        console.log('BackgroundGeolocation state: ', state);
      });

      // Event: location.  Listen to location events coming out.
      me.bgGeo.on('location', me.onBackgroundGeolocation);

      // Event: motionchange. Listen to motionchange events.
      me.bgGeo.on('motionchange', function(location) {
        console.log('- motionchanged: ', JSON.stringify(location));
        me.setState({
          isStationary: !location.is_moving,
          paceButtonStyle: (location.is_moving) ? styles.redButton : styles.greenButton
        });
      });

      // Event: sync:  This fires after plugin successfully synced to server.
      me.bgGeo.on('sync', function(rs) {
        console.log('- sync complete: ', JSON.stringify(rs));
      });

      // Event: http
      me.bgGeo.on('http', function(response) {
        console.log('- EVENT: http', JSON.stringify(response));
      });

      // Event: error
      me.bgGeo.on('error', function(error) {
        alert(error.type + ' error: ' + error.code);
        console.log('- ERROR: ', JSON.stringify(error));
      });
    });

    return {
      zoom: 11,
      odometer: 0,
      isEnabled: false,
      isStationary: true,
      paceButtonStyle: styles.greenButton,
      navigateButton: 'navigate'
    };
  },
  onAppStateChange(state) {
    if (state === 'active') {
      var me = this;
      me.bgGeo.getCurrentPosition({timeout: 1000}, function(location) {
        console.log('- received current position: ', location);
      }, function(error) {
        alert('Location error: ' + error);
      });
    }
  },
  onClickSettings() {
    this.props.navigator.push({
      id: 'settings',
      sceneConfig: Navigator.SceneConfigs.FloatFromBottom,
    });
  },
  onToggleEnabled(enabled) {
    var me = this;

    if (!enabled && !this.state.isStationary) {
      this.onToggleStationary();
    }
    this.setState({
      isEnabled: enabled,
      odometer: 0
    }, function() {
      AsyncStorage.setItem("state", JSON.stringify(me.state));
    });

    this.bgGeo.resetOdometer(function() {
      console.log('- resetOdometer success');
    });

    if (enabled) {
      this.bgGeo.start(function() {
        // Successfully started.  Now fetch current position.
        me.bgGeo.getCurrentPosition({timeout: 1000}, function(location) {
          console.log('[js] received current position: ', location);
        }, function(error) {
          alert('Location error: ' + error);
        });
      });
    } else {
      this.bgGeo.stop();
    }
  },
  onToggleStationary() {
    var me = this;
    var value = !this.state.isStationary;

    this.setState({
      isStationary: value,
      paceButtonStyle: (value) ? styles.greenButton : styles.redButton
    });

    this.bgGeo.changePace(!value);
  },
  onUpdatePosition() {
    var me = this;
    this.setState({
      navigateButton: 'load-d'
    });

    me.bgGeo.getCurrentPosition({timeout: 1000}, function(location) {
      me.bgGeo.getGeofences(function(rs) {
        console.log('- current geofences: ', rs);
      });
      me.setState({
        navigateButton: 'navigate'
      });
    }, function(error) {
      alert('Location error: ' + error);
      me.setState({
        navigateButton: 'navigate'
      });
    });
  },
  onBackgroundGeolocation(location) {
    console.log('- [js] bgGeo location: ', JSON.stringify(location));
    var me    = this,
        now   = ((location.timestamp) ? new Date(location.timestamp) : new Date()),
        label = [now.getHours(), now.getMinutes(), now.getSeconds()].join(':');

    me.bgGeo.getOdometer(function(distance) {
      me.setState({
        odometer: (distance/1000).toFixed(1)
      });
    });
  },
  onRegionChange(location) {
    //this.setState({ currentZoom: location.zoom });
  },
  onRegionWillChange(location) {
    //console.log(location);
  },
  onUpdateUserLocation(location) {
    //console.log('[js]MapBox location: ', location);
  },
  onOpenAnnotation(annotation) {
    //console.log(annotation);
  },
  onRightAnnotationTapped(e) {
    //console.log(e);
  },
  render: function() {

    return (
      <View style={styles.container}>
        <View style={styles.map}><Text>Map Goes Here</Text></View>
        <View style={styles.toolbar}>
          <TouchableHighlight style={[styles.locationButton, styles.iconButton]} underlayColor={"transparent"} onPress={this.onUpdatePosition}>
            <Icon name={this.state.navigateButton} size={24} color="#4f8ef7" />
          </TouchableHighlight>
          <Text>{this.state.odometer}km</Text>

          <SwitchIOS style={styles.enabledButton} value={this.state.isEnabled} onValueChange={this.onToggleEnabled}></SwitchIOS>

          <TouchableHighlight style={[this.state.paceButtonStyle, styles.stationaryButton, styles.iconButton]} underlayColor={"transparent"} onPress={this.onToggleStationary}>
            <Icon name={this.state.isStationary ? 'play' : 'pause'} size={24} />
          </TouchableHighlight>

        </View>
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    marginTop: 10,
    backgroundColor: 'transparent',
  },
  map: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  toolbar: {
    //top: 50,
    height: 50,
    padding: 5,
    justifyContent: 'center',
    alignItems: 'center'
  },
  settingsButton: {
    position: 'absolute',
    left: 10,
    top: 15
  },
  buttonText: {
    color: 'blue',
    fontSize: 16
  },
  locationButton: {
    position: 'absolute',
    left: 0,
    top: 0
  },
  spinner: {
    position: 'absolute',
    top: 10,
    left: 40
  },
  iconButton: {
    width: 50,
    height: 50,
    justifyContent: 'center',
    alignItems: 'center'
  },
  enabledButton: {
    position: 'absolute',
    top: 10,
    right: 60
  },
  stationaryButton: {
    position: 'absolute',
    top: 0,
    right: 0
  },
  paceButton: {

  },
  redButton: {
    backgroundColor: '#ff1300'
  },
  greenButton: {
    backgroundColor: '#4cd964'
  },
  text: {
    padding: 2
  }
});

module.exports = Map;
<commit_msg>Remove logs from ios app<commit_after>'use strict';

var React                 = require('react-native');
var Icon                  = require('react-native-vector-icons/Ionicons');
var BackgroundGeolocation = require('react-native-background-geolocation');
var SettingsService       = require('./SettingsService');

SettingsService.init('iOS');

var mapRef = 'mapRef';

var {
  AsyncStorage,
  StyleSheet,
  MapView,
  AppStateIOS,
  Text,
  TextInput,
  View,
  SwitchIOS,
  Navigator,
  NavButton,
  TouchableHighlight
} = React;

var Map = React.createClass({

  getInitialState() {
    var me = this;

    AsyncStorage.getItem("state")
    .then((values) => {
      if (values !== null){
        values = JSON.parse(values);
        values.isStationary = true;
        me.setState(values);
        if (values.isEnabled) {
          me.onToggleEnabled(values.isEnabled);
        }
      }
    })
    .catch((error) => console.error("- error: ", error.message))
    .done();

    AppStateIOS.addEventListener('change', this.onAppStateChange);

    this.bgGeo = BackgroundGeolocation;

    // Fetch bg-geo settings.
    SettingsService.getValues(function(values) {

      // Configure Background Geolocation.
      me.bgGeo.configure(values);

      // Event: location.  Listen to location events coming out.
      me.bgGeo.on('location', me.onBackgroundGeolocation);

      // Event: motionchange. Listen to motionchange events.
      me.bgGeo.on('motionchange', function(location) {
        console.log('- motionchanged: ', JSON.stringify(location));
        me.setState({
          isStationary: !location.is_moving,
          paceButtonStyle: (location.is_moving) ? styles.redButton : styles.greenButton
        });
      });

      // Event: sync:  This fires after plugin successfully synced to server.
      me.bgGeo.on('sync', function(rs) {
        console.log('- sync complete: ', JSON.stringify(rs));
      });

      // Event: http
      me.bgGeo.on('http', function(response) {
        console.log('- EVENT: http', JSON.stringify(response));
      });

      // Event: error
      me.bgGeo.on('error', function(error) {
        alert(error.type + ' error: ' + error.code);
        console.log('- ERROR: ', JSON.stringify(error));
      });
    });

    return {
      zoom: 11,
      odometer: 0,
      isEnabled: false,
      isStationary: true,
      paceButtonStyle: styles.greenButton,
      navigateButton: 'navigate'
    };
  },
  onAppStateChange(state) {
    if (state === 'active') {
      var me = this;
      me.bgGeo.getCurrentPosition({timeout: 1000}, function(location) {
        console.log('- received current position: ', location);
      }, function(error) {
        alert('Location error: ' + error);
      });
    }
  },
  onClickSettings() {
    this.props.navigator.push({
      id: 'settings',
      sceneConfig: Navigator.SceneConfigs.FloatFromBottom,
    });
  },
  onToggleEnabled(enabled) {
    var me = this;

    if (!enabled && !this.state.isStationary) {
      this.onToggleStationary();
    }
    this.setState({
      isEnabled: enabled,
      odometer: 0
    }, function() {
      AsyncStorage.setItem("state", JSON.stringify(me.state));
    });

    this.bgGeo.resetOdometer(function() {
      console.log('- resetOdometer success');
    });

    if (enabled) {
      this.bgGeo.start(function() {
        // Successfully started.  Now fetch current position.
        me.bgGeo.getCurrentPosition({timeout: 1000}, function(location) {
          console.log('[js] received current position: ', location);
        }, function(error) {
          alert('Location error: ' + error);
        });
      });
    } else {
      this.bgGeo.stop();
    }
  },
  onToggleStationary() {
    var me = this;
    var value = !this.state.isStationary;

    this.setState({
      isStationary: value,
      paceButtonStyle: (value) ? styles.greenButton : styles.redButton
    });

    this.bgGeo.changePace(!value);
  },
  onUpdatePosition() {
    var me = this;
    this.setState({
      navigateButton: 'load-d'
    });

    me.bgGeo.getCurrentPosition({timeout: 1000}, function(location) {
      me.bgGeo.getGeofences(function(rs) {
        console.log('- current geofences: ', rs);
      });
      me.setState({
        navigateButton: 'navigate'
      });
    }, function(error) {
      alert('Location error: ' + error);
      me.setState({
        navigateButton: 'navigate'
      });
    });
  },
  onBackgroundGeolocation(location) {
    console.log('- [js] bgGeo location: ', JSON.stringify(location));
    var me    = this,
        now   = ((location.timestamp) ? new Date(location.timestamp) : new Date()),
        label = [now.getHours(), now.getMinutes(), now.getSeconds()].join(':');

    me.bgGeo.getOdometer(function(distance) {
      me.setState({
        odometer: (distance/1000).toFixed(1)
      });
    });
  },
  onRegionChange(location) {
    //this.setState({ currentZoom: location.zoom });
  },
  onRegionWillChange(location) {
    //console.log(location);
  },
  onUpdateUserLocation(location) {
    //console.log('[js]MapBox location: ', location);
  },
  onOpenAnnotation(annotation) {
    //console.log(annotation);
  },
  onRightAnnotationTapped(e) {
    //console.log(e);
  },
  render: function() {

    return (
      <View style={styles.container}>
        <View style={styles.map}><Text>Map Goes Here</Text></View>
        <View style={styles.toolbar}>
          <TouchableHighlight style={[styles.locationButton, styles.iconButton]} underlayColor={"transparent"} onPress={this.onUpdatePosition}>
            <Icon name={this.state.navigateButton} size={24} color="#4f8ef7" />
          </TouchableHighlight>
          <Text>{this.state.odometer}km</Text>

          <SwitchIOS style={styles.enabledButton} value={this.state.isEnabled} onValueChange={this.onToggleEnabled}></SwitchIOS>

          <TouchableHighlight style={[this.state.paceButtonStyle, styles.stationaryButton, styles.iconButton]} underlayColor={"transparent"} onPress={this.onToggleStationary}>
            <Icon name={this.state.isStationary ? 'play' : 'pause'} size={24} />
          </TouchableHighlight>

        </View>
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    marginTop: 10,
    backgroundColor: 'transparent',
  },
  map: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  toolbar: {
    //top: 50,
    height: 50,
    padding: 5,
    justifyContent: 'center',
    alignItems: 'center'
  },
  settingsButton: {
    position: 'absolute',
    left: 10,
    top: 15
  },
  buttonText: {
    color: 'blue',
    fontSize: 16
  },
  locationButton: {
    position: 'absolute',
    left: 0,
    top: 0
  },
  spinner: {
    position: 'absolute',
    top: 10,
    left: 40
  },
  iconButton: {
    width: 50,
    height: 50,
    justifyContent: 'center',
    alignItems: 'center'
  },
  enabledButton: {
    position: 'absolute',
    top: 10,
    right: 60
  },
  stationaryButton: {
    position: 'absolute',
    top: 0,
    right: 0
  },
  paceButton: {

  },
  redButton: {
    backgroundColor: '#ff1300'
  },
  greenButton: {
    backgroundColor: '#4cd964'
  },
  text: {
    padding: 2
  }
});

module.exports = Map;
<|endoftext|>