Issues (121)

src/js/mivhak.resources.js (1 issue)

Labels
Severity
1
/**
2
 * Any <pre> element inside the mivhak wrapper is considered to be a Mivhak 
3
 * resource. When a new Mivhak instance is created, the list of resources is 
4
 * parsed nad stored in this object.
5
 * 
6
 * @returns {Resources}
7
 */
8
var Resources = function() {
9
    this.data = [];
10
};
11
12
/**
13
 * Return the number of resources
14
 * @returns {Number}
15
 */
16
Resources.prototype.count = function() {
17
    return this.data.length;
18
};
19
20
/**
21
 * Add a resource to the list. Given a <pre> element, this function will extract
22
 * all the attributes beginning with 'miv-' and the element's content and insert
23
 * it to the list of resources.
24
 * 
25
 * @param {DOMElement} pre
26
 */
27
Resources.prototype.add = function(pre) {
28
    this.data.push($.extend({},
29
        Mivhak.resourceDefaults,{
0 ignored issues
show
The variable Mivhak seems to be never declared. If this is a global, consider adding a /** global: Mivhak */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
30
            pre:pre, 
31
            content: pre.textContent
32
        },
33
        readAttributes(pre)
34
    ));
35
};
36
37
/**
38
 * Get a resource by a given index
39
 * @param {Number} i
40
 * @returns {Object}
41
 */
42
Resources.prototype.get = function(i) {
43
    return this.data[i];
44
};
45
46
/**
47
 * Update the content of the resource corresponding to the given index.
48
 * 
49
 * @param {number} i
50
 * @param {string} content
51
 */
52
Resources.prototype.update = function(i, content) {
53
    this.data[i].content = content;
54
};
55
56