From 1190047bf2a3b9cf9ea8a44716c696b0ef8de4bd Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sun, 11 Aug 2013 21:38:58 -0500 Subject: [PATCH] * VRFS-478 done with ctrl + shift + 0 secret hotkey to make browser act like a native client --- app/assets/javascripts/corp/contact.js | 1 - app/assets/javascripts/homeScreen.js | 25 +++++- app/assets/stylesheets/client/home.css.scss | 14 ++++ app/controllers/clients_controller.rb | 12 +++ app/views/clients/_bands.html.erb | 13 +++ app/views/clients/_home.html.erb | 91 +++++++++++++++------ app/views/clients/_musicians.html.erb | 13 +++ app/views/clients/index.html.erb | 2 + config/application.rb | 3 + config/environments/production.rb | 2 + 10 files changed, 148 insertions(+), 28 deletions(-) create mode 100644 app/views/clients/_bands.html.erb create mode 100644 app/views/clients/_musicians.html.erb diff --git a/app/assets/javascripts/corp/contact.js b/app/assets/javascripts/corp/contact.js index a4852590c..0b963ab68 100644 --- a/app/assets/javascripts/corp/contact.js +++ b/app/assets/javascripts/corp/contact.js @@ -52,7 +52,6 @@ $('div.field', $feedback).removeClass('error'); $submit.val("THANKS!"); - }). fail(function(xhr, textStatus, errorMessage) { $submit.val("SEND"); diff --git a/app/assets/javascripts/homeScreen.js b/app/assets/javascripts/homeScreen.js index 349369a14..eeedd9245 100644 --- a/app/assets/javascripts/homeScreen.js +++ b/app/assets/javascripts/homeScreen.js @@ -22,15 +22,32 @@ } function mouseenterTile() { - console.log("mouseenterTile!") $(this).addClass('hover'); } function mouseleaveTile() { - console.log("mouse leave tile") $(this).removeClass('hover'); } + function switchClientMode(e) { + // ctrl + shift + 0 + if(e.ctrlKey && e.shiftKey && e.keyCode == 48) { + console.log("switch client mode!"); + var act_as_native_client = $.cookie('act_as_native_client'); + + console.log("currently: " + act_as_native_client); + if(act_as_native_client == null || act_as_native_client != "true") { + console.log("forcing act as native client!"); + $.cookie('act_as_native_client', 'true', { expires: 120, path: '/' }); + } + else { + console.log("remove act as native client!"); + $.removeCookie('act_as_native_client'); + } + window.location.reload(); + } + } + function userHasDevices() { // undo any earlier disabling $('.homecard.createsession, .homecard.findsession').removeClass('disabled'); @@ -60,6 +77,9 @@ $('.homecard.profile, .homecard.feed, .homecard.account').on('mouseenter', mouseenterTile); $('.homecard.profile, .homecard.feed, .homecard.account').on('mouseleave', mouseleaveTile); $('div[layout-id=ftue]').on("ftue_success", refreshDeviceState); + if(gon.allow_force_native_client) { + $('body').on('keyup', switchClientMode); + } } function updateTiles() { @@ -83,6 +103,7 @@ app.bindScreen('home', screenBindings); events(); + }; this.beforeShow = beforeShow; diff --git a/app/assets/stylesheets/client/home.css.scss b/app/assets/stylesheets/client/home.css.scss index 1e3ef1148..8347b83ca 100644 --- a/app/assets/stylesheets/client/home.css.scss +++ b/app/assets/stylesheets/client/home.css.scss @@ -24,6 +24,12 @@ .homecard.account { background-image: url(/assets/content/bkg_home_account.jpg); } +.homecard.bands { + background-image: url(/assets/content/bkg_home_bands.jpg); +} +.homecard.musicians { + background-image: url(/assets/content/bkg_home_musicians.jpg); +} .homecard.disabled { cursor:default; @@ -65,4 +71,12 @@ .homecard.account.hover { background-image: url(/assets/content/bkg_home_account_x.jpg); } +.homecard.bands.hover { + background-image: url(/assets/content/bkg_home_bands_x.jpg); +} +.homecard.musicians.hover { + background-image: url(/assets/content/bkg_home_musicians_x.jpg); +} + + diff --git a/app/controllers/clients_controller.rb b/app/controllers/clients_controller.rb index a5924bdaa..043c1efd7 100644 --- a/app/controllers/clients_controller.rb +++ b/app/controllers/clients_controller.rb @@ -8,6 +8,18 @@ class ClientsController < ApplicationController gon.check_for_client_updates = Rails.application.config.check_for_client_updates gon.fp_apikey = Rails.application.config.filepicker_rails.api_key gon.fp_upload_dir = Rails.application.config.filepicker_upload_dir + gon.allow_force_native_client = Rails.application.config.allow_force_native_client + + # is this the native client or browser? + user_agent = request.env["HTTP_USER_AGENT"] + @nativeClient = !user_agent.blank? && user_agent.downcase.include?("jamkazam") + + # allow override of the client type if configured to so, and if we find the override cookie in place + if Rails.application.config.allow_force_native_client + unless cookies[:act_as_native_client].nil? + @nativeClient = (cookies[:act_as_native_client] == "true") ? true : false + end + end if current_user render :layout => 'client' diff --git a/app/views/clients/_bands.html.erb b/app/views/clients/_bands.html.erb new file mode 100644 index 000000000..88aa5fd7a --- /dev/null +++ b/app/views/clients/_bands.html.erb @@ -0,0 +1,13 @@ + +
+
+ +

bands

+ <%= render "screen_navigation" %> +
+

This feature not yet implemented

+
diff --git a/app/views/clients/_home.html.erb b/app/views/clients/_home.html.erb index 2f1266a0e..3e9255132 100644 --- a/app/views/clients/_home.html.erb +++ b/app/views/clients/_home.html.erb @@ -1,31 +1,72 @@
- -
-
-

create session

-
+ + <% if @nativeClient %> +
+
+

create session

+ +
-
-

find session

-
+
+

find session

+ +
-
-

profile

-
+
+

profile

+ +
-
-

feed

-
+
+

feed

+ +
- -
\ No newline at end of file +
+ <% else %> +
+
+

feed

+ +
+
+
+

bands

+ +
+
+
+

musicians

+ +
+
+
+

profile

+ +
+
+ +
+ <% end %> + +
diff --git a/app/views/clients/_musicians.html.erb b/app/views/clients/_musicians.html.erb new file mode 100644 index 000000000..c8f0615cd --- /dev/null +++ b/app/views/clients/_musicians.html.erb @@ -0,0 +1,13 @@ + +
+
+ +

musicians

+ <%= render "screen_navigation" %> +
+

This feature not yet implemented

+
diff --git a/app/views/clients/index.html.erb b/app/views/clients/index.html.erb index 4ecedce50..e6072909a 100644 --- a/app/views/clients/index.html.erb +++ b/app/views/clients/index.html.erb @@ -19,6 +19,8 @@ <%= render "session" %> <%= render "profile" %> <%= render "feed" %> +<%= render "bands" %> +<%= render "musicians" %> <%= render "testBridge" %> <%= render "account" %> <%= render "account_identity" %> diff --git a/config/application.rb b/config/application.rb index 30f0ffd44..92401bd64 100644 --- a/config/application.rb +++ b/config/application.rb @@ -143,5 +143,8 @@ if defined?(Bundler) # client update killswitch; turn on if client updates are broken and are affecting users config.check_for_client_updates = true + + # allow hot-key to switch between native and normal client + config.allow_force_native_client = true end end diff --git a/config/environments/production.rb b/config/environments/production.rb index cbe0f825e..f4328abb5 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -80,4 +80,6 @@ SampleApp::Application.configure do # filepicker app configured to use S3 bucket jamkazam config.filepicker_rails.api_key = "AhUoVoBZSLirP3esyCl7Zz" config.fp_secret = 'HZBIMSOI5VAQ5LXT4XLG6XA7IE' + + config.allow_force_native_client = false end