Tag Archives: javascript

SimpleBlog Work Post

4:30pm – This’ll be a short work session since I have to be somewhere in less than an hour, but I want to try and solve the AJAX error if I can before that. I’ve already taken a look at it and I’ve got no clue what’s going wrong. I don’t see any new code that would interfere with the jquery get function, yet it returns a fail result. So, I’ve gotta figure out under what conditions it could fail.

4:33pm – Oho! I found the problem. When I went to the php page itself it gave a syntax error. That explains it. That should be easy enoug to fix.

4:35pm – It doesn’t seem to have a syntax error in the file itself. I’ll try re-uploading it in case I don’t have the most recent version on the server.

4:46pm – Well I’ve gotten rid of the AJAX error but I still don’t have any posts showing. I wonder why that could be.

5:01pm – The AJAX error is gone, it was mostly a bunch of syntax errors in the PHP. But now it’s not putting up any posts and it’s not giving any errors. I added a data dump to console and found that it was getting a false result from the PHP script. That means the database connection isn’t working properly, in one of a few ways. It’ll take some effort to figure out what’s going wrong there, and I’m low on time, so I’m going to head out.

Tagged , , ,

SimpleBlog Work Post

3:15pm – Well, my problem mysteriously resolved itself when I cleared my cookies, which makes as little sense as the problem itself. For now I’m going to ignore it, since there’s nothing I can do, and continue programming. There’s a bug with the cookie anyways, so I need to implement a logout function. I’ll do that now.

3:35pm – I’m having trouble figuring out how to end the session when I’m doing the PHP side as a web service. I’m not sure but I think I’m going to have my sessions never end, server-side, while they end locally in browser, because it’s impossible to always have the browser close out sessions at the end. I’m not sure if this isn’t how the thing’s meant to be used either.

For now I’m going to do this the easy way and see if anything goes wrong.

4:07pm – Well the logout seems to be working fine. The cafe’s internet isn’t, though. It takes a while to load anything, if it loads at all… And it’s uncomfortably hot. I don’t think I’ll stick around for the second hour like I planned.

The next thing I need to do is figure out how I broke the basic post display, and fix it.

Tagged , ,

SimpleBlog Work Post

7:48pm – Some friends gave me some suggestions for my null != null is true problem, so I’ll give them a try.

8:19pm – No dice. Even when I have it as if(sessionID) and sessionID is null,

8:24pm – I’ve made progress! It’s a browser issue. In FireFox it works perfectly, but in Chrome it fails miserably.

8:33pm – Well that’s as far as I’ve been able to get. This really has me stumpped. I tried switching over to the !== operator but that doesn’t do any different. In Chrome, null !== null is true, and in Firefox null !== null is false.

Tagged ,

SimpleBlog Work Post

3:51pm – When I last left my Simpleblog, everything had broken. It thinks it’s logged in when it shouldn’t, and it throws an AJAX Error when it tries to download/display the posts. No more javascript errors though.

4:09pm – I put some console outputs into the code. For some reason the sessionID is coming out as null. Not sure how that’s happening…

4:16pm – Okay WHAT!? if(sessionID != null) is being passed even though sessionID is null. It being null is the only time that it should not pass! Debugging is one thing but I don’t know how to fix it when it’s clearly defying a logic gate. >.< 4:26pm - I've tested null comparison outside of my project and it works fine. Why doesn't it work here? It doesn't make sense! Argh. 4:28pm - if(null != null) console.log ("null != null"); doesn't print to console, so why does it evaluate as true immediately after? I have it printing sessionID to console immediately before the comparison; it's null, and yet null != null is proving true. Why? 4:33pm - It's google time. Here's something from StackOverflow... No that doesn't help. I don't see anything else that's like my problem. Shoot. I'm completely stumped, here. I'm going to give up for now and think about it, and maybe some friends will have an idea.

Tagged ,

SimpleBlog Work Post

10:29am- I finally have internet at the cafe I’m working at. I’ve been working for about a half hour aready, working on the login function JavaScript. I’m about to make some modifications to the php login function to stop code insertion.

11:44am- I’ve been working quite a while and haven’t tested anything. I’m sure something will go wrong with this code, and debugging it is going to be a pain. I’m still working on the login function. Right now I’m working on the part where it shows the hidden logged in options bar and hides the login form.

12:13pm- Now I’ve got it so that if there’s a session ID cookie it displays as if you’re logged in. It’s getting close to test time.

12:20pm- Test time! Also lunch time. I’ll be debugging until my food gets here. I’ve got my first bug too. The login form is nolonger displaying to the right of the page with the CSS Formatting.

1:14pm- Well I got the javascript errors cleared out, but now it’s throwing ajax errors displaying the entries. Unfortunately I’ve hit my limit, it’s hard to keep my eyes open. I need a nap, so this is where I’m calling it for now.

Tagged , , , , ,

SimpleBlog Work Post

Well I’ve finally found time to work on my SimpleBlog project again. Well, this isn’t the only time. Last time I worked on it, I didn’t save my notes, so I’ll summarize here.

I added a CheckLogin function to model_SimpleBlog to check the login data, and removed the checkLogin function from controller_SimpleBlog.php because its unneccesary now. The web app will know it’s logged in because it’ll have a session id, or it won’t. Checking the login data will happen on login.

9:51am- Getting started. The work I did last time has got the groundwork done for logging in and returning a Session ID. Now I need to make the login form work and make the system check for a cookie with a session id. I’ll start with the latter part.

10:47am- Okay it now checks for a session ID in the cookie when the page loads, and if it finds one it assumes the user is logged in. Next I need to make the login form work, but that’ll have to wait for next time. I just remembered something I had to do at home.

Tagged , , , ,

Progress Update

MyFirstChatroom is coming along. I’ve decided to start by getting the hand-entered entries from the database onto the chatroom box to make sure my pipeline is working, before moving on to live updates and posting entries.

It’s been a while so I’ve got to refresh my memory on how to have two PHP scripts talk to eachother. Looks like the only way is to have the controller contain an instance of the model.

The model has an array that the controller needs to access in a variety of ways but I don’t want to make it public, so I’ll have to make a variety of accessor functions next. For now, I’m out of time.

Tagged , , , ,

More MyFirstChatroom Design

So, I’m continuing to work on the basic design of MyFirstChatroom. After discussing it with my brother, I’ve decided that the model_Chatroom class will model the entire database. So, it will have an array of 201 entries, and when that list fills up it will delete the last one and push the newest one in.

Database:
id
timestamp
chatentry

I’ll make the chatentry a TEXT type. That’ll give it a max size of 65,535, way more than enough for any chatting. I’ll have to make sure to limit the input to nothing beyond that, though.

Okay, the table has been placed on the database. If I need to change it, I can modify it later.

*work work work*

It occurs to me that a timestamp must be unique, since it’s accurate down to the clockspeed of the cpu and thus each call to the timestamp function is at a different time, so I can use it as the primary key of my db after all. That’ll save me the trouble of recycling 200 ids and simplify everything, so I’ll do that. *does that*

*work work*

For the most part I’m just copying the structure of most of my PHP programs. I’ve got a nice, commented block of code for accessing databases that I use. Not much to say about it. Making the model_Chatroom class work.

I’ve finished the Retrieve() function, which gets the list of chat entries from the database. Now I’m doing the Create() function, which creates a new entry, and deletes the oldest if there are already 200.

Alright I think that’s enough for now. The next thing I need to do is write the code that determines if there are over 200, and finds the oldest to delete it. I might have to figure out a different way of sorting the chat entries in order to rank them in age. Timestamp is probably different between MySQL and PHP.

Tagged , , , , , ,

Designing MyFirstChatroom

So to start with I’m making a chatroom. I’m calling the project MyFirstChatroom since it kind of is, and it’s simple.

There’ll be an AJAX/JQuery View, a PHP Script Controller and Model covering a MySQL Database. For this version of the chatroom I’ll be recording a log of the last, let’s say two hundred things said on the chatroom. When I convert it to a MUCK I’ll probably just fill the user’s view with whatever is posted in their vicinity instead, so that they can carry it with them room to room.

I’ve hit my first problem with the design. I’ll be keeping a database of previous paragraphs up to two hundred. But, as they pass that and are deleted, the id of the stored paragraphs will keep going up, eventually running out. So, I’ll have to set it up to recycle ids after it gets to two hundred.

Hmm… If I’m going to be saving chat lines, that’ll be seperate from the chatroom itself, and eventually the users. So, I’ll have to make a model for chat paragraphs as well.

The way I’m thinking about it now, I’m pretty sure I’m violating database rules. Maybe 1st Normal Form…

I talked about it with my brother some, and he thinks I should be good to just make the model an array of entries representing the one table. So I’ll give that a go.

Tagged , , , , , ,

WebMUCK

Well Ludum Dare didn’t go so well, I spent the whole weekend trying to get my tools to work. Hopefully I’ll be better prepared next time.

I’m starting a new project today, something I should be able to put proudly into my portfolio. I’m going to make a Web based MUCK. MUCK stands for Multi User Chat Kingdom. They’ve been around since the internet stone age and haven’t changed much since then. In form, they’re like a series of linked, themed chatrooms representing a virtual space. Unfortunately they’re so old that you have to connect to them with a dedicated client, and interact with people using arcane text commands.

I’ve decided to make a web based MUCK system. Linked chatrooms should be simple enough to do quickly and complex enough to show my skills, I hope.

To begin with, I’ll make a simple chatroom. Then I’ll add in the account system, and finally set up connections. I can build other MUCK features on top of that; they usually have programmable objects in MUCKs that say or do things when you interact with them. Though, I might just expose the client interface, so that people can make chatbots to do that with whatever they’re familiar with. But one step at a time.

My first chatroom will be done MVC Style. The Model and Controller will be PHP classes while the view will be done with JQuery and AJAX.

I’ll post more on here when I hit a stumbling block but for now I’m just setting up the basics.

Tagged , , , , , , ,