javascript namespace library
Rev. | Tiempo | Autor | Mensaje |
---|---|---|---|
1c3b9bb66f95 | 2019-08-07 12:06:50 | frostbane | develop tip 与 feature/comments 合并 |
0dd89af2c356 | 2019-08-07 12:06:38 | frostbane | feature/comments close |
a28bac94f141 | 2019-08-07 12:05:26 | frostbane | feature/comments add comments |
181ccf45e283 | 2018-12-24 15:05:56 | frostbane | develop Merge with feature/version |
5e0b08450f8c | 2018-12-24 15:05:51 | frostbane | feature/version close |
490e0a445f71 | 2018-12-24 15:05:43 | frostbane | feature/version update version |
59842a7f3e9e | 2018-12-24 15:02:12 | frostbane | develop Merge with feature/init |
0aaf2d2f0383 | 2018-12-24 15:02:07 | frostbane | feature/init close |
1ad0daac98f2 | 2018-12-24 15:01:40 | frostbane | feature/init add init argument |
95cc0152a1da | 2017-12-15 19:46:13 | 繧「繝ォ萓ソ | develop merge release/0.1.0 |
Nombre | Rev. | Tiempo | Autor |
---|---|---|---|
V0.0.0 | 65b277bb3d5e | 2017-12-15 12:39:18 | 繧「繝ォ萓ソ |
V0.0.1 | 90817041cd89 | 2017-12-15 13:31:30 | 繧「繝ォ萓ソ |
V0.1.0 | 6cb3341977ec | 2017-12-15 19:44:41 | 繧「繝ォ萓ソ |
tip | 1c3b9bb66f95 | 2019-08-07 12:06:50 | frostbane |
Nombre | Rev. | Tiempo | Autor | Mensaje |
---|---|---|---|---|
default | 2bdb0953f049 | 2017-12-15 19:45:40 | 繧「繝ォ萓ソ | V0.1.0 タグをチェンジセット... |
develop | 1c3b9bb66f95 | 2019-08-07 12:06:50 | frostbane | 与 feature/comments 合并 |
feature/comments | 0dd89af2c356 | 2019-08-07 12:06:38 | frostbane | close |
feature/export | b4ebd35f8951 | 2017-12-15 14:06:19 | 繧「繝ォ萓ソ | close |
feature/init | 0aaf2d2f0383 | 2018-12-24 15:02:07 | frostbane | close |
feature/initial code | de1eb64d6d70 | 2017-12-15 13:30:15 | 繧「繝ォ萓ソ | close |
feature/readme | b9ed1fc33489 | 2017-12-15 14:12:07 | 繧「繝ォ萓ソ | close |
feature/refactor | 5464e58c298b | 2017-12-15 17:58:41 | 繧「繝ォ萓ソ | close |
feature/version | 5e0b08450f8c | 2018-12-24 15:05:51 | frostbane | close |
release/0.0.1 | f75207b1bed9 | 2017-12-15 13:31:17 | 繧「繝ォ萓ソ | close |
release/0.1.0 | ccab48ea268d | 2017-12-15 19:44:27 | 繧「繝ォ萓ソ | close |
Wrap libraries into a namespace.
$ hg clone https://bitbucket.org/frostbane/micro-namespace
$ npm install micro-namespace
var ns = require("micro-namespace");
<script type="text/javascript"
src="micro-namespace.js"></script>
simple namespace
// create fb.common.util namespace
namespace("fb.common.util");
// add methods to fb.common.util
fb.common.util.formatDate = function(...){ ... };
fb.common.util.logError = function(...){ ... };
// use the methods/classes
if(!fb.common.util.formatDate("2017/12/14")){
fb.common.util.logError("format failed");
}
namespace and object
// create fb.common.extra namespace with methods
namespace("fb.common.extra", {
getDateNow :function(){ ... },
getServerUrl :function(){ ... },
AjaxParser :function(){ ... },
});
// use the methods/classes
var now = fb.common.extra.getDateNow();
var host = fb.common.extra.getServerUrl();
var ax = new fb.common.extra.AjaxParser();
amd require
var ns = require("micro-namespace");
ns("fb.ajax", {
getUsername :function(){ ... },
});
var user = fb.ajax.getUsername();
initialize object
the third parameter (init) is called under the context of the second parameter (obj) after the namespace is created.
namespace("fb.common.upload", {
uploadFile :function(){},
initUploader :function(){},
resetErrors :function(){},
}, function(){
// exported methods can be accessed with this
this.initUploader();
this.resetErrors();
$(function(){
$("#cal").datepicker();
});
});