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 createRequest() { | |
| var result = null; | |
| if (window.XMLHttpRequest) { | |
| // FireFox, Safari, etc. | |
| result = new XMLHttpRequest(); | |
| if (typeof xmlhttp.overrideMimeType != 'undefined') { | |
| result.overrideMimeType('text/xml'); // Or anything else | |
| } | |
| } | |
| else if (window.ActiveXObject) { |
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
| $.each(messages.reverse(), function(index, message) { | |
| $('#messageList').append( | |
| '<li><span class="list-title">' + | |
| message.userName + '</span>' + | |
| '<abbr class="list-timestamp" title="' + | |
| message.datePosted + '"></abbr>' + | |
| '<p class="list-text">' + message.messageText + '</p></li>'); | |
| } | |
| }); |
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
| window.onload = function() { | |
| var url = "http://example.org/address_from_postcode.txt?postcode="; | |
| var fieldsets = document.getElementsByTagName("fieldset"); | |
| for (var foo in fieldsets) { | |
| if (fieldsets[foo].className == "address") { | |
| var textareas = fieldsets[foo].getElementsByTagName("textarea"); | |
| for (var bar in textareas) { | |
| if (textareas[bar].className == "address") { | |
| fieldsets[foo].address = textareas[bar]; | |
| break; |
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 data-ng-app="form-example" class="row form-horizontal" novalidate> | |
| <div class="control-group"> | |
| <label class="control-label" for="inputEmail">Email</label> | |
| <div class="controls"> | |
| <input type="email" id="inputEmail" placeholder="Email" data-ng-model="email" required> | |
| <div class="input-help"> | |
| <h4>Invalid Email</h4> | |
| </div> | |
| </div> | |
| </div> |
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
| <a href="#" title="blabla" data-poload="/test.php">blabla</a> | |
| $('*[data-poload]').bind('hover',function(){ | |
| var e=$(this); | |
| e.unbind('hover'); | |
| $.get(e.data('poload'),function(d){ | |
| e.popover({content: d}).popover('show'); | |
| }); | |
| }); |
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
| // Bad | |
| $("a").click(function(e) { | |
| $(this).addClass("active"); | |
| $(this).parent().siblings().find("a").removeClass("active"); | |
| var o = $(this).offset(); | |
| }); | |
| // Better | |
| $("a").click(function(e) { | |
| var $t = $(this), |
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
| unction Color(r, g, b) { | |
| this.r = r; | |
| this.g = g; | |
| this.b = b; | |
| } | |
| Color.prototype.getAverage = function () { | |
| var total = this.r + this.g + this.b; | |
| var avg = total / 3; | |
| return parseInt(avg, 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
| var LoggerFactory = { | |
| getLogger: function() { | |
| return window.console; | |
| }, | |
| //log | |
| }; | |
| /* Example Usage */ | |
| var logger = LoggerFactory.getLogger(); | |
| logger.log("something to log"); |
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 obj = { | |
| a: undefined, | |
| b: null, | |
| c: false | |
| }; | |
| // a, b, c all found | |
| for ( var prop in obj ) { | |
| document.writeln( "Object1: " + prop ); | |
| } |