//получить куку user
cookie("user");
// установить куку "user" равную "john"
cookie("user", "John");
// установить куку "user" равную "john" на 24 часа
cookie("user", "John", 24);
// установить куку "user" равную "john" на 1 месяц для пути "/"
cookie("user", "John", 24 * 30, "/");
// установить куку "user" равную "john" на 1 месяц для страницы "auth" домена ".example.net"
cookie("user", "John", 24 * 30, "/", ".example.net");
function parse(str) {
var result = {};
if (str) {
str.toLowerCase().replace(/^\?/, "").split("&").forEach(function(pair) {
pair = pair.split("=");
result[pair[0]] = !pair[1] ? true : pair[1];
});
}
return result;
}
parse("oid=219670389&id=166774936&hash=65b39c9dedc35fe5");
// {oid: "219670389", id: "166774936", hash: "65b39c9dedc35fe5"}
...
bindings: {
hashchange: {
paramsMatcher: paramsMatcher,
querySeparator: "&",
// don't greedily match slashes in routing rules
matchSlashes: false,
bind: function () {
can.bind.call(window, 'hashchange', setState);
},
unbind: function () {
can.unbind.call(window, 'hashchange', setState);
},
// Gets the part of the url we are determinging the route from.
// For hashbased routing, it's everything after the #, for
// pushState it's configurable
matchingPartOfURL: function () {
return location.href.split(/#!?/)[1] || "";
},
// gets called with the serialized can.route data after a route has changed
// returns what the url has been updated to (for matching purposes)
setURL: function (path) {
location.hash = "#!" + path;
return path;
},
root: "#!"
}
},
...
var App = {
parent: {
parent2: { // это ваш модуль, здесь его и описываем
method: function() {
return "Hello!";
}
}
}
}
var method = extend(App, "parent.parent2.method"); // "Hello!"
console.log(method); // "Hello!"
console.log(App.parent.parent2.method()); // "Hello!"
console.log(method == App.parent.parent2.method); // true