Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separated data from presentation #110

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ Hand-picked registry of Node.js frameworks.

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D
3. If you're adding a framework, add it to `./projects.js`
4. Commit your changes: `git commit -am 'Add some feature'`
5. Push to the branch: `git push origin my-new-feature`
6. Submit a pull request :D

## License
[MIT License](https://github.com/azat-co/nodeframework/blob/master/LICENSE) © Azat Mardan
38 changes: 38 additions & 0 deletions assets/js/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
$(document).ready(function() {
// Check if `projects.js` was loaded before this file.
// `projects` is defined in `projects.js`.
if (typeof projects !== 'undefined') {
// Loop over each project
projects.forEach(function (project) {
if (project.hasOwnProperty('tags')) {
// Project has tag(s), so add to every list that matches the tag.
project.tags.forEach(function (tag) {
addProjectToProjectList(tag, project);
});
} else {
// The project doesn't have any tags, so add it to the "other" section.
addProjectToProjectList('other', project);
}
});
} else {
// `projects.js` needs to be loaded before this file
console.error('Please load `projects.js` before `main.js`!');
}

function addProjectToProjectList(tag, project) {
var element = '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You think we can use a template generator here? Like Handlebars?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I do agree that is simple as create the template with element variable. Just thinking here...


element += '<li>';
element += '<i class="icon-check"></i> <a href="' + project.homepage + '">' + project.name + '</a> ';
if (project.annotation) { element += '(' + project.annotation + ') '; }
element += '<iframe src="http://ghbtns.com/github-btn.html?user=' + project.github.user + '&repo=' + project.github.repo + '&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>';
element += '<a data-toggle="collapse" data-parent="#mvc" href="#project-link-container_' + project.github.user + '__' + project.github.repo + '">';
element += '<i class="icon-info icon-stack-1x icon-inverse"></i>';
element += '</a>';
element += '<div id="project-link-container_' + project.github.user + '__' + project.github.repo + '" class="panel-collapse collapse">';
project.links.forEach(function (link) { element += '[<a href="' + link.url + '">' + link.title + '</a>]&nbsp;'; });
element += '</div>';
element += '</li>';

return $('#project-list-' + tag).append(element);
}

$('[rel=tooltip]').tooltip();

// Add spin.js to lazy load container
Expand Down
2 changes: 1 addition & 1 deletion assets/js/main.min.js

Large diffs are not rendered by default.

Loading