Reputation Activity
-
Barth got a reaction from auxio in Quiz Game - Javascript, jQueryJSON 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.
-
Barth reacted to Fran Haselden in Payment by Debit CardNope. You will get taken to a screen where you specify if you want to pay via your PayPal account, or just credit/debit.
I used simplecart.js on my site, as I was not happy with the very generic styling of the PayPal cart. It was really easy to implement and meant I had more control over how the cart displayed. I created my own Add to Basket buttons, basket viewer (slide-out from the side) and my own checkout page.
Took about 5 minutes to get the basic simplecart.js functionality working, then it was just a case of styling it and working with my own jQuery to refine the customer journey.
Example:
-
Barth reacted to Skateside in Mastering JavascriptDownvote! Dislike!
... we need a button for that ...
Pure Javascript is far more versatile than jQuery, jQuery is pretty limited to the browser whereas Javascript is appearing in browsers, serves, TVs, mobile phones, Windows 8 ... there's no reason to limit yourself to a browser-based library like that.
Back to the question at hand, there are a few good books I can recommend (all with handy links to Amazon). Each of them generally keep away from code examples using libraries and their advice can be used on any platform.
Javascript: The Good Parts by Douglas Crockford - this is a must read generally. Crockford defines a sub-set of Javascript that stays away from the language's more esoteric or confusing elements. Having read this book (and cyber-stalked Doug through YUI theatre), I found my code less confusing to other people (including myself) and better laid out. I can read old code much better now than I could in years gone by.
Pro Javascript Design Patterns by Ross Harmes and Dustin Diaz - this was the book that got me thinking along object oriented lines and finally understanding that programming concept. The book goes through classic programing patterns and just knowing about those helped me code in a more logical way, opening up inheritance to me for the first time.
Maintainable Javascript by Nicholas C Zakas - I'm only part way through this book and already it's helped me make my code more maintainable. This has the advantage of making more sense in the future as well as maintaining large applications. This book also has some great advice about coding Javascript in a team.
I hope that helps
-
Barth reacted to Renaissance-Design in 960 Grid LayoutThe best introduction to grid theory.
The best resource for responsive design.
-
Barth reacted to dap in New, self-taught & confused website ownermaybe something more like this (pretty much based around your colours and those from my lavender pic in the header and Georgia instead of times
-
Barth got a reaction from adamsmith in large text boxesNormal CSS should do it
resize:none;
-
Barth got a reaction from kingy da killa in help with regexJust 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>
-
Barth got a reaction from factor10 in help please: jquery slideshow and a shadow under a divHere is the simple quick solution for your shadow without changing a whole load of code; set it as the background image and position it at the bottom
.textbox { width:387px; height:auto; background:url('shadow.gif') no-repeat bottom #CCCCFF; margin:10px; padding:20px 20px 67px 20px; position:static; }
Notice how I added an extra 47px of padding-bottom to make up for the image height
-
Barth got a reaction from Alluziion in JS Screen Resolution Redirection ProblemTry
if (screen.width == 1920 && screen.height == 1080) { window.location="Wallpapers_1920x1080.php"; } else if (screen.width == 1600 && screen.height == 900) { window.location="Wallpapers_1600x900.php"; }
-
Barth got a reaction from person4659 in IE 8 and VistaThis is a good explanation about the different types of positioning and how they differ http://css-tricks.com/1191-absolute-relative-fixed-positioining-how-do-they-differ/
And a guide on good use of floats http://css-tricks.com/795-all-about-floats/
-
Barth got a reaction from PhunkRabbit in How to send HTML emails with multiple attachments in PHPAs the current guides on the web seem to overcomplicate how to do this, I thought I’d try to make a simpler guide, using a single function in php. Please note that this script doesn't include any validation, all this does is send the email.
This is an example of how to use the function
Starting off with the basic details, pretty much self-explanatory
$RecipientEmail = "joebloggs@example.com"; $RecipientName = "Joe Bloggs"; $SenderEmail = "fredbloggs@example.com"; $SenderName = "Fred Bloggs"; $subject = "lorem ipsum";
You can specify multiple emails with cc and bcc, the emails must be separated with commas
$cc = "alice@example.com, bob@example.com"; $bcc = "johndoe@example.com";
Set the type as blank for the message to be HTML (recommended), or set it as plain for plain text
// For HTML $type = ""; // For plain text $type = "plain";
Your message can contain UTF-8 characters, so this will allow you to send emails in multiple languages
(Just using "lorem ipsum" in this example)
$message = "<b>Sed urna odio, imperdiet a semper ut, fermentum ut tellus.</b> Quisque tempor venenatis quam, ut porttitor lacus pretium sit amet.";
In addition you can change the priority of the email
// For normal leave it blank $priority = ""; // For high use "high" $priority = "high"; // For low use "low" $priority = "low";
The attachments
Attachments are specified in an array, in the format location:type:name
The reason for having both location and name in the attachments is simple. It is better to have the name mountains.jpg instead of IMG_0001.JPG appear when the recipient opens the email.
Colons have to be used to separate each section, and the location cannot be external (i.e. another website)
You can do it like this
$attachments = array("attachments/01.jpg:image/jpeg:one.jpg", "attachments/01.jpg:image/jpeg:two.jpg", "attachments/03.jpg:image/jpeg:three.jpg");
Or like this (Both work exactly the same)
$attachments[0] = "attachments/01.jpg:image/jpeg:one.jpg"; $attachments[1] = "attachments/02.jpg:image/jpeg:two.jpg"; $attachments[2] = "attachments/03.jpg:image/jpeg:three.jpg"; // And so on...
If you don't need attachments, just leave it blank
$attachments = "";
Introducing the function
Here is a clear layout, just showing the variables from above being passed into the function
$sent = Email($RecipientEmail, $RecipientName, $SenderEmail, $SenderName, $cc, $bcc, $subject, $message, $attachments, $priority, $type); echo $sent ? "It worked!!" : "It didn't work"; // ^ This is used to test if it worked
The full function
I’ve put it into a block of full code so it’s easier to copy, I’ve included comments to try and explain how it works. I recommend that you put this somewhere separate and name it something like “email.function.php”, and include it in your main code.
e.g.
include('email.function.php');
Without further ado the full function…
// This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License function Email($remail, $rname, $semail, $sname, $cc, $bcc, $subject, $message, $attachments, $priority, $type) { // Checks if carbon copy & blind carbon copy exist if($cc != null){$cc="CC: ".$cc."\r\n";}else{$cc="";} if($bcc != null){$bcc="BCC: ".$bcc."\r\n";}else{$bcc="";} // Checks the importance of the email if($priority == "high"){$priority = "X-Priority: 1\r\nX-MSMail-Priority: High\r\nImportance: High\r\n";} elseif($priority == "low"){$priority = "X-Priority: 3\r\nX-MSMail-Priority: Low\r\nImportance: Low\r\n";} else{$priority = "";} // Checks if it is plain text or HTML if($type == "plain"){$type="text/plain";}else{$type="text/html";} // The boundary is set up to separate the segments of the MIME email $boundary = md5(@date("Y-m-d-g:ia")); // The header includes most of the message details, such as from, cc, bcc, priority etc. $header = "From: ".$sname." <".$semail.">\r\nMIME-Version: 1.0\r\nX-Mailer: PHP\r\nReply-To: ".$sname." <".$semail.">\r\nReturn-Path: ".$sname." <".$semail.">\r\n".$cc.$bcc.$priority."Content-Type: multipart/mixed; boundary = ".$boundary."\r\n\r\n"; // The full message takes the message and turns it into base 64, this basically makes it readable at the recipients end $fullmessage .= "--".$boundary."\r\nContent-Type: ".$type."; charset=UTF-8\r\nContent-Transfer-Encoding: base64\r\n\r\n".chunk_split(base64_encode($message)); // A loop is set up for the attachments to be included. if($attachments != null) { foreach ($attachments as $attachment) { $attachment = explode(":", $attachment); $fullmessage .= "--".$boundary."\r\nContent-Type: ".$attachment[1]."; name=\"".$attachment[2]."\"\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment\r\n\r\n".chunk_split(base64_encode(file_get_contents($attachment[0]))); } } // And finally the end boundary to set the end of the message $fullmessage .= "--".$boundary."--"; return mail($rname."<".$remail.">", $subject, $fullmessage, $header); }
Thanks, if I’ve missed out anything please let me know, and I hope that this helps