Skip to content

Enre 1 #95

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

Merged
merged 5 commits into from
Oct 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 44 additions & 14 deletions avRegistration/fields/dni-field-directive/dni-field-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,62 @@
angular.module('avRegistration')
.directive('avrDniField', function($state) {
function link(scope, element, attrs) {
scope.dni_re = /^[XYZ]?\d{7,8}[A-Z]$/;
var dni_re = /^([0-9]{1,8}[A-Z]|[LMXYZ][0-9]{1,7}[A-Z])$/;

/**
* Normalizes dnis, using uppercase, removing characters not allowed and
* left-side zeros
*/
function normalize_dni(dni) {
if (!dni) {
return "";
}

var allowed_chars = "QWERTYUIOPASDFGHJKLZXCVBNM1234567890";
var dni2 = dni.toUpperCase();
var dni3 = "";
for (var i = 0; i < dni2.lenth; i++) {
var char = dni2[i];
if (allowed_chars.indexOf(char) >= 0) {
dni3 += char;
}
}
var numbers = "1234567890";
var last_char = "";
var dni4 = "";
for (var i = 0; i < dni3.lenth; i++) {
var char = dni3[i];
if ((last_char==="" || '1234567890'.indexOf(last_char) === -1) && c === '0') {
}
dni4 += char;
last_char = char;
}
return dni4;
}

// returns true if regex matches or if there's no regex
scope.validateDni = function(str) {
// If no valid value passed
if (!str) {
str = '';
scope.validateDni = function(dni) {
var norm_dni = normalize_dni(dni);

if (!norm_dni.match(dni_re)) {
return true;
}
// Ensure upcase and remove whitespace
str = str.toUpperCase().replace(/\s/, '');

var prefix = str.charAt(0);
var index = "XYZ".indexOf(prefix);
var prefix = norm_dni.charAt(0);
var index = "LMXYZ".indexOf(prefix);
var niePrefix = 0;
if (index > -1) {
niePrefix = index;
str = str.substr(1);
norm_dni = norm_dni.substr(1);
if (prefix === 'Y') {
str = "1" + str;
norm_dni = "1" + norm_dni;
} else if (prefix === 'Z') {
str = "2" + str;
norm_dni = "2" + norm_dni;
}
}
var dni_letters = "TRWAGMYFPDXBNJZSQVHLCKE";
var letter = dni_letters.charAt( parseInt( str, 10 ) % 23 );
return letter === str.charAt(str.length - 1);
var letter = dni_letters.charAt( parseInt( norm_dni, 10 ) % 23 );
return letter === norm_dni.charAt(norm_dni.length - 1);
};
}
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ angular.module('avRegistration')
utilsScript: "election/utils.js",
separateDialCode: true,
initialCountry: "auto",
preferredCountries: ["es", "gb", "us"],
autoPlaceholder: "aggressive",
placeholderNumberType: "MOBILE",
geoIpLookup: function(callback) {
var applyCountry = function()
{
var countryCode = (ipData && ipData.country) ? ipData.country : "";
var countryCode = (ipData && ipData.country) ? ipData.country : "es";
callback(countryCode);
};
if (ipData) {
Expand Down Expand Up @@ -90,4 +91,4 @@ angular.module('avRegistration')
link: link,
templateUrl: 'avRegistration/fields/tel-field-directive/tel-field-directive.html'
};
});
});
5 changes: 4 additions & 1 deletion avRegistration/register-directive/register-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ angular.module('avRegistration')

scope.getLoginDetails = function (eventId) {
if (!scope.admin) {
return {path: 'election.public.show.login', data: {id: eventId}};
return {
path: 'election.public.show.login_email',
data: {id: eventId, email: scope.email}
};
} else {
return {path: 'admin.login_email', data:{email: scope.email}};
}
Expand Down
35 changes: 26 additions & 9 deletions dist/appCommon-v103111.8.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,10 @@ angular.module("avRegistration").factory("Authmethod", [ "$http", "$cookies", "C
email: scope.email
}
} : {
path: "election.public.show.login",
path: "election.public.show.login_email",
data: {
id: eventId
id: eventId,
email: scope.email
}
};
}, scope.signUp = function(valid) {
Expand Down Expand Up @@ -590,12 +591,27 @@ angular.module("avRegistration").factory("Authmethod", [ "$http", "$cookies", "C
};
} ]), angular.module("avRegistration").directive("avrDniField", [ "$state", function($state) {
function link(scope, element, attrs) {
scope.dni_re = /^[XYZ]?\d{7,8}[A-Z]$/, scope.validateDni = function(str) {
str || (str = ""), str = str.toUpperCase().replace(/\s/, "");
var prefix = str.charAt(0), index = "XYZ".indexOf(prefix), niePrefix = 0;
index > -1 && (niePrefix = index, str = str.substr(1), "Y" === prefix ? str = "1" + str : "Z" === prefix && (str = "2" + str));
var dni_letters = "TRWAGMYFPDXBNJZSQVHLCKE", letter = dni_letters.charAt(parseInt(str, 10) % 23);
return letter === str.charAt(str.length - 1);
function normalize_dni(dni) {
if (!dni) return "";
for (var allowed_chars = "QWERTYUIOPASDFGHJKLZXCVBNM1234567890", dni2 = dni.toUpperCase(), dni3 = "", i = 0; i < dni2.lenth; i++) {
var char = dni2[i];
allowed_chars.indexOf(char) >= 0 && (dni3 += char);
}
for (var last_char = "", dni4 = "", i = 0; i < dni3.lenth; i++) {
var char = dni3[i];
("" === last_char || -1 === "1234567890".indexOf(last_char)) && "0" === c, dni4 += char,
last_char = char;
}
return dni4;
}
var dni_re = /^([0-9]{1,8}[A-Z]|[LMXYZ][0-9]{1,7}[A-Z])$/;
scope.validateDni = function(dni) {
var norm_dni = normalize_dni(dni);
if (!norm_dni.match(dni_re)) return !0;
var prefix = norm_dni.charAt(0), index = "LMXYZ".indexOf(prefix), niePrefix = 0;
index > -1 && (niePrefix = index, norm_dni = norm_dni.substr(1), "Y" === prefix ? norm_dni = "1" + norm_dni : "Z" === prefix && (norm_dni = "2" + norm_dni));
var dni_letters = "TRWAGMYFPDXBNJZSQVHLCKE", letter = dni_letters.charAt(parseInt(norm_dni, 10) % 23);
return letter === norm_dni.charAt(norm_dni.length - 1);
};
}
return {
Expand Down Expand Up @@ -639,11 +655,12 @@ angular.module("avRegistration").factory("Authmethod", [ "$http", "$cookies", "C
utilsScript: "election/utils.js",
separateDialCode: !0,
initialCountry: "auto",
preferredCountries: [ "es", "gb", "us" ],
autoPlaceholder: "aggressive",
placeholderNumberType: "MOBILE",
geoIpLookup: function(callback) {
var applyCountry = function() {
var countryCode = ipData && ipData.country ? ipData.country : "";
var countryCode = ipData && ipData.country ? ipData.country : "es";
callback(countryCode);
};
ipData ? applyCountry() : ipCallbacks.push(applyCountry);
Expand Down
Binary file added dist/img/flags.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading