Diff of /static/js/main.js [000000] .. [314dda]

Switch to unified view

a b/static/js/main.js
1
/**************************************************************************************
2
 * Project     : Chest X-Ray Pathology Detection and Localization using Deep Learning
3
 * Author Name : Rammuni Ravidu Suien Silva
4
 * UoW No      : 16267097
5
 * IIT No      : 2016134
6
 * Module      : Final Year Project 20/21
7
 * Supervisor  : Mr Pumudu Fernando
8
9
 * Prototype    : Web Interface - FrontEnd
10
 * File         : Main JS logic functions for the UI functionality
11
 * University of Westminster, UK || IIT Sri Lanka
12
 **************************************************************************************/
13
// TODO: USER GUIDE
14
// Setting path for relevant localization images
15
function localizationPathAdd(count_str) {
16
    let count = parseInt(count_str);// Can be used for error handling
17
    // Dynamic src creation
18
    $('.det-row').each(function (i, row_el) {
19
        let pathology_id = i;
20
        let cxr_popup_img_class = ".cxrPopupImg-" + pathology_id;
21
22
        $(row_el).on("click", function () {
23
            srcAdd(pathology_id, cxr_popup_img_class);
24
        });
25
    });
26
}
27
28
// Modifying the SRC
29
function srcAdd(pathology_id, cxr_popup_img_id) {
30
    let forceRefresh = '?' + Math.floor(Math.random() * 10000); // Force the browser to refresh image
31
    // URL generation for the target image
32
    // used library - http://stewartpark.github.io/Flask-JSGlue/ (PIP Installed)
33
    let urlPath = Flask.url_for('get_cxr_detect_img', {"pathology_id": pathology_id}) + forceRefresh;
34
    //Setting the image src
35
    $(cxr_popup_img_id).attr('src', urlPath);
36
}
37
38
// PDF Results
39
function printResults() {
40
    if (localized) {
41
        let completed = $('.det-row').each(function (i, row_el) {
42
            let pathology_id = i;
43
            let cxr_popup_img_id = ".cxrPopupImg-" + pathology_id;
44
            srcAdd(pathology_id, cxr_popup_img_id);
45
        });
46
        $.when(completed).then(function (x) {
47
            setTimeout(
48
                function () {
49
                    window.print();
50
                }, 3000);
51
        });
52
    } else {
53
        window.print();
54
    }
55
}
56
57
// Temporary loading icon for localization images
58
function setLoaderIcon() {
59
    let loadingURL = Flask.url_for("static", {"filename": "icons/loading_gif.gif"});
60
    $(".cxr-loc-img").attr('src', loadingURL);
61
}