Everything posted by Barth
-
[Javascript]What's the difference?
setInterval requires a delay as it's second parameter, without it the code may not run properly in some browsers.
-
Need help with opening a GZ file
When serving the file set the header for 'Content-Encoding' to 'gzip'
-
Problem regarding the speed of the website
Quick tip: Get YSlow for your browser, it will really help you quickly identify your problems http://yslow.org/
-
Quiz Game - Javascript, jQuery
JSON maybe a smoother way to store the questions compared to XML when using javascript. Using an object to store the results for the questions should be straight forward (same format as JSON). This will also allow you to easily use web storage with little hassle if it’s ever needed (e.g. Save their progress if they leave the page) Overall your plan sounds fine to me.
-
Can a loop be outputted from inner html?
Bit of a late reply, but a something like this would do the job (not tested): function action() { var films = document.getElementById('films'); for(var a = 0, aLen = movie.length; a < aLen; a++) { films.innerHTML+= movie[a]; } }
-
Scroll Script Problem
You have a 404 error for the images, so you may have just uploaded them to the wrong directory? Also "section one" appears to be used as a class and not an id on the page, so maybe try using getElementsByClassName('section one')[0] on line 12.
-
Website Viewing
I don't really know what you're trying to ask. I'm guessing maybe something wrong with your css? You say it shows ok most of the time, so try adding a css reset to the head of the document. http://meyerweb.com/eric/tools/css/reset/ It's a long shot but theres nothing to really go off here.
-
Speed reading application
I'm working on an interactive tutorial to make what to do clearer. But in the meantime as an example: - Find a large amount of text, maybe something from Wikipedia that’s a lot to read, copy and paste that into the textbox, press render. You can now choose between two different views, follow and flash. Follow is similar to conventional reading, while flash flashes just the word(s) to read. It will go to follow by default after pressing render (you can change the view in the bottom left corner) Options are found in the bottom right; these allow you to change things like the text size and speed (words per minute) and options specific to each view. All options can be changed on the fly. Play around with them. Autosave stores your current state in localStorage, includes the text you have entered, pointer position and options. This is orange when it is on (will probably add on/off to text description soon). The media buttons work like they would on any other media player. The progress bar can be dragged / clicked on to seek the word at that position. Also in Follow view you can click on a word to immediately seek to that position. Hope this helped
-
Speed reading application
Hey all, I’m looking for some feedback for my speed reading web app http://www.momentumreader.com/. It is an early version, but the application itself works fine on most desktop browsers. I’m still working on a mobile UI and better splash screen. Keyboard controls are implemented; they are - / + for speed, Enter to toggle play / pause, and left / right arrows to skip. These are not mentioned on the splash screen yet. Let me know if you come across anything that is unclear, any bugs etc. any recommendations will be appreciated. Thanks
-
Payment by Debit Card
Paypal do offer non users an option to pay through credit/debit cards through website payments standard. It is also relatively easy to implement through an instant payment notification (IPN) Links: https://www.paypal.com/webapps/mpp/paypal-payments-standard http://net.tutsplus.com/tutorials/php/using-paypals-instant-payment-notification-with-php/ (maybe outdated)
-
PHP MySQL real time chat application without JavaScript
I can’t disagree with you; your comment explains why it shouldn’t be used a lot better than my original explanation. I’d just like to say that this was only made as just a bit of fun after being told that real time applications on the web are impossible without Javascript or plugins. And yes, node.js + socket.io = amazing, would definitely recommend if anyone is looking at taking real time applications seriously. Also, before anyone asks me why I didn’t use MySQLi or PDO, it was purely because MySQL was slightly faster at fetching the data from the database in my case, I should have mentioned this in the OP
- 8 replies
-
- php
- mysql
- javascript
- chat
-
Tagged with:
-
PHP MySQL real time chat application without JavaScript
@webdesigner93, i really just mean for people to take the relevant parts from it. Looking at the code now i can see it's a mess and its lost most of it's formatting for some reason when i posted it. Here is an attachment of the original file with the formatting intact so it's a bit easier to read noscriptchat.php
- 8 replies
-
- php
- mysql
- javascript
- chat
-
Tagged with:
-
PHP MySQL real time chat application without JavaScript
This was originally a small side project I made a while ago, purely just to show that chat applications can be made without Javascript or any other components such as Java or Flash. It’s not being used, so it will be good to share it on here. Screenshot: Things to note: This works by http streaming the chat through an iframe. This will stop working if the user choses to stop loading the page. This has only been tested locally on XAMPP. This script may be a bit buggy, as it hasn’t been rigorously tested. Uses the minimum amount of validation required for it to work. The naming of the php file does not matter. The chat frame will not automatically scroll. I recommend that you don’t use this on your website, as there are better ways to do real time chat. Only use this as guidance/reference/help if you chose to make a real time PHP application. Have fun trying this out, this will work out the box; all you need to do is change the database details at the top of the page, and make sure your http server and MySQL are running. <?php // Real time chat application without the use of Javascript // CC http://creativecommons.org/licenses/by-sa/3.0/ by Barth class noscript_chat { // Change these values to match your MySQL database details. const noscript_host = "localhost"; const noscript_username = "root"; const noscript_password = "password"; // If the details are correct it will install the database and table. // No need to edit below this line. // Sorry for lack of comments in some parts const noscript_database = "noscript"; const noscript_table = "chat"; public $name; public $message; public function noscript_connect() { return mysql_connect(self::noscript_host,self::noscript_username,self::noscript_password); } public function noscript_select() { return mysql_select_db(self::noscript_database,$this->noscript_connect()); } // Gets the latest message position ($number) private function start_position() { $pointer = mysql_fetch_array(mysql_query("SELECT `number` FROM `".self::noscript_table."` ORDER BY `number` DESC LIMIT 0,1;")); return $pointer["number"]; } // Uses the latest known message position ($number) and checks if there are any newer messages, // if so it echos them, and returns the latest message position. private function get_chat($number) { $latest = @mysql_query("SELECT `number`,`name`,`message` FROM `".self::noscript_table."` WHERE `number` > ".$number.";"); while($stream = @mysql_fetch_array($latest)) { echo "<div style='float:left;width:270px;'>".$stream["name"].": ".htmlspecialchars($stream["message"],ENT_QUOTES)."<br /><br /></div>"; $number = $stream["number"]; } return $number; } public function stream_chat() { @apache_setenv('no-gzip', 1); @ini_set('zlib.output_compression', 0); @ini_set('implicit_flush', 1); for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); } ob_implicit_flush(1); $number = $this->start_position(); // Infinite loop while(1) { // Get the latest messages and update the position $number = $this->get_chat($number); // Flush (send) the messages to the browser flush(); // Wait 0.25 seconds usleep(250000); } } // Insert a message into the table public function insert_message() { return mysql_query("INSERT INTO `".self::noscript_table."` (`name`,`message`) VALUES ('".mysql_escape_string($this->name)."','".mysql_escape_string($this->message)."');"); } // Used for installing the database and table if they don't exist private function create_database() { return mysql_query("CREATE DATABASE IF NOT EXISTS `".self::noscript_database."` ;"); } private function create_table() { return mysql_query("CREATE TABLE IF NOT EXISTS `".self::noscript_table."` (`number` int(4) NOT NULL AUTO_INCREMENT, `name` varchar(12) NOT NULL, `message` varchar(200) NOT NULL, PRIMARY KEY (`number`) ) ENGINE=MyISAM DEFAULT CHARSET=ascii AUTO_INCREMENT=1 ;"); } public function install_noscript() { $this->create_database(); $this->noscript_select(); $this->create_table(); } } // Start of page header("Content-type: text/html; charset=ASCII"); $request = @$_GET["request"]; $name = @$_POST["name"]; $noscript = new noscript_chat; if($request) { $noscript->noscript_select(); if($request=="stream") { set_time_limit(0); // Blank div for browsers that require 2k bytes for flush to work (Internet explorer and older versions of Chrome). echo "<div style='visibility:hidden;'>".str_repeat(" ", 2010)."</div>"; $noscript->stream_chat(); } elseif($request=="messenger") { @session_start(); if(@$_POST["message"]!=null) { $noscript->name = $_SESSION["noscript_name"]; $noscript->message = $_POST["message"]; $noscript->insert_message(); } echo "<form action='' method='post'>".$_SESSION["noscript_name"].": <input type='text' name='message' maxlength='200' /><input type='submit' value='Send'></form>"; } } elseif($name) { @session_start(); $_SESSION["noscript_name"] = $name; echo "<div style='margin:auto;width:300px;height:500px;'><iframe src='?request=stream' frameborder='0' scrolling='yes' style='float:left;width:300px;height:450px;'> </iframe><iframe src='?request=messenger' frameborder='0' scrolling='no' style='float:left;width:300px;height:50px;'></iframe></div>"; } else { $noscript->noscript_connect(); $noscript->install_noscript(); echo "<form action='' method='post'>Username: <input type='text' name='name' maxlength='15' /><input type='submit' value='Join'></form>"; } ?>
- 8 replies
-
- php
- mysql
- javascript
- chat
-
Tagged with:
-
Small payments UK
Paypal's mass payment might be a good solution https://www.paypal.c...verview-outside Edit: Sorry only quickly read post, ignore what i just posted. There might be something in the paypal api that allows you to do what you asked.
-
Hello! I'm new here :)
I would say that there's nothing wrong with the designs on both websites, they look a lot better than most of the websites posted on here for review. I think you just need to refine the sites a bit more; for example the second one is not very friendly on a screen with a low resolution (1024 x 768), leading to sideways scrolling just to centre the site and some parts of the text being out of place
-
setTImeout function not working in firefox
Something simple like this may solve your problem setTimeout(function(){init();}, 2000);
-
Please rewiew my new design
Well I can't see anything wrong with it. Just like your previous designs it's really well done, good job
-
large text boxes
Normal CSS should do it resize:none;
-
help with regex
if(!empty($variable)) In human (Is the variable not empty?) It is basically checking if the variable contains something It can also be done in different ways, such as these if($variable!= null) if($variable!= "") Hope this helps
-
help with regex
Just use an IF statement to check if $email has a value. On a side note I changed the regex to make it more effective validating an email, making sure that it is invalid when no domain is entered, e.g. it will now be invalid when they enter an email like "example@example" unlike before <?php $email = $_POST['email']; $regex = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"; if(!empty($email)) { if (eregi($regex, $email)) { echo $email . " is a valid email."; } else { echo $email . " is an invalid email."; } } ?> <form action="try.php" method="post" /> Email<input type="text" name="email"> <input type="submit" name="submit" /> </form>
-
Need help with my contactform...
If it's that line on your original code, it's because you are using ' " ' inside your error, when you are using the same thing to define its contents Change $errors[] = " value="Only numbers please!"; To something like $errors[] = "Only numbers please!"; If it's not that you've probably missed out the semicolon at the end, or you're missing a '{' or '}' somewhere
-
Need help with my contactform...
Looking back at the code, it does look messy and there are better ways of doing it, but they would require a lot more modification to the code, this is just a quick short term solution I made in a short amount of time. This is how it would be implemented into your code – <?php if(isset($_POST['name']) && isset($_POST['phone']) && isset($_POST['email']) && isset($_POST['message'])){ $errors = array(); $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $message = $_POST['message']; if(empty($name)){ $errors[] = "Ad your name!"; } if(empty($phone)){ $errors[] = "Fill your number!"; } if(!is_numeric($phone)){ $errors[] = "Only numbers please!"; } if(empty($email)){ $errors[] = "Fill a valid Email"; } if(empty($message)){ $errors[] = "Please type a message!"; } if(!empty($errors)) { // JavaScript popup echo "<script type=\"text/javascript\">alert('"; foreach($errors as $error){ echo $error."\\n"; } echo "');</script>"; // NoScript echo "<noscript>"; foreach($errors as $error){ echo $error, "<br />"; } echo "</noscript>"; } } else{ ini_set("SMTP", "smtp.trondan.se"); $to = "trondan@live.se"; $subject = "From trondan"; $headers = "From: ".$email; $body = "Email From:$name -- Number: $phone -- Email: $email -- Message: $message"; mail($to, $subject, $body, $headers); echo "Message sent!"; } } ?> <html> <head> <link href="http://trondan.se/erik/form.css" media="all" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function restoreValue(obj){ if(obj.value == ""){ obj.value = obj.defaultValue; } } function clearValue(obj){ if(obj.value == obj.defaultValue){ obj.value = ""; } } </script> </head> <body> <form action="" method="POST"> <font style="font-size:13px" color="#C0C0C0" face="Arial"> <input type="text" name="name" onfocus="clearValue(this);" onblur="restoreValue(this);" style="position:absolute;left:79px;top:15px;width:351px;color:#C0C0C0;font-family:Arial;font-size:13px;z-index:2" name="Name" value="Name"> <input type="email" name="email" onfocus="clearValue(this);" onblur="restoreValue(this);"style="position:absolute;left:79px;top:59px;width:351px;color:#C0C0C0;font-family:Arial;font-size:13px;z-index:4" name="email" value="Email"> <input type="text" name="phone" onfocus="clearValue(this);" onblur="restoreValue(this);" style="position:absolute;left:79px;top:103px;width:351px;color:#C0C0C0;font-family:Arial;font-size:13px;z-index:7" name="phone" value="Phone"> <textarea name="message" id="Text" onfocus="clearValue(this);" onblur="restoreValue(this);" style="position:absolute;left:80px;top:147px;width:350px;height:270px;color:#C0C0C0;font-family:Arial;font-size:13px;z-index:6" rows="13" cols="31">Message</textarea> <input id="submit" type="submit" value="Contact me" style="position:absolute;left:310px;top:425px;width:120px;height:40px;z-index:23"> </font> </form> </body> </html>
-
Need help with my contactform...
To put your errors into a pop up you would need to use if(!empty($errors)) { // JavaScript popup echo "<script type=\"text/javascript\">alert("; foreach($errors as $error){ echo "'".$error."' + '\\n' + "; } echo "'');</script>"; // NoScript, in case javascript is disabled echo "<noscript>"; foreach($errors as $error){ echo $error, "<br />"; } echo "</noscript>"; }
-
Need help with my contactform...
Javascript alert should do it http://www.w3schools.com/js/js_popup.asp Use something like: echo "<script type=\"text/javascript\">alert('You can only use numbers');</script>";
-
PHP Send Email not working properly
nice to know that you got it sorted out in the end lol