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
| function clearForm(form) { | |
| // iterate over all of the inputs for the form | |
| // element that was passed in | |
| $(':input', form).each(function() { | |
| var type = this.type; | |
| var tag = this.tagName.toLowerCase(); // normalize case | |
| // it's ok to reset the value attr of text inputs, | |
| // password inputs, and textareas | |
| if (type == 'text' || type == 'password' || tag == 'textarea') | |
| this.value = ""; |
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
| $('#username').keyup(function() { | |
| $('#submit').attr('disabled', !$('#username').val()); | |
| }); |
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
| $("form :input").focus(function() { | |
| $("label[for='" + this.id + "']").addClass("labelfocus"); | |
| }).blur(function() { | |
| $("label").removeClass("labelfocus"); | |
| }); |
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
| apikey = "YOUR GOOGLE API KEY GOES HERE" | |
| shorten_url = (url, success_callback, error_callback) -> | |
| xhr = Titanium.Network.createHTTPClient() | |
| xhr.open "POST", "https://www.googleapis.com/urlshortener/v1/url?key=" + apikey | |
| xhr.setRequestHeader "Content-type", "application/json" | |
| xhr.onload = () -> success_callback xhr.status, xhr.responseText | |
| xhr.onerror = () -> error_callback xhr.status, xhr.responseText | |
| content = "{\"longUrl\": \"#{url}\"}" |
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
| message = "This is a test string. This has a repeat or two. This might even have a third." | |
| message.indexOf "This", 0 | |
| # => 0 | |
| # Modifying the start parameter | |
| message.indexOf "This", 5 | |
| # => 23 | |
| message.lastIndexOf "This" | |
| # => 49 |
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
| i * 2 for i in [1..10] |
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
| [1..1000].reduce (t, s) -> t + 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
| $(document).ready -> | |
| # Basic Examples | |
| $.get '/', (data) -> | |
| $('body').append "Successfully got the page." | |
| $.post '/', | |
| userName: 'John Doe' | |
| favoriteFlavor: 'Mint' | |
| (data) -> $('body').append "Successfully posted to the page." |
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
| sudo killall -9 mysqld |
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
| // $.getScript() | |
| var scriptUrl = "ajax/script.php"; | |
| $("#getScript").click(function(){ | |
| $("#result").html(ajax_load); | |
| $.getScript(scriptUrl, function(){ | |
| $("#result").html(""); | |
| }); | |
| }); |