GitHub Library
A small library for personal use.
- Build the package:
npm run-script build
- Testing the package:
npm run-script test
API
Github.addComment( target, comment ) ⇒ Undefined
Param | Type | Default | Description |
---|---|---|---|
target |
String |
document |
Selector object |
comment |
Object |
Comment data |
Adding a comment to a template.
Example:
window.addEventListener("load", function () {
Github.getComments("octocat/Hello-World", 1,
function (error, comments) {
if (error) { throw new Error(error); }
// code
});
});
Github.getComments( repos, issue, callback ) ⇒ Array
Param | Type | Default | Description |
---|---|---|---|
repos |
String |
Repository name | |
issue |
Number |
Issue number | |
callback |
Function |
Function handler |
Getting a list of comments.
Example:
<!-- Template -->
<script type="text/html" id="template">
<div class="panel panel-default">
<!-- Title -->
<div class="panel-heading">
<img class="github-avatar img-rounded" src="{{= it.avatar }}">
<a href="{{= it.url }}"><strong>{{= it.user }}</strong></a>
<span>commented on {{= it.date }}</span>
</div>
<!-- Content -->
<div class="panel-body">{{= it.content }}</div>
</div>
</script>
<!-- Script loading comments -->
<script defer type="text/javascript">
window.addEventListener("load", function () {
Github.getComments("octocat/Hello-World", 1,
function (error, comments) {
if (error) { throw new Error(error); }
comments.forEach(function (comment) {
Github.addComment("#comments", comment);
});
});
});
</script>
License
MIT. Copyright (c) Valentin Popov.