Sebastian Wallin wallin

View mobilecss.js
1 2 3 4 5 6 7 8
(function(d, l, c) {
while(c=l.pop()){
if(navigator.userAgent.match(new RegExp(c, 'i'))){
d[c]=!0;
d.documentElement.className+=' '+c;
}
}
}(document, ['iphone', 'mobile', 'android']));
View angular-inputFocus.coffee
1 2 3 4 5 6 7 8 9 10
angular.module('ui.inputFocus', []).directive "input", [->
restrict: "E"
require: '?^ngModel'
link: (scope, elm, attrs, ctrl) ->
return unless ctrl
ctrl.$focus = no
elm.focus ->
scope.$apply(-> ctrl.$focus = yes)
elm.blur ->
scope.$apply(-> ctrl.$focus = no)
View http_text_response.coffee
1 2 3 4 5 6 7 8 9 10
# If you have an API that returns JSON but want the reponse as raw text you
# can override Angulars built in JSON response parser by using an identity
# function as response transformer function
 
$http.get("/myapi",
{ transformResponse: (d, h) -> return d } # return raw response
)
.success((data, status, headers) ->
# data is now pure text
alert("Response is text: #{angular.isString(data)}")
View angular-configure-http.coffee
1 2 3 4 5 6 7 8
angular.module('myApp').config([
'$httpProvider'
($httpProvider) ->
# For all request types
$httpProvider.defaults.headers.common['Content-Type'] = 'application/json'
# For GET only
$httpProvider.defaults.headers.get['My-Header']='value'.
])
View ie-cors-fix.coffee
1 2 3 4 5 6 7 8 9 10
$.ajaxTransport((options, originalOptions, jqXHR) ->
if window.XDomainRequest
xdr = null
return {
send: (headers, completeCallback) ->
# Match protocol since XDR doesn't allow differences
if 'http:' is document.location.protocol
options.url = options.url.replace('https:', 'http:')
 
xdr = new XDomainRequest()
View .gitconfig
1 2 3 4 5 6 7 8 9 10
[color]
diff = auto
status = auto
branch = auto
[alias]
b = branch
ba = branch -a
ci = commit
co = checkout
d = diff
View multiple_touchdrag.html
1 2 3 4 5 6 7 8 9 10
<html>
<head>
<meta charset=utf-8 />
<title>Drag n' drop touch demo - sewa.se</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=0;" />
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<style type="text/css">
.draggable {
position: absolute;
left: 30px;
View jsmc_exercise2.html
1 2 3 4 5 6 7 8 9 10
<!-- 1. -->
<script type="text/javascript" charset="utf-8">
function log(string){
document.getElementById('log').innerHTML += (string + '<br/>');
}
 
document.getElementById('the_div').addEventListener(
'click', function(){ log('the_div!') }, true);
 
document.getElementById('the_list').addEventListener(
View jsmc2_excercise1.js
1 2 3 4 5 6 7 8 9
var Person = function (name) {
this.name = name;
}
 
Person.prototype.getName = function () {
return this.name;
}
 
// 1. Write a class to support the following code:
View jsmc_homework1.js
1 2 3 4 5 6 7 8 9
/////// Homework 1 ///////
 
var logCar = function (car) {
car = car || {};
car.make = car.make || 'anonymous car';
car.color = car.color || 'uncolored';
var a = /^[aeiouy]/.test(this.color) ? 'an' : 'a';
console.log('I\'m ' + a + ' ' + car.color + ' ' + car.make);
};
Something went wrong with that request. Please try again.