Skip to content
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

DCI number conversion and validation #29

Merged
merged 1 commit into from
Jul 31, 2017
Merged

DCI number conversion and validation #29

merged 1 commit into from
Jul 31, 2017

Conversation

ChaimW
Copy link
Contributor

@ChaimW ChaimW commented Jul 2, 2017

Completes Issue #4

@ChaimW ChaimW mentioned this pull request Jul 5, 2017
@ChaimW
Copy link
Contributor Author

ChaimW commented Jul 5, 2017

@Nightfirecat @april

@Nightfirecat
Copy link
Contributor

I'll try to load this up and test after work today.

@ChaimW
Copy link
Contributor Author

ChaimW commented Jul 5, 2017

i have it running at http://csun.edu/~csw61793/decklist

Copy link
Contributor

@Nightfirecat Nightfirecat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are mostly stylistic changes, will verify algorithm and logic shortly, but the demo seems to be working fine.

An aside, I feel we may want to add a note if the DCI number is rewritten. Not a warning, necessarily, but just a notice so the user is aware that 10-digit DCI numbers are desired, and what their 10-digit DCI number would be.

@@ -0,0 +1,71 @@
var primes = [43,47,53,71,73,31,37,41,59,61,67,29];
function isValid(number){
number += "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

number = number.toString();

function isValid(number){
number += "";
if(number.length >= 8){
if(number.length == 8 || number.length == 10){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (, not if(
) {, not ){

var primes = [43,47,53,71,73,31,37,41,59,61,67,29];
function isValid(number){
number += "";
if(number.length >= 8){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (, not if(
) {, not ){

@@ -0,0 +1,71 @@
var primes = [43,47,53,71,73,31,37,41,59,61,67,29];
function isValid(number){
Copy link
Contributor

@Nightfirecat Nightfirecat Jul 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these functions should be more descriptively named? Or perhaps nested so that they don't bleed into global namespace?

e: Looking at this comment again, there may not be as much room to do this as I thought; just was a thought of mine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

) {, not ){

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions nested, spacing changed

else return -1; // for a under 8-digit number, return -1 (evals to true)
}
function getTenDigit(number){
number += "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

number = number.toString();

for (var i = 0; i < number.length; i++){
sum += parseInt(number[i]) * primes[i];
}
var check = (Math.floor(sum / 10) % 9) + 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon

var check = (Math.floor(sum / 10) % 9) + 1
return check;
}
function getTenIfValid(number){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

) {, not ){

return check;
}
function getTenIfValid(number){
if(getTenDigit(number)){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (, not if(
) {, not ){

@@ -327,6 +327,10 @@ function generateDecklistPDF(outputtype) {
}

dcinumber = $('#dcinumber').val();
if(dcinumber){ // only if there is a dci number
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (, not if(
) {, not ){

@@ -327,6 +327,10 @@ function generateDecklistPDF(outputtype) {
}

dcinumber = $('#dcinumber').val();
if(dcinumber){ // only if there is a dci number
dcinumber = getTenIfValid(dcinumber);
dcinumber += ""; //convert to string (function returns an int)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dcinumber = getTenIfValid(dcinumber).toString();

@Nightfirecat
Copy link
Contributor

BTW, you can also name your branch gh-pages (or configure the rendered page in your repo settings) rather than manually hosting it elsewhere. Just so you know. ;)

@ChaimW
Copy link
Contributor Author

ChaimW commented Jul 6, 2017

Yeah, i was trying to test some things while my dev machine was acting up, so all I had was my phone. It was fairly simple to ssh to my school stuff and do a clone, rather than teach myself github pages.

@ChaimW
Copy link
Contributor Author

ChaimW commented Jul 7, 2017

@Nightfirecat I think I got them all. I also updated the host.

@ChaimW
Copy link
Contributor Author

ChaimW commented Jul 10, 2017

@april Is there something further that I need to do for this? this is my first real pull request, so I'm slightly unfamiliar with how to do it.

@april
Copy link
Owner

april commented Jul 10, 2017

Sorry, I've been traveling the last couple weeks. Could I ask you to squash it all into a single commit, please?

} else if (validationObject['error'] === 'invalid') {
notifications.push(prop, ['DCI number is invalid', validType]);
} else if (validationObject['warning'] === 'nocheck') {
notifications.push(prop, ['We cannot verify that your DCI# is valid as it is in an old format. Please double-check it.', validType]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be consistent about using DCI Number vs. DCI #.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, my bad.

@ChaimW
Copy link
Contributor Author

ChaimW commented Jul 10, 2017

@april Squashed, updating host.

@Nightfirecat
Copy link
Contributor

Looks good as far as I'm concerned. Style changes are mostly consistent with existing code, and the algorithms seem sound.

@ChaimW
Copy link
Contributor Author

ChaimW commented Jul 31, 2017

Hey, @april I just wanted to know if this can get pulled so that I can work with a current copy when I start on #11. I plan to start that once this is closed.

@april april merged commit 85f1b49 into april:master Jul 31, 2017
@april
Copy link
Owner

april commented Jul 31, 2017

If you're on Twitter, I'd be happy to credit you. :)

@ChaimW ChaimW deleted the dci-numbers branch August 1, 2017 15:04
@ChaimW
Copy link
Contributor Author

ChaimW commented Aug 1, 2017

I'm on Twitter @imanEngineer2

@tooomm
Copy link

tooomm commented Dec 5, 2017

@Nightfirecat wrote:
BTW, you can also name your branch gh-pages (or configure the rendered page in your repo settings) rather than manually hosting it elsewhere. Just so you know. ;)

Is that still true? That would be damn sweet!!

@april Do you run decklist.org directly from gh pages?

@Nightfirecat
Copy link
Contributor

I don't believe so, since GH pages (still?) doesn't allow for custom certs on custom domains. That said, you can definitely host it from GH pages in development: https://nightfirecat.github.io/decklist/

@april
Copy link
Owner

april commented Dec 5, 2017

I can probably push it to gh-pages, if folks would like. I can't run it directly from GitHub because as @Nightfirecat said, they don't yet support certificates on custom domains.

@tooomm
Copy link

tooomm commented Dec 5, 2017

Which certificates are we talking about? What are they used for?


you can definitely host it from GH pages in development

GH pages in development? Hmm, what do you mean?

@Nightfirecat
Copy link
Contributor

Server HTTPS cert. And by "in development", I mean you can host directly from GitHub on *.github.io from a repository's development code.

@tooomm
Copy link

tooomm commented Dec 5, 2017

Oh right, it could be production code too then. ;)

HTTPS is actually possible with gh pages and a custom domain if you combine it with a free cloudflare account. Just do a quick google search, there are a lot of articles. If you want to safe some hosting costs...

@Nightfirecat
Copy link
Contributor

@april FYI, there's a fair bit of discussion on isaacs/github#156 regarding a slow roll-out of custom domain certs on GitHub's part for GH pages. It's not immediately available, but at some point, it sounds like this will be fully supported and available for new sites. Once that's available, it might be worth just running decklist.org off GH pages?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants