PageSourceSearch

https://ta-tum.com/js/modules/student/profile/section/Album.js

js ta-tum.com collected 2026-09-24 11:28:53 UTC 4,496 bytes, 145 lines download raw bytes

1/**
2 * Module Profile Album
3 * @description 
4 * @author Alejandro Micheloud
5 */
6
7var StudentProfileAlbum = function (sco) {
8    var scope = sco;
9    var builded = false;
10    var data_ob = null;
11    var current_page = null;
12    var amount_pages = null;
13
14    /**
15     * Se invoca cuando el módulo recibe foco
16     * @returns {undefined}
17     */
18    function show() {
19        if (!builded) {
20            build(doStart);
21        } else {
22            doStart();
23        }
24    }
25
26    function doStart() {
27        scope.show();
28        getMyCromos();
29    }
30    function getMyCromos() {
31        mDiscover.showLoading();
32        mCom.ajax("student/cromos", "GET", "", function (data, status) {
33            mDiscover.hideLoading();
34            data_ob = data.projects;
35            current_page = 0;
36            amount_pages = data_ob.length;
37            if (amount_pages === 0) {
38                emptyAlbum();
39            } else {
40                render();
41            }
42        }, function (err, status, msg) {
43            mDiscover.hideLoading();
44            mToast.toast(lang.student_album_cromo_error, 3000);
45            console.log(err);
46            console.log(status);
47            console.log(msg);
48        });
49    }
50    function emptyAlbum() {
51        scope.find(".d-album").addClass("empty");
52        scope.find(".btn").hide();
53        scope.find(".d-project-name").html(lang.student_album_cromo_empty);
54    }
55    function render() {
56        scope.find(".d-album").removeClass("empty");
57        var project = data_ob[current_page];
58        var classroom = project.classroom;
59        var cromos = project.cromos;
60        scope.find(".d-classroom-icon").attr("style", 'background-image:url(' + classroom.avatar + ')');
61        scope.find(".d-classroom-name").html(classroom.name);
62        scope.find(".d-project-icon").attr("style", 'background-image:url(' + project.icon + ')');
63        scope.find(".d-project-name").html('“' + project.title + '”');
64        var html = "";
65        for (var i = 0; i < cromos.length; i++) {
66            html += getHtmlCromo(cromos[i]);
67        }
68        scope.find(".d-cromos").html(html);
69        scope.find(".d-cromos").append(getHtmlCromoEmpty());
70
71        scope.find(".d-pages").html("Página " + (current_page + 1) + " de " + amount_pages);
72        scope.find(".btn").removeClass("disabled");
73        if (current_page === 0)
74            scope.find(".btn.prev").addClass("disabled");
75        if ((current_page + 1) >= amount_pages)
76            scope.find(".btn.next").addClass("disabled");
77    }
78
79    /**
80     * Constructor de módulo
81     * @returns {undefined}
82     */
83    function build(callback) {
84
85        builded = true;
86
87        scope.html(getHtmlModule());
88        scope.find(".btn.next").click(function () {
89            if (current_page < (amount_pages - 1)) {
90                current_page++;
91                render();
92            }
93        });
94        scope.find(".btn.prev").click(function () {
95            if (current_page > 0) {
96                current_page--;
97                render();
98            }
99        });
100        if (isFunction(callback)) {
101            callback();
102        }
103    }
104
105    /**
106     * Constructor
107     * @returns {undefined}
108     */
109    function init() {
110        // nada, latente hasta show
111    }
112    init();
113
114    // helpers
115    /* html of module */
116    function getHtmlModule() {
117        return '<div class="d-student-m-album">' +
118                '   <div class="d-album">' +
119                '       <div class="d-classroom-icon"></div>' +
120                '       <div class="d-classroom-icon-bg"></div>' +
121                '       <div class="d-classroom-name"></div>' +
122                '       <div class="d-project-icon"></div>' +
123                '       <div class="d-project-name"></div>' +
124                '       <div class="btn btn-bitmap next"></div>' +
125                '       <div class="btn btn-bitmap prev"></div>' +
126                '       <div class="d-cromos"></div>' +
127                '       <div class="d-pages"></div>' +
128                '   </div>';
129        '</div>';
130    }
131    function getHtmlCromo(cromo) {
132        return '<div class="d-cromo">' +
133                '   <div class="d-image c' + cromo.icon + '"></div>' +
134                '   <div class="d-name">' + cromo.title + '</div>' +
135                '</div>';
136    }
137    function getHtmlCromoEmpty() {
138        return '<div class="d-cromo empty">' +
139                '' +
140                '</div>';
141    }
142
143    // public methods
144    this.show = show;
145};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.