-
Notifications
You must be signed in to change notification settings - Fork 1
HOT FEECHERS ROLLIN THRU #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chenan02
wants to merge
8
commits into
whuang8:master
Choose a base branch
from
chenan02:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e5d706f
Add home controller and button
chenan02 4fb324e
Add home controller and button
chenan02 4526b75
Merge branch 'master' of https://github.com/chenan02/ButtonKing
chenan02 55f15d5
Remove unneccessary files
chenan02 1b9b0e7
Add User name storage
chenan02 22e677d
HITTIN EM W DAT LOGIN MODAL
chenan02 1b94a5b
TIMER FUNKTION COMIN IN HOT
chenan02 618bbf0
CHECK OUT DIS SESSIONS AND AJAX CALL STORING
chenan02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,3 +15,5 @@ | |
| /log/* | ||
| !/log/.keep | ||
| /tmp | ||
|
|
||
| *.DS_Store | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,4 +13,5 @@ | |
| //= require jquery | ||
| //= require jquery_ujs | ||
| //= require turbolinks | ||
| //= require bootstrap | ||
| //= require_tree . | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // we want this global timer to be accessed by all user threads | ||
|
|
||
| var userOwns = false; | ||
|
|
||
| $(document).on('click', '#button', function() { | ||
| if(userOwns == false) { | ||
| startClock(); | ||
| userOwns = true; | ||
| } | ||
| else { | ||
| // when someone else clicks button, you lose it and get set to zero | ||
| // store session name and time in db | ||
|
|
||
| var stopTime = $time.innerHTML; | ||
| $.post("/users", | ||
| { | ||
| time: stopTime | ||
| }, | ||
| function() { | ||
| alert("congratz u got a time of: " + stopTime); | ||
| } | ||
| ); | ||
| stopClock(); | ||
| resetClock(); | ||
| userOwns = false; | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| var clsStopwatch = function() { | ||
| // Private vars | ||
| var startAt = 0; // Time of last start / resume. (0 if not running) | ||
| var lapTime = 0; // Time on the clock when last stopped in milliseconds | ||
|
|
||
| var now = function() { | ||
| return (new Date()).getTime(); | ||
| }; | ||
|
|
||
| // Public methods | ||
| // Start or resume | ||
| this.startClock = function() { | ||
| startAt = startAt ? startAt : now(); | ||
| }; | ||
|
|
||
| // Stop or pause | ||
| this.stopClock = function() { | ||
| // If running, update elapsed time otherwise keep it | ||
| lapTime = startAt ? lapTime + now() - startAt : lapTime; | ||
| startAt = 0; // Paused | ||
| }; | ||
|
|
||
| // Reset | ||
| this.resetClock = function() { | ||
| lapTime = startAt = 0; | ||
| }; | ||
|
|
||
| // Duration | ||
| this.time = function() { | ||
| return lapTime + (startAt ? now() - startAt : 0); | ||
| }; | ||
| }; | ||
|
|
||
| var x = new clsStopwatch(); | ||
| var $time; | ||
| var clocktimer; | ||
|
|
||
| function pad(num, size) { | ||
| var s = "0000" + num; | ||
| return s.substr(s.length - size); | ||
| } | ||
|
|
||
| function formatTime(time) { | ||
| var h = m = s = ms = 0; | ||
| var newTime = ''; | ||
|
|
||
| h = Math.floor( time / (60 * 60 * 1000) ); | ||
| time = time % (60 * 60 * 1000); | ||
| m = Math.floor( time / (60 * 1000) ); | ||
| time = time % (60 * 1000); | ||
| s = Math.floor( time / 1000 ); | ||
| ms = time % 1000; | ||
|
|
||
| newTime = pad(h, 2) + ':' + pad(m, 2) + ':' + pad(s, 2) + ':' + pad(ms, 3); | ||
| return newTime; | ||
| } | ||
|
|
||
| function showClock() { | ||
| $time = document.getElementById('time'); | ||
| updateClock(); | ||
| } | ||
|
|
||
| function updateClock() { | ||
| $time.innerHTML = formatTime(x.time()); | ||
| } | ||
|
|
||
| function startClock() { | ||
| clocktimer = setInterval("updateClock()", 1); | ||
| x.startClock(); | ||
| } | ||
|
|
||
| function stopClock() { | ||
| x.stopClock(); | ||
| clearInterval(clocktimer); | ||
| } | ||
|
|
||
| function resetClock() { | ||
| stopClock(); | ||
| x.resetClock(); | ||
| updateClock(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Place all the behaviors and hooks related to the matching controller here. | ||
| # All this logic will automatically be available in application.js. | ||
| # You can use CoffeeScript in this file: http://coffeescript.org/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| $(window).load(function(){ | ||
| $('#signinModal').modal('show'); | ||
| }); | ||
|
|
||
| function closeModal() { | ||
| $('#signinModal').modal('hide'); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,5 @@ | |
| *= require_tree . | ||
| *= require_self | ||
| */ | ||
|
|
||
| @import "bootstrap"; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Place all the styles related to the home controller here. | ||
| // They will automatically be included in application.css. | ||
| // You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| class HomeController < ApplicationController | ||
| def index | ||
| @user = User.new | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,21 @@ | ||
| class UsersController < ApplicationController | ||
| def new | ||
| def create | ||
| User.create( | ||
| name: session[:name], | ||
| time: params[:time] | ||
| ) | ||
| redirect_to root_path | ||
| end | ||
|
|
||
| def store_user | ||
| # so user can stay on same page and reuse session name | ||
| session[:name] = user_params[:name] | ||
| redirect_to root_path | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def user_params | ||
| params.require(:user).permit(:name) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| module HomeHelper | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <%= image_tag "button.png", id: "button" %> | ||
|
|
||
| <div>Time: <span id="time"></span></div> | ||
|
|
||
| <%= render partial: 'users/new' %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <div class="modal fade" id="signinModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | ||
| <div class="modal-dialog" role="document"> | ||
| <div class="modal-content"> | ||
| <div class="modal-header"> | ||
| <h4 class="modal-title">Sign in</h4> | ||
| </div> | ||
| <div class="modal-body"> | ||
| <%= form_for @user, remote: true, url: store_user_path, method: "post", class: "form-inline" do |f| %> | ||
| <%= f.label "Hi! What's your name?" %> | ||
| <%= f.text_field :name, class: "form-control" %> | ||
| </div> | ||
| <div class="modal-footer"> | ||
| <%= f.submit "Play!", class: "btn btn-primary", onclick: "closeModal()" %> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,58 +1,5 @@ | ||
| Rails.application.routes.draw do | ||
| get 'users/new' | ||
|
|
||
| # The priority is based upon order of creation: first created -> highest priority. | ||
| # See how all your routes lay out with "rake routes". | ||
|
|
||
| # You can have the root of your site routed with "root" | ||
| # root 'welcome#index' | ||
|
|
||
| # Example of regular route: | ||
| # get 'products/:id' => 'catalog#view' | ||
|
|
||
| # Example of named route that can be invoked with purchase_url(id: product.id) | ||
| # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase | ||
|
|
||
| # Example resource route (maps HTTP verbs to controller actions automatically): | ||
| # resources :products | ||
|
|
||
| # Example resource route with options: | ||
| # resources :products do | ||
| # member do | ||
| # get 'short' | ||
| # post 'toggle' | ||
| # end | ||
| # | ||
| # collection do | ||
| # get 'sold' | ||
| # end | ||
| # end | ||
|
|
||
| # Example resource route with sub-resources: | ||
| # resources :products do | ||
| # resources :comments, :sales | ||
| # resource :seller | ||
| # end | ||
|
|
||
| # Example resource route with more complex sub-resources: | ||
| # resources :products do | ||
| # resources :comments | ||
| # resources :sales do | ||
| # get 'recent', on: :collection | ||
| # end | ||
| # end | ||
|
|
||
| # Example resource route with concerns: | ||
| # concern :toggleable do | ||
| # post 'toggle' | ||
| # end | ||
| # resources :posts, concerns: :toggleable | ||
| # resources :photos, concerns: :toggleable | ||
|
|
||
| # Example resource route within a namespace: | ||
| # namespace :admin do | ||
| # # Directs /admin/products/* to Admin::ProductsController | ||
| # # (app/controllers/admin/products_controller.rb) | ||
| # resources :products | ||
| # end | ||
| root 'home#index' | ||
| resources :users | ||
| post 'store_user', to: 'users#store_user', as: 'store_user' | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # encoding: UTF-8 | ||
| # This file is auto-generated from the current state of the database. Instead | ||
| # of editing this file, please use the migrations feature of Active Record to | ||
| # incrementally modify your database, and then regenerate this schema definition. | ||
| # | ||
| # Note that this schema.rb definition is the authoritative source for your | ||
| # database schema. If you need to create the application database on another | ||
| # system, you should be using db:schema:load, not running all the migrations | ||
| # from scratch. The latter is a flawed and unsustainable approach (the more migrations | ||
| # you'll amass, the slower it'll run and the greater likelihood for issues). | ||
| # | ||
| # It's strongly recommended that you check this file into your version control system. | ||
|
|
||
| ActiveRecord::Schema.define(version: 20160615013423) do | ||
|
|
||
| create_table "users", force: :cascade do |t| | ||
| t.string "name" | ||
| t.string "time" | ||
| t.datetime "created_at", null: false | ||
| t.datetime "updated_at", null: false | ||
| end | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| require 'test_helper' | ||
|
|
||
| class HomeControllerTest < ActionController::TestCase | ||
| # test "the truth" do | ||
| # assert true | ||
| # end | ||
| end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obvi this is copypasta sry we can take out what we dont need later