From 6404edf28fffda4faacfd9d5ee09ab6cd608e91d Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Sun, 11 Nov 2018 22:12:31 +0530 Subject: [PATCH 01/13] [Plots2 Sign Up] Added warnings for empty fields Gave user an alert of empty fields in the Sign Up Form. Change in: /app/views/users/_form.html.erb language used: javascript --- app/views/users/_form.html.erb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index e4d41353b9..ab43f60bb6 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -161,8 +161,18 @@ From e28959fa404e0e6abff950d0fc2e52110d57cf65 Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Tue, 13 Nov 2018 21:20:35 +0530 Subject: [PATCH 02/13] Added noty.JS and detected empty fields Added warnings for empty fields --- app/views/users/_form.html.erb | 68 ++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 15 deletions(-) diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index ab43f60bb6..cbdfae7620 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -1,5 +1,4 @@ <%= form_for @user, :url => {:controller => 'users', :action => @action}, :html => {:class => "row"} do |f| %> - <% if f.error_messages != "" %>
<%= f.error_messages %>
<% end %>
@@ -148,7 +147,7 @@ <% if params[:controller] == "users" && (params[:action] == "new" || params[:action] == "create") %> - + <%= t('users._form.log_in') %> <% elsif params[:controller] == "users" && params[:action] == "edit" %> @@ -157,24 +156,60 @@ <% end %> - + +
@@ -186,3 +221,6 @@ alert("Field Required"); <% end %> + From b06659f84d6aa14d67551600772b9ef836abbba5 Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Wed, 14 Nov 2018 00:20:48 +0530 Subject: [PATCH 03/13] Removed redundant code --- app/views/users/_form.html.erb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index cbdfae7620..9d95689e43 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -187,9 +187,6 @@ for(i=0;i 0) { From 27b421d6c20a35fd93bcd4cb7990527f90dc4e4a Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Wed, 14 Nov 2018 00:33:30 +0530 Subject: [PATCH 04/13] Added instruction comments + Code indentation --- app/views/users/_form.html.erb | 60 +++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 9d95689e43..6347fb658e 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -168,44 +168,50 @@ */ - function checkInputs() { - var input1 = document.getElementById("username").value; - var input2 = document.getElementById("email").value; - var input3 = document.getElementById("password").value; - var input4 = document.getElementById("password-confirmation").value; - var inputs = [input1, input2, input3, input4]; - var fields = ["Username", "Email", "Password", "Password-confirmation"]; - var inputsLength = inputs.length; - var emptyFields = []; - var i; - var errors=0; - /* -space - */ +function checkInputs() { + //Getting all inputs stored in a variable +var input1 = document.getElementById("username").value; +var input2 = document.getElementById("email").value; +var input3 = document.getElementById("password").value; +var input4 = document.getElementById("password-confirmation").value; + //Array for all inputs +var inputs = [input1, input2, input3, input4]; + //Array for name of all inputs +var fields = ["Username", "Email", "Password", "Password-confirmation"]; + //Getting length of the array +var inputsLength = inputs.length; + //Using this array to store all fields left empty by the user +var emptyFields = []; + //for loop +var i; + //counting err +var errors=0; + //Loop to check empty inputs and fill in their names in the array of emptyFields[] for(i=0;i 0) { new Noty({ - type:'error', + type:'error', text: "Please fill In: " + emptyFields, animation: { - open: 'animated bounceInRight', // Animate.css class names - close: 'animated bounceOutRight', - timeout: 500 // Animate.css class names + open: 'animated bounceInRight', // Animate.css class names + close: 'animated bounceOutRight', + timeout: 500 // Animate.css class names } -}).show(); + }).show(); } else { - $(this).addClass("disabled") // disable the button after it is clicked - .html(""); // make a spinner that spins when clicked - console.log("Success ! No errors found...") - alert("no errors found"); + $(this).addClass("disabled") // disable the button after it is clicked + .html(""); // make a spinner that spins when clicked + console.log("Success ! No errors found...") + alert("no errors found"); } +//closing function checkInputs(); } From 0d52ec138d38cdac37c235856a0c4bce9829c106 Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Thu, 15 Nov 2018 04:32:43 +0530 Subject: [PATCH 05/13] removed Redundant code [2] removed console.log [+1] which I typed in earlier for testing... --- app/views/users/_form.html.erb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 6347fb658e..5e94418308 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -208,8 +208,6 @@ if(errors > 0) { else { $(this).addClass("disabled") // disable the button after it is clicked .html(""); // make a spinner that spins when clicked - console.log("Success ! No errors found...") - alert("no errors found"); } //closing function checkInputs(); } From 8cd925d707613373a8e62e415dbffd68cee99129 Mon Sep 17 00:00:00 2001 From: Gaurav Sachdeva Date: Thu, 15 Nov 2018 04:59:38 +0530 Subject: [PATCH 06/13] code as per file format Co-Authored-By: rohancl --- app/views/users/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 5e94418308..c1b4e0fa21 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -188,7 +188,7 @@ var i; var errors=0; //Loop to check empty inputs and fill in their names in the array of emptyFields[] for(i=0;i Date: Thu, 15 Nov 2018 05:04:38 +0530 Subject: [PATCH 07/13] Code indentation - 4 spaces per indent level Beautification + code formatting --- app/views/users/_form.html.erb | 321 ++++++++++++++------------------- 1 file changed, 134 insertions(+), 187 deletions(-) diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index c1b4e0fa21..fdd96347f5 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -1,227 +1,174 @@ -<%= form_for @user, :url => {:controller => 'users', :action => @action}, :html => {:class => "row"} do |f| %> - <% if f.error_messages != "" %>
<%= f.error_messages %>
<% end %> -
+ +<%= form_for @user, :url => {:controller => 'users', :action => @action}, :html => {:class => "row"} do |f| %> +<% if f.error_messages != "" %> +
<%= f.error_messages %>
+<% end %> +
<% if params[:controller] == "users" && @action == "create" %>
-

Sign up with

+

Sign up with

<% if Rails.env == "production" %> -
+
<%= render :partial => "layouts/social_icons" %> - <% end %> -
- -
-

OR

- -
-
-
- + <% end %> +
+
+

OR

+
+
+
<%= f.text_field :username, { tabindex: 1, class: 'form-control', id: 'username' } %> - -
- - <% end %> - -
- <% if Rails.env == "production" %> - <% if params[:controller] == "users" && params[:action] == "edit" %> -
-
-
- <%= render :partial => "layouts/social_icons" %> -
- <% end %> <% end %> -
- - - - <%= f.text_field :email, { tabindex: 3, placeholder: "you@email.com", class: 'form-control', id: 'email' } %> - +
+ <% if Rails.env == "production" %> + <% if params[:controller] == "users" && params[:action] == "edit" %> +
+ +
+
+ <%= render :partial => "layouts/social_icons" %> +
+ <% end %> + <% end %> +
+ + <%= f.text_field :email, { tabindex: 3, placeholder: "you@email.com", class: 'form-control', id: 'email' } %>
- -
- <% if @user.crypted_password.nil? %> + <% if @user.crypted_password.nil? %> - <% else %> + <% else %> - <% end %> - <%= f.password_field :password, { placeholder: I18n.t('users._form.password'), - tabindex: 4, - class: 'form-control', - id: 'password' } - %> + <% end %> + <%= f.password_field :password, { placeholder: I18n.t('users._form.password'), + tabindex: 4, + class: 'form-control', + id: 'password' } + %>
-
- - <%= f.password_field :password_confirmation, { placeholder: I18n.t('users._form.confirm_password'), - tabindex: 5, - class: 'form-control', - id: 'password-confirmation' } - %> + + <%= f.password_field :password_confirmation, { placeholder: I18n.t('users._form.confirm_password'), + tabindex: 5, + class: 'form-control', + id: 'password-confirmation' } + %>
- -
- - <%= f.text_area :bio, { placeholder: I18n.t('users._form.add_bio'), - rows: 8, - class: 'form-control', - tabindex: 6 } - %> + + <%= f.text_area :bio, { placeholder: I18n.t('users._form.add_bio'), + rows: 8, + class: 'form-control', + tabindex: 6 } + %>
- - <% if params[:controller] == "users" && (params[:action] == "new" || params[:action] == "create") %> - - <% if Rails.env == "production" && !params[:spamaway] %> - - <%= recaptcha_tags %> - - <% else %> - - <%= fields_for @spamaway do |spam| %> - -
- - -

- <%= t('users._form.spam_filtering') %> -

- - <% vars = [:statement1, :statement2, :statement3, :statement4] %> - <% turingtest = Spamaway.get_pairs vars.length %> - <% turingtest.each_index do |i| %> - -
- <% [0,1].each_with_index do |s, j| %><% statement = turingtest[i][s] %> -
- -
- <% end %> -
-
- + <% if Rails.env == "production" && !params[:spamaway] %> + <%= recaptcha_tags %> + <% else %> + <%= fields_for @spamaway do |spam| %> +
+ +

+ <%= t('users._form.spam_filtering') %> +

+ <% vars = [:statement1, :statement2, :statement3, :statement4] %> + <% turingtest = Spamaway.get_pairs vars.length %> + <% turingtest.each_index do |i| %> +
+ <% [0,1].each_with_index do |s, j| %><% statement = turingtest[i][s] %> +
+ +
<% end %> - -
- -
- - <%= spam.text_area :follow_instructions, { class: "form-control col-md-6", - rows: 8, - tabindex: 7, - placeholder: I18n.t('users._form.dont_write_here') } - %> - -
- +
+
<% end %> - - <% end %> - - - + <% end %> -
- - <% if params[:controller] == "users" && (params[:action] == "new" || params[:action] == "create") %> - + <% if params[:controller] == "users" && (params[:action] == "new" || params[:action] == "create") %> <%= t('users._form.log_in') %> - - <% elsif params[:controller] == "users" && params[:action] == "edit" %> - + <% elsif params[:controller] == "users" && params[:action] == "edit" %> - - <% end %> - - - - + <% end %> + + +
- -
- -
+
+
<%= render :partial => 'users/photo' %> -
- +
<% end %> + From 113f1ada2c3f670f0c5970e0a4966b91a55acb08 Mon Sep 17 00:00:00 2001 From: gauravano Date: Thu, 15 Nov 2018 17:11:49 +0530 Subject: [PATCH 08/13] minor changes --- app/views/users/_form.html.erb | 274 ++++++++++++++++----------------- 1 file changed, 135 insertions(+), 139 deletions(-) diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index fdd96347f5..323f5efd43 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -1,174 +1,170 @@ - - <%= form_for @user, :url => {:controller => 'users', :action => @action}, :html => {:class => "row"} do |f| %> -<% if f.error_messages != "" %> -
<%= f.error_messages %>
-<% end %> -
+ <% if f.error_messages != "" %> +
<%= f.error_messages %>
+ <% end %> + +
<% if params[:controller] == "users" && @action == "create" %> -
+

Sign up with

-
- <% if Rails.env == "production" %> -
- <%= render :partial => "layouts/social_icons" %> - <% end %> -
-
+
+ + <% if Rails.env == "production" %> +
+ <%= render :partial => "layouts/social_icons" %> +
+ <% end %> + +

OR

-
-
-
+
+ +
+ +
- <%= f.text_field :username, { tabindex: 1, class: 'form-control', id: 'username' } %> - -
+ <%= f.text_field :username, {tabindex: 1, class: 'form-control', id: 'username'} %> + +
<% end %>
- <% if Rails.env == "production" %> + <% if Rails.env == "production" %> <% if params[:controller] == "users" && params[:action] == "edit" %> -
+
-
-
+
+
<%= render :partial => "layouts/social_icons" %> -
- <% end %> +
<% end %> -
- - <%= f.text_field :email, { tabindex: 3, placeholder: "you@email.com", class: 'form-control', id: 'email' } %> + <% end %> + +
+ + + <%= f.text_field :email, {tabindex: 3, placeholder: "you@email.com", class: 'form-control', id: 'email'} %>
- <% if @user.crypted_password.nil? %> + <% if @user.crypted_password.nil? %> - <% else %> + <% else %> - <% end %> - <%= f.password_field :password, { placeholder: I18n.t('users._form.password'), - tabindex: 4, - class: 'form-control', - id: 'password' } - %> + <% end %> + <%= f.password_field :password, {placeholder: I18n.t('users._form.password'), + tabindex: 4, + class: 'form-control', + id: 'password'} + %>
- - <%= f.password_field :password_confirmation, { placeholder: I18n.t('users._form.confirm_password'), - tabindex: 5, - class: 'form-control', - id: 'password-confirmation' } - %> + + <%= f.password_field :password_confirmation, {placeholder: I18n.t('users._form.confirm_password'), + tabindex: 5, + class: 'form-control', + id: 'password-confirmation'} + %>
- - <%= f.text_area :bio, { placeholder: I18n.t('users._form.add_bio'), - rows: 8, - class: 'form-control', - tabindex: 6 } - %> + + <%= f.text_area :bio, {placeholder: I18n.t('users._form.add_bio'), + rows: 8, + class: 'form-control', + tabindex: 6} + %>
<% if params[:controller] == "users" && (params[:action] == "new" || params[:action] == "create") %> - <% if Rails.env == "production" && !params[:spamaway] %> - <%= recaptcha_tags %> - <% else %> - <%= fields_for @spamaway do |spam| %> -
- -

- <%= t('users._form.spam_filtering') %> -

- <% vars = [:statement1, :statement2, :statement3, :statement4] %> - <% turingtest = Spamaway.get_pairs vars.length %> - <% turingtest.each_index do |i| %> -
- <% [0,1].each_with_index do |s, j| %><% statement = turingtest[i][s] %> -
- -
+ <% if Rails.env == "production" && !params[:spamaway] %> + <%= recaptcha_tags %> + <% else %> + <%= fields_for @spamaway do |spam| %> +
+ +

+ <%= t('users._form.spam_filtering') %> +

+ <% vars = [:statement1, :statement2, :statement3, :statement4] %> + <% turingtest = Spamaway.get_pairs vars.length %> + <% turingtest.each_index do |i| %> +
+ <% [0, 1].each_with_index do |s, j| %> + <% statement = turingtest[i][s] %> +
+ +
+ <% end %> +
+
<% end %> -
-
- <% end %> -
-
- <%= spam.text_area :follow_instructions, { class: "form-control col-md-6", - rows: 8, - tabindex: 7, - placeholder: I18n.t('users._form.dont_write_here') } +
+
+ <%= spam.text_area :follow_instructions, {class: "form-control col-md-6", + rows: 8, + tabindex: 7, + placeholder: I18n.t('users._form.dont_write_here')} %> -
- <% end %> - <% end %> - +
+ <% end %> + <% end %> + <% end %>
- <% if params[:controller] == "users" && (params[:action] == "new" || params[:action] == "create") %> + <% if params[:controller] == "users" && (params[:action] == "new" || params[:action] == "create") %> - + <%= t('users._form.log_in') %> - <% elsif params[:controller] == "users" && params[:action] == "edit" %> + <% elsif params[:controller] == "users" && params[:action] == "edit" %> - <% end %> - - - + })(); + + function checkInput() { + var username = document.getElementById("username").value; + var email = document.getElementById("email").value; + var password = document.getElementById("password").value; + var password_conf = document.getElementById("password-confirmation").value; + var input_fields = [username, email, password, password_conf]; + var fields = ["Username", "Email", "Password", "Password-confirmation"]; + + var emptyFields = []; + var errors = 0; + for (var i = 0; i < input_fields.length; i++) { + if (input_fields[i] === "") { + errors++; + emptyFields.push(fields[i]); + } + } + if (errors > 0) { + notyNotification('sunset', 10000, 'error', 'topRight', "Please complete the following fields: " + emptyFields); + } + else { + $(this).addClass("disabled") + .html(""); + } + } +
-
-
+
+
<%= render :partial => 'users/photo' %> -
+
<% end %> - + From b39c46e3264aa952407483a8440ecf0c64db67b4 Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Sat, 17 Nov 2018 18:15:36 +0530 Subject: [PATCH 09/13] Included typeahead.jquery.js typeahead.jquery.js is required for post.js to work --- app/assets/javascripts/application.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 3362501a67..4014448735 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -13,6 +13,7 @@ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD // GO AFTER THE REQUIRES BELOW. // +//= require typeahead.js/dist/typeahead.jquery.js //= require jquery //= require jquery_ujs //= require bootstrap/dist/js/bootstrap.min.js From 51198b8e72a2712725407848e304a53dd755943b Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Sat, 17 Nov 2018 18:50:07 +0530 Subject: [PATCH 10/13] Update .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1d613d8b2c..b105e35f20 100644 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,6 @@ config/config.yml config/initializers/site_keys.rb config/initializers/secret_token.rb public/system -public/lib db/openid-store/ www.example.com/ dump.rdb From 38b73e4a89a06f20bf498d77202c7ee3ab197485 Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Sat, 17 Nov 2018 18:59:36 +0530 Subject: [PATCH 11/13] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b105e35f20..1d613d8b2c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ config/config.yml config/initializers/site_keys.rb config/initializers/secret_token.rb public/system +public/lib db/openid-store/ www.example.com/ dump.rdb From 01f062cfa6226805534a8aec1baa8b9517348b70 Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Sat, 17 Nov 2018 19:30:49 +0530 Subject: [PATCH 12/13] Added typeahead.jquery.js it's required for post.js to function --- app/assets/javascripts/post.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/post.js b/app/assets/javascripts/post.js index 4daf9d8c81..2605d2f593 100644 --- a/app/assets/javascripts/post.js +++ b/app/assets/javascripts/post.js @@ -1,3 +1,4 @@ +//=require typeahead.js/dist/typeahead.jquery.js jQuery(document).ready(function() { $('.datepicker').datepicker() From d869cc1425a4a1cb561f7da7cbb2d233089354d7 Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Sat, 17 Nov 2018 19:32:44 +0530 Subject: [PATCH 13/13] Added link to post.js --- app/views/editor/rich.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/editor/rich.html.erb b/app/views/editor/rich.html.erb index fb95d871a0..4fd69455ab 100644 --- a/app/views/editor/rich.html.erb +++ b/app/views/editor/rich.html.erb @@ -4,6 +4,7 @@ +