Skip to content

Instantly share code, notes, and snippets.

View oliverm2112's full-sized avatar

Oliver Merk oliverm2112

View GitHub Profile
@oliverm2112
oliverm2112 / MyApp.js
Last active December 25, 2015 02:29
form test JS
app = angular.module('MyApp', []);
app.controller('MyCtrl', ['$scope', function ($scope) {
$scope.model = {
test : 'hello'
};
$scope.submitForm = function () {
alert('Dirty: ' + $scope.theForm.$dirty);
@oliverm2112
oliverm2112 / index.html
Last active December 25, 2015 02:29
Form tests
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body ng-app="MyApp" ng-controller="MyCtrl">
<form name="theForm" action="newpage.html" method="post">
<input type="text" ng-model="model.test"/>
</form>
@oliverm2112
oliverm2112 / ListCtrl_ETC.js
Last active December 16, 2015 20:49
Select list challenge
// cell-template.html
<div ng-cell-has-focus ng-dblclick="editCell()">
<div class="ngCellText">{{getRankName(model.crew[row.rowIndex].rankID)}}</div>
</div>
//cell-edit-template.html
<div>
<select
ng-model="model.crew[row.rowIndex].rankID"
ng-options="rank.rankID as rank.rankName for rank in model.ranks"
@oliverm2112
oliverm2112 / appSpec.js
Last active December 16, 2015 19:00
Test suite
'use strict';
describe('Unit: Testing app', function () {
var enterprise,
enterprise2,
deps,
hasModule = function (m) {
return deps.indexOf(m) >= 0;
};
@oliverm2112
oliverm2112 / karma.conf.js
Last active December 16, 2015 18:59
karma config
basePath = '';
files = [
JASMINE,
JASMINE_ADAPTER,
// 3rd-party
'../app/lib/angular-1.1.4.js',
'lib/angular-mocks.js',
@oliverm2112
oliverm2112 / DialogService.js
Last active December 16, 2015 10:48
DialogService.js
app.factory('dialog', ['$rootScope', '$dialog', function ($rootScope, $dialog) {
$rootScope.$on('alert', function (event, data) {
console.log('alert function:', event.name, data);
/** data should have:
- title, message and optionally, a callback
*/
@oliverm2112
oliverm2112 / app.js
Last active December 16, 2015 10:39
Needed for POSTs to ColdFusion
$httpProvider.defaults.transformRequest = function (data) {
if (data) {
return $.param(data);
}
};
@oliverm2112
oliverm2112 / gateway.cfm
Created April 19, 2013 16:56
CF gateway test
<cfheader name="Access-Control-Allow-Origin" value="*" />
<cfoutput>Content-Type: #GetHttpRequestData().headers['Content-Type']#</cfoutput>
<cfoutput>cgi.request_method=#cgi.request_method#</cfoutput>
<cfoutput>FORM: #serializeJSON(form)#</cfoutput>
<cfoutput>URL: #serializeJSON(url)#</cfoutput>
@oliverm2112
oliverm2112 / httpService.js
Last active December 16, 2015 10:28
Sample POST function
service.post = function (data) {
$http({
method : 'POST',
url : CFGATEWAY,
data : data
})
.success(function (data, status, headers, config) {
console.log('Post OK!!!', data);
$rootScope.$broadcast(name + '.success', data);
})
@oliverm2112
oliverm2112 / app.js
Last active December 16, 2015 10:28
POST fix!
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';