Statistics
| Branch: | Revision:

blinker / firefox.plugin / data / scripts / helpers.js @ master

History | View | Annotate | Download (3.354 KB)

1 76dd22bd KevinTaron
/*
2
 * Copyright 2015 Thies Pfeiffer and Dimitri Heil and Kevin Taron
3
 * Blinker is distributed under the terms of the GNU General Public License
4
 * 
5
 * This file is part of Blinker.
6
 * 
7
 * Blinker is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 * 
12
 * Blinker is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU General Public License for more details.
16
 * 
17
 * You should have received a copy of the GNU General Public License
18
 * along with Blinker. If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
/*
22
*        shorten a string to a given length and return the shortened string, if it has no node opening brackets inside of it like an " <img [...]> " or something
23
*/
24
function shortenString(str, length) {
25
        //console.log("functions.js :: "+"shortenString()" + ", str:" +str +", length: "+length);
26
        if (str !== null) {
27
                if (str.toLowerCase().indexOf("<") > -1) {
28
                        //console.log("'<' - node opening bracket found in the name of a gaze link - not shortening it, because it could be an html node");
29
                        return str;
30
                }
31
32
                if (str.length < length) {
33
                        return str;
34
                } else {
35
                        return str.substring(0, length) + "...";
36
                }
37
        }
38
}
39
40
41
/*
42
*        move the status div with the mouse 
43
*/
44
function mousemoved(e) {
45
        /*mouseX = e.clientX + window.scrollX;
46
        mouseY = e.clientY + window.scrollY*/
47
        $("#status").css("left", e.clientX + 30 + window.scrollX + "px");
48
        $("#status").css("top", e.clientY + window.scrollY + "px");
49
        
50
}
51
52
53
//callable functions from the 4 point gaze gestures 
54
55
/*        ######################################################################################
56
*        ADD FUNCTIONS THAT SHOULD BE ENABLED FOR CALLING FROM THE 4-POINT-GESTURE MODE [START]
57
*        ######################################################################################
58
*/
59
60
var pageBack = function(){
61
        window.history.back();
62
};
63
64
var pageForward = function(){
65
        window.history.forward();
66
};
67
68
var pageReload = function(){
69
        location.reload();
70
};
71
72
/*        ####################################################################################
73
*        ADD FUNCTIONS THAT SHOULD BE ENABLED FOR CALLING FROM THE 4-POINT-GESTURE MODE [END]
74
*        ####################################################################################
75
*/
76
77
78
//show a notification with a given font-awesome icon (http://fortawesome.github.io/Font-Awesome/icons/) and string
79
function showNotification(faicon, str) {
80
        //$("#notification").html("<div class='notif_icon'><i class='fa fa-"+faicon+"'></i></div><div class='notif_text'>"+str+"</div>");
81
        console.log("Notification: " + str);
82
        $("#notification").stop();        
83
        $("#notification").html("<table><tr><td class='notif_icon'><i class='fa fa-" + faicon + "'></i></td><td class='notif_text'>" + str + "</td></tr></table>");
84
        $("#notification").fadeIn("fast");
85
        $('#notification').fadeOut(3000);
86
87
}
88
//make the function visible from a page-script
89
exportFunction(showNotification, unsafeWindow, {defineAs: "showNotification"});
90
91
92
93
function closeAll() {
94
        closePieMenu();
95
        closePieMenuKeyboard();
96
        closeOnscreenbox();
97
        setScrollAtBorder();
98
99
        acceptKeyboardInput();
100
}