Custom Javascript Objects with Embedded JQuery
To all of you non coding geeks, you don’t have to read this. It might confuse bewilder bore you to death not be of relevance to you.
As some of you know, I’m a multimedia developer (read: web developer… that seems to be the majority of what I do) at a relatively new University in Southern Ontario, Canada. I’ve been working on a website for first year students to brush up on writing and math skills. Back at the beginning, someone had the idea of having a “virtual campus” as another means of students finding their information.
One thing led to another, it started with Flash, then moved over to an AJAX solution.
I worked on said AJAX solution and had it working relatively nicely. However, due to some usability quirks, I needed to rewrite a huge chunk of code.
I decided to objectify it, purely for my own amusement and further education.
The problem that I kept on having is that whenever I used a JQuery call and needed to reference the object’s properties, it would always give me an undefined error. Being the Actionscript junkie I am, and knowing that Actionscript borrows heavily from Javascript, I tried using parent.variable instead of this.variable.
It all seems to be working at this point. But I thought this might be of some use to someone, somewhere. I thought it was working, however, what using parent.variable did was created a variable outside of both the JQuery and VirtualCampus objects. Not a great idea, however, it served my purpose and was a lot easier than using the VirtualCampus object to extend the JQuery object.
Quick example:
function VirtualCampus() {
this.campus_location = []; //array with locations visited
this.campus_depth = 0; // what level in the nav tree they are at
this.campus_faculty = 0; // id of faculty they entered
this.current_info = []; // Data for current location in VC
$.getJSON(‘virtualcampus/vc.js’, function(jsony){ // Get JSON data for campus
$.each(jsony.location, function(i, item) {
parent.campus_info[i] = [];
parent.campus_info[i][0] = jsony.location[i].name;
parent.campus_info[i][1] = jsony.location[i].file;
parent.campus_info[i][2] = jsony.location[i].depth;
parent.campus_info[i][3] = jsony.location[i].faculty;
});
});
}
So there’s the constructor, that sets variables and gets the JSON data for the VirtualCampus. Notice the parent.campus_info 2D array… that’s stored as global scope. I tried very hard to make it local to the object, but JQuery and my object weren’t playing nice. If anyone has any idea how to get around that, let me know.
Double Crunch Challenge: Post-Post-Week Wrap-up
So the week after the… uhh, week after the double crunch challenge, I’m still doing crunches (though I’ve dropped it to 100 per day), I’m still eating relatively healthy (save for the Wendy’s my wife and I got for dinner because we were in a bit of a rush).
I’ve included having a handful of nuts between meals to keep the metabolism going. Water doesn’t seem to do it, even though I drink about 2 litres over the course of the day.
Today I started including lunges in my morning exercise. I’m not all that good at them because of balance issues, but I still got a burn from doing them, which is a good thing.
Interesting note: the guy I share my office with (I got to find a shorter way to say that – what about gismow?) just started on P90X. I looked at that at one point, but the pre-requisites definitely don’t allow for fat guys to start with that routine. Maybe once I get to that first plateau. Maybe.
Until Seth gets back (which I believe he said would be next week) I’ll add a new exercise each week. Maybe I should get my Wii Fit involved again. But I can’t watch BT and exercise at the same time if the Wii Fit is involved. Hmmmm.
Double Crunch Challenge: Day 5
Let me answer your question: Yes, it still hurts; but not as much as it did yesterday. That means my body just might be getting used to it. I spread out the crunches throughout the day – fifty when I wake up, fifty just before (or when I get) to work, fifty at lunch, fifty when I get home or after dinner, then fifty before I got to bed. It only really hurts once I hit the forty mark.
The greens: last night I had green beans. Leftovers went good in a salad for lunch today too. Tonight: I’m thinking spinach. Raw, in a salad. Throw some fruit in there and a light vinaigrette – that’s good eating!
Today’s question from PrimalStride:
Where do you get your power from? Are you able to survive, to thrive, and to flourish through the strength of your friendships with others? Do you have a deep religious fervor that keeps you going? Perhaps you just know, deep within yourself, that you are able to do whatever you wish?
I said in yesterday’s update that I wanted to be able to do physical activities with my family without running out of steam. I believe that drives me more than anything else. I am a Jesus follower, however, I don’t know that my relationship and belief in him would push me to get in shape; though I do like to joke every once in a while that “the Catholic Church says that gluttony is one of the deadly sins; I don’t know if it will send you to hell, but it sure will get you to heaven faster.”
Double Crunch Challenge: Update
On day 4 of the double crunch challenge: I’m hurting.
I’ve been faithfully doing my 250 crunches a day and have had very little difficulty in eating a different green vegetable each day. Friday was Green Peppers, Saturday was Broccoli and Celery (Looky! Double Dose!), Sunday was Asparagus. Today? Any suggestions?
Did I say I’m hurting? Wait… my fellow office dweller is gone for lunch. Time for 50 crunches! That’ll bring me up to 150 for the day.
…
I’m back. Yes, I might be going insane when I hurt and I’m doing the very thing that makes me hurt, but hey – (cliche alert) no pain, no gain!
Today’s question posed by our PrimalStride fearless leader, Seth:
What do you look forward to most when you imagine yourself living a truly healthy lifestyle?
I see running around with my son without running out of breath after 10 minutes. I see looking forward to walking with my wife. I don’t see me better at sports, but definitely enjoying them more despite my lack of coordination.
It occurs to me that I should look at last week’s challenge (even though I had not committed to PrimalStride yet) and incorporate it into my daily routine.
New Year’s Resolutions
It’s been a while since I’ve blogged. Yes, I’ve been on twitter, I’ve been on Facebook (but only because facebook grabs my tweets automagically) but I’ve never really done any significant writing in over a year.
That’s about to change.
I’ve seen others talk about wanting to blog again, and making a new year’s resolution to blog at least once a week. I think that’s an attainable goal. But here are some other goals I’ve been thinking about.
Time Management
I spend way too much time in front of the TV. I probably spend too much time sleeping (6-7 hours is enough, right?). So actually saying “I’ll only watch 1 hour of TV a night, 2 hours if there’s something good on” might make a meaningful difference in productivity and brain power. Besides, I’m already getting into the habit of holding my son in front of the TV and letting him watch because it distracts him. Not a good habit to get into. And scheduling time that I sleep will let me do more…
Exercise
Oh yeah. The big fat (pun intended) popular New Year’s resolution. Go to the gym. Work out. Lose weight. I’ve made it before, and judging by my waist size, it’s never really stuck. I’m sure 90% of people who make that resolution fall off the wagon within a few weeks. Time management should help me out a little… if I schedule it, I must follow through.
And a little backing doesn’t hurt either. Primalstride.com, run by Seth Simonds, is a week-by-week weight loss challenge – so each week, you get a new challenge. This week’s challenge he’s dubbed the double crunch challenge: 250 abdominal muscle crunches a day, and a new green vegetable each day.
Blogging
Well, obviously, if you’re reading this, you see why I want to blog. As the tag line of the blog says, I’m going to write about technology, new fatherhood, politics, health and just about anything I feel the need to write about. I’m just going to write what I want, when I want; but try and do it at least once a week.
I’ve made my resolutions… wait, no. I’ve made promises to myself. Resolutions just seem to get broken. What about you?
Just When You Thought It Was Safe
I wrote a while back about Facebook killing my inner child. Seems I’m not the only one.
If you’re asking yourself, “Who is this guy?” He’s the executive producer of a rather successful science-fiction franchise. And a writer.
It’s No Wonder
Yet another mud-slinging session in parliament. I’m really getting sick and tired of this sort of thing.
Just read this for the back story. I don’t want to reiterate the whole stinkin’ thing.
This is yet another reason that voter apathy in Canada is at an all time high. So here’s my take on the whole thing:
- The Liberals are accusing the Conservatives of bribing. Talk about the pot calling the kettle black. Do we remember the reason that the Liberals got voted out in the first place? Oh, that’s right. We don’t remember. The collective memory of Canada is shorter than the attention span of an ADHD kid.
- The Conservatives are making bribes. Can we say Liberals all over again? I think they should just merge those two parties, give the other parties (that seem to actually give a damn) a chance to get into office. Except the NDP. I shudder at the thought of “Prime Minister Jack Layton.” I need to go and clean myself now.
There are some days when I wish I didn’t care about my country and its political system. That might account for part of my high blood pressure.
Obama-nation
I have never really understood American politics. It seems a little redundant and convoluted. But of course my American teacher would take offense to that; many an American would even go as far as to say that Canadian (and, by association, British) politics are confusing. That’s not really the purpose of this article.
Rick Mercer, a comedian/Canadian political pundit (that could very well be compared to Jon Stewart) put the real comparison that needs to be addressed. Canada is known – even prideful – about its diversity. People of all nationalities, religions, sexual orientations and skin colours all live in relative harmony up here in the great white north.
But one look at our party leaders, a big white guy, a skinny white guy and a mustached white guy, would make you think otherwise. Sure, there is one female that I know of that is the head of a party, but that party does not have any seats currently, so you really can’t count it (how ever much you may or may not want to).
America is known the world over as a “melting pot,” which means (for a lack of a better dictionary) that everyone that enters into American citizenship does his or her hardest not to show the culture from whenst they came. And yet their political landscape, yes, has a few white guys themselves, but the front runners for one of the parties are a woman and a black man.
I say – good for them. Canada needs to learn a political lesson from the Americans. Not the confusing ones… the ones that show that the norm – or the white lawyers from Montreal, Toronto and Calgary – don’t need to be followed anymore. Voter apathy in Canada with the 30 and below set – including yours truly – is at an all time low. The political landscape in the US is more exciting than it’s ever been.
I think its time to kick out the white guy, the white guy and the other white guy. This coming from a white guy.
Facebook is Killing My Inner Child
Another barrage of useless “applications.” People who develop these things better not call themselves developers; I’d call them annoyance mongers. More “events” that I won’t attend. People challenging me to another “Lost” trivia game. And the list goes on and on.
I find that every time I visit Facebook that all I’m doing is saying “no” to something else someone has invited me to. Don’t get me wrong, I like the fact that I can catch up with people I haven’t seen in ages and have been trying to find (or not, but still don’t mind getting in contact with again). I just don’t want to waste more than 5-10 minutes a day on Facebook, just see what people are up to – but when I waste that time, like I said before, saying “no” to ridiculous wastes of time, I tend not to check in on people out of pure annoyance.
I guess it doesn’t help that I’ve got 150+ people on my list; more than the average guy, thankfully a lot less than a musician or celebrity.
I would be the first person to sign up to “Facebook Light,” You know, back in the good ol’ days when Facebook was friends finding each other, posting pictures (which I won’t do anymore, but that’s beside the point) and joining groups of like minded/similar interested people. I miss that. The only problem seems to be that I may be one of a select few that do.
Observations of a Canadian in America
Ok, so I figured I’d rattle the chain a little just to see if I can stir up some more readers. After driving for two days on US highways, here are some observations I’ve made.
- No one on the eastern seaboard has cruise control, nor knows what keeping a consistent speed is.
- Quebec is the 51st state.
- Turn signals are an option on most vehicles sold in the eastern United States.
- When the speed limit sign says, say, 65mph, the actual speed limit is 52mph in the right lane and 78mph in the left lane… and if there’s a middle lane, the limit is 59mph.
- Traffic is a phenomena that people have not really experienced to it’s fullest… drive into Toronto on any given day at 9am. Taken into consideration the size of the cities that I’ve been in traffic in (Toronto, Calgary and Chicago) and the time taken to get through said traffic, Toronto still seems to be the worst I’ve experienced. (I realize that Los Angeles and New York City are probably worse.)
That’s all for now. I will probably think of some more in the next few days.
