Skip to content

Instantly share code, notes, and snippets.

View mauritslamers's full-sized avatar

Maurits Lamers mauritslamers

  • Den Haag, Netherlands
View GitHub Profile
Arrayobservers = SC.Application.create({
NAMESPACE: 'Arrayobservers',
VERSION: '0.1.0',
store: SC.Store.create().from(SC.Record.fixtures)
});
Arrayobservers.objects = [SC.Object.create({foo: 1}), SC.Object.create({foo: 2})];
SC.RunLoop.begin();
Arrayobservers.setPath('objects.1.foo', 5); // don't know what you are actually doing
SC.RunLoop.end();
Arrayobservers.contentNotifyingObjects.get('computedProperty'); //should be 6
Arrayobservers = SC.Application.create({
NAMESPACE: 'Arrayobservers',
VERSION: '0.1.0',
store: SC.Store.create().from(SC.Record.fixtures)
});
@mauritslamers
mauritslamers / main_page.js
Created May 18, 2011 11:22
rentalUnitController
ScHerestay.rentalUnitController = SC.ObjectController.create({
contentBinding: SC.Binding.single('ScHerestay.rentalUnitsController.selection')
});
My.coreStateChart = SC.Statechart.create({
rootState: SC.State.design({
initialSubstate: 'checkingState',
checkingState: SC.State.design({
enterState: function(){
return SC.Async.perform('isLoggedInCheck');
},
exitState: function() {
App.Choice = SC.Record.extend({
label: SC.Record.attr(String, { isRequired: YES }),
question: SC.Record.toOne("App.Question", { isMaster: NO })
});
App.Question = SC.Record.extend({
question: SC.Record.attr(String, { isRequired: YES }),
quiz: SC.Record.toOne("App.Quiz", { isMaster: NO }),
choices: SC.Record.toMany("App.Choice"),
correctAnswers: SC.Record.toMany("App.Choice")
GX.itemController = SC.ObjectController.create({
invoiceVatBinding: 'GX.invoiceForItemController.hasVAT',
hasVAT: function(){
return this.get('invoiceVat');
}.property('invoiceVat')
});
GX.invoiceForItemController = SC.ObjectController.create({
contentBinding: "GX.itemController.invoice"
// need to add destroy of internal cache on destroy...
SC.ManyArray.reopen({
// Set up observers.
contentDidChange: function() {
var observedRecords = this._observedRecords;
if (!observedRecords) observedRecords = this._observedRecords = [];
var record, i, len;
// If any items in observedRecords are not in content, stop observing them.
// somewhere in your data source:
someMethod: function () {
SC.Request.getUrl('http://your.url.here').json().notify(this, this._myCallbackMethod).send();
},
_myCallbackMethod: function (result) {
if (SC.ok(result)){
// successfully retrieved
var myData = result.get('body');
<html>
<head>
<title>AudioPlayground</title>
<style>* {box-sizing: border-box;}</style>
</head>
<body>
<h3>AudioPlayground</h3>
<p>If you're happy and you know it, clap your hands!</p>
<script>
var Recording = function(cb){