« first day (1599 days earlier)      last day (3356 days later) » 

6:00 AM
That should be the structure of your app
All you're doing is loading the view from the url a) when the page loads and b) when the url changes
And then you're loading another view when a link is clicked
 
aha, yes that is what I want to do I guess.. Damn, that was a lot of code I havn't considered
 
What you need to do is implement router.loadPage
All it does is take a url, grab that page using ajax, insert it into the document, and change the url
 
aha, so instead of having pushstate inside my httpRequest, I should use router.loadPage?
 
Oh, I forgot that you'll need a callback for loadPage
Hold on
Does that make sense?
 
Ok, that made more sence yes, the 1st question would be, where ou have written, implement this, what should I write there? Something like calling my nav.eventlistener on the nr 1, calling my Mat(url) on the 2nd, and the third I cant quite understand thou..
Then there is the part of insertIntoDom, that should just by instead of html as argument, the name of the div I want to change content of?
 
6:15 AM
You already wrote the code for router.loadPage pretty much
It's just the ajax stuff
But instead of document.getElement blah blah you can just do callback(xmlhttp.responseText)
 
aha, well yes, that makes sence
 
What you're doing is sending the result of your request to the callback that the user specified
In this case it's insertIntoDOM
which is where you'd insert the response text into the dom
 
Hi all
 
I see, so am I understaning correct, that where you have written 1 and 2 as comments, I should have my ajax function, in this case Mat(url), or is it that I should call the loadPage from my httpRequest - Mat(url)
Sorry, I am probably in a bit over my head here
 
You'd pretty much copy and paste the contents of Mat into loadPage
 
6:21 AM
oh
 
They serve the same purpose
 
Ok, is the loadPage a reserved javascript word, or could it be anything, like i.e Mat?
 
It's the name of the function that you're using to load a page
You can call it whatever you want, but you should try to make it as descriptive as you can
 
as my onclicks all have Mat(this.href), could I just change loadPage to Mat, or have you taken into account that I change my anchors? :)
I see :)
 
Pretend that onclick doesn't exist
 
6:25 AM
Oh ok
 
for(i = 0; i < routes.length; i++){
	routes[i].addEventListener("click", function(){
		router.loadPage(this.href, insertIntoDOM);
	});
}
Instead you want to add a listener to each of your elements
 
oh of course, yes that is why I suspected you had done something clever
 
So do you understand the flow of control?
 
I do understand that it reads from top to bottom etc, and stops executing if it comes over return, if I remember correctly
 
URL is changed -> the router loads the page -> it calls a callback, which inserts the response into the dom
 
6:27 AM
or that it goes back up
wow, well, to be honest, a lot to get my head around :)
 
Anyone familiar with node/sequelize?
 
why browserify is used?
to keep the code in structure right?
 
Well, the browser does run the code from top to bottom
So what it does is create the 3 functions (router, insertIntoDOM, and loadInitialState) then it attaches the event listeners
 
but yes, I understand that is the way it should work, and from reading javascript, I can understand the functions, after studying it a bit1 First priority of course, is to get all of it to work, learning javascript I understand, takes a lot of time, as it is so many keywords etc
 
From there on, the code is asynchronous
Do you know what that means?
 
6:30 AM
I see
 
Im trying to initialize sequalize and sync the model with db but keep getting the error: role "username" does not exist
this happens when I try to fireup server.js
 
well yes, it sits back there somewhere, I have viewed a lot of ajax tutorials.. In my layman's terms, it is like doing something on the server.. Sending a request to the server, getting an answer, and gdoing something with that answer
 
More generally, it means it can do multiple things at the same time
 
and asynchrone, will mean something like using the onreadystatechange, to change my html, with responseText..
Aha, of course
 
So instead of waiting until task 1 is done, it starts task 2 while task 1 is still running
 
6:33 AM
Okay, that makes sence as to why it is so much faster, and not needing reloading
 
To make this work, javascript uses callbacks, which are functions that are called when a task is completed
So you set onreadystate to a callback, which is called when the http request is complete
 
ah, such as a if statement, of a for or while loop is complete, it calls the function?
 
Those are all synchronous
 
oh hehe
 
If I told you, "Go to the store and buy some eggs when you get there"
Buying eggs would be your callback
 
6:36 AM
hehe I love metafors, that puts in in good perspective yes
 
what is the main purpose of browserify?
 
I kindof understood that already, difficult to understand the terms is all
callback was an unfamiliar term for me
 
Ok so addEventListener sets a callback that's launched when event occurs
 
Is it to keep the code in structure?
 
@Mr_Green Sec
 
6:37 AM
k
 
So what the code does is it tells the browser "When these events occur, call this function"
 
ok, that seems logic yes, only occurs when clicked for onclick, or reloaded in case of popstate, right?
or changed url of course
 
Which is exactly what we want because we're supposed to do something when the url changes
 
Ah, ok, so a callback, is a function that is not auto-called?
 
If it helps you to think about it like that, sure
There's nothing stopping you from calling it on your own though
So does it make sense how this code works?
 
6:40 AM
It makes more sence yes, you are good at ecplaining, and very patient with this beginner :)
 
Thanks
 
@Meredith there?
 
crl
!!> var callback=(arg)=>console.log('from cb:', arg); ((foo, cb)=>cb(foo))('test', callback)
 
@crl "undefined" Logged: "from cb:","test"
 
@Mr_Green Yeah what was your question again?
 
6:44 AM
what is the main purpose of browserify?
I am actually planning to create my new project with code in structure
I am already decided to use browserify and requirejs
 
So that you can run your node app on the client without wanting to cut open your wrists
 
but my senior dev and also by little googling I came to know that I should replace requirejs with browserify
I didn't get it :|
I have no idea about nodejs (if that is what you meant by node app)
 
what I am struggling with of course, is gettiing all of this to work as it is right now, I kind of am not sure where to begin..
Let me see if I can get it right, or somewhat right, inside the insertIntoDom, should it be responseText?
And inside getCurrentURL, hm I am not sure what to put, should I split my httprequest code? That doesn't seem to logic for me, but as they are part of one var - router, it is possible I guess..
 
@Mr_Green You don't have any experience with node?
 
nope
 
6:47 AM
@sunto Look through the code and see what gets passed to insertIntoDOM. getCurrentURL just returns the current url. Look through the location API documentation to figure that out
@Mr_Green Then you probably won't see the benefits of it
 
ok, thanks alot for your help :)
 
yeah
 
It basically lets you pretend you're running node on the client
Requirejs is just a module loader
I think it's pretty stupid
 
i think i need to read a lot about it
 
I think it just lets you load scripts as you need them instead of all at once
And idk how I feel about that
 
6:52 AM
ok thanks I will check that
 
It just feels a little too complicated for an issue that's not very important imo
 
hmm even I feel the same now
 
Do you use bower?
 
hehe no
honestly, I am fed up with grunt, gulp, bower, browserify stuff from past 7 days :)
I did research on all (to some extent)
 
Yeah I definitely recommend using bower and gulp
Those will actually make your life easier
 
6:58 AM
hmm ok will check them again
Thanks :)
 
Bower and browserify aren't really alternatives to each other
But they have a lot of overlap and it sounds like bower's probably better for your situation
 
Can I ask @Meredith, if you have any suggestions to what I should learn more about? Like, what to search for in tutorials? I have been seraching for how to use onpopstate, and pushstate, and I have been watching all of buckysroom tutorials for the beginners part.. Then I have watched Advanced javascript Tutroials 101, but I am struggling to find the things I need.. Been searching also for ajax and history javascript tutorials and stuff like that, but most of it is with jQuery etc..
Sorry to bother you so, but you've been really helpful, now I understand much more, and also that I need to ge
 
Tutorials bad textbooks good
 
aha! Heh good point that :)
Will get me a javascript textbook, sounds like a good idea!
Any good suggestions?
 
I recommend JavaScript: The Good Parts, Speaking JavaScript, JavaScript Design Patterns, and Maintainable JavaScript
 
7:02 AM
Very nice, that is noted :)
 
Just download the ebooks and read them when you have some free time
 
@sunto are u beginner?
 
Perfect :)
 
They're all pretty quick reads
 
@Mr_Green Oh yes indeed, started learning html css and javascript 10 months ago!
Gotten a lot more understanding for it the last couple of months :)
and even more so, the last couple of hours :D
 
7:05 AM
ohh it seems you are not a pure beginner.. then you can go with "javascript: good parts" as suggested by meredith
I don't recommend that book for pure freshers
 
crl
@sunto What do you really need to do? I don't think you need history.pushState for your site
 
Hm, well I have a good understanding for logic I think, and the hiearchy of javascript etc
 
@Mr_Green Speaking javascript -> the good parts -> maintainable -> design patterns
The order I'd recommend reading them in
 
@crl Well, i maybe not need ajax at all, but I found it was a way of getting fewer html pages, wich is a good thing when writing, and wanting a faster webpage etc.. And of course, I want to learn javascript, so that I can maaybe start creating webpages
 
Hi i have one question , when i merge two javascripts in a same page it doesn't works however it works seperately, whats the cause of this?
 
7:07 AM
@Meredith nice I don't know about other books :)
 
Nice Meredith, that I will do, in that order :)
 
just "the good parts"
@Mano Is there any error in console?
 
Speaking Javascript does a really good job of introducing you to the language
The good parts refines your knowledge
 
@Mr_Green no error shown
 
 0 down vote favorite


when we click on "Yes" price shifted to "NO" with -$97.00 we need when customer click on "YES" price remians there with +$97.00 if customer clicks "No" then price remains there with -$97.00
here is my code:

var suffix = "_" + formId + "_" + productFieldId;
jQuery(".gfield_option" + suffix + ", .gfield_shipping_" + formId).find(".gfield_radio").each(function(){
        var selected_price = 0;
        var selected_value = jQuery(this).find("input:checked").val();
        var fieldId = gformGetFieldId(this);
 
7:10 AM
Post your code
 
pls help
 
@Mr_Green I just opened a random page of speaking javascript and it said "For normal web development, you should use a module system such as RequireJS or Browserify"
Well there you go
 
hehe
 
@crl I need pushstate, so that I don't have hacks, like hashes.. This make my url's look ugly etc.. And Therefore, I found pushstate a good way, because it changes my url completely, not as adding a new html page, and therefore adding another slash.. I do dislike webpages with to long url's, I think instead it should have descriptive titles, not url's that say, like; www.mypage.com/html-tips/this-is-a-good-way-to-code-pages.html
Then I would rather have; www.mypage.com/good-coding.html And rather have some top level html pages, wich describe what you are already in, like www.mypage.com/html
 
currently, I am reading this to understand module patterns addyosmani.com/writing-modular-js
 
7:13 AM
I need help on .replace issue
 
@JeffreyCarandang Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
content.replace( /\[wptabsy([^]*)\]([^\]]*)\[\/wptabsy]/g, function( all,attr,con) {
return html( 'wp-wptabsy', attr , con);
})
 
crl
@sunto Oh, for doing one-paged website, there are also frameworks like Angular, but I haven't learned it yet
 
In my page i used datepicker and the required JS is
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

In the same page i want to use editable dropdown menu and the required code is

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
 
the regex is treating all the occurence as one
I've added /g and still not working
I hope someone can help me. Thanks!
 
7:15 AM
Any ideas or suggestions ?
 
what are you trying to replace?
 
@crl
I see, well yes, I kind of mixed it in, it is like a one page webpage, only I have spread around my content in a 4 page layout, so that It has more sence. Like haveing js, html, and css, in separate html pages, and all the methods of each language loaded by ajax
 
@crl He's a beginner, so it's probably better to pretend that angular doesn't exist for now
@sunto Just say that you don't want to have to load your header, your css, your scripts, and your images every time the user visits a new page
 
Anyone? THanks!
 
Hehe yes, good idea ;) Framworks, hm, wordpress and Joomla are frameworks? Maybe not angular, but frameworks for making things easier right?
indeed
 
7:17 AM
@JeffreyCarandang what are you trying to replace?
Can you create a simple fiddle to show us?
 
[wptabsy attr="value"]CONTENT[/wptabsy]
 
@sunto Angular can be an enigma at times
 
@Mr_Green every occurence of that shortcode
 
hehe enigma translated to cryptic, and riddle
 
currently if I've added multiple shortcode it's treating them as one
 
7:19 AM
so funny, but think it made your point yes ;)
 
@JeffreyCarandang Are you trying to make a bbcode-type-thing?
I recommend not doing that
 
@JeffreyCarandang it seems you wrote a function with name "html" right?
return html( 'wp-wptabsy', attr , con);
 
@Mr_Green its tinymce extension, it's fine
 
^ html is function right?
 
yup, it's a function ;)
 
7:20 AM
add new constructor to it
return new html( 'wp-wptabsy', attr , con);
 
ah, so it is a kind of libarary like jQuery? hehe you are right it is to early for a beginner, I will focus on javascript, and download those book you mentioned )
 
@Mr_Green
[wptabsy attr="value"]CONTENT[/wptabsy] asdfasdfasdfa
[wptabsy attr="value"]CONTENT[/wptabsy], if I've added something like this, it's been replaced once
 
crl
@Meredith I find it quite over-complicate too
 
38 secs ago, by Mr_Green
return new html( 'wp-wptabsy', attr , con);
^ add "new" constructor
 
Idk if I'd say it's over-complicated because it does simplify a lot of things
But the people who created it are on another level
 
7:22 AM
frameworks I find, is not good when wanting to learn. But still, I have read many places, that I waste my time, if not using frameworks, or libararies like jQuery etc..
 
@Mr_Green it's a function not a class
 
I heard angular will be completely rewritten again
@JeffreyCarandang did you try it?
 
Yeah angular 2.0
@JeffreyCarandang Javascript doesn't have classes
 
crl
@Mr_Green Will it be simpler?
 
@Mr_Green yeah and it returned [object Object]
 
7:23 AM
ok
 
No it didn't
 
crl
news.ycombinator.com/item?id=7522520 hmm just say that about angular
 
Are you using alert to show the result?
 
I think using pure ES6 will be better in future days
nobody will care about angular and also jquery
I think so
 
I only need two-way data binding
That's all I need to make me happy
 
7:24 AM
I have a list with stuff. Trying to add a button to the data.
How do I do this - i.imgur.com/JjKKnd6.png
 
Anything else I can do on my own, I don't care
 
@Mr_Green do you think this is the problem? /[wptabsy([^]*)]([^]]*)[\/wptabsy]/g
 
If you just want two-way data binding something like Knockout will do, no need for AngularJS.
 
because of this one : ([^]]*)\
 
I'm using bootstrap and jquery.
 
7:26 AM
@JeffreyCarandang yes I think so
 
@Qantas94Heavy The problem is that I already know angular, so learning another mv* framework is just tiring
Even if it suits my needs better
 
@Mr_Green do you have any idea on what should I'll be adding there? Thank you
 
nope trying..
 
@Meredith: yeah, that weighs quite heavily on one's choices
 
Like there are times where I've found myself including angular just for the data binding
And then forcing myself to use the rest of it for no reason
 
7:29 AM
it is confusing
@JeffreyCarandang
 
What are thoutghs on Ruby? Is Ruby like an alternative to javascript?
 
Ruby is for hipsters
 
I saw a page using it, and mistaked it for ajax functionality
as i could see, it was slow, but that may be just there coding
their*
 
You saw a page using ruby?
 
or something, not entirely sure what ruby is i guess, I understood it is like a scripting language
 
7:32 AM
It's not used on the front end
 
I complained to them about slow user experience, when a page was updating their webpage, And what I thought was php or ajax, the responded that they use ruby
when a company was updating their page*
 
Oh so they used it on the backend
Yeah that's a thing
It's better than php
 
You're basically building a bbcode parser
 
I'm using bootstrap and jquery.
anyone?
I have a list with stuff. Trying to add a button to the data.
I have a list with stuff. Trying to add a button to the data.
 
7:36 AM
aha, I see:) but ajax, and php, doesn't it do something of the same? I mean, php is a server based language as I could understand, but actually, when looking at the code and stuff in php, it seemed like a combined html and scripting language.. A guy I know told me I should learn Php, but I kind of haven't seen the need for it
Especially, when he told me he never made dynamic webpages :p
 
Php runs on the server
Ajax is just a means of communicating with the server
Php devs smell bad
 
oh, so not just talking to theserver, but running "html" from there directly?
hehehe
 
No, ajax just talks to the server
It doesn't run anything
 
I see, I mean php runs from it, and ajax just communicates what You say it should communicate?=
php seemed unnessasary at least, I guess anyone here would think the same? :) Or is it something I should consider studying?
 
Ajax requests the file -> php processes it -> php outputs it -> ajax grabs the output -> ajax returns the output to the client
 
7:40 AM
aha, you have a way of making me understand :)
 
Nothing is complicated in computer science
It's just a matter of how abstracted it is
 
@JeffreyCarandang seems as regex is failing
 
@Mr_Green yeah but it's working on my end
but it's treating them as one, I'm not so good at regex. I need some help
 
Hum, yes I guess that is true! Everything is easy when u know it! ;) "Problem" with computer language, is all the different ways of explaining it to someone who doesn't now it, I guess it is like a med-schoool student having to learn some latin! :)
And like with w3schools, only using x and y as examples, just get confusing after a while!
 
Don't use w3schools btw
It's a great way to learn how to do things incorrectly
 
7:45 AM
Hehe that I understood somewhere along the way also, As I am coding in html5, they have only complicated my learning :)
 
The one thing w3schools is good for is css
And even then it's only because of the reference
And even then it's still not that good and there are better places to go
 
oh, and: w3schools is not affiliated with w3c
 
Aha, well yes I have learned a lot of css from there, and html to be honest, but every time I need something in javascript, they simply don't explain thing at all for me, and it seem like a lot of useful stuff is missing.. Good for reference to keywords maybe, I am not sure..
 
Oh wow they have an angular section now
 
@JeffreyCarandang regex101.com/r/hW3pO7/2
 
7:49 AM
hum, strange.. w3c is worldwideweb standards?
 
world wide web consortium
 
WOW!! thanks a lot @Mr_Green
 
They're the old white dudes who tell us what's hip and fresh
 
welcome :)
 
Haha :)
 
7:50 AM
@sunto not strange at all, w3schools is nothing but a cash-grab and they chose the name intentionally to sound w3c related
 
It got replaced :) just didn't pass the attributes on the function, will figure that out. Thanks again @Mr_Green
 
Their angular tutorial thing is surprisingly not horrible
It's just not very good
And it's probably not that helpful
 
hehe good point @ivarni
Yeah, I learned much from BuckyRoberts - tutorials, at least for the beginner parts.. But some russiand game maker learned me more useful stuff, like using arrays with parameters, althogu I need to watch that more, as it is a complex topic! :)
 
@sunto Use MDN instead, developer.mozilla.org/en-US, it's way better IMO :)
 
I see :)
 
7:54 AM
Aww they dont offer an angular certificate
 
@ivarni and that worked them to earn huge money.. right? :)
 
God could you guys imagine someone trying to convince you that they know angular
And showing you their w3schools certification?
I'd cry
 
hehe
 
this is just ridiculous
 
what method do you guys use to have classes in js? i know there are like 3 methods but i dont know witch is the best
 
As ad's are a way of making a lot of money on websites, I still find them terribly irritating for users.. Would it be possible to create a web-browser, that doesn't allow ads, in the traditional sence?
 
@Mr_Green the company that runs it (Refsnes Data) made roughly half a million euros in 2013 according to official norwegian data. I wouldn't say "huge" but it's still money, right?
 
Or, would it be reasonable? :op
 
@Meredith cool, thank you
 
@sunto You could
But there are already apps that do the same thing
 
7:59 AM
good point
The thing I really would like, is a social site, not allowed on google :D ;)
 

« first day (1599 days earlier)      last day (3356 days later) »