8values / 8values.github.io

The 8values political quiz
MIT License
983 stars 409 forks source link

Fixing JavaScript #109

Open jhh-dev opened 4 years ago

jhh-dev commented 4 years ago

I noticed variables are declared as var instead of using let or const someone should change all of them to their respected type. If no ones willing to do this I'm alright with working on this.

Genora51 commented 4 years ago

The let syntax isn't supported in really old browsers, and although I think it's useful to update the codebase to ES2015, maybe this is something to be done for V2 when we restructure the code entirely; in the meantime I will look into ensuring that we can run on as many browsers as possible while updating the code to respect ES2015 standards.

Genora51 commented 4 years ago

Having said that, const is widely supported, so I do recommend introducing const declarations into the code even if we leave out lets for the time being.

jhh-dev commented 4 years ago

Sounds great! If you're looking for help I'd be more than happy to assist you with this.

JoshuaKimsey commented 4 years ago

let has been around long enough and the overwhelming percentage of browsers that support it means that let could and probably should replace var. Only old versions of IE wouldn't support it effectively, and with 7 now EOL, those old versions of IE will soon also fade away. I do think that let needs to replace var to comply with proper JavaScript notation standards.

Genora51 commented 4 years ago

Yes, you might be right. In that case by all means make a start on modernising the JS.

I do think the codebase could do with a drastic overhaul anyway, and my intention once some of the outstanding issues are resolved is to majorly restructure the code with modern browsers in mind. But for the time being, these kinds of fixes are 100% worthwhile.

SAIDIALI09 commented 4 years ago

I’m very grateful to join the GITHUB.

phetw commented 4 years ago

You can write modern JavaScript syntax and have them transpile to multiple format ie. es5 and es6 and ship them separately for both old and newer browsers. You can utilise bundle tools such as webpack, rollup and transpile tool like babel.

Genora51 commented 4 years ago

That's not really an option for github pages hosting unfortunately, and without changing the domain it requires some more drastic codebase restructuring.

I do want to attempt some of those larger-scale changes in v2, but for now we can just update to the more widely-supported features like let and const.

doamatto commented 3 years ago

That's not really an option for github pages hosting unfortunately

With GitHub actions, we could have it run any of those tools and push it to the gh-pages with an action like this; I don't think it would need to much restructuring either. We can have it bundle to virtually any directory, meaning it can be the same place as the old files (removing the need to update the references in HTML files), and we can technically use any JS files (we can declare folders or explicit files).

Regardless, I think it is a good idea for us to use let and const over var. If we really need to support IE, we can include polyfills/use a bundling tool like aforementioned

Nirajn2311 commented 3 years ago

Hi I'd like to help out with modernizing this repo. Has this been taken up by someone or do I just start?

Genora51 commented 3 years ago

Not that I know of; if you want to start moving to let and const, just make a fork and give it a go!

Nirajn2311 commented 3 years ago

I was working on this today and found 3 variables repeated in all HTML files but never used anywhere.

var sc_project=11325211;
var sc_invisible=1;
var sc_security="fd9f0659";

What is the use of them?

doamatto commented 3 years ago

I was working on this today and found 3 variables repeated in all HTML files but never used anywhere.

var sc_project=11325211;
var sc_invisible=1;
var sc_security="fd9f0659";

What is the use of them?

As far as I can see, there isn't any purpose to them. I think @Genora51 would need to confirm if they would be safe to remove and/or their purpose.

Genora51 commented 3 years ago

So, looking back over that code I'm pretty sure that stuff was some basic analytics @TristanBomb put in way back at the start of the project - I would encourage a pull request to take out all of that code (google analytics, statcounter), otherwise I'll do it myself in a couple weeks when I have some time.