MCPcopy Create free account
hub / github.com/aralejs/aralejs.github.io / insertModules

Function insertModules

static/index.js:33–79  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

31 });
32
33 function insertModules(data) {
34
35 if ($('#module-wrapper').length === 0) {
36 return;
37 }
38
39 data = data.sort(function(a, b) {
40 return a.name[0] > b.name[0];
41 });
42
43 for (var i = 0; i < data.length; i++) {
44 var item = $('<div class="module">\
45 <a class="module-name" target="_blank" href="#"></a>\
46 <span class="module-version"></span>\
47 <p class="module-description"></p>\
48 </div>');
49
50 var pkg = data[i];
51 var family = pkg.family || pkg.root;
52
53 item.find(".module-name").html(pkg.name)
54 .attr('href', '/' + pkg.name + '/')
55 .attr('title', pkg.name);
56 item.find(".module-version").html(pkg.version);
57 item.find(".module-description").html(pkg.description)
58 .attr('title', pkg.description);
59
60 if (family === 'gallery' || family === 'jquery') {
61 item.find(".module-name").attr('href', pkg.homepage);
62 $('.modules-' + family).append(item).prev().show();
63 } else if (family === 'arale') {
64 if (pkg.keywords) {
65 $('.modules-' + pkg.keywords[0]).append(item).prev().show();
66 } else {
67 $('.modules-widget').append(item).prev().show();
68 }
69 } else if (family === 'alipay') {
70 var url = [
71 'http://arale.alipay.im',
72 (pkg.family || pkg.root),
73 pkg.name
74 ].join('/') + '/';
75 item.find(".module-name").attr('href', url);
76 $('.modules-alipay').append(item).prev().show();
77 }
78 }
79 }
80
81 function color(items) {
82 items = $(items);

Callers 1

index.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected