Jump to content

ghostcoder

Members
  • Posts

    26
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

ghostcoder's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, I'm using pushState, replaceState and popstate events along with Ajax to change content on a new project I'm working on. The basics are very simple and I've finally got it working well. However, I need to find a way to track and determine when a user is moving forward or back through the browser history, so that I can adjust the transitions properly. In my case, if someone goes back, I want the transition to be left to right, otherwise, right to left. I'm thinking the only way might be in a cookie. The system needs to remember history even if the person backs out of the site. ( as in, if you first load phpfreaks.com and the navigate to a site, move around a bit and then use the back button to go back to phpfreaks. Then, you may decide to click forward again to the site. Does anyone have any ideas on the easiest way to do this? Keeping some sort of array in a cookie, maybe?
  2. Ok, so I'm a fairly decent Javascript programmer and I've coded the majority of my functions from scratch along the way. However, I'm trying to get with the program here and separate as many event function calls from my HTML as possible. I'm also trying to decide if I should use Jquery or YUI or something, as opposed to writing everything myself. But that is a side question. One thing that in my studying so far is that I don't understand how advanced Event Delegation and Bubbling will work in some scenarios. For example, say I have a member search page and it displays 20 members at a time. Each member is in a DIV, but within that DIV, there is a small icon and if you hover over that icon, it triggers an onmouseover event. I currently have that event in line on the element. in short, it might looks something like this: <img src='/skin/default/magnify.gif' class='magnify' alt='mag' border='0' onmouseover="showfloat('/img/24386/9533.jpg','User name','United States, Southeast', 24386);" onmouseout='hidefloat();' /> So, the showfloat function has info that is easily assigned to it when generated by PHP. Img, username, location, and member id. Now, I suppose I could assign an event listener to every img with the class 'magnify'. Perhaps I could also create an ID tag for each of these images with the member ID. But how could I get all of the variables that I need to use in my showfloat function? I imagine I could do an AJAX call, but that wouldn't be nearly as fast as having all of that info preloaded in the page like I currently do. In another situation, I have a stream of posts, similar to a forum or to FB. Currently, I assign a lot of ID tags to DIVs using words along with an ID to identify which DIV I need for any particular javascript event. //I have a DIV id that looks like this: <div id='replyfield1234'></div> //then, I have a bunch of events in the HTML linked to the ID. Couple of examples onclick="doAddComment('addcomment', 1234); return false;" onblur='expandInput(this.id, 2, 117944);' //different ID for a reply In this situation, when there are so many events going on for so many DIVs and sub elements, how do I assign event listeners to everything and manage to keep track of the IDs? I can't assign the same ID more than once, and I still need to keep track of every event element relating to a particular ID. As above & in some cases, I might want to pass more info than just an ID to a function triggered by the event. Should I just wrap everything in a single parent labeled by an ID number? And then when events are triggered, I would somehow extract the ID of the parent in the Bubbling? I was looking at Twitter and I saw they have unique IDs in their html code, such as: data-tweet-id="2350143172699996##" data-item-id="2350143172699996##" Not sure how these work, or how you would access them from Javascript. If anyone has any feedback, I would appreciate it. I'm sure, like most programming things, once it really 'clicks' then I'll be off to the races.
  3. I don't see any delete query. Maybe you could post the code that handles the POST data and the deleting of the message.
  4. On a quick scan, I'd change your delete line from DELETE FROM writing WHERE a=$a to DELETE FROM writing WHERE a='$a' LIMIT 1 But I might not use $a as my variable name. Also, I'd escape it first. You can also echo what the value of your post data is and exit before you run the SQL. Then you can do a select on the table with the same value and see if it returns more than one row or not.
  5. Do you have a specific question? Asking about a 'messaging system' is quite vague.
  6. Have you checked out the Array page on php.net? http://php.net/manual/en/language.types.array.php Arrays can contain arrays, so you have true multidimensional arrays. You can also use an integer or a string for a key. print_r is handy for printing an array's contents to the browser, for example, so you can see what's going on with it at any time. Best thing to do is to start creating some arrays and playing with adding and accessing values to them. Hope this helps...
  7. Quick update. I'm still testing things, but since I added session_write_close(); to my php scripts being called via AJAX, I've not had a single browser freeze up! * knocks on wood * Thanks for the tip ajlisowski, and thanks for the other feedback as well. I'll report back here if things change.
  8. Thanks F1Fan, I'll check out the Firebug. I already use the web developer add on and it's awesome. Although it hasn't given me any hints here. Ajlisowski, thanks for the feeback. I have not been doing any session_write_close(); calls. I do a session_start() and that's about it. There is a place where I call session_destroy, but it has only been in certain cases. I will try session_write_close() and see what happens! I'll report back when I find out anything new... thanks again.
  9. I'd start by putting quotes around form values. name = 'form1' onlick='test();' etc... You can also put an alert above the var mytext line, just to make sure the function is being called when you click the button. alert('infunction');
  10. Start by adding a semi-colon after game() in your init function.
  11. Ok so I have an Ajax chat app that I've created. Works great. However, when running it locally on my Windows XP box with Apache installed, it freezes up over time, like in 30 minutes or something. It's very odd. I'm thinking it might be MySQL related, but it is definitely Apache related some of the time. The trick to getting it going again is switching Apache off and back on again. However, I'm getting tired of doing this over and over again. Any ideas ?
  12. Hello everyone, I have created a chat application and I'm really pretty happy with it. Only criticism so far seems to be that people don't always know when there is new chat. I have already coded in a few alerts to let the users know, but I think they still want more options. I have embedded a sound file that plays whenever a new chat comes in and the window isn't in focus. This works great. I also flash the top window title, works pretty good. This all happens on the popup window where the chat is running. Unfortunately, I don't have control over flashing the window tab in the bottom tray or anything. I guess people are used to Skype or Yahoo, which are actual applications. I'm just curious if anyone as any additional ideas or trick that I could employ to make it easier for my users to know if a new chat comes through. Thanks for reading.
  13. Where are the images coming from and how are they getting populated into your HTML output? A broken image in HTML will look the same in HTML as a regular image. You could use php or javascript to test the images. But I would consider using .htaccess Just depends on your specific needs.
  14. $_SERVER["REMOTE_ADDR"] Check this value and if you are not happy with it (empty or whatever), you can redirect them to another script.
  15. Jeffery, you cannot stop a php script and interact with it. Php is server side, so it will run the whole script before outputting the result to your browser. This is why you need to use a form to post the info back to the server. Use javascript and write a little function that takes your input and posts the value back to the server. You'll then run a php script to grab the posted variables and send your mail or do whatever else you want it to do. What I've done in the past is to have a form in the html with some hidden values. Like: <form method='post' name='myform' action='myscript.php'> <input type='hidden' name='mycustomfield' value='' /> </form> You can then take the variable in javascript and set that value before submitting the form. function formSubmit(form,info){ form.mycustomfield.value=info; form.submit(); } In php you grab the value of mycustomfield $_POST['mycustomfield'];
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.