<commit_before>  $(document).keydown(function (e) {
      var keyCode = e.keyCode || e.which,
      arrow = {left: 37, up: 38, right: 39, down: 40 };

      switch (keyCode) {
          case arrow.left:
              $('.previous').trigger('click');
          break;
          case arrow.right:
              $('.next').trigger('click');
          break;
          case arrow.down:
              $('.topOfMain .more').trigger('click');
          break;
          case arrow.up:
              $('.topOfMain .more-back').trigger('click');
          break;
          default: return; // allow other keys to be handled
      }
      e.preventDefault();
      // prevent default action (eg. page moving up/down)
      // but consider accessibility (eg. user may want to use keys to choose a radio button)
  });
// Menu

(function() {
  $(".flyout-btn").click(function() {
    console.log('click 1');
    $(".flyout-btn").toggleClass("btn-rotate");
    $(".overlay").toggleClass("open");
    // $(".flyout").find("a").removeClass();

    $li = $('.topOfMain');
    sendGAEvent('menu-button-click', username + "#" + $li.attr('cardId'), $li.attr('cardIndex'));

    return $(".flyout").removeClass("flyout-init fade").toggleClass("expand");
  });

  $(".flyout").find("a").click(function() {
    console.log('click 2');
    $(".flyout-btn").toggleClass("btn-rotate");
    $(".flyout").removeClass("expand").addClass("fade");
    return $(this).addClass("clicked");
  });

  $(".share").find("a").click(function() {
    console.log('click 3');
    return $(this).addClass("clicked");
  });

  $(".share").click(function() {
    console.log('click 5');
    $(".flyout-btn").toggleClass("btn-rotate");
    $(".share-buttons-wrap").toggleClass("hide zoomIn");
    $(".overlay").toggleClass("open");
  });

  $('.removed-from-deck').delay(1000).remove();

  $(".flyout").find("a").click(function (e) {
    console.log('click 6');
    e.preventDefault();                   // prevent default anchor behavior
    var goTo = this.getAttribute("href"); // store anchor href

    // do something while timeOut ticks ...

    setTimeout(function(){
         window.location = goTo;
    }, 550);

});

}).call(this);

function clickPulse(x, y, $pulseElem) {

    var clickY = y - $pulseElem.offset().top;
    var clickX = x - $pulseElem.offset().left;
    var setX = parseInt(clickX);
    var setY = parseInt(clickY);

    $pulseElem.find("svg.click-circle").remove();
    $pulseElem.append('<svg class="click-circle"><circle cx="'+setX+'" cy="'+setY+'" r="'+100+'"></circle></svg>');

    var c = $pulseElem.find("circle");
    c.animate(
        {
          "r" : $pulseElem.outerWidth()
        }, 200, function() { $pulseElem.find("svg.click-circle").remove(); }
    );
}

function sendGAEvent(eventAction, eventLabel, eventValue) {
    var gaObj = {};
    gaObj.eventCategory = 'card-stack';
    gaObj.eventAction = eventAction;
    gaObj.eventLabel = eventLabel;
    gaObj.eventValue = eventValue;

    console.log('gaObj', gaObj);
    console.log(ga);

    ga('send', 'event', gaObj);
}

window.logInfoClick = function(elem) {
    var $elem = $(elem);
    var cardLi = $elem.parentsUntil('ul', 'li')[0];
    sendGAEvent('infoLink_click', cardLi.getAttribute('cardId'), username);
};

<commit_msg>remove logging of ga function<commit_after>  $(document).keydown(function (e) {
      var keyCode = e.keyCode || e.which,
      arrow = {left: 37, up: 38, right: 39, down: 40 };

      switch (keyCode) {
          case arrow.left:
              $('.previous').trigger('click');
          break;
          case arrow.right:
              $('.next').trigger('click');
          break;
          case arrow.down:
              $('.topOfMain .more').trigger('click');
          break;
          case arrow.up:
              $('.topOfMain .more-back').trigger('click');
          break;
          default: return; // allow other keys to be handled
      }
      e.preventDefault();
      // prevent default action (eg. page moving up/down)
      // but consider accessibility (eg. user may want to use keys to choose a radio button)
  });
// Menu

(function() {
  $(".flyout-btn").click(function() {
    console.log('click 1');
    $(".flyout-btn").toggleClass("btn-rotate");
    $(".overlay").toggleClass("open");
    // $(".flyout").find("a").removeClass();

    $li = $('.topOfMain');
    sendGAEvent('menu-button-click', username + "#" + $li.attr('cardId'), $li.attr('cardIndex'));

    return $(".flyout").removeClass("flyout-init fade").toggleClass("expand");
  });

  $(".flyout").find("a").click(function() {
    console.log('click 2');
    $(".flyout-btn").toggleClass("btn-rotate");
    $(".flyout").removeClass("expand").addClass("fade");
    return $(this).addClass("clicked");
  });

  $(".share").find("a").click(function() {
    console.log('click 3');
    return $(this).addClass("clicked");
  });

  $(".share").click(function() {
    console.log('click 5');
    $(".flyout-btn").toggleClass("btn-rotate");
    $(".share-buttons-wrap").toggleClass("hide zoomIn");
    $(".overlay").toggleClass("open");
  });

  $('.removed-from-deck').delay(1000).remove();

  $(".flyout").find("a").click(function (e) {
    console.log('click 6');
    e.preventDefault();                   // prevent default anchor behavior
    var goTo = this.getAttribute("href"); // store anchor href

    // do something while timeOut ticks ...

    setTimeout(function(){
         window.location = goTo;
    }, 550);

});

}).call(this);

function clickPulse(x, y, $pulseElem) {

    var clickY = y - $pulseElem.offset().top;
    var clickX = x - $pulseElem.offset().left;
    var setX = parseInt(clickX);
    var setY = parseInt(clickY);

    $pulseElem.find("svg.click-circle").remove();
    $pulseElem.append('<svg class="click-circle"><circle cx="'+setX+'" cy="'+setY+'" r="'+100+'"></circle></svg>');

    var c = $pulseElem.find("circle");
    c.animate(
        {
          "r" : $pulseElem.outerWidth()
        }, 200, function() { $pulseElem.find("svg.click-circle").remove(); }
    );
}

function sendGAEvent(eventAction, eventLabel, eventValue) {
    var gaObj = {};
    gaObj.eventCategory = 'card-stack';
    gaObj.eventAction = eventAction;
    gaObj.eventLabel = eventLabel;
    gaObj.eventValue = eventValue;

    console.log('gaObj', gaObj);

    ga('send', 'event', gaObj);
}

window.logInfoClick = function(elem) {
    var $elem = $(elem);
    var cardLi = $elem.parentsUntil('ul', 'li')[0];
    sendGAEvent('infoLink_click', cardLi.getAttribute('cardId'), username);
};

<|endoftext|>


<commit_before>module.exports = function(grunt) {

  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      build: {
        src: 'src/<%= pkg.name %>.js',
        dest: 'build/<%= pkg.name %>.min.js'
      }
    },
    qunit: {
      files: ['test/index.html']
    }
  });

  grunt.registerTask('test', ['qunit']);

  grunt.registerTask('default', ['qunit', 'uglify']);

};<commit_msg>Change the uglify config.<commit_after>module.exports = function(grunt) {

  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> v<%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      build: {
        src: 'src/canal.js',
        dest: 'canal.min.js'
      }
    },
    qunit: {
      files: ['test/index.html']
    }
  });

  grunt.registerTask('test', ['qunit']);

  grunt.registerTask('default', ['qunit', 'uglify']);

};<|endoftext|>


<commit_before>(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var Server = require('./server');
var Friend = require('./friend');
var Movie = require('./movie');

function AppViewModel() {
    // PRIVATE
    var API_URL = 'localhost';
    var ACCESS_TOKEN = $('#access-token').html();
    var self = this;
    var server = new Server(API_URL);

    var flipCard = function() {
        // DO JQUERY FLIP HERE
    };

    var nextCard = function() {
        // DO JQUERY DISCARD HERE

    };

    // PUBLIC
    self.currentFriends = ko.observableArray([]);

    self.onNewMovie = function(movie) {

    };

    self.onRightSwipe = function() {
        flipCard();
    };

    self.onLeftSwipe = function() {
        nextCard();
    };
}

module.exports = AppViewModel;
},{"./friend":3,"./movie":4,"./server":5}],2:[function(require,module,exports){
var AppViewModel = require('./appviewmodel');

ko.applyBindings(new AppViewModel());
},{"./appviewmodel":1}],3:[function(require,module,exports){
function Friend() {
    var self = this;
}

module.exports = Friend;
},{}],4:[function(require,module,exports){
function Movie() {

}

module.exports = Movie;
},{}],5:[function(require,module,exports){
function Server(url) {
    var self = this;

    self.getNextTrailer = function() {

    };
}

module.exports = Server;
},{}]},{},[2])<commit_msg>Remove main js from public<commit_after><|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {
  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      files: {
        src: ['Gruntfile.js']
      },
      options: {
        force: true,
        reporter:  require('jshint-stylish'),
        jshintrc: true,
        ignores: ['node_modules/**', 'sample/**', 'docs/**', 'lib-cov']
      },
      lib: {
        files: {
          src: ['lib/**/*.js']
        }
      },
      test: {
        files: {
          src: ['test/**/*.js']
        }
      }
    },
    docco: {
      options: {
        layout: 'parallel'
      },
      api: {
        files: {
          src: ['ravel.js', 'lib/**']
        }
      }
    },
    watch: {
      api: {
        files: ['Gruntfile.js', 'lib/**', 'ravel.js'],
        tasks: ['jshint', 'docco'],
        options: {
          spawn: false
        }
      }
    },
    clean: {
      'coverage': ['lib-cov'],
      'docs': ['docs']
    },
    env : {
      options : {
        add: {
          LOG_LEVEL: 'trace'
        }
      },
      test : {
        LOG_LEVEL : 'critical'
      }
    },
    blanket: {
      coverage: {
        src: ['ravel.js', 'lib/'],
        dest: 'lib-cov/'
      },
      options: {
        'data-cover-flags':true
      }
    },
    mochaTest: {
      ravel: {
        options: {
          reporter: 'spec',
          quiet:false,
          colors:true
        },
        src: ['test/**/*.js']
      },
      coverage: {
        options: {
          reporter: 'html-cov',
          quiet: true,
          captureFile: 'test/coverage.html'
        },
        src: ['test/**/*.js']
      },
      coverageLcov: {
        options: {
          reporter: 'mocha-lcov-reporter',
          quiet: true,
          captureFile: 'test/coverage.lcov'
        },
        src: ['test/**/*.js']
      }
    },
    coveralls: {
      options: {
        src: 'test/coverage.lcov',
        force: false
      }
    },
    open: {
      coverage: {
        path: 'test/coverage.html'
      }
    }
  });

  grunt.registerTask('default', ['jshint:lib', 'docco', 'watch']);
  grunt.registerTask('test-cli', [
    'env:test',
    'clean:coverage',
    'jshint',
    'blanket',
    'mochaTest:ravel',
    'mochaTest:coverage',
    'mochaTest:coverageLcov',
    'clean:coverage'
  ]);
  grunt.registerTask('test', ['test-cli', 'open:coverage']);
  grunt.registerTask('travis', ['test-cli', 'coveralls']);

};
<commit_msg>Tweaking coveralls config in Gruntfile to see if it will actually work.<commit_after>'use strict';

module.exports = function(grunt) {
  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      files: {
        src: ['Gruntfile.js']
      },
      options: {
        force: true,
        reporter:  require('jshint-stylish'),
        jshintrc: true,
        ignores: ['node_modules/**', 'sample/**', 'docs/**', 'lib-cov']
      },
      lib: {
        files: {
          src: ['lib/**/*.js']
        }
      },
      test: {
        files: {
          src: ['test/**/*.js']
        }
      }
    },
    docco: {
      options: {
        layout: 'parallel'
      },
      api: {
        files: {
          src: ['ravel.js', 'lib/**']
        }
      }
    },
    watch: {
      api: {
        files: ['Gruntfile.js', 'lib/**', 'ravel.js'],
        tasks: ['jshint', 'docco'],
        options: {
          spawn: false
        }
      }
    },
    clean: {
      'coverage': ['lib-cov'],
      'docs': ['docs']
    },
    env : {
      options : {
        add: {
          LOG_LEVEL: 'trace'
        }
      },
      test : {
        LOG_LEVEL : 'critical'
      }
    },
    blanket: {
      coverage: {
        src: ['ravel.js', 'lib/'],
        dest: 'lib-cov/'
      },
      options: {
        'data-cover-flags':true
      }
    },
    mochaTest: {
      ravel: {
        options: {
          reporter: 'spec',
          quiet:false,
          colors:true
        },
        src: ['test/**/*.js']
      },
      coverage: {
        options: {
          reporter: 'html-cov',
          quiet: true,
          captureFile: 'test/coverage.html'
        },
        src: ['test/**/*.js']
      },
      coverageLcov: {
        options: {
          reporter: 'mocha-lcov-reporter',
          quiet: true,
          captureFile: 'test/coverage.lcov'
        },
        src: ['test/**/*.js']
      }
    },
    coveralls: {
      full: {
        src: 'test/coverage.lcov',
        options: {
          force: true
        }
      }
    },
    open: {
      coverage: {
        path: 'test/coverage.html'
      }
    }
  });

  grunt.registerTask('default', ['jshint:lib', 'docco', 'watch']);
  grunt.registerTask('test-cli', [
    'env:test',
    'clean:coverage',
    'jshint',
    'blanket',
    'mochaTest:ravel',
    'mochaTest:coverage',
    'mochaTest:coverageLcov',
    'clean:coverage'
  ]);
  grunt.registerTask('test', ['test-cli', 'open:coverage']);
  grunt.registerTask('travis', ['test-cli', 'coveralls']);

};
<|endoftext|>


<commit_before>$(function(){
  var uploadUrl = '/api/upload';
  var $username = $('input[data-name="username"]');
  var $video = $('#videodivs');
  var $preview = $('#snapshotdiv');
  var $previewImage = $('#resultimage');
  var $previewImageContainer = $('#resultdiv');
  var $loading = $('#loaderImage');
  var readyToSubmit = false;
  var submitting = false;
  var currentDataUrl = '';
  var animationSpeed = 'slow';

  function getKeyCode(event){
    return (typeof event.which == "number") ? event.which : event.keyCode;
  }

  function grabImage(){
    currentDataUrl = takeSnapshot();
    $username.focus();
    $video.hide();
    readyToSubmit = true;
  }

  function discardImage(){
    $username.val('');
    submitting = false;
    currentDataUrl = '';

    $preview.hide();
    $previewImageContainer.fadeOut(animationSpeed, function(){
      $video.fadeIn(animationSpeed, function(){
        readyToSubmit = false;
      });
    });
  }

  function submitImage(){
    console.log('Sending image to server....');
    submitting = true;
    startAnimation();

    $.post(uploadUrl, {'dataUrl': currentDataUrl, 'username': $username.val()})
    .done(function(data){
      console.log(data);
      stopAnimation();
      $previewImage.attr('src', data);
      $preview.fadeOut(animationSpeed, function(){
        $previewImageContainer.fadeIn(animationSpeed, function() {
          setTimeout(function() {
            discardImage();
          }, 3000);
        });
      });
    })
    .fail(function(error){
      console.log(error);
      stopAnimation();
      discardImage();
    })
  }

  $username.keydown(function(event){
    var keyCode = getKeyCode(event);
    if (keyCode == '32') {
      // Disable space in username input
      event.preventDefault();
      return;
    } else if (keyCode == '13') {
      // Submit image
      if (!submitting){
        submitImage();
      }
    }
  });

  $(document).keydown(function(event) {
    var keyCode = getKeyCode(event);
    if (keyCode == '32') {
      // Disable space
      event.preventDefault();
      // Take a picture
      grabImage();
    }
    else if (keyCode == '27') {
      // Cancel
      discardImage();
    }
  });

  // Loader animation
  var cSpeed=9;
  var cWidth=64;
  var cHeight=64;
  var cTotalFrames=12;
  var cFrameWidth=64;
  var cImageSrc='/img/loading_sprites.png';

  var cImageTimeout=false;
  var cIndex=0;
  var cXpos=0;
  var cPreloaderTimeout=false;
  var SECONDS_BETWEEN_FRAMES=0;

  function startAnimation(){
    $loading.css('background-image', 'url(' + cImageSrc + ')')
            .css('width', cWidth + 'px')
            .css('height', cHeight + 'px')
            .show();

    //FPS = Math.round(100/(maxSpeed+2-speed));
    FPS = Math.round(100/cSpeed);
    SECONDS_BETWEEN_FRAMES = 1 / FPS;

    cPreloaderTimeout=setTimeout(function() { continueAnimation(); }, SECONDS_BETWEEN_FRAMES/1000);
  }

  function continueAnimation(){
    cXpos += cFrameWidth;
    //increase the index so we know which frame of our animation we are currently on
    cIndex += 1;

    //if our cIndex is higher than our total number of frames, we're at the end and should restart
    if (cIndex >= cTotalFrames) {
      cXpos =0;
      cIndex=0;
    }

    $loading.css('backgroundPosition', (-cXpos)+'px 0');
    cPreloaderTimeout=setTimeout(function() { continueAnimation(); }, SECONDS_BETWEEN_FRAMES*1000);
  }

  function stopAnimation(){//stops animation
    $loading.hide();
    clearTimeout(cPreloaderTimeout);
    cPreloaderTimeout=false;
  }
});<commit_msg>Added validation for username, empty usernames are now not allowed.<commit_after>$(function(){
  var uploadUrl = '/api/upload';
  var $username = $('input[data-name="username"]');
  var $video = $('#videodivs');
  var $preview = $('#snapshotdiv');
  var $previewImage = $('#resultimage');
  var $previewImageContainer = $('#resultdiv');
  var $loading = $('#loaderImage');
  var readyToSubmit = false;
  var submitting = false;
  var currentDataUrl = '';
  var animationSpeed = 'slow';

  function getKeyCode(event){
    return (typeof event.which == "number") ? event.which : event.keyCode;
  }

  function grabImage(){
    currentDataUrl = takeSnapshot();
    $username.focus();
    $video.hide();
    readyToSubmit = true;
  }

  function discardImage(){
    $username.val('');
    submitting = false;
    currentDataUrl = '';

    $preview.hide();
    $previewImageContainer.fadeOut(animationSpeed, function(){
      $video.fadeIn(animationSpeed, function(){
        readyToSubmit = false;
      });
    });
  }

  function submitImage(){
    if (!$username.val()){
      console.log('Username missing...aborting.')
      return;
    }
    console.log('Sending image to server....');
    submitting = true;
    startAnimation();

    $.post(uploadUrl, {'dataUrl': currentDataUrl, 'username': $username.val()})
    .done(function(data){
      console.log(data);
      stopAnimation();
      $previewImage.attr('src', data);
      $preview.fadeOut(animationSpeed, function(){
        $previewImageContainer.fadeIn(animationSpeed, function() {
          setTimeout(function() {
            discardImage();
          }, 3000);
        });
      });
    })
    .fail(function(error){
      console.log(error);
      stopAnimation();
      discardImage();
    })
  }

  $username.keydown(function(event){
    var keyCode = getKeyCode(event);
    if (keyCode == '32') {
      // Disable space in username input
      event.preventDefault();
      return;
    } else if (keyCode == '13') {
      // Submit image
      if (!submitting){
        submitImage();
      }
    }
  });

  $(document).keydown(function(event) {
    var keyCode = getKeyCode(event);
    if (keyCode == '32') {
      // Disable space
      event.preventDefault();
      // Take a picture
      grabImage();
    }
    else if (keyCode == '27') {
      // Cancel
      discardImage();
    }
  });

  // Loader animation
  var cSpeed=9;
  var cWidth=64;
  var cHeight=64;
  var cTotalFrames=12;
  var cFrameWidth=64;
  var cImageSrc='/img/loading_sprites.png';

  var cImageTimeout=false;
  var cIndex=0;
  var cXpos=0;
  var cPreloaderTimeout=false;
  var SECONDS_BETWEEN_FRAMES=0;

  function startAnimation(){
    $loading.css('background-image', 'url(' + cImageSrc + ')')
            .css('width', cWidth + 'px')
            .css('height', cHeight + 'px')
            .show();

    //FPS = Math.round(100/(maxSpeed+2-speed));
    FPS = Math.round(100/cSpeed);
    SECONDS_BETWEEN_FRAMES = 1 / FPS;

    cPreloaderTimeout=setTimeout(function() { continueAnimation(); }, SECONDS_BETWEEN_FRAMES/1000);
  }

  function continueAnimation(){
    cXpos += cFrameWidth;
    //increase the index so we know which frame of our animation we are currently on
    cIndex += 1;

    //if our cIndex is higher than our total number of frames, we're at the end and should restart
    if (cIndex >= cTotalFrames) {
      cXpos =0;
      cIndex=0;
    }

    $loading.css('backgroundPosition', (-cXpos)+'px 0');
    cPreloaderTimeout=setTimeout(function() { continueAnimation(); }, SECONDS_BETWEEN_FRAMES*1000);
  }

  function stopAnimation(){//stops animation
    $loading.hide();
    clearTimeout(cPreloaderTimeout);
    cPreloaderTimeout=false;
  }
});<|endoftext|>


<commit_before>module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        nodemon: {
            dev: {
                script: 'bin/www',
                options: {
                    ignore: ['node_modules/**', 'public/**','views/**'],
                    ext: 'js',
                    watch: ['bin/www', 'routes/**', 'app.js'],
                    env: {
                        NODE_ENV: 'dev'
                    },
                    nodeArgs: ['--debug'],
                    cwd: __dirname,
                    callback: function (nodemon) {
                        nodemon.on('log', function (event) {
                            console.log(event.colour);
                        });
                    },
                }
            }
        },
        watch: {
            files: ['bin/www', '*.js', '**/*.js', '!node_modules/**', '!.git/**', '!public/javascripts/**'],
            tasks: ['jshint']
        },
        jshint: {
            all: ['**/*.js', '**/*.json', '!node_modules/**', '!public/**'],
            options: {
                ignore: ['node_modules/**', 'public/**']
            }
        },
        concurrent: {
            options: {
                "logConcurrentOutput": true
            },
            dev: {
                tasks: ['nodemon', 'watch']
            },
            debug: {
                tasks: ['nodemon', 'watch']
            }
        },
        simplemocha: {
            options: {
                globals: [], // Add whitelisted globals here
                timeout: 3000,
                ignoreLeaks: false,
                ui: 'bdd',
                reporter: 'spec'
            },
            all: { src: ['test/**/*.js'] }
        }
    });

    // Load plugins/tasks
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-concurrent');
    grunt.loadNpmTasks('grunt-nodemon');
    grunt.loadNpmTasks('grunt-simple-mocha');

    // Grunt task(s).
    grunt.registerTask('default', ['concurrent:dev']);
    grunt.registerTask('test', ['simplemocha']);
};<commit_msg>remove debug<commit_after>module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        nodemon: {
            dev: {
                script: 'bin/www',
                options: {
                    ignore: ['node_modules/**', 'public/**','views/**'],
                    ext: 'js',
                    watch: ['bin/www', 'routes/**', 'app.js'],
                    env: {
                        NODE_ENV: 'dev'
                    },
                    cwd: __dirname,
                    callback: function (nodemon) {
                        nodemon.on('log', function (event) {
                            console.log(event.colour);
                        });
                    },
                }
            }
        },
        watch: {
            files: ['bin/www', '*.js', '**/*.js', '!node_modules/**', '!.git/**', '!public/javascripts/**'],
            tasks: ['jshint']
        },
        jshint: {
            all: ['**/*.js', '**/*.json', '!node_modules/**', '!public/**'],
            options: {
                ignore: ['node_modules/**', 'public/**']
            }
        },
        concurrent: {
            options: {
                "logConcurrentOutput": true
            },
            dev: {
                tasks: ['nodemon', 'watch']
            },
            debug: {
                tasks: ['nodemon', 'watch']
            }
        },
        simplemocha: {
            options: {
                globals: [], // Add whitelisted globals here
                timeout: 3000,
                ignoreLeaks: false,
                ui: 'bdd',
                reporter: 'spec'
            },
            all: { src: ['test/**/*.js'] }
        }
    });

    // Load plugins/tasks
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-concurrent');
    grunt.loadNpmTasks('grunt-nodemon');
    grunt.loadNpmTasks('grunt-simple-mocha');

    // Grunt task(s).
    grunt.registerTask('default', ['concurrent:dev']);
    grunt.registerTask('test', ['simplemocha']);
};<|endoftext|>


<commit_before>module.exports = function(grunt) {

	grunt.initConfig({

		// Allows for referencing of package property values
		pkg: grunt.file.readJSON('package.json'),

		bower: {
			install: {
				options: {
					cleanBowerDir: false,
					copy: false,
					install: true,
					verbose: true
				}
			}
		},

		copy: {
			dist: {
				files: [
					// Make all targets in 'src' directory copy to a location
					// in 'dist' relative to own directory

					// { expand:true, cwd:'src/', src:['*.html','*.png','*.ico'], dest:'dist' },
					// { expand:true, cwd:'src/js/', src:['**'], dest:'dist/js' },
					// { expand:true, cwd:'src/img/', src:['*.svg','*.png','*.jpg','*.jpeg'], dest:'dist/img' },
					// { expand:true, cwd:'src/fonts/', src:['**'], dest:'dist/fonts' }

					{	// html
						expand: true,
						flatten: false,
						cwd: 'src/',
						src: ['**/*.html','**/*.md'],
						dest: 'dist'
					},
					{	// favicon
						expand: true,
						flatten: false,
						cwd: 'src/',
						src: ['*.png', '*.ico'],
						dest: 'dist'
					},
					{	// images
						expand: true,
						flatten: false,
						cwd: 'src/images/',
						src: ['**/*'],
						dest: 'dist/images'
					},
					{	// media
						expand: true,
						flatten: false,
						cwd: 'src/media/',
						src: ['**/*'],
						dest: 'dist/media'
					},
					{
						// fonts
						expand: true,
						flatten: false,
						cwd: 'src/fonts/',
						src: ['**'],
						dest: 'dist/fonts'
					}
				]
			}
		},

		concat: {
			jquery: { files: {
				// jquery.min.js
				'dist/js/vendor/jquery/jquery.min.js':
					['bower_components/jquery/dist/jquery.min.js'],
				// jquery.min.map
				'dist/js/vendor/jquery/jquery.min.map':
					['bower_components/jquery/dist/jquery.min.map']
			}},
			waypoint: { files: {
				// jquery-waypoints.min.js
				'dist/js/vendor/jquery/plugins/jquery-waypoints.min.js':
					['bower_components/jquery-waypoints/waypoints.min.js']
			}},
			scrollit: { files: {
				// jquery-scrollIt.min.js
				'dist/js/vendor/jquery/plugins/jquery-scrollIt.min.js':
					['bower_components/ScrollIt/scrollIt.min.js']
			}}
		},

		sass: {
			options: {
				// Helps Sass task resolve Foundation dependencies
				loadPath: 'bower_components/foundation/scss',
				style: 'compressed',
				quiet: true
			},
			dist: { files: {
				// startup-sass.min.css
				'dist/css/startup-sass.min.css': 'src/scss/main.scss'
			}}
		},

		watch: {
			grunt: { files: ['Gruntfile.js'] },
			copy: {
				files: ['src/**'],
				tasks: ['copy']
			},
			sass: {
				files: 'src/scss/**/*.scss',
				tasks: ['sass'],
				livereload: true
			},

		}

	});

	grunt.loadNpmTasks('grunt-bower-task');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-sass');
	grunt.loadNpmTasks('grunt-contrib-watch');

	grunt.registerTask('build', ['bower:install', 'concat', 'copy', 'sass']);
	grunt.registerTask('default', ['watch']);

}<commit_msg>Removed Markdown from Grunt 'copy' targets<commit_after>module.exports = function(grunt) {

	grunt.initConfig({

		// Allows for referencing of package property values
		pkg: grunt.file.readJSON('package.json'),

		bower: {
			install: {
				options: {
					cleanBowerDir: false,
					copy: false,
					install: true,
					verbose: true
				}
			}
		},

		copy: {
			dist: {
				files: [
					// Make all targets in 'src' directory copy to a location
					// in 'dist' relative to own directory

					// { expand:true, cwd:'src/', src:['*.html','*.png','*.ico'], dest:'dist' },
					// { expand:true, cwd:'src/js/', src:['**'], dest:'dist/js' },
					// { expand:true, cwd:'src/img/', src:['*.svg','*.png','*.jpg','*.jpeg'], dest:'dist/img' },
					// { expand:true, cwd:'src/fonts/', src:['**'], dest:'dist/fonts' }

					{	// html
						expand: true,
						flatten: false,
						cwd: 'src/',
						src: ['**/*.html'],
						dest: 'dist'
					},
					{	// favicon
						expand: true,
						flatten: false,
						cwd: 'src/',
						src: ['*.png', '*.ico'],
						dest: 'dist'
					},
					{	// images
						expand: true,
						flatten: false,
						cwd: 'src/images/',
						src: ['**/*'],
						dest: 'dist/images'
					},
					{	// media
						expand: true,
						flatten: false,
						cwd: 'src/media/',
						src: ['**/*'],
						dest: 'dist/media'
					},
					{
						// fonts
						expand: true,
						flatten: false,
						cwd: 'src/fonts/',
						src: ['**'],
						dest: 'dist/fonts'
					}
				]
			}
		},

		concat: {
			jquery: { files: {
				// jquery.min.js
				'dist/js/vendor/jquery/jquery.min.js':
					['bower_components/jquery/dist/jquery.min.js'],
				// jquery.min.map
				'dist/js/vendor/jquery/jquery.min.map':
					['bower_components/jquery/dist/jquery.min.map']
			}},
			waypoint: { files: {
				// jquery-waypoints.min.js
				'dist/js/vendor/jquery/plugins/jquery-waypoints.min.js':
					['bower_components/jquery-waypoints/waypoints.min.js']
			}},
			scrollit: { files: {
				// jquery-scrollIt.min.js
				'dist/js/vendor/jquery/plugins/jquery-scrollIt.min.js':
					['bower_components/ScrollIt/scrollIt.min.js']
			}}
		},

		sass: {
			options: {
				// Helps Sass task resolve Foundation dependencies
				loadPath: 'bower_components/foundation/scss',
				style: 'compressed',
				quiet: true
			},
			dist: { files: {
				// startup-sass.min.css
				'dist/css/startup-sass.min.css': 'src/scss/main.scss'
			}}
		},

		watch: {
			grunt: { files: ['Gruntfile.js'] },
			copy: {
				files: ['src/**'],
				tasks: ['copy']
			},
			sass: {
				files: 'src/scss/**/*.scss',
				tasks: ['sass'],
				livereload: true
			},

		}

	});

	grunt.loadNpmTasks('grunt-bower-task');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-sass');
	grunt.loadNpmTasks('grunt-contrib-watch');

	grunt.registerTask('build', ['bower:install', 'concat', 'copy', 'sass']);
	grunt.registerTask('default', ['watch']);

}<|endoftext|>


<commit_before>$(document).ready(function () {

    /*document.ontouchstart = function(e){
        e.preventDefault();
    } */

    jQuery('.addwebcam').bind('click tap', function(e) {
        jQuery('#cameraformwebcam').show(); //opens up a new form
        jQuery('.addwebcam').hide(); //now hide the button
    });

    //load appropriate map and also prepopulate from and to fields
    var param = _getParameters();
    switch (param.type) {
        case "search":
            $.ajax({
                url: "/navigate/search",
                data: {
                    search: param.search
                },
                success: function (data) {
                    $("#map-wrapper").html(data);
                    $("#map-directions-end").val(param.search);
                }
            });
            break;
        case "directions":
            $.ajax({
                url: "/navigate/nav",
                data: {
                    from: param.from,
                    to: param.to
                },
                success: function (data) {
                    $("#map-directions-start").val(param.from);
                    $("#map-directions-end").val(param.to);
                    $("#map-wrapper").html(data);
                }
            });
    }

    //preload some feed items
    $.getJSON('/report/getall', function (data) {
        $.each(data, function (key, val) {
            var time = _processDate(new Date(val.time));
            var type = val.type;
            var comment = val.comment;
            _createFeedItem(time,type,comment);
        });
    });

    /**
     * retrieve the get parameters and their values in a querystring
     * @returns urlParams   url parameters in object format
     * @private
     */
    function _getParameters() {
        var decode, match, pl, query, search, urlParams;
        pl = /\+/g;
        search = /([^&=]+)=?([^&]*)/g;
        decode = function (s) {
            return decodeURIComponent(s.replace(pl, " "));
        };
        query = window.location.search.substring(1);
        urlParams = {};
        while ((match = search.exec(query))) {
            urlParams[decode(match[1])] = decode(match[2]);
        }
        return urlParams;
    };

    /**
     * process a js Date object
     * @param date
     * @private
     */
    function _processDate(date) {
        var longdate = date.toDateString();
        var time = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
        return longdate + " @ " + time;
    }

    var isWindowSize = ($(window).width() >= 768);

    //connect to socket.io
    try {
    var socket = io.connect('/');
    socket.on('livereport', function (data) {

        data=data.report; //@todo for some reason there is a nested report
        _createFeedItem(_processDate(new Date(data.time)),data.type,data.comment);
        incrementBadge();
    });
    } catch(err) {

    }

    /**
     * dragging mobile sidebar
     */
    $("#feed-btn,#dir-btn").mousedown(function(e){
        if($(window).width() < 768 && $("#map-content").hasClass("normal")) {
            $(document).mousemove(function(e){

                if (e.which===1 &&
                    $("#map-content").hasClass("normal") &&
                    e.pageY < $(window).height() &&
                    e.pageY > 0 &&
                    e.pageX < $(window).width() &&
                    e.pageX > 0
                    ) {
                    $("#map-content").height(e.pageY);
                }
                else {
                    $("#map-content").removeClass("normal");
                    changeMobileSidebar(true);
                    $(document).unbind("mousemove");
                    return;
                }
                return;

            });
            return;
        }
        if($(window).width() < 768 && $("#map-content").hasClass("collapsed")) {

            var latestHeight = $("#map-content").height();

            $(document).mousemove(function(e){

                /*$(document).mouseup(function(e){
                    if (Math.abs(e.pageY) - latestHeight >60) {
                        $("#map-content").removeClass("collapsed");
                        _closeMobileSidebar();
                        $(document).unbind("mousemove");
                    }
                    else {
                        $("#map-content").height(latestHeight);
                    }
                });*/

                if (e.which ===1 &&
                    $("#map-content").hasClass("collapsed") &&
                    e.pageY < $(window).height() &&
                    e.pageY > 0 &&
                    e.pageX < $(window).width() &&
                    e.pageX > 0
                    ) {
                        $("#map-content").height(e.pageY);
                        if (Math.abs(e.pageY) - latestHeight <60){
                            $("#map-content").height('20%');
                        }

                }
                //if (Math.abs(e.pageY) - $("#map-content").height() >20){
                //    $("#map-content").height(e.pageY);
                //}
                else if ($("#map-content").hasClass("normal")) {$(document).unbind("mousemove");}

                if ($("#map-content").height() - latestHeight >60 && e.which===0){
                    $("#map-content").removeClass("collapsed");
                    _closeMobileSidebar();
                    $(document).unbind("mousemove");
                    return;
                }
                //$(document).unbind("mousemove");
                return;

            });
            return;
        }
        return;
    });

    /**
     * switch to the feed tab on click
     */
    $("#feed-btn").click(function() {
        $("#directions").fadeOut();
        $("#feed").fadeIn();

        $("#sidebar .btn").removeClass("on");
        $(this).addClass("on");
        changeMobileSidebar($("#map-content").hasClass("normal"));
        clearBadge();
    });

    /**
     *
     */
    $("#dir-btn").click(function() {
        $("#feed").fadeOut();
        $("#directions").fadeIn();

        $("#sidebar .btn").removeClass("on");
        $(this).addClass("on");
        changeMobileSidebar($("#map-content").hasClass("normal"));
    });

    /**
     * toggle the open/closed state of the sidebar
     */
    $("#shrink-arrow").click(function() {
        /*$(this).innerHTML='';*/
        var type=$(this).data('type');
        if(type=='close') {
            _closeWindowSidebar();
        } else if (type=='open') {
            _openWindowSidebar();
        }
    });

    /**
     * show the feed tab in the sidebar on click
     */
    $("#feed-btn").click(function() {
        $("#directions").hide();
        $("#feed").fadeIn();
    });

    /**
     * change scrollbar location on window resize
     * switch to the mobile scrollbar formatting if necessary
     */
    $(window).resize(function() {

        if ($(window).width() < 768 && isWindowSize) {
            isWindowSize = false;
            var barType = $("#shrink-arrow").data('type');
            if (barType=="close"){
                _openMobileSidebar(0);
                $("#map-content,.navbar").click(function() {
                    _closeMobileSidebar();
                });
            }
            else {
                _closeMobileSidebar();
            }
        } else if ($(window).width() >= 768 && !isWindowSize) {
            isWindowSize = true;
            var mobileBarClosed = $("#map-content").hasClass("normal");
            if (mobileBarClosed) {
                _closeWindowSidebar();
                _closeMobileSidebar();
            }

            else {
                _openWindowSidebar();
                $("#map-content").css({'height':'', "background-color": "transparent"}).removeClass("collapsed").addClass("normal");
                $(".navbar").css("background-color", "");
            }
        }
        setTimeout(function(){
            google.maps.event.trigger(map, 'resize');
        },500);

    });

});

function incrementBadge(){
    if (!($('#feed-btn').hasClass('on'))) {
        $('#feed-badge').html(getInt($('#feed-badge').html())+1);
    }
}

function clearBadge(){
    $('#feed-badge').html(0);
}
/**
 * parses integer, returns 0 if empty string
 * @param num
 * @returns {*}
 */
function getInt(num){
    if(num=="") {
        return 0;
    }
    else {
        return parseInt(num);
    }
}

/**
 * create new feed item
 * @param time
 * @param type
 * @param comment
 */
function _createFeedItem(time,type,comment) {
    var html=$('

' + '
' + type + '

' + comment + '

—' + time + '

');
    $("#live-feed").prepend(html);
    html.removeClass('feed-item-hidden',300);
}

/**
 * switch to the mobile sidebar
 * @param bool normal       whether in normal state
 */
function changeMobileSidebar(normal) {
    if(normal && $(window).width() < 768) {
        _openMobileSidebar(500);
        //click anywhere to exit list
        // TODO: assign in initialization, have check state
        $("#map-content,.navbar").click(function() {
            _closeMobileSidebar();
        });
    }
}

/**
 * close the mobile sidebar
 */
function _closeMobileSidebar() {
    time=500;
    $("#sidebar .btn").removeClass("on");
    $("#map-content").css({"background-color": "transparent"}).removeClass("collapsed").addClass("normal");
    //$("#map-content").css({'height':'', "background-color": "transparent"}).removeClass("collapsed").addClass("normal");
    $("#map-content").animate({
        height: '100%'
    }, time, function(){});
    $(".navbar").css("background-color", "");
    setTimeout(function(){
        google.maps.event.trigger(map, 'resize');
    },500);
}

/**
 * open the mobile sidebar
 * @param int t     animation time of height change
 */
function _openMobileSidebar(t) {
    $("#map-content").css({'min-height':'60px', "background-color": "rgba(0,0,0,0.4)"}).removeClass("normal").addClass("collapsed");
    $("#map-content").animate({
        height: '20%'
    }, t, function(){});
    $(".navbar").css("background-color", "#223044");
}

/**
 * close the main desktop sidebar
 */
function _closeWindowSidebar() {
    $("#shrink-arrow").data('type', 'open').html('');
    $("#map-content").css('width','100%');
    setTimeout(function(){
        google.maps.event.trigger(map, 'resize');
    },500);
}

/**
 * open the main desktop sidebar
 */
function _openWindowSidebar() {
    $("#shrink-arrow").data('type', 'close').html('');
    $("#map-content").css('width','');
}

window.map = new function() {
    this.initialize = function() {
        var latlng = new google.maps.LatLng(53.481136,-2.227279);
        var myOptions = {
            zoom: 12,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        this.gmap = new google.maps.Map(document.getElementById("map-content"), myOptions);

        google.maps.event.addDomListenerOnce(this.gmap, 'idle', function() {
            window.directions.get('344234568', '2345009892');
        });
    };
    google.maps.event.addDomListener(window, "load", this.initialize);
};

window.directions = new function() {
    /**
     * get directions by request
     * @param start     start location
     * @param end       end location
     */
    this.get = function(start, end) {
        var url = '/navigate/nav?start=' + encodeURIComponent(start) + '&end=' + encodeURIComponent(end);
        $.getJSON(url, function(data) {
            console.log('Directions data:', data);
            window.directions.renderList(start, end, data['roads']);
            window.directions.renderMap(data['path']);
        });
    };

    this.directionsPanel = $("#directions .side-content");
    this.renderList = function(start, end, roads) {
        var startElem = $('

');
        startElem.text(start).appendTo(this.directionsPanel);

        var directionsList = $('

');
        directionsList.appendTo(this.directionsPanel);
        for (var i=0; i<roads.length; i++) {
            var name = roads[i]['name'];
            var roadElem = $('

');
            roadElem.text(name).appendTo(directionsList);
        }

        var endElem = $('

');
        endElem.text(end).appendTo(this.directionsPanel);
    };

    this.renderMap = function(path) {
        // TODO: use MVC path type for easier updating
        // TODO: fix line display
        var coors = [];
        for (var i=0; i<path.length; i++) {
            coors.push(new google.maps.LatLng(path[i].lat, path[i].lon));
        }
        var line = new google.maps.Polyline({
            'path': coors,
            'strokeColor': "#FF0000",
            'strokeOpacity': 1.0,
            'strokeWeight': 5
        });
        line.setMap(window.map.gmap);
    }
};
<commit_msg>added touch events<commit_after>$(document).ready(function () {

    document.ontouchstart = function(e){
        e.preventDefault();
    }

    jQuery('.addwebcam').bind('click tap', function(e) {
        jQuery('#cameraformwebcam').show(); //opens up a new form
        jQuery('.addwebcam').hide(); //now hide the button
    });

    //load appropriate map and also prepopulate from and to fields
    var param = _getParameters();
    switch (param.type) {
        case "search":
            $.ajax({
                url: "/navigate/search",
                data: {
                    search: param.search
                },
                success: function (data) {
                    $("#map-wrapper").html(data);
                    $("#map-directions-end").val(param.search);
                }
            });
            break;
        case "directions":
            $.ajax({
                url: "/navigate/nav",
                data: {
                    from: param.from,
                    to: param.to
                },
                success: function (data) {
                    $("#map-directions-start").val(param.from);
                    $("#map-directions-end").val(param.to);
                    $("#map-wrapper").html(data);
                }
            });
    }

    //preload some feed items
    $.getJSON('/report/getall', function (data) {
        $.each(data, function (key, val) {
            var time = _processDate(new Date(val.time));
            var type = val.type;
            var comment = val.comment;
            _createFeedItem(time,type,comment);
        });
    });

    /**
     * retrieve the get parameters and their values in a querystring
     * @returns urlParams   url parameters in object format
     * @private
     */
    function _getParameters() {
        var decode, match, pl, query, search, urlParams;
        pl = /\+/g;
        search = /([^&=]+)=?([^&]*)/g;
        decode = function (s) {
            return decodeURIComponent(s.replace(pl, " "));
        };
        query = window.location.search.substring(1);
        urlParams = {};
        while ((match = search.exec(query))) {
            urlParams[decode(match[1])] = decode(match[2]);
        }
        return urlParams;
    };

    /**
     * process a js Date object
     * @param date
     * @private
     */
    function _processDate(date) {
        var longdate = date.toDateString();
        var time = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
        return longdate + " @ " + time;
    }

    var isWindowSize = ($(window).width() >= 768);

    //connect to socket.io
    try {
    var socket = io.connect('/');
    socket.on('livereport', function (data) {

        data=data.report; //@todo for some reason there is a nested report
        _createFeedItem(_processDate(new Date(data.time)),data.type,data.comment);
        incrementBadge();
    });
    } catch(err) {

    }

    /**
     * dragging mobile sidebar
     */
    $("#feed-btn,#dir-btn").mousedown(function(e){
        if($(window).width() < 768 && $("#map-content").hasClass("normal")) {
            $(document).mousemove(function(e){

                if (e.which===1 &&
                    $("#map-content").hasClass("normal") &&
                    e.pageY < $(window).height() &&
                    e.pageY > 0 &&
                    e.pageX < $(window).width() &&
                    e.pageX > 0
                    ) {
                    $("#map-content").height(e.pageY);
                }
                else {
                    $("#map-content").removeClass("normal");
                    changeMobileSidebar(true);
                    $(document).unbind("mousemove");
                    return;
                }
                return;

            });
            return;
        }
        if($(window).width() < 768 && $("#map-content").hasClass("collapsed")) {

            var latestHeight = $("#map-content").height();

            $(document).mousemove(function(e){

                /*$(document).mouseup(function(e){
                    if (Math.abs(e.pageY) - latestHeight >60) {
                        $("#map-content").removeClass("collapsed");
                        _closeMobileSidebar();
                        $(document).unbind("mousemove");
                    }
                    else {
                        $("#map-content").height(latestHeight);
                    }
                });*/

                if (e.which ===1 &&
                    $("#map-content").hasClass("collapsed") &&
                    e.pageY < $(window).height() &&
                    e.pageY > 0 &&
                    e.pageX < $(window).width() &&
                    e.pageX > 0
                    ) {
                        $("#map-content").height(e.pageY);
                        if (Math.abs(e.pageY) - latestHeight <60){
                            $("#map-content").height('20%');
                        }

                }
                //if (Math.abs(e.pageY) - $("#map-content").height() >20){
                //    $("#map-content").height(e.pageY);
                //}
                else if ($("#map-content").hasClass("normal")) {$(document).unbind("mousemove");}

                if ($("#map-content").height() - latestHeight >60 && e.which===0){
                    $("#map-content").removeClass("collapsed");
                    _closeMobileSidebar();
                    $(document).unbind("mousemove");
                    return;
                }
                //$(document).unbind("mousemove");
                return;

            });
            return;
        }
        return;
    });

    /**
     * switch to the feed tab on click
     */
    $("#feed-btn").click(function() {
        $("#directions").fadeOut();
        $("#feed").fadeIn();

        $("#sidebar .btn").removeClass("on");
        $(this).addClass("on");
        changeMobileSidebar($("#map-content").hasClass("normal"));
        clearBadge();
    });

    /**
     *
     */
    $("#dir-btn").click(function() {
        $("#feed").fadeOut();
        $("#directions").fadeIn();

        $("#sidebar .btn").removeClass("on");
        $(this).addClass("on");
        changeMobileSidebar($("#map-content").hasClass("normal"));
    });

    /**
     * toggle the open/closed state of the sidebar
     */
    $("#shrink-arrow").click(function() {
        /*$(this).innerHTML='';*/
        var type=$(this).data('type');
        if(type=='close') {
            _closeWindowSidebar();
        } else if (type=='open') {
            _openWindowSidebar();
        }
    });

    /**
     * show the feed tab in the sidebar on click
     */
    $("#feed-btn").click(function() {
        $("#directions").hide();
        $("#feed").fadeIn();
    });

    /**
     * change scrollbar location on window resize
     * switch to the mobile scrollbar formatting if necessary
     */
    $(window).resize(function() {

        if ($(window).width() < 768 && isWindowSize) {
            isWindowSize = false;
            var barType = $("#shrink-arrow").data('type');
            if (barType=="close"){
                _openMobileSidebar(0);
                $("#map-content,.navbar").click(function() {
                    _closeMobileSidebar();
                });
            }
            else {
                _closeMobileSidebar();
            }
        } else if ($(window).width() >= 768 && !isWindowSize) {
            isWindowSize = true;
            var mobileBarClosed = $("#map-content").hasClass("normal");
            if (mobileBarClosed) {
                _closeWindowSidebar();
                _closeMobileSidebar();
            }

            else {
                _openWindowSidebar();
                $("#map-content").css({'height':'', "background-color": "transparent"}).removeClass("collapsed").addClass("normal");
                $(".navbar").css("background-color", "");
            }
        }
        setTimeout(function(){
            google.maps.event.trigger(map, 'resize');
        },500);

    });

});

function incrementBadge(){
    if (!($('#feed-btn').hasClass('on'))) {
        $('#feed-badge').html(getInt($('#feed-badge').html())+1);
    }
}

function clearBadge(){
    $('#feed-badge').html(0);
}
/**
 * parses integer, returns 0 if empty string
 * @param num
 * @returns {*}
 */
function getInt(num){
    if(num=="") {
        return 0;
    }
    else {
        return parseInt(num);
    }
}

/**
 * create new feed item
 * @param time
 * @param type
 * @param comment
 */
function _createFeedItem(time,type,comment) {
    var html=$('

' + '
' + type + '

' + comment + '

—' + time + '

');
    $("#live-feed").prepend(html);
    html.removeClass('feed-item-hidden',300);
}

/**
 * switch to the mobile sidebar
 * @param bool normal       whether in normal state
 */
function changeMobileSidebar(normal) {
    if(normal && $(window).width() < 768) {
        _openMobileSidebar(500);
        //click anywhere to exit list
        // TODO: assign in initialization, have check state
        $("#map-content,.navbar").click(function() {
            _closeMobileSidebar();
        });
    }
}

/**
 * close the mobile sidebar
 */
function _closeMobileSidebar() {
    time=500;
    $("#sidebar .btn").removeClass("on");
    $("#map-content").css({"background-color": "transparent"}).removeClass("collapsed").addClass("normal");
    //$("#map-content").css({'height':'', "background-color": "transparent"}).removeClass("collapsed").addClass("normal");
    $("#map-content").animate({
        height: '100%'
    }, time, function(){});
    $(".navbar").css("background-color", "");
    setTimeout(function(){
        google.maps.event.trigger(map, 'resize');
    },500);
}

/**
 * open the mobile sidebar
 * @param int t     animation time of height change
 */
function _openMobileSidebar(t) {
    $("#map-content").css({'min-height':'60px', "background-color": "rgba(0,0,0,0.4)"}).removeClass("normal").addClass("collapsed");
    $("#map-content").animate({
        height: '20%'
    }, t, function(){});
    $(".navbar").css("background-color", "#223044");
}

/**
 * close the main desktop sidebar
 */
function _closeWindowSidebar() {
    $("#shrink-arrow").data('type', 'open').html('');
    $("#map-content").css('width','100%');
    setTimeout(function(){
        google.maps.event.trigger(map, 'resize');
    },500);
}

/**
 * open the main desktop sidebar
 */
function _openWindowSidebar() {
    $("#shrink-arrow").data('type', 'close').html('');
    $("#map-content").css('width','');
}

window.map = new function() {
    this.initialize = function() {
        var latlng = new google.maps.LatLng(53.481136,-2.227279);
        var myOptions = {
            zoom: 12,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        this.gmap = new google.maps.Map(document.getElementById("map-content"), myOptions);

        google.maps.event.addDomListenerOnce(this.gmap, 'idle', function() {
            window.directions.get('344234568', '2345009892');
        });
    };
    google.maps.event.addDomListener(window, "load", this.initialize);
};

window.directions = new function() {
    /**
     * get directions by request
     * @param start     start location
     * @param end       end location
     */
    this.get = function(start, end) {
        var url = '/navigate/nav?start=' + encodeURIComponent(start) + '&end=' + encodeURIComponent(end);
        $.getJSON(url, function(data) {
            console.log('Directions data:', data);
            window.directions.renderList(start, end, data['roads']);
            window.directions.renderMap(data['path']);
        });
    };

    this.directionsPanel = $("#directions .side-content");
    this.renderList = function(start, end, roads) {
        var startElem = $('

');
        startElem.text(start).appendTo(this.directionsPanel);

        var directionsList = $('

');
        directionsList.appendTo(this.directionsPanel);
        for (var i=0; i<roads.length; i++) {
            var name = roads[i]['name'];
            var roadElem = $('

');
            roadElem.text(name).appendTo(directionsList);
        }

        var endElem = $('

');
        endElem.text(end).appendTo(this.directionsPanel);
    };

    this.renderMap = function(path) {
        // TODO: use MVC path type for easier updating
        // TODO: fix line display
        var coors = [];
        for (var i=0; i<path.length; i++) {
            coors.push(new google.maps.LatLng(path[i].lat, path[i].lon));
        }
        var line = new google.maps.Polyline({
            'path': coors,
            'strokeColor': "#FF0000",
            'strokeOpacity': 1.0,
            'strokeWeight': 5
        });
        line.setMap(window.map.gmap);
    }
};
<|endoftext|>


<commit_before>
module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),
        build: {
            path: "build/<%= pkg.version %>",
            vendor: "<%= build.path %>/vendor"
        },
        clean: {
            dist: ["<%= build.path %>/*"]
        },
        jshint: {
            files: ["Gruntfile.js", "src/**/*.js"],
            options: {
                globals: {
                    jQuery: true
                }
            }
        },
        concat: {
            options: {
                sourceMap: true
            },
            vendors: {
                src: [
                    "./bower_components/webcomponentsjs/webcomponents-lite.js",
                    "./bower_components/jquery/dist/jquery.js",
                    "./bower_components/bootstrap/dist/js/bootstrap.js",
                    "./bower_components/bootstrap-table/dist/bootstrap-table.js",
                    "./bower_components/bootstrap-treeview/dist/bootstrap-treeview.js",
                    "./bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js",
                    "./bower_components/bootstrap-validator/dist/validator.js",
                    "./bower_components/moment/moment.js",
                    "./bower_components/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js",
                    "./bower_components/underscore/underscore.js",
                    "./bower_components/backbone/backbone.js",
                    "./bower_components/highcharts-release/highcharts.js",
                    "./bower_components/qtip2/jquery.qtip.js",
                    "./bower_components/uri.js/src/URI.js",
                    "./bower_components/cookies-js/dist/cookies.js",
                    "./bower_components/crypto-js/crypto-js.js"
                ],
                dest: "<%= build.path %>/vendors.js"
            }
            // ,jsorolla: {
            //     src: [
            //         "./lib/jsorolla/src/lib/clients/rest-client.js",
            //         "./lib/jsorolla/src/lib/clients/cellbase-client-config.js",
            //         "./lib//jsorolla/src/lib/clients/cellbase-client.js",
            //         "./lib/jsorolla/src/lib/clients/opencga-client-config.js",
            //         "./lib/jsorolla/src/lib/clients/opencga-client.js",
            //         "./lib/jsorolla/src/lib/cache/indexeddb-cache.js",
            //         "./lib/jsorolla/src/lib/utils.js",
            //         "./lib/jsorolla/src/lib/svg.js",
            //         "./lib/jsorolla/src/lib/region.js",
            //         "./lib/jsorolla/src/lib/visualisation/lollipop.js",
            //         "./lib/jsorolla/src/lib/opencga/variant/variant-utils.js"
            //     ],
            //     dest: "<%= build.path %>/jsorolla-clients.js"
            // }
            // ,genomeViewer: {
            //     src: [
            //         // "./lib/jsorolla/build/2.0.0-beta/genome-browser/gv-config.js",
            //         // "./lib/jsorolla/build/2.0.0-beta/genome-browser/genome-browser.js"
            //     ],
            //     dest: "<%= build.path %>/genome-browser.js"
            // }
        },
        uglify: {
            options: {
                banner: "/*! IVA <%= grunt.template.today(\"dd-mm-yyyy\") %> */\n"
            },
            dist: {
                files: {
                    "<%= build.path %>/vendors.min.js": ["<%= build.path %>/vendors.js"],
                    // '<%= build.path %>/jsorolla.min.js': ['<%= build.path %>/jsorolla-clients.js']
                }
            }
        },
        copy: {
            dist: {
                files: [
                    {   expand: true, cwd: "lib/jsorolla/src/lib/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/cache/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib/cache" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/clients/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib/clients" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/data-adapter/feature/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib/data-adapter/feature" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/opencga/variant/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib/opencga/variant" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/visualisation/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib/visualisation" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/widgets/feature/info/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib/widgets/feature/info" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/widgets/", src: ["ux-window.js"], dest: "<%= build.path %>/jsorolla/lib/widgets" },
                    {   expand: true, cwd: "lib/jsorolla/src/genome-browser/", src: ["**"], dest: "<%= build.path %>/jsorolla/genome-browser" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap/dist/css/bootstrap.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap-table/dist/bootstrap-table.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap-treeview/dist/bootstrap-treeview.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["fontawesome/css/font-awesome.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["qtip2/jquery.qtip.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["fontawesome/fonts/*"], dest: "<%= build.path %>/fonts" },
                    {   flatten: true, expand: true, cwd: "./lib", src: ["jsorolla/styles/css/style.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./lib", src: ["jsorolla/styles/img/*"], dest: "<%= build.path %>/img" },
                    {   expand: true, cwd: "./bower_components", src: ["polymer/*"], dest: "<%= build.vendor %>" },
                    {   expand: true, cwd: "src", src: ["index.html"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src", src: ["conf/config.js"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src", src: ["conf/tools.js"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src", src: ["conf/panels.js"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src", src: ["conf/icd10.js"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "./", src: ["LICENSE"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src/img/", src: ["*"], dest: "<%= build.path %>/img" }
                ]
            }
        },
        processhtml: {
            options: {
                strip: true
            },
            dist: {
                files: {
                    "<%= build.path %>/index.html": ["src/index.html"]
                }
            }
        },
        vulcanize: {
            default: {
                options: {
                    // Task-specific options go here.
                    stripComments: true,
                    excludes: ["bower_components/polymer/polymer.html"]
                },
                files: {
                    "<%= build.path %>/iva-app.html": "src/iva-app.html"
                }
            }
        },
        watch: {
            files: ["<%= jshint.files %>"],
            tasks: ["jshint"]
        },
        replace: {
            dist: {
                options: {
                    patterns: [
                        {
                            match: /\.\.\/bower_components/g,
                            replacement: "vendor"
                        },
                        {
                            match: /\.\.\/lib\/jsorolla\/src/g,
                            replacement: "jsorolla"
                        }
                    ]
                },
                files: [
                    {expand: true, flatten: true, src: ["<%= build.path %>/index.html"], dest: "<%= build.path %>"},
                    {expand: true, flatten: true, src: ["<%= build.path %>/iva-app.html"], dest: "<%= build.path %>"},

                ]
            }
        }
    });

    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-processhtml");
    grunt.loadNpmTasks("grunt-vulcanize");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-replace");

    grunt.registerTask("default", ["clean", "jshint", "copy", "concat", "uglify", "processhtml", "vulcanize", "replace"]);
    grunt.registerTask("cl", ["clean"]);
};<commit_msg>Fix boostrap-treeview path in the build<commit_after>
module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),
        build: {
            path: "build/<%= pkg.version %>",
            vendor: "<%= build.path %>/vendor"
        },
        clean: {
            dist: ["<%= build.path %>/*"]
        },
        jshint: {
            files: ["Gruntfile.js", "src/**/*.js"],
            options: {
                globals: {
                    jQuery: true
                }
            }
        },
        concat: {
            options: {
                sourceMap: true
            },
            vendors: {
                src: [
                    "./bower_components/webcomponentsjs/webcomponents-lite.js",
                    "./bower_components/jquery/dist/jquery.js",
                    "./bower_components/bootstrap/dist/js/bootstrap.js",
                    "./bower_components/bootstrap-table/dist/bootstrap-table.js",
                    "./bower_components/bootstrap-treeview/src/js/bootstrap-treeview.js",
                    "./bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js",
                    "./bower_components/bootstrap-validator/dist/validator.js",
                    "./bower_components/moment/moment.js",
                    "./bower_components/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js",
                    "./bower_components/underscore/underscore.js",
                    "./bower_components/backbone/backbone.js",
                    "./bower_components/highcharts-release/highcharts.js",
                    "./bower_components/qtip2/jquery.qtip.js",
                    "./bower_components/uri.js/src/URI.js",
                    "./bower_components/cookies-js/dist/cookies.js",
                    "./bower_components/crypto-js/crypto-js.js"
                ],
                dest: "<%= build.path %>/vendors.js"
            }
            // ,jsorolla: {
            //     src: [
            //         "./lib/jsorolla/src/lib/clients/rest-client.js",
            //         "./lib/jsorolla/src/lib/clients/cellbase-client-config.js",
            //         "./lib//jsorolla/src/lib/clients/cellbase-client.js",
            //         "./lib/jsorolla/src/lib/clients/opencga-client-config.js",
            //         "./lib/jsorolla/src/lib/clients/opencga-client.js",
            //         "./lib/jsorolla/src/lib/cache/indexeddb-cache.js",
            //         "./lib/jsorolla/src/lib/utils.js",
            //         "./lib/jsorolla/src/lib/svg.js",
            //         "./lib/jsorolla/src/lib/region.js",
            //         "./lib/jsorolla/src/lib/visualisation/lollipop.js",
            //         "./lib/jsorolla/src/lib/opencga/variant/variant-utils.js"
            //     ],
            //     dest: "<%= build.path %>/jsorolla-clients.js"
            // }
            // ,genomeViewer: {
            //     src: [
            //         // "./lib/jsorolla/build/2.0.0-beta/genome-browser/gv-config.js",
            //         // "./lib/jsorolla/build/2.0.0-beta/genome-browser/genome-browser.js"
            //     ],
            //     dest: "<%= build.path %>/genome-browser.js"
            // }
        },
        uglify: {
            options: {
                banner: "/*! IVA <%= grunt.template.today(\"dd-mm-yyyy\") %> */\n"
            },
            dist: {
                files: {
                    "<%= build.path %>/vendors.min.js": ["<%= build.path %>/vendors.js"],
                    // '<%= build.path %>/jsorolla.min.js': ['<%= build.path %>/jsorolla-clients.js']
                }
            }
        },
        copy: {
            dist: {
                files: [
                    {   expand: true, cwd: "lib/jsorolla/src/lib/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/cache/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib/cache" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/clients/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib/clients" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/data-adapter/feature/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib/data-adapter/feature" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/opencga/variant/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib/opencga/variant" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/visualisation/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib/visualisation" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/widgets/feature/info/", src: ["*.js"], dest: "<%= build.path %>/jsorolla/lib/widgets/feature/info" },
                    {   expand: true, cwd: "lib/jsorolla/src/lib/widgets/", src: ["ux-window.js"], dest: "<%= build.path %>/jsorolla/lib/widgets" },
                    {   expand: true, cwd: "lib/jsorolla/src/genome-browser/", src: ["**"], dest: "<%= build.path %>/jsorolla/genome-browser" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap/dist/css/bootstrap.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap-table/dist/bootstrap-table.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap-treeview/dist/bootstrap-treeview.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["fontawesome/css/font-awesome.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["qtip2/jquery.qtip.min.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./bower_components", src: ["fontawesome/fonts/*"], dest: "<%= build.path %>/fonts" },
                    {   flatten: true, expand: true, cwd: "./lib", src: ["jsorolla/styles/css/style.css"], dest: "<%= build.path %>/css" },
                    {   flatten: true, expand: true, cwd: "./lib", src: ["jsorolla/styles/img/*"], dest: "<%= build.path %>/img" },
                    {   expand: true, cwd: "./bower_components", src: ["polymer/*"], dest: "<%= build.vendor %>" },
                    {   expand: true, cwd: "src", src: ["index.html"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src", src: ["conf/config.js"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src", src: ["conf/tools.js"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src", src: ["conf/panels.js"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src", src: ["conf/icd10.js"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "./", src: ["LICENSE"], dest: "<%= build.path %>/" },
                    {   expand: true, cwd: "src/img/", src: ["*"], dest: "<%= build.path %>/img" }
                ]
            }
        },
        processhtml: {
            options: {
                strip: true
            },
            dist: {
                files: {
                    "<%= build.path %>/index.html": ["src/index.html"]
                }
            }
        },
        vulcanize: {
            default: {
                options: {
                    // Task-specific options go here.
                    stripComments: true,
                    excludes: ["bower_components/polymer/polymer.html"]
                },
                files: {
                    "<%= build.path %>/iva-app.html": "src/iva-app.html"
                }
            }
        },
        watch: {
            files: ["<%= jshint.files %>"],
            tasks: ["jshint"]
        },
        replace: {
            dist: {
                options: {
                    patterns: [
                        {
                            match: /\.\.\/bower_components/g,
                            replacement: "vendor"
                        },
                        {
                            match: /\.\.\/lib\/jsorolla\/src/g,
                            replacement: "jsorolla"
                        }
                    ]
                },
                files: [
                    {expand: true, flatten: true, src: ["<%= build.path %>/index.html"], dest: "<%= build.path %>"},
                    {expand: true, flatten: true, src: ["<%= build.path %>/iva-app.html"], dest: "<%= build.path %>"},

                ]
            }
        }
    });

    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-processhtml");
    grunt.loadNpmTasks("grunt-vulcanize");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-replace");

    grunt.registerTask("default", ["clean", "jshint", "copy", "concat", "uglify", "processhtml", "vulcanize", "replace"]);
    grunt.registerTask("cl", ["clean"]);
};<|endoftext|>


<commit_before>require('es6-promise').polyfill();

module.exports = function(grunt) {

  var sauceLaunchers = require('./test/sauceLaunchers');

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
      options: {
        jshintrc: true
      }
    },
    mochaTest: {
      test: {
        src: ['test/**/*.spec.js']
      }
    },
    browserify: {
      dist: {
        src: ['src/index.js'],
        dest: 'dist/<%= pkg.name %>.js',
        options: {
          browserifyOptions: {
            standalone: 'Reflux'
          }
        },
      }
    },
    uglify: {
      dist: {
        src: 'dist/reflux.js',
        dest: 'dist/reflux.min.js'
      }
    },
    watch: {
      files: ['<%= jshint.files %>'],
      tasks: ['build']
    },
    karma: {
      local: {
        configFile: 'karma.conf.js',
        options: {
            browsers: ['PhantomJS']
        }
      },
      sauce: {
        configFile: 'karma.conf.js',
        options: {
          reporters: ['dots', 'saucelabs'],
          sauceLabs: {
            public: 'public',
            testName: 'RefluxJS Karma Tests',
            recordVideo: false,
            recordScreenshot: false
          },
          customLaunchers: sauceLaunchers,
          browsers: Object.keys(sauceLaunchers)
        }
      }
    }
  });

  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  grunt.registerTask('test', ['jshint', 'mochaTest', 'karma:local']);

  grunt.registerTask('travis', ['test', 'karma:sauce']);

  grunt.registerTask('build', ['test', 'browserify', 'uglify']);

  grunt.registerTask('default', ['watch']);

};
<commit_msg>Added longer timeout<commit_after>require('es6-promise').polyfill();

module.exports = function(grunt) {

  var sauceLaunchers = require('./test/sauceLaunchers');

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
      options: {
        jshintrc: true
      }
    },
    mochaTest: {
      test: {
        src: ['test/**/*.spec.js']
      }
    },
    browserify: {
      dist: {
        src: ['src/index.js'],
        dest: 'dist/<%= pkg.name %>.js',
        options: {
          browserifyOptions: {
            standalone: 'Reflux'
          }
        },
      }
    },
    uglify: {
      dist: {
        src: 'dist/reflux.js',
        dest: 'dist/reflux.min.js'
      }
    },
    watch: {
      files: ['<%= jshint.files %>'],
      tasks: ['build']
    },
    karma: {
      local: {
        configFile: 'karma.conf.js',
        options: {
            browsers: ['PhantomJS']
        }
      },
      sauce: {
        configFile: 'karma.conf.js',
        options: {
          reporters: ['dots', 'saucelabs'],
          sauceLabs: {
            public: 'public',
            testName: 'RefluxJS Karma Tests',
            recordVideo: false,
            recordScreenshot: false
          },
          customLaunchers: sauceLaunchers,
          browsers: Object.keys(sauceLaunchers),
          captureTimeout: 120000
        }
      }
    }
  });

  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  grunt.registerTask('test', ['jshint', 'mochaTest', 'karma:local']);

  grunt.registerTask('travis', ['test', 'karma:sauce']);

  grunt.registerTask('build', ['test', 'browserify', 'uglify']);

  grunt.registerTask('default', ['watch']);

};
<|endoftext|>


<commit_before>
App = {
	init: function() {
		var endpoint = 'http://localhost:3000/jawbone';
		$.ajax({
			url: endpoint,
			method: 'GET',
			headers: {
	          'Accept': 'application/json',
	          'Authorization': 'Bearer b6_3pfGGwEi3Q2vrLdoIRfFK59dIENPZEcqJqnkeCcki7I-52Pt9BQwPL5RD418q8EvaJSumcI0GoYT-V9UbpVECdgRlo_GULMgGZS0EumxrKbZFiOmnmAPChBPDZ5JP',
	        },
			success: function(data) {
				var steps = data.data.items[0].title;
				$('.steps').html(steps);
			},
			error: function(response) {
				console.log('data error', response);
			}
		});

	}
}
App.init();
<commit_msg>third commit<commit_after>
App = {
	init: function refreshData() {
		var endpoint = 'http://localhost:3000/jawbone';
		$.ajax({
			url: endpoint,
			method: 'GET',
			headers: {
	          'Accept': 'application/json',
	          'Authorization': 'Bearer b6_3pfGGwEi3Q2vrLdoIRfFK59dIENPZEcqJqnkeCcki7I-52Pt9BQwPL5RD418q8EvaJSumcI0GoYT-V9UbpVECdgRlo_GULMgGZS0EumxrKbZFiOmnmAPChBPDZ5JP',
	        },
			success: function(data) {
				var steps = data.data.items[0].title;
				$('.steps').html(steps);
				console.log("Hi you have new");

			},
			error: function(response) {
				console.log('data error', response);
			}
		});

	setInterval(refreshData, 50000);
	}
}
App.init();

<|endoftext|>


<commit_before>$(document).ready(function() {
  $('#parse').click(function() {
    try {
      var myCodeMirror = $(".CodeMirror")[0].CodeMirror
      var source = myCodeMirror.getValue()

      out.className = "unhidden";

      // Import: Change: $('#input').val() -> source, i forget it, again
      var tree = calculator.parse(source);
      plegadoConstantes(tree);
      $('#output').html(JSON.stringify(tree,undefined,2));
    } catch (e) {
      $('#output').html('

\n' + String(e) + '\n

');
    }
  });

  $("#examples").change(function(ev) {
    var f = ev.target.files[0];
    var r = new FileReader();
    r.onload = function(e) {
      var contents = e.target.result;

      var myCodeMirror = $('.CodeMirror')[0].CodeMirror;
      myCodeMirror.setValue(contents);
    }
    r.readAsText(f);
  });

});
function plegadoConstantes(tree){
	switch (tree.type){
		case "BLOCK":
		case "procedure":
			if(tree.hasOwnProperty("procs") && tree.procs != "NULL"){
				plegadoConstantes(tree.procs);
			}
			if(tree.hasOwnProperty("stat")){
				for (var i in tree.stat.statement_list){
					plegadoConstantes(tree.stat.statement_list[i]);
				}
			}
			break;
		case "=":
			tree.left = tree.value;
			alert(tree.value);
			break;
		case "CALL":
			break;
		case "BEGIN":
			break;
		case "IF":
			break;
		case "IFELSE":
			break;
		case "ODD":
			break;
		case "==":
		case "!=":
		case "<=":
		case "<":
		case ">":
		case ">=":
		case "-":
		case "+":
		case "*":
		case "/":

		break;
		case "NUMBER":
			break;
		case "ID":
			break;
	}
}

<commit_msg>change<commit_after>$(document).ready(function() {
  $('#parse').click(function() {
    try {
      var myCodeMirror = $(".CodeMirror")[0].CodeMirror
      var source = myCodeMirror.getValue()

      out.className = "unhidden";

      // Import: Change: $('#input').val() -> source, i forget it, again
      var tree = calculator.parse(source);
      plegadoConstantes(tree);
      $('#output').html(JSON.stringify(tree,undefined,2));
    } catch (e) {
      $('#output').html('

\n' + String(e) + '\n

');
    }
  });

  $("#examples").change(function(ev) {
    var f = ev.target.files[0];
    var r = new FileReader();
    r.onload = function(e) {
      var contents = e.target.result;

      var myCodeMirror = $('.CodeMirror')[0].CodeMirror;
      myCodeMirror.setValue(contents);
    }
    r.readAsText(f);
  });

});
function plegadoConstantes(tree){
	switch (tree.type){
		case "BLOCK":
		case "procedure":
			if(tree.hasOwnProperty("procs") && tree.procs != "NULL"){
				plegadoConstantes(tree.procs);
			}
			if(tree.hasOwnProperty("stat")){
				for (var i in tree.stat.statement_list){
					plegadoConstantes(tree.stat.statement_list[i]);
				}
			}
			break;
		case "=":
			tree.left = tree.value;
			var num = {
				type:"Number",
				value:tree.value
			}
			var treeN = {
				type: "=",
				left: tree.right,
				right: num
			}
			alert(JISON.stringify(treeN));
			break;
		case "CALL":
			break;
		case "BEGIN":
			break;
		case "IF":
			break;
		case "IFELSE":
			break;
		case "ODD":
			break;
		case "==":
		case "!=":
		case "<=":
		case "<":
		case ">":
		case ">=":
		case "-":
		case "+":
		case "*":
		case "/":

		break;
		case "NUMBER":
			break;
		case "ID":
			break;
	}
}

<|endoftext|>


<commit_before>$(document).ready(function(){
	//JqueRY carousel home. .testeSlice
	var total = $(".testeSlice li").size();
	if(total > 3)
		{
			var ultimo = $(".testeSlice li:last").clone().prependTo(".testeSlice");
			$(".testeSlice").css("left","-385px");
			$(".s-direita").on("click",function(){
				$(".testeSlice").css("left","+=385px");
				//$(".testeSlice li:first").appendTo(".testeSlice");
				return false;
			})
			$(".s-esquerda").on("click",function(){
				//$(".testeSlice li:last").prependTo(".testeSlice");
				$(".testeSlice").css("left","-=385px");
				return false;
			})
		}
	//
	$(".loadAjax").on("click","a",function(){
		$(".loadAjax").fadeOut("fast",function(){
			$('html, body').css({
			    'overflow': 'auto',
			    'height': 'auto'
			});
		});
		return false;
	});
	$(".abrirContato").on("click",function(){
		$.ajax({
	        url: basePatch+"/contato",
	        success: function( data )
	        {
	        	$(".loadAjax").html(data);
	        	$(".loadAjax").fadeIn("fast",function(){
	        		$('html, body').css({
		        	    'overflow': 'hidden',
		        	    'height': '100%'
		        	})
	        	});
	        }
	    });
		return false;
	})

	$(".nav-button").click(function () {
		$(".nav-button,.box-menu").toggleClass("open");
	});
	var w = window.innerWidth;
	if(w <= 800)
	{
		$(".g-produtos").css('overflow-x', 'auto');
	}
	window.onresize = function(event) {
		if(w <= 800)
			{
				$(".g-produtos").css('overflow-x', 'auto');
			}
	};
	$(window).scroll(function() {
			var posicao = $(document).scrollTop();
			if(posicao >= 88)
				{
					$("#wowslider-container1").css("top",(posicao-88)+"px");
				}
			else
				{
					$("#wowslider-container1").css("top","0px");
				}
			if(posicao >= 0)
			{
				$(".h-container-top").css("top",(posicao-0)+"px");
			}
		else
			{
				$(".h-container-top").css("top","0px");
			}

		});
	var cont = 1;
	$(".listaImagensTecnologia li").each(function( key, value ) {
		switch (cont)
		{
		case 1:
		  $("a",this).addClass("effect-top");
		  break;
		case 2:
			$("a",this).addClass("effect-left");
		  break;
		case 3:
			$("a",this).addClass("effect-bottom");
		  break;
		case 4:
			$("a",this).addClass("effect-right");
		  break;
		}
			if(cont == 4)
				{
				cont = 1;
				}
			else
				{
				cont++;
				}
		});
});<commit_msg>dereck<commit_after>$(document).ready(function(){
	//JqueRY carousel home. .testeSlice
	var total = $(".testeSlice li").size();
	if(total > 3)
		{
			var ultimo = $(".testeSlice li:last").clone().prependTo(".testeSlice");
			$(".testeSlice").css("left","-385px");
			$(".s-direita").on("click",function(){
				$(".testeSlice li").animate({
				    left: "+=385px"
				  }, {duration:800, queue:false} );
				return false;
			})
			$(".s-esquerda").on("click",function(){
				//$(".testeSlice li:last").prependTo(".testeSlice");
				$(".testeSlice li").animate({
				    left: "-=385px"
				  }, {duration:800, queue:false} );
				return false;
			})
		}
	//
	$(".loadAjax").on("click","a",function(){
		$(".loadAjax").fadeOut("fast",function(){
			$('html, body').css({
			    'overflow': 'auto',
			    'height': 'auto'
			});
		});
		return false;
	});
	$(".abrirContato").on("click",function(){
		$.ajax({
	        url: basePatch+"/contato",
	        success: function( data )
	        {
	        	$(".loadAjax").html(data);
	        	$(".loadAjax").fadeIn("fast",function(){
	        		$('html, body').css({
		        	    'overflow': 'hidden',
		        	    'height': '100%'
		        	})
	        	});
	        }
	    });
		return false;
	})

	$(".nav-button").click(function () {
		$(".nav-button,.box-menu").toggleClass("open");
	});
	var w = window.innerWidth;
	if(w <= 800)
	{
		$(".g-produtos").css('overflow-x', 'auto');
	}
	window.onresize = function(event) {
		if(w <= 800)
			{
				$(".g-produtos").css('overflow-x', 'auto');
			}
	};
	$(window).scroll(function() {
			var posicao = $(document).scrollTop();
			if(posicao >= 88)
				{
					$("#wowslider-container1").css("top",(posicao-88)+"px");
				}
			else
				{
					$("#wowslider-container1").css("top","0px");
				}
			if(posicao >= 0)
			{
				$(".h-container-top").css("top",(posicao-0)+"px");
			}
		else
			{
				$(".h-container-top").css("top","0px");
			}

		});
	var cont = 1;
	$(".listaImagensTecnologia li").each(function( key, value ) {
		switch (cont)
		{
		case 1:
		  $("a",this).addClass("effect-top");
		  break;
		case 2:
			$("a",this).addClass("effect-left");
		  break;
		case 3:
			$("a",this).addClass("effect-bottom");
		  break;
		case 4:
			$("a",this).addClass("effect-right");
		  break;
		}
			if(cont == 4)
				{
				cont = 1;
				}
			else
				{
				cont++;
				}
		});
});<|endoftext|>


<commit_before>$(document).ready(function(){
  $.getJSON("static/sampledata.json", function(data) {
    console.log(data);
    window.model = {
      "scans":ko.observableArray(),
      "filename":"",
      "filetype":"png",
      showScan:function(data) {
        console.log(data);
      },
      newScan: function() {
        console.log("newScan");
        $.ajax(
          '/api/scanimage?filename='
            +window.model.filename
            +window.model.filetype,
          {success: function(data,status) {
              window.model.showAlert("Scan queued");
            }
          }
        );
      },
      preview: function() {
        console.log("preview");
        $.ajax(
          '/api/preview',
          {success: function(data,status) {
              window.model.showAlert("Preview queued");
            }
          }
        );
      },
      updateFlatbed: function(filename) {
        $(".app-imagepreview").empty();
        $("",{src:"/scans/"+filename}).appendTo(".app-imagepreview");
      },
      showAlert: function(text) {
        var alertCount = $("alerts").children().length;
        $("#alerts").append('
'+text+'
');
        //$("#alert"+alertCount).alert();
        setTimeout(function() {
          $("#alert"+alertCount).alert('close');
        }, 5000);
      }
    }
    $.each(data.scans, function(i,d) {window.model.scans.push(d);});
    console.log(window.model);
    ko.applyBindings(window.model);
    var socket = io.connect(); // Emit ready event.
    socket.emit('ready'); // Listen for the talk event.
    socket.on('updated',
      function(data) {
        var scans = data.scans
        console.log(scans);
        $.each(scans, function(i,d) {
          console.log(d);
          window.model.scans.push(d);
        });
      });
    socket.on('scanComplete',
      function(data) {
        console.log('scan completed');
        var image = data.filename;
        window.model.updateFlatbed(image);
      }
    );
     socket.on('previewComplete',
      function(data) {
        console.log('preview completed');
        var image = data.filename;
        window.model.updateFlatbed(image);
      }
    );
  });
});
<commit_msg>Fix some code issues. Closes #2.<commit_after>$(document).ready(function(){
  $.getJSON("static/sampledata.json", function(data) {
    console.log(data);
    window.model = {
      "scans":ko.observableArray(),
      "filename":"",
      "filetype":"png",
      showScan:function(data) {
        console.log(data);
      },
      newScan: function() {
        console.log("newScan");
        $.ajax(
          '/api/scanimage?filename=' +
            window.model.filename +
            window.model.filetype,
          {success: function(data,status) {
              window.model.showAlert("Scan queued");
            }
          }
        );
      },
      preview: function() {
        console.log("preview");
        $.ajax(
          '/api/preview',
          {success: function(data,status) {
              window.model.showAlert("Preview queued");
            }
          }
        );
      },
      updateFlatbed: function(filename) {
        $(".app-imagepreview").empty();
        $("",{src:"/scans/"+filename}).appendTo(".app-imagepreview");
      },
      showAlert: function(text) {
        var alertCount = $("alerts").children().length;
        $("#alerts").append('
'+text+'
');
        //$("#alert"+alertCount).alert();
        setTimeout(function() {
          $("#alert"+alertCount).alert('close');
        }, 5000);
      }
    };
    $.each(data.scans, function(i,d) {window.model.scans.push(d);});
    console.log(window.model);
    ko.applyBindings(window.model);
    var socket = io.connect(); // Emit ready event.
    socket.emit('ready'); // Listen for the talk event.
    socket.on('updated',
      function(data) {
        var scans = data.scans;
        console.log(scans);
        $.each(scans, function(i,d) {
          console.log(d);
          window.model.scans.push(d);
        });
      });
    socket.on('scanComplete',
      function(data) {
        console.log('scan completed');
        var image = data.filename;
        window.model.updateFlatbed(image);
      }
    );
     socket.on('previewComplete',
      function(data) {
        console.log('preview completed');
        var image = data.filename;
        window.model.updateFlatbed(image);
      }
    );
  });
});
<|endoftext|>