Skip to content

Instantly share code, notes, and snippets.

View jack4it's full-sized avatar

Jack Ma jack4it

View GitHub Profile
@jack4it
jack4it / contact.js
Last active December 15, 2015 21:02
var contact = function(name, gender) {
this.name = name;
this.gender = gender;
}
exports.contact = contact;
var Contact = require("./contact").contact;
var contacts = [
new Contact("Jack", "M"),
new Contact("Eugenia", "F")
];
exports.contacts = contacts;
define(function () {
var contact = function(name, gender) {
this.name = name;
this.gender = gender;
}
return contact;
});
define(["contact.amd"], function(Contact) {
var contacts = [
new Contact("Jack", "M"),
new Contact("Eugenia", "F")
];
return contacts;
});
export class Contact {
constructor(name, gender) {
this.name = name;
this.gender = gender;
}
}
import { Contact } from "./contact.es6";
export var contacts = [
new Contact("Jack", "M"),
new Contact("Eugnenia", "F")
];
<input type="text" onmouseover="javascript:this.select()" value="This is to be selected when hovering over the mouse"></input>
less.render(lessInput, options)
.then(function(output) {
// output.css = string of css
// output.map = string of sourcemap
// output.imports = array of string filenames of the imports referenced
},
function(error) {
});
exports.translate = function (load) {
return System.import("less/lib/less-browser")
.then(function (lesscWrapper) {
return lesscWrapper(window, {
async: true,
errorReporting: "Console"
});
})
.then(function (lessc) {
return lessc.render(load.source, {
var cssInject = "(function(c){var d=document,a='appendChild',i='styleSheet',s=d.createElement('style');s.type='text/css';d.getElementsByTagName('head')[0][a](s);s[i]?s[i].cssText=c:s[a](d.createTextNode(c));})";
var escape = function (source) {
return source
.replace(/(["\\])/g, '\\$1')
.replace(/[\f]/g, '\\f')
.replace(/[\b]/g, '\\b')
.replace(/[\n]/g, '\\n')
.replace(/[\t]/g, '\\t')
.replace(/[\r]/g, '\\r')