// jQuery
$(document).ready(function() {
// code
})
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
| $('#btn-animate').click(function() { | |
| // Shake the 'Codes' dropdown | |
| animEl = $('#dropdown-codes'); | |
| animEl.addClass('shake animated'); // ~add the anim. CSS class | |
| animEl.one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function (e) { | |
| animEl.removeClass('shake animated'); // ~remove it when finished | |
| }); | |
| }); |
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
| /* | |
| Found on StackOverflow: | |
| iPhone Safari Web App opens links in new window | |
| https://stackoverflow.com/questions/2898740/iphone-safari-web-app-opens-links-in-new-window | |
| I have problem with web after adding icon to Home Screen. If the web is launched from Home Screen, all links will open in new window in Safari (and lose full screen functionality). How can I prevent it? I couldn't find any help, only the same unanswered question. | |
| ANSWER: |
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
| // Changes XML to JSON | |
| function xmlToJson(xml) { | |
| // Create the return object | |
| var obj = {}; | |
| if (xml.nodeType == 1) { // element | |
| // do attributes | |
| if (xml.attributes.length > 0) { | |
| obj["@attributes"] = {}; |
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 toJSON(node) { | |
| node = node || this; | |
| var obj = { | |
| nodeType: node.nodeType | |
| }; | |
| if (node.tagName) { | |
| obj.tagName = node.tagName.toLowerCase(); | |
| } else | |
| if (node.nodeName) { | |
| obj.nodeName = node.nodeName; |
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 elementToObject(element, o) { | |
| var el = $(element); | |
| var o = { | |
| tagName: el.tagName | |
| }; | |
| var i = 0; | |
| for (i ; i < el.attributes.length; i++) { | |
| o[el.attributes[i].name] = el.attributes[i].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
| // Method used in Google Analytics: | |
| (function(d, script) { | |
| script = d.createElement('script'); | |
| script.type = 'text/javascript'; | |
| script.async = true; | |
| script.onload = function(){ | |
| // remote script has loaded | |
| }; | |
| script.src = 'http://www.google-analytics.com/ga.js'; |
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 | |
| /** | |
| * Output debug message to browser console | |
| */ | |
| function debug_to_console($data) { | |
| if(is_array($data) || is_object($data)) | |
| { | |
| echo("<script>console.log('PHP: ".json_encode($data)."');</script>"); | |
| } else { | |
| echo("<script>console.log('PHP: ".$data."');</script>"); |
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 winston = require('winston'); | |
| winston.add( | |
| winston.transports.File, { | |
| filename: 'node-log-file.json.log', | |
| level: 'info', | |
| json: true, | |
| eol: '\n', // for Windows, or `eol: '\n',` for *NIX OSs | |
| timestamp: true | |
| } | |
| ); |
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: javascript: (function() { | |
| var s = 'https://nytimes.github.io/svg-crowbar/svg-crowbar.js'; | |
| var e = document.createElement('script'); | |
| e.setAttribute('src', s); | |
| e.setAttribute('class', 'svg-crowbar'); | |
| document.body.appendChild(e); | |
| })(); |