This file contains 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 addCssToDocument(css) { | |
var styleElement = document.createElement('style'); | |
document.getElementsByTagName('head')[0].appendChild(styleElement); | |
var isIe = styleElement.styleSheet; | |
if (isIe) | |
styleElement.styleSheet.cssText = css; | |
else | |
styleElement.appendChild(document.createTextNode(css)); | |
} |
This file contains 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 PubSub on e.g. jQuery */ | |
PubSub.apply($); | |
function addText(text) { | |
$('body').append('<p>' + text + '</p>'); | |
} | |
function logChange(text) { | |
console.log('new text: ' + text); | |
} |
This file contains 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 calcAzimut = function (p1, p2) { | |
'use strict'; | |
var toDeg = function (x) { | |
return x * 180 / Math.PI; | |
}, | |
dy = p2.latitude - p1.latitude, | |
dx = p2.longitude - p1.longitude; | |
return ( | |
(dx > 0) ? toDeg((Math.PI * 0.5) - Math.atan(dy / dx)) : |
This file contains 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
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php | |
// good javascript | |
(function ($) { | |
'use strict'; | |
$(function () { | |
$('[placeholder]') | |
.focus(function () { | |
var input = $(this); | |
if (input.val() === input.attr('placeholder')) { |