import {ASSIGNED, ACTIVE} from '../../Domain/Inspections/InspectionState'
export default class InspectionsApi {
constructor(api, inspectionMapper) {
this.api = api;
this.inspectionMapper = inspectionMapper;
}
async retrieve() {
var raw = await this.api.get('inspections', {
query: {
clerk_id: 'me',
state_id: [ASSIGNED, ACTIVE]
}
});
return raw.body.map(insp => this.inspectionMapper.fromApi(insp));
}
}function switchEntries() {
if (document.all) {
document.election.presidents.item(0).text = 'Bill Clinton';
}
else if (document.layers) {
document.election.presidents[0].text = 'Bill Clinton';
}
else if (document.getElementById) {
document.election.leaving.text = 'Bill Clinton';
}
}
<FORM NAME="election">
<SELECT NAME="presidents">
<OPTION NAME="leaving">Al Gore
<OPTION SELECTED>George W. Bush
</SELECT>
<INPUT TYPE="button" VALUE="Switch first option"
onclick="switchEntries()">
</FORM>$('input[type="button"]').click(function() {
$('option:first').text('Bill Clinton');
});<form>
<select>
<option>Al Gore</option>
<option selected>George W. Bush</option>
</select>
<input type="button" value="Switch first option" />
</form>(function() {
var myVar = ...;
// your code here...
})();(function($, undefined) {
// $ bound to dependency jQuery
$.doSomething();
// undefined is actually undefined
})(jQuery);define(['jquery'] , function ($) {
function add(a, b) {
return a + b;
}
return add;
});adder.js
define(['adder', 'jquery'] , function(adder, $) {
adder(3, 4); // 7
});main.js
var $ = require('jquery');
function add(a, b) {
return a + b;
}
module.exports = add;square = (x) -> x * x
math =
root: Math.sqrt
square: square
cube: (x) -> x * square x
cubes = (math.cube num for num in list)var square = function(x) {
return x * x;
};
var math = {
root: Math.sqrt,
square: square,
cube: function(x) {
return x * square(x);
}
};
var cubes = (function() {
var i, len, results;
results = [];
for (i = 0, len = list.length; i < len; i++) {
num = list[i];
results.push(math.cube(num));
}
return results;
})();"use strict";
// Accessors
var x = { get foo() { return 'abc'; } }
// Functional programming
[1, 2, 3, 4].filter(function(x) { return x % 2 === 0; })
.map(function(x) { return x * x; })
.forEach(function(x) { console.log(x); });import {ASSIGNED, ACTIVE} from '../../Domain/Inspections/InspectionState'
export default class InspectionsApi {
constructor(api, inspectionMapper) {
this.api = api;
this.inspectionMapper = inspectionMapper;
}
async retrieve() {
var raw = await this.api.get('inspections', {
query: {
clerk_id: 'me',
state_id: [ASSIGNED, ACTIVE]
}
});
return raw.body.map(insp => this.inspectionMapper.fromApi(insp));
}
}var HelloMessage = React.createClass({
render: function() {
return <div>Hello {this.props.name}</div>;
}
});
React.render(<HelloMessage name="John" />, mountNode);