Jump to content

remenissions

Members
  • Posts

    53
  • Joined

  • Last visited

Everything posted by remenissions

  1. Not that its bad at all I know its easy and simple, I just like to learn things myself. Rather learn how to do it then learn how to use their functions
  2. What do you mean? I am just trying to get some help correcting the timing on my script. I have made it very readable and just trying to find some one who might know how to help me fix the timing issue.
  3. Hey guys, I'm trying to make an animation handler that I can use in any sittuation. It works, but the only problem I am having is that because the progress is determined by time it will not start at the starting point I give it, I tried to make a work around it but then it messes up the duration. For instance, if I want it to go from 200px to 400px in 1 second the time will keep going but the animation won't begin until it gets from 0 to 200px, which sets the timing off. I've messed with it for manyyyyyyyyyyyy hours trying to figure out how to get this to work. Just no luck yet.. Any help would be greatly appreciated!!! /* Function : animate(element, control, startPos, endPos, duration, delta); */ function animation(curObj) { var start = new Date; /* -Animation Interval- */ var animation_Interval = setInterval(function() { /* -Determine current duration- */ var progress = (new Date - curObj.start)/curObj.duration; document.getElementById("testObj").innerHTML = progress + "<br><br>:"+progress+":<br><br>" + document.getElementById("testObj").style.height; /* -/Determine current duration- */ /* -Prevents over-animating- */ if(progress > 1) progress = 1; /* -/Prevents over-animating- */ /* -Animate element- */ var delta = curObj.delta(progress); curObj.control(delta); /* -/Animate element- */ /* -End animation- */ if(progress == 1) { clearInterval(animation_Interval); document.getElementById("testObj").innerHTML = progress + "<br><br>:"+progress+":<br><br>" + document.getElementById("testObj").style.height; } /* -/End animation- */ }, curObj.delay || 10); /* -/Animation Interval- */ } function animate(element, control, startPos, endPos, duration, delta) { animation({ id: element, delay: 10, start: new Date, end: endPos, duration: duration || 1000, delta: delta || linear, control_Id: control, control: function(delta) { animation_Control(element, control, startPos, endPos, delta); } }); } function animation_Control(element, control, startPos, endPos, delta) { /* -Determine increase or decrease && set temporary position- */ var tempPos = startPos < endPos ? endPos*delta > startPos ? endPos*delta : startPos : (startPos - (startPos*delta)) > endPos ? startPos - (startPos*delta) : endPos; /* -/Determine increase or decrease && set temporary position- */ /* -Set position- */ var obj = document.getElementById(element); switch(control) { case "width": obj.style.width = tempPos + "px"; break; case "height": obj.style.height = tempPos + "px"; break; case "left": obj.style.left = tempPos + "px"; break; case "right": obj.style.right = tempPos + "px"; break; case "top": obj.style.top = tempPos + "px"; break; case "bottom": obj.style.bottom = tempPos + "px"; break; case "opacity": obj.style.opacity = tempPos/10; obj.style.filter = 'alpha(opacity=' + tempPos*10 + ')'; break; } /* -/Set position- */ } function linear(progress) { return progress; } function quad(progress) { return Math.pow(progress, 2); } function circ(progress) { return 1 - Math.sin(Math.acos(progress)); } function back(progress, x) { return Math.pow(progress, 2) * ((x + 1) * progress - x); } function bounce(progress) { for(var a = 0, b = 1, result; 1; a += b, b /= 2) { if (progress >= (7 - 4 * a) / 11) { return -Math.pow((11 - 6 * a - 11 * progress) / 4, 2) + Math.pow(b, 2); } } } var bounceEaseOut = makeEaseOut(bounce); function makeEaseOut(delta) { return function(progress) { return 1 - delta(1 - progress); } } <button onclick="animate('testObj', 'height', 100, 0, 1000);">Open</button> <button onclick="animate('testObj', 'height', 350, 100, 1000, linear);">Close</button> <div id="testObj" style="color: white; background-color: blue; width: 80px; height: 50px; position: absolute; left: 10px;"></div>
  4. I implemented it in and works great and eliminated those errors in ie, but for some reason in ie the script stops like 3 images short and because it does it doesn't allow the script to finish and replace location. I debugged it in fire fox and saw no errors. Works fine in google chrome as well. Just not sure why it won't work in ie. I'm on linux with my desktop so i've been messing around on my laptop trying to get it to work for the past 4 hours, not sure why it won't. Would anyone mind taking a look at it? I'm not sure if lets me post the whole page into this, It didn't for the last so here it is. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <?php /* Retrieve Pictures */ echo "<script type='text/javascript' > var image_url = new Array();"; $dir_Array = array('/subVanity/VanityPics/', '/subVanity/VanityBackgrounds/'); $ctr = 0; /* -Load images from server- */ for($k=0; $k<count($dir_Array); $k++) { if ($handle = opendir($_SERVER["DOCUMENT_ROOT"].$dir_Array[$k])) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { echo "image_url[$ctr] = '{$dir_Array[$k]}{$entry}';"; $ctr++; } } closedir($handle); } } /* -/Load images from VanityPics- */ echo "</script>"; /* Retrieve Pictures */ ?> <script type="text/javascript" > /* Preload Script */ window.onload = function() { /* Detect Images && Create Them */ if (document.images) { /* -Progress control- */ var progress = 100/image_url.length; var curImage = 0; var progress_Percent = 0; /* -/Progress control- */ /* -Create new image object && array- */ preload_Image = new Array(); for(i=0; i<=image_url.length; i++) { preload_Image[i] = new Image(); preload_Image[i].src = image_url[i]; } /* -/Create new image object && array- */ /* -Call load check- */ check_Load(); /* -/Call load check- */ } /* /Detect Images && Create Them */ /* Check Loading Progress */ function check_Load() { /* -Loading complete :: Send to new header- */ if (curImage == image_url.length) { document.getElementById("process_Load").innerHTML = 100 + "%"; //window.location.replace("/lobby.vanity.php"); return; } /* -/Loading complete :: Send to new header- */ /* -Update each load- */ for(i=0; i <= image_url.length; i++) { preload_Image[i].onload = function() { progress_Percent += progress; document.getElementById("process_Load").innerHTML = Math.round(progress_Percent) + "%"; document.getElementById("load_Bar").style.width = Math.round(progress_Percent)*4-10 + "px"; /* Debug info */ document.getElementById("debug0").innerHTML = "length: " + image_url.length; document.getElementById("debug1").innerHTML = "progress: " + progress; document.getElementById("debug2").innerHTML = "Percent: " + progress_Percent; document.getElementById("debug3").innerHTML += "<br>image " + curImage + ": " + preload_Image[curImage].src; document.getElementById("debug5").innerHTML = "pre-curImage: " + curImage; /* /Debug info */ curImage++; /* Debug info */ document.getElementById("debug6").innerHTML = "post-curImage: " + curImage; /* /Debug info */ } } /* -/Update each load- */ /* -Repeat this.function()- */ var timer = setTimeout(function(){check_Load();},10); /* -/Repeat this.function()- */ } /* /Check Loading Progress */ } /* /Preload Script */ </script> <style type="text/css"> #load_Box { font-size: 20px; font-weight: 900; color: white; position: absolute; top: 50%; left: 50%; margin-left: -260px; margin-top: -150px; padding: 5px; width: 400px; height: 55px; text-align: center; background-image: url('/subVanity/VanityPics/loadBg.png'); background-repeat: no-repeat; } a:hover { text-decoration: none; color: white; text-shadow: -1px -1px #424242; cursor: pointer; } </style> </head> <body style="background-color: black;"> <span style="padding: 5px; color: white;" id="debug0"></span> <span style="padding: 5px; color: white;" id="debug1"></span> <span style="padding: 5px; color: white;" id="debug2"></span> <span style="padding: 5px; color: white;" id="debug4"></span> <span style="padding: 5px; color: white;" id="debug5"></span> <span style="padding: 5px; color: white;" id="debug6"></span> <br> <span style="padding: 5px; color: white;" id="debug3"></span> <div id='load_Box'> <img id='load_Bar' style='width: 0px; height: 45px; float: left;' src='/subVanity/VanityPics/loadBar.png' alt='loading...'> <span style='position: absolute; left: 50%; top: 15px; margin-left: -30px;' id='process_Load'>0%</span> <a href='/lobby.vanity.php' style='position: absolute; top: 60px; margin-left: -60px; left: 50%;text-decoration: none; color: #424242; font-size: 15px;' >(Skip preload)</a> </div> </body> </html>
  5. Wow man I did not expect an answer so fast ty I appreciate it!!!
  6. The problem I'm having is when I use getElementById() it works in google and ffox but with Ie it declares the object as null since the html hasn't been loaded yet. It works but in ie it will mess up the count aswell. Is there a way around this to do what I want? Like with a document.write or something /* Check Loading Progress */ function check_Load(images) { /* -Loading complete :: Send to new header- */ if (curImage == image_url.length) { document.getElementById("process_Load").innerHTML = 100 + "%"; //window.location.replace("/lobby.vanity.php"); return; } /* -/Loading complete :: Send to new header- */ /* -Update each load- */ for(i=0; i <= image_url.length; i++) { preload_Image[i].onload = function() { progress_Percent += progress; //document.getElementById("process_Load").innerHTML = Math.round(progress_Percent) + "%"; //document.getElementById("load_Bar").style.width = (Math.round(progress_Percent)*(4-10)) + "px"; curImage++; document.getElementById("debug").innerHTML = curImage; } } /* -/Update each load- */ /* -Repeat this.function()- */ var timer = setTimeout("check_Load()",10) /* -/Repeat this.function()- */ } /* /Check Loading Progress */
  7. I didn't think anything was wrong with my code because it worked fine outside of a function, the sql wasn't working because my where variables were not being passed through. Common sense i just didn't think of it lol thank you
  8. Thank you so much for your help Thrope I appreciate it :]
  9. Hi I was trying to run an mysql statement in a function and it wasn't working. I'm sure it has something to do with global variables but when I tried running the statement with the connect in the function it still did not work. I am running MySQL server version --5.1.58-1ubuntu1 basically my code looks like this <?php include(" database connect "); include(" proc "); if(!empty($_POST[''])) run_function(); ?> proc funcion run_function() { mysql_query("") or die(mysql_error()); } The error prints nothing but if I take it out of the function the code works. If I require the database connect in the function, still nothing.. Do I need to pass my connect variables or something? or will this simply not work. [/code]
  10. Hey guys, I'm in need of a little help with sql. I'm just wanting to make sure I do this correctly. I have a mysql statement for adding contacts from request list to friends list. Before I was using two statements to check if the users already existed as friends (to prevent duplicates), but I'm wanting to use one statement. I've looked around a little and I have a few examples such as the following, but do these statements require a primary key? I haven't really looked much into what primary keys do I'd just assume its a special id for a certail row or table or something. I just want to be for certain I'm doing this correctly before I do submit it live on my server. INSERT INTO `table` (value1, value2) SELECT 'stuff for value1', 'stuff for value2' FROM `table` WHERE NOT EXISTS (SELECT * FROM `table` WHERE value1='stuff for value1' AND value2='stuff for value2') LIMIT 1 Here is what I currently have going on, though I'm not sure if "IGNORE" works w\o a primary key either and from what I've seen its not really preferred. /* Adding Contacts */ if(!empty($_POST['addPosition']) && !empty($_POST['targetId'])) { /* -Delete from requests- */ deleteContact($_POST['addPosition'], $_POST['targetId']); /* -/Delete from requests- */ /* -Insert target into friends list- */ mysql_query("INSERT IGNORE INTO Friends_List (Requester_Id, Friend_Id) VALUES ('". mysql_real_escape_string($_POST['targetId']) ."', '". mysql_real_escape_string($userId) ."')"); echo "User successfully added!"; /* -/Insert target into friends list- */ } /* /Adding Contacts */
  11. Thank you for your reply, I had never looked into this really. I saw a couple posts about it but didn't quite understand it at first glance. Just tested it with a simple <?php echo $_SERVER["DOCUMENT_ROOT"]."<br>".$_SERVER['SCRIPT_FILENAME']; ?> Its just what I needed :], thank you.
  12. Hey all, I've been having an issue with require_once from another sub-directory. Origionally I had all my php files in the same spot but I wanted to make a library to clean things up a bit. Atm I am trying to access my /subFolder/frame_work/sql/dbconnect.rem.php with require once from /subFolder/frame_work/account_data/accountHandler.rem.php. I have looked around a little bit and i know requires\includes looks in relative directorys. So one obvious solution would be to include the entire path name. "var/www/subFolder/frame_work/sql/dbconnect.rem.php". My problem is I will be accessing this from multiple directories and on localhost the root directory is var opposed to my server which is public_html. I like to edit my stuff in localhost before going public with it and it is going to be a real pain if I have to keep switching var to public_html in every file before I upload. Is there any other solutions I could approach? Any responses would be much appreciated. Thank you for your time.
  13. Hey mjdamato, again I appreciate your response. I am using my own server to run it on and there will be roughly 50-100 people using the site, not all at once so the traffic won't be too bad. I'm just trying to expand what I know and make this the best I can make it. I went through and re-changed a lot of things to make the site revolve around Id's instead of passing usernames. I worked with what you showed me and came up with something a little less clean than yours however it does do the trick and hopefully is not too bad. I did have a few questions about some symbols, not really sure how ':' or '?' is used, I've only been coding a couple months now. I'll probably google it later. Anyways here's what I came up with for the final code. It can query a maximum of 3 times. One to get the usernames and set them as sessions as you demonstrated (I really liked that Idea, never would have thought of it). Another only when they first click the user they wish to speak to, it'll load all previous chat. And then one upon each request to determine if there are any new Messages. Anyways here's the code if you have any opinions feel free to give them, I'm just trying to improve what I do know so any help is much appreciated. Also timestamps worked like a charm. I parsed it in javascript and used it to show when the last message was sent from each individual user, so I thought that was really neat <?php session_start(); /* Checking User */ if(!isset($_SESSION['User_Name']) && !isset($_COOKIE["VanityUser"])) { exit(); } if(isset($_COOKIE["VanityUser"]) != '') $userId = $_COOKIE["VanityUser"]; else $userId = $_SESSION['User_Name']; $friendId = $_GET["friendId"]; /* Checking User */ ?> <?php require_once("DATABASE"); /* Set Usernames */ if(!isset($_SESSION['names'][$userId]) || !isset($_SESSION['names'][$friendId])) { $query = "SELECT User_Id, Username FROM User_Info WHERE User_Id IN ('{$userId}', {$friendId})"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) $_SESSION['names'][$row['User_Id']] = $row['Username']; } /* Set Usernames */ /* Access Stamps */ if(!isset($_GET['laststamp'])) $last_Access="0000000000"; else $last_Access=$_GET['laststamp']; /* /Access Stamps */ /* Recieve Conversation Once Upon Open */ if($_GET["load"] != '') { $result = mysql_query("SELECT Rank, Sender, Reciever, Instant_Message FROM Instant_Messenger WHERE Sender IN ('{$userId}', {$friendId}) AND Reciever IN ('{$userId}', {$friendId}) ORDER BY Created_Date"); while($row = mysql_fetch_array($result)) { $sender_name = $_SESSION['names'][$row['Sender']]; echo "{$row['Rank']} {$sender_name}: {$row['Instant_Message']} <br>\n"; } } else { /* /Recieve Conversation Once Upon Open */ /* Check If New Message Exists And Sends */ $result = mysql_query("SELECT * FROM Instant_Messenger WHERE Sender IN ('{$userId}', {$friendId}) AND Reciever IN ('{$userId}', {$friendId}) AND Created_Date > $last_Access ORDER BY Created_Date"); while($row = mysql_fetch_array($result)) { $sender_name = $_SESSION['names'][$row['Sender']]; echo "{$row['Rank']} {$sender_name}: {$row['Instant_Message']} <br>\n"; $last_Access=$row['Created_Date']; } } /* /Check If New Message Exists */ /* Echo Time Stamp Hidden */ echo "<span style='display:none;'>$last_Access</span>"; /* /Echo Time Stamp Hidden */ ?>
  14. That other code didn't work quite right and it won't let me edit it, Sorry if you guys already read through it... This code right here is what I have and it works. Again, I am just worried with this repeating every 1000ms it could be too many requests for the server. <?php session_start(); /* Checking User */ if(!isset($_SESSION['User_Name']) && !isset($_COOKIE["VanityUser"])) { header('Location: BLANK'); } if(isset($_COOKIE["VanityUser"]) != '') $User = $_COOKIE["VanityUser"]; else $User = $_SESSION['User_Name']; /* Checking User */ ?> <?php require_once("DATABASE"); /* Gets User && Friend Id# */ $userIdresult = mysql_query("SELECT User_Id FROM User_Info where Username ='".$User."'"); while($row = mysql_fetch_array($userIdresult)) { $userId = $row['User_Id']; } $friendIdresult = mysql_query("SELECT User_Id FROM User_Info where Username ='".$_GET["Friend"]."'"); while($row = mysql_fetch_array($friendIdresult)) { $friendId = $row['User_Id']; } /* /Gets User && Friend Id# */ /* Recieve Conversation Once Upon Open */ if($_GET["load"] != '') { $result = mysql_query("SELECT * FROM Instant_Messenger WHERE Sender = '".$userId."' AND Reciever = '".$friendId."' OR (Sender = '".$friendId."' AND Reciever = '".$userId."') ORDER BY IM_Id"); while($row = mysql_fetch_array($result)) { if($row['Sender'] == $userId) echo $row['Rank'] . $User . ": " . $row['Instant_Message'] . "<br>"; else echo $row['Rank'] . $_GET["Friend"] . ": " . $row['Instant_Message'] . "<br>"; } } /* /Recieve Conversation Once Upon Open */ /* Check If New Message Exists And Sends */ $query = "SELECT * FROM Instant_Messenger WHERE Sender = '".$userId."' AND Reciever = '".$friendId."' OR (Sender = '".$friendId."' AND Reciever = '".$userId."') AND (Sviewed = '0' OR Rviewed = '0') ORDER BY IM_Id"; $result = mysql_query($query) or die(mysql_error()); $New_Message = mysql_num_rows($result); if($New_Message != 0) { while($row = mysql_fetch_array($result)) { if($userId==$row['Sender'] && $row['Sviewed'] == 0) { echo $row['Rank'] . $User . ": " . $row['Instant_Message'] . "<br>"; mysql_query("UPDATE Instant_Messenger SET Sviewed = -1 WHERE IM_Id = '".$row['IM_Id']."'"); //Updates Sender to viewed by Id } else if($userId==$row['Reciever'] && $row['Rviewed'] == 0) { echo $row['Rank'] . $_GET["Friend"] . ": " . $row['Instant_Message'] . "<br>"; mysql_query("UPDATE Instant_Messenger SET Rviewed = -1 WHERE IM_Id = '".$row['IM_Id']."'"); //Updates Reciever to viewed by Id } } } /* /Check If New Message Exists And Sends */ ?>
  15. Hey, I got the requests and everything set up, Javascript side works fine and only sends a request every 1 second if a request is not already sent. However I'm curious on some opinions as far as the php request goes. Every one second this Php script will be reloaded. I'm hoping it isn't too many requests to where it'll be hard on the server. If so any opinions on what I can do? <?php session_start(); /* Checking User */ if(!isset($_SESSION['User_Name']) && !isset($_COOKIE["VanityUser"])) { header('Location: INTENTIONALLY BLANK'); } if(isset($_COOKIE["VanityUser"]) != '') $User = $_COOKIE["VanityUser"]; else $User = $_SESSION['User_Name']; /* Checking User */ ?> <?php require_once("DATABASE"); /* Gets User && Friend Id# */ $userIdresult = mysql_query("SELECT User_Id FROM User_Info where Username ='".$User."'"); while($row = mysql_fetch_array($userIdresult)) { $userId = $row['User_Id']; } $friend = $_GET["Friend"]; /* /Gets User && Friend Id# */ /* Recieve Conversation Once Upon Open */ if($_GET["load"] != '') { $result = mysql_query("SELECT * FROM Instant_Messenger WHERE Sender = '".$userId."' AND Reciever = '".$friend."' OR (Sender = '".$friend."' AND Reciever = '".$userId."') ORDER BY IM_Id"); while($row = mysql_fetch_array($result)) { echo $row['Rank'] . $row['Sender'] . ": " . $row['Instant_Message'] . "<br>"; } } else { /* /Recieve Conversation Once Upon Open */ /* Recieve And Expire All New Messages */ $result = mysql_query("SELECT * FROM Instant_Messenger WHERE Sender = '".$userId."' AND Reciever = '".$friend."' OR (Sender = '".$friend."' AND Reciever = '".$userId."') AND (Sviewed = '0' OR Rviewed = '0') ORDER BY IM_Id"); while($row = mysql_fetch_array($result)) { if($userId==$row['Sender'] && $row['Sviewed'] == 0) { echo $row['Rank'] . $row['Sender'] . ": " . $row['Instant_Message'] . "<br>"; mysql_query("UPDATE Instant_Messenger SET Sviewed = -1 WHERE IM_Id = '".$row['IM_Id']."'"); //Updates Sender to viewed by Id } if($userId==$row['Reciever'] && $row['Rviewed'] == 0) { echo $row['Rank'] . $row['Sender'] . ": " . $row['Instant_Message'] . "<br>"; mysql_query("UPDATE Instant_Messenger SET Rviewed = -1 WHERE IM_Id = '".$row['IM_Id']."'"); //Updates Reciever to viewed by Id } } } /* Recieve And Expire All New Messages */ ?>
  16. Ok I'll see what I can come up with and post back afterwords, Thank you for your advice :]
  17. Ok that makes sense thanks for the tip. for javascript sending the request im using setinterval(ajax,300) that sound fine? I wasn't sure if a continuously running script like that to check for updated messages would be ok running continuously? ik this is php so if you're not sure np. I'm jw, I'm fairly new to coding I spend a lot of time reading on my own to figure out things as Ideas come to my mind. As far as this I just could not stand using a some one elses been trying to use my own stuff
×
×
  • 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.