Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Thursday, October 11, 2012

Finding an ideal directory structure

My recent forays into coding have left me with some pretty confusing directory structures. I tend to break up my directories thusly: (I'm talking about web dev for the time being)

[myProj] - project
    [scr] - scripts
        [php and javascript files that store functionality]
    [mod] - modules
        [php scripts that will be include()d and rendered on the page]
    [img] - images
        [pictures and such]
    [css] - style
        [css files]

An avid onlooker would notice that where I can, I name my folders a three letter abbreviation of their full name. This is because I am lazy.

Tuesday, October 2, 2012

Awesome uploading gif generator!

I don't spruik much but I just found this and it's awesome

Loading GIF generator

I am always trying to find decent free loading gifs and that has a selection of pretty much all the ones you ever see on the net. I thought it worth noting down in case I am looking for it again later.

Monday, September 3, 2012

Prototype is so handy

I have been javascripting like a madman recently. I now have quite a bit of experience in the language. Here's a few fiddles I did to get my head around stuff like objects, dragging stuff and AJAX calls:

My JsFiddles directory

Try the cards program, you can upload a picture and give it a name/description. It's supposed to be a jumping off point for making online card games like magic the gathering or w/e.

Friday, December 2, 2011

Reserved words in Mysql

Here's a quick one for anyone who has a query that just won't work (insert and update in particular). Mysql reserves certain words for its own uses. One such word (and the reason for this post) is 'desc'. An oft used abbreviation for 'description', 'desc' recently caused me three hours of confusing, frustrating code rewrites and function restructuring. Turns out naming a column 'desc' is a right reserved for mysql, and if you try it mysql will not tell you about it, just imply a syntax error. Mysql hogs 'desc' and other common names. Seems a bit selfish to me.

Just out of interest, here's a list of mysql reserved words that you should keep handy in case of an insolvable refusal of your query.

I fucking hate mysql.

Sunday, July 31, 2011

toggleSlide() and while loops.

I came across a problem tonight

That I thought I'd share a solution to. I was mysql_fetch_array()ing in a while loop to output a bunch of data in seperate divs, and since it was getting bulky and cluttered I decided to add a toggleSlide() so I could collapse them individually.

So I decided to supply an argument in the form of the entry id returned by the loop. I appended the id to the end of the divs in the loop and to the argument of my slide() function using a PHP echo. And this is where I hit a snag.

When you give toggleSlide() an argument and put it in the onclick selector, it accumulates your clicks. This must have something to do with the + sign you need to use when you add the argument. What this means is that

Function slide(arg) {
$('document').ready(function() {
$('#button'+arg).onClick(function() {
$('#slider'+arg).toggleSlide();
});
});

Will have an odd and unexpected effect. The first click won't have an effect at all, the second click will slide up and then back down, the thid click will move three times and so on. The trick here is to add an unbind() command to the button element. So

Function slide(arg) {
$('document').ready(function() {
$('#button'+arg).onClick(function() {
$('#slider'+arg).toggleSlide();
$('#button').unbind('click');
});
});

Will have your loop returned divs sliding around nicely!

Just to clarify, the div returned by your loop would look like this:

<div id="button<?php echo $id; ?>" onclick="slide(<?php echo $id ?>)"><img src="someimage.png" /></div>
<div id="slider<?php echo $id; ?>">Some content</div>

Look at me, gettin all tutorialicious and junk.