Sunday, May 31, 2015

New project idea

Just a little note to the last post. I've done the usual debugging and gone through my code from method to method. So as far as i could find some articles from this issue about Chrome i found out that the window.open() method didn't work only by itself. It has to be in a callback function that would be triggered by a user (according to an article on Stackoverflow). And i think it won't work in the browsers console, i couldn't add for example a simple click event handler. That'll work only if i could give it into the source code of the page i think. Enough to that, let's move on to the next topic.

I thought about that what to do next to gain some knowledge and expertise with jQuery and Javascript in general. And again my friend came up with the idea (maybe in the future i should call him as my mentor :) ) that an online game application would be just good enough to practice these things. More specifically a Poker app. And eventually i realized that there's a lot of potential in that as well. I can keep this project and later add some other functionalities to it such as creating an sql database to store data about users, creating the submitting/registration form to that using php. So basically that would be it. My plan is that i'll do the main platform html than style it with css and write the code to get the game up and running. And as i'm learning right now the basics of sql and php i'll add these later. Stay tuned.

Monday, May 25, 2015

Using the console

So it's been a while since i wrote something. I've been a little bit busy. It's not easy to coordinate the time i have. I must learn every day, but i have to go to the gym too. Because it gives me some push and refreshes me even if i used to feel myself tired. And there's my band, we should practice our new song and put a new one together. There's a lot of stuff to do but i could manage it sofar.
Now let's go to the issue i wrote recently about. It was a bit tricky 'cause the links with the downloadable document were hidden inside in a div element which can be opened with an anchor tag. So i couldn't just grab the anchor tags on the actual page because they were not the download links. And that's where some magic should happen. Ok, i know for a senior developer or even for a junior it's easy as a sunday morning (thanks Lionel and Faith no more). But for me it was a good practice. Before i get into any further, here's my code.




The anchor tags i needed were inside div elements with the class of document_txt. But there was also some tags i didn't needed. They had the class of infolink. So i took them away from the object with the not method. Then i had to scan through all the elements of the object that i just created. I used the each method for that. It has a callback function and inside of this callback i put all the code that does the right thing for me with every element of the object. First i must create a local variable to get the id of the particular document. So i grabbed with $(this) the actual anchor element. Then i get the href attribute of it which containes the link to details of the document. That link looks like:



I wanted that id in the end of that link and at the same i should rewrite the link so instead of details there would be download. The split method creates from the link an array where every character would be an element of this array. Inside the parentheses we can specify where the method should separate the characters. In this case it's nothing because we want to make from every letter and number a different array element. Then i used the slice method. With that i could make a new array only with the numbers at the end of the link. That would be the id i needed. In the parentheses i gave to the method the index of the element where it should the count begin with (remember an array is always zero based, so the first element of the array has the index of 0). And secondly the number where the count should end. But that's not enough 'cause we can't use that as an array, we need the string to put that at the end of the new link which comes in the next line of the code. I used the join method to put the numbers together to get a string again. It'll join these characters together with the element which we write between the parentheses. In this case again it'll be nothing, because we want the numbers to come right after each other. Good, now this string of the id is stored in the variable with the name of id. The next local variable would be the link which would create the new href attribute for every anchor tag that it runs through. Like before we grab the actual element with $(this) then again with the attr method we can set the new href attribute. It can be done if as a second parameter we pass in some string in. That string would be ofcourse the new link and at the end of it the particular id. Notice that the id isn't hardcoded, we add it dynamically to every piece of the object. And with the last line of code we just open every new link that we have created. We can do that with the javascript window.open method. As parameter we pass in the local variable. As a result we have some tabs inside the browser opened where the download of all the documents begins.
I must say that this worked for me only in firefox. I've tried it in chrome but there somehow it didn't. I'll be working on that. But if you have some idea what could be the problem please let me know.

Sunday, May 17, 2015

Little makeup and a new task

Ok, so i got a feedback from a friend that this last post was not that clear as i wanted it to be. I have to admit it. It's a bit scary though as i read it through. My goal is that everybody who struggling with the same issues i have right now could see that they're not alone on this adventure. I wrote that it's not easy. I want to correct that. It's easy, it takes only time. But the time works for you not against you. Think about it, with every day that you learn on you'll become more and more trained. And you don't have to spend hours in front of the monitors. I practice every day about an hour or so. Of course if i have more time than i raise that learning time also.
As i mentioned before (i think i did) i'm about to become more familiar with jquery. I think it's a great tool to the front and back-end development. Many tasks are much easier with it. This friend who gave me the feedback told me an interesting issue that you could handle with jquery right in the browsers console. Let's say you're on a page that have search field and you can type in some criterias and then as results we have many links with documents. If you click on the links the download of the document begins. But what if we're to lazy to click on every link? We can manipulate the DOM (Document Object Model which contains all the elements within the page div's paragraphs etc.) with jquery and select all these elements that include the anchor tag with the link of the downloadable document. So i've never had such a task, i'm wondering how because i should had to.
In the next post i'll write down how i solved this issue. See you soon.

Monday, May 11, 2015

Technical difficulties

I think it's time to write something about what i want to share through this blog. My learning process as i keep digging deeper and deeper into the world of front-end and back-end development. It's not easy and it take some time until you can easily solve a problem. Debug somebody elses code but let's just not go so far, debug your own code. Or imagine that you get an offer from a client to make her website more interactive and user friendly. Oh yeah and maybe she wants to make a webshop or something that needs some server side programming with database handling as well. And the list could be much longer.
What i meant with it is that you have to invest the right amount of time. Practice a lot, read many books and articles as you can in this topic. Watch tutorial videos, that can help a lot. I would suggest to find the right person who really knows how to teach how to make clear these things. I think Jeffrey Way is really good in that. He has a bunch of articles and tutorials on tuts+, i definitely recommend to check them out.

So let's get to coding. The basics of javascript and jquery are more or less in my pocket. Or the syntax at least. But here comes the fun. If you are into bigger projects (as you probably would) there is'nt enough to just drag the scripts into a .js file and reference it in the html file. You should make your code as clear as it's possible. It's also very important where and when you get into the DOM. And there comes into play the Object Oriented Programming. I think you should already clear with that if not read this article. I'm not gonna able to write that down so good as the author (Richard) has on that page. If you're like to build a plugin or an application this knowledge is the must have.
That would be it for today. See you soon.

Wednesday, May 6, 2015

A long time ago...

This time i thought it'd be good if i write something about how i come to learn these foreign languages. It was back 7 years ago when i met the programming itself as i had to learn the basics of the C-language at the Budapest Institute of Technology. The plan was that i'll become an electrical engineer. Not much to it, i didn't finished the school (now i know that i had to). And honestly at that time the programming had not so much influence on me.
But it changed like 3 years ago when a friend of mine gave me an idea that i should start to learn web-development. Since i lost my job before that, i digged myself into it. Of course i started with HTML and CSS. It went good and then there was also a bit of javascript. But before i could finish the courses i accepted a job offer and i was like ok now i have job so i don't need to continue with that. Oh god how bad that decision was from me. And after 2 years this friend just came up with this thing again. So i took a deep breath and began to start it over again.
I was very motivated (and still) this time and luckily the things i learned once before were still in my head and they all just came forward. That was last year september. The time flew by quickly and i'm here right now. Trying to grow my expertise with JQuery and with javascript in general. I'm scratching the surface of the back-end development as well. I don't know how but the OOP just came into my life only a few weeks ago. In the courses before and in the exercises i done were nothing or not so much info from it. But thanks to some great articles and great tutorial videos i understand it much better and all of a sudden it all makes sense. I need to practise this of course but i'm on the right way now and i'm not gonna lose the path this time. Must.not.give.up.

Sunday, May 3, 2015

First steps

So let's just begin. But before that i must clear some things. This is my first blog, i'm not a huge blogger. I'm not that type of a guy who just shares every moment of his life. Facebook? Actually i'm just there. I swipe through the posts once a day and sometimes i'm posting some music or something funny but thats it.
But i'm about to change that. I thought it might be good if i start to write a blog. About what? About what i'm doing right now and it's to learn some coding. More specifically the language of the web. Including the basics as HTML and CSS then the more epic stuff with the front-end and back-end development (JQuery, PHP, AJAX, JSON, SQL).
So maybe it'll be not so interesting for those who already working in this area for years, but i hope that i can find the way to the people they're in the same situation as i am right now. I'd like to motivate them as well (ok, let's be honest only motivate because from me they could'nt learn that much). That'll be also a good way for me to track my learning process.
I think i'll post some other things so it won't be that boring. Something about my hobbies. I'm a guitar player and i have a metal band. But my musical interest includes also the orchestral music and i'm into composing more or less (i'm trying to upgrade my skills in that). Other than that i also like to workout, which i do almost 2 years now. Since than it became a part of my life.
So i'd like to show and prove that with so much activities (and of course next to a fulltime job) you can learn new things and move forward.
Thats it for now. Stay tuned.