blinker / firefox.plugin / data / functions.js @ a03cd52e
History | View | Annotate | Download (63.492 KB)
| 1 | a03cd52e | Thies Pfeiffer | /*
|
|---|---|---|---|
| 2 | * Copyright 2015 Thies Pfeiffer and Dimitri Heil
|
||
| 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 | var gazeFunctions = {
|
||
| 22 | /*
|
||
| 23 | * open a given url in a given target (_self / _blank)
|
||
| 24 | */
|
||
| 25 | openURL: function(url, target) { |
||
| 26 | //console.log("functions.js :: " + "gazeFunctions.openURL()" + ", url: " + url + ", target: " + target);
|
||
| 27 | $("#wheelSelector").css("display", "none"); |
||
| 28 | edgeFunctions.clearDivs(); |
||
| 29 | $("#wheelSelector").empty(); |
||
| 30 | wheelSelectorShowing = false;
|
||
| 31 | window.open(url, target); |
||
| 32 | }, |
||
| 33 | /*
|
||
| 34 | * Positions the gazeLinkOption-fields according to the number of gazeConfirmations-fileds and the gazeLinks-Div position
|
||
| 35 | *
|
||
| 36 | * @gazeLinkNumber: the number of the gazeLink the gazeLinkOptions should be appended to
|
||
| 37 | */
|
||
| 38 | showGazeLinkOptions: function(gazeLinkNumber) { |
||
| 39 | //console.log("functions.js :: " + "gazeFunctions.showGazeLinkOptions()" + ", gazeLinkNumber: " + gazeLinkNumber);
|
||
| 40 | gazeFunctions.hideGazeLinkOptions(); |
||
| 41 | //console.log("gazeLinkNumber: "+ gazeLinkNumber);
|
||
| 42 | |||
| 43 | var selectedDivOffset = $("#gazeLinkNum_" + gazeLinkNumber).offset(); |
||
| 44 | //console.log("selectedDivOffset X: "+selectedDivOffset.left);
|
||
| 45 | //console.log("selectedDivOffset Y: "+selectedDivOffset.top);
|
||
| 46 | |||
| 47 | if (blickBrowserSettings.gazeConfirmationSteps === 0) { |
||
| 48 | $("#leftGazeOption_" + gazeLinkNumber).css("left", (gazeInformation.gazeLinksPosition.x - $("#leftGazeOption_" + gazeLinkNumber).width() - window.scrollX) - 1 + "px"); |
||
| 49 | $("#leftGazeOption_" + gazeLinkNumber).css("top", (gazeInformation.gazeLinksPosition.y + selectedDivOffset.top - $("#gazeLinks").offset().top) + "px"); |
||
| 50 | $("#leftGazeOption_" + gazeLinkNumber).css("height", blickBrowserSettings.gazeConfirmationSize+"px"); |
||
| 51 | $("#leftGazeOption_" + gazeLinkNumber).css("width", blickBrowserSettings.gazeConfirmationSize+"px"); |
||
| 52 | |||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | $("#rightGazeOption_" + gazeLinkNumber).css("left", (gazeInformation.gazeLinksPosition.x + $("#gazeLinks").width() - window.scrollX) - 1 + "px"); |
||
| 57 | $("#rightGazeOption_" + gazeLinkNumber).css("top", (gazeInformation.gazeLinksPosition.y + selectedDivOffset.top - $("#gazeLinks").offset().top) + "px"); |
||
| 58 | $("#rightGazeOption_" + gazeLinkNumber).css("height", blickBrowserSettings.gazeConfirmationSize+"px"); |
||
| 59 | $("#rightGazeOption_" + gazeLinkNumber).css("width", blickBrowserSettings.gazeConfirmationSize+"px"); |
||
| 60 | |||
| 61 | |||
| 62 | $('.gazeLinkOption').stop(); |
||
| 63 | $("#leftGazeOption_" + gazeLinkNumber).fadeIn(); |
||
| 64 | $("#rightGazeOption_" + gazeLinkNumber).fadeIn(); |
||
| 65 | //gazeInformation.gazeLinks[gazeLinkNumber]
|
||
| 66 | } else {
|
||
| 67 | //console.log("GAZEPOS X: "+gazeInformation.gazeLinksPosition.x);
|
||
| 68 | $("#leftGazeConfirmation_" + gazeLinkNumber + "_0").css("left", (gazeInformation.gazeLinksPosition.x - $("#leftGazeOption_" + gazeLinkNumber).width() - window.scrollX) - 1 + "px"); |
||
| 69 | $("#leftGazeConfirmation_" + gazeLinkNumber + "_0").css("top", (gazeInformation.gazeLinksPosition.y + selectedDivOffset.top - $("#gazeLinks").offset().top) + "px"); |
||
| 70 | $("#leftGazeConfirmation_" + gazeLinkNumber + "_0").css("height", blickBrowserSettings.gazeConfirmationSize+"px"); |
||
| 71 | $("#leftGazeConfirmation_" + gazeLinkNumber + "_0").css("width", blickBrowserSettings.gazeConfirmationSize+"px"); |
||
| 72 | |||
| 73 | |||
| 74 | $("#rightGazeConfirmation_" + gazeLinkNumber + "_0").css("left", (gazeInformation.gazeLinksPosition.x + $("#gazeLinks").width() - window.scrollX) - 1 + "px"); |
||
| 75 | $("#rightGazeConfirmation_" + gazeLinkNumber + "_0").css("top", (gazeInformation.gazeLinksPosition.y + selectedDivOffset.top - $("#gazeLinks").offset().top) + "px"); |
||
| 76 | $("#rightGazeConfirmation_" + gazeLinkNumber + "_0").css("height", blickBrowserSettings.gazeConfirmationSize+"px"); |
||
| 77 | $("#rightGazeConfirmation_" + gazeLinkNumber + "_0").css("width", blickBrowserSettings.gazeConfirmationSize+"px"); |
||
| 78 | |||
| 79 | |||
| 80 | $('.gazeLinkOption').stop(); |
||
| 81 | $("#leftGazeConfirmation_" + gazeLinkNumber + "_0").fadeIn(); |
||
| 82 | $("#rightGazeConfirmation_" + gazeLinkNumber + "_0").fadeIn(); |
||
| 83 | } |
||
| 84 | |||
| 85 | }, |
||
| 86 | /*
|
||
| 87 | * Hide all gazeLinkOption-fields
|
||
| 88 | */
|
||
| 89 | hideGazeLinkOptions: function() { |
||
| 90 | //console.log("functions.js :: " + "gazeFunctions.hideGazeLinkOptions()");
|
||
| 91 | |||
| 92 | $(".gazeLinkOption").css("display", "none"); |
||
| 93 | |||
| 94 | }, |
||
| 95 | /*
|
||
| 96 | * Check for links at the current gazePosition
|
||
| 97 | */
|
||
| 98 | checkForLinks: function() { |
||
| 99 | /*if (!blickBrowserSettings.autoReadingMode) {*/
|
||
| 100 | if (!blickBrowserSettings.explicitMode) {
|
||
| 101 | if (!gazeCorrectionMode) {
|
||
| 102 | //console.log("functions.js :: "+"gazeFunctions.checkForLinks()" );
|
||
| 103 | if ($("#noFocusHider").css("display") == "none") { |
||
| 104 | //console.log("functions.js :: "+"gazeFunctions.checkForLinks()"+" :: #noFocusHider is not displayed" );
|
||
| 105 | if (!linkCheckRunning) {
|
||
| 106 | //console.log("functions.js :: "+"gazeFunctions.checkForLinks()"+" :: linkCheckRunning is false" );
|
||
| 107 | if (!controlBarShowing) {
|
||
| 108 | //console.log("functions.js :: "+"gazeFunctions.checkForLinks()"+" :: controlBarShowing is false" );
|
||
| 109 | if (!wheelSelectorShowing) {
|
||
| 110 | //console.log("functions.js :: "+"gazeFunctions.checkForLinks()"+" :: wheelSelectorShowing is false" );
|
||
| 111 | if (!gazeLinksShowing) {
|
||
| 112 | //console.log("functions.js :: "+"gazeFunctions.checkForLinks()"+" :: gazeLinksShowing is false" );
|
||
| 113 | |||
| 114 | //console.log("Check for links initiated");
|
||
| 115 | |||
| 116 | $("#gazeLinks").css("display", "none"); |
||
| 117 | $("#closeGazeLinks").css("display", "none"); |
||
| 118 | $("#itemSelector").css("display", "none"); |
||
| 119 | $("#gazeLinks").empty(); |
||
| 120 | |||
| 121 | |||
| 122 | //getLinksFromElementBelow
|
||
| 123 | if (blickBrowserSettings.getLinksFromElementBelow === true) { |
||
| 124 | linkCheckRunning = true;
|
||
| 125 | findLinksInElementBelow(); |
||
| 126 | linkCheckRunning = false;
|
||
| 127 | |||
| 128 | |||
| 129 | } |
||
| 130 | |||
| 131 | //getLinksFromArea
|
||
| 132 | if (blickBrowserSettings.getLinksFromArea === true) { |
||
| 133 | linkCheckRunning = true;
|
||
| 134 | findLinksInAreaFast(); |
||
| 135 | linkCheckRunning = false;
|
||
| 136 | } |
||
| 137 | |||
| 138 | |||
| 139 | |||
| 140 | |||
| 141 | } else {
|
||
| 142 | //console.log("functions.js :: " + "gazeFunctions.checkForLinks()" + " :: gazeLinksShowing: " + gazeLinksShowing);
|
||
| 143 | } |
||
| 144 | } else {
|
||
| 145 | //console.log("functions.js :: " + "gazeFunctions.checkForLinks()" + " :: wheelSelectorShowing: " + wheelSelectorShowing);
|
||
| 146 | } |
||
| 147 | } else {
|
||
| 148 | //console.log("functions.js :: " + "gazeFunctions.checkForLinks()" + " :: linkCheckRunning: " + linkCheckRunning);
|
||
| 149 | } |
||
| 150 | } else {
|
||
| 151 | //console.log("functions.js :: " + "gazeFunctions.checkForLinks()" + " :: gazeCorrectionMode: " + gazeCorrectionMode);
|
||
| 152 | } |
||
| 153 | } |
||
| 154 | } else {
|
||
| 155 | //console.log("functions.js :: " + "gazeFunctions.checkForLinks()" + " :: #noFocusHider: " + $("#noFocusHider").css("display"));
|
||
| 156 | } |
||
| 157 | } else {
|
||
| 158 | //console.log("functions.js :: " + "gazeFunctions.checkForLinks()" + " :: explicitMode: " + blickBrowserSettings.explicitMode);
|
||
| 159 | /*}
|
||
| 160 | } else {*/
|
||
| 161 | //console.log("functions.js :: " + "gazeFunctions.checkForLinks()" + " :: autoReadingMode: " + blickBrowserSettings.autoReadingMode);
|
||
| 162 | } |
||
| 163 | }, |
||
| 164 | |||
| 165 | /*
|
||
| 166 | * Show gazeConfirmations according to it's id and the selected gazeLink and gazeLink-Div position
|
||
| 167 | *
|
||
| 168 | * @id: the id of the gazeOption or gazeConfirmation that should be positioned
|
||
| 169 | */
|
||
| 170 | showConfirmationDiv: function(id) { |
||
| 171 | console.log("functions.js :: " + "gazeFunctionss.showConfirmationDiv() ID:" + id); |
||
| 172 | var selectedDivOffset;
|
||
| 173 | var split;
|
||
| 174 | /*
|
||
| 175 | * if it is a gazeOption
|
||
| 176 | */
|
||
| 177 | if (id.toLowerCase().indexOf("option") > -1) { |
||
| 178 | split = id.split("_");
|
||
| 179 | selectedDivOffset = $("#gazeLinkNum_" + parseInt(split[1])).offset(); |
||
| 180 | |||
| 181 | if (id.indexOf("left") > -1) { |
||
| 182 | |||
| 183 | $("#" + id).css("left", (gazeInformation.gazeLinksPosition.x - window.scrollX - ((blickBrowserSettings.gazeConfirmationSteps + 1) * blickBrowserSettings.gazeConfirmationSize)) - 2 + "px"); |
||
| 184 | |||
| 185 |