This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var invalid_fields = 0; //global var can be accessed without calling function | |
| function validate() | |
| { | |
| invalid_fields = 0; // reset counter | |
| $("[required]").each(function(){ | |
| var val = $(this).val(); | |
| if(val == "" || val == null || val.match('/select/i')) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function time_ago($pastTime) | |
| { | |
| $datetime1=new DateTime("now"); | |
| $datetime2=date_create($pastTime); | |
| $diff=date_diff($datetime1, $datetime2); | |
| $timemsg=''; | |
| if($diff->y > 0){ | |
| $timemsg = $diff->y .' year'. ($diff->y > 1?"'s":''); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript: void((function(d) { | |
| var modalblock = document.getElementById("reg-overlay"); | |
| modalblock.parentElement.removeChild(modalblock); | |
| var style = document.createElement('style'); | |
| style.type = 'text/css'; | |
| style.innerHTML = 'body,html { overflow: auto !important; }'; | |
| d.getElementsByTagName("head")[0].appendChild(style); | |
| })(document)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * display a styled jQuery UI dialog box in place of the native javascript alert() | |
| * | |
| * message string HTML message to display | |
| * title string optional title text to display in header of confirmation box | |
| * callback function optional function to trigger when user clicks "OK" | |
| * | |
| */ | |
| function uiAlert(settings) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $url = "https://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=" . urlencode($_GET['addr']); | |
| $ch = curl_init(); | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $raw_xml = curl_exec($ch); | |
| curl_close($ch); | |
| $xml = new SimpleXMLElement($raw_xml); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <input type="text" placeholder="sample text"> | |
| <script> | |
| function hasPlaceholder() | |
| { | |
| var psuedoInput = document.createElement("input"); | |
| return "placeholder" in psuedoInput | |
| } | |
| $(document).ready(function(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div> | |
| <textarea id="myTextarea" class="lengthcount" maxlength="150"></textarea> | |
| </div> | |
| <div> | |
| <input type="text" id="myInput" class="lengthcount" maxlength="40"> | |
| </div> | |
| <script type="text/javascript"> | |
| function charCount(element) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Return a formated string from a date Object mimicking PHP's date() functionality | |
| * | |
| * format string "Y-m-d H:i:s" or similar PHP-style date format string | |
| * date mixed Date Object, Datestring, or milliseconds | |
| * | |
| */ | |
| function dateFormat(format,date){ | |
| if(!date || date === "") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| /** | |
| * Show the time and update it every second | |
| * | |
| * clock_id (string) DOM id value of element to update | |
| * offset (int) Optional value to modify local time by, usefull if synchronizing to another clock | |
| */ | |
| function clock(clock_id, offset) | |
| { | |
| if(offset == null || offset == ""){ offset = 0; } |