Overview
Comment: | [fx] open URL from tooltip |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | fx | webext2 |
Files: | files | file ages | folders |
SHA3-256: |
9be9daf794d1968dcd9a17132ae0e1db |
User & Date: | olr on 2017-08-29 16:08:00 |
Other Links: | branch diff | manifest | tags |
Context
2017-08-29
| ||
16:09 | [fx] move openURL to parent object check-in: dce23987ab user: olr tags: fx, webext2 | |
16:08 | [fx] open URL from tooltip check-in: 9be9daf794 user: olr tags: fx, webext2 | |
12:33 | [fx] main panel: help section check-in: b8ce0aa31d user: olr tags: fx, webext2 | |
Changes
Modified gc_lang/fr/webext/background.js from [fd656c9d96] to [326c22ae1a].
︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | } else { console.log("[background] don’t know where to send results"); console.log(e.data); } break; case "textToTest": case "fullTests": case "getOptions": case "getDefaultOptions": case "resetOptions": // send result to panel browser.runtime.sendMessage(e.data); browser.storage.local.set({"gc_options": result}); break; | > > > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | } else { console.log("[background] don’t know where to send results"); console.log(e.data); } break; case "textToTest": case "fullTests": // send result to panel browser.runtime.sendMessage(e.data); break; case "getOptions": case "getDefaultOptions": case "resetOptions": // send result to panel browser.runtime.sendMessage(e.data); browser.storage.local.set({"gc_options": result}); break; |
︙ | ︙ | |||
89 90 91 92 93 94 95 | /* Messages from the extension (not the Worker) */ function handleMessage (oRequest, xSender, sendResponse) { //console.log(xSender); | > | < < < < < > > > > | > | > > > | | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | /* Messages from the extension (not the Worker) */ function handleMessage (oRequest, xSender, sendResponse) { //console.log(xSender); let {sCommand, dParam, dInfo} = oRequest; switch (sCommand) { case "getOptions": case "getDefaultOptions": case "setOptions": case "setOption": case "resetOptions": case "textToTest": case "fullTests": xGCEWorker.postMessage(oRequest); break; case "openURL": browser.tabs.create({url: dParam.sURL}); break; default: console.log("[background] Unknown command: " + sCommand); } //sendResponse({response: "response from background script"}); } browser.runtime.onMessage.addListener(handleMessage); function handleConnexion (xPort) { let iPortId = xPort.sender.tab.id; // identifier for the port: each port can be found at dConnx[iPortId] dConnx.set(iPortId, xPort); xPort.onMessage.addListener(function (oRequest) { let {sCommand, dParam, dInfo} = oRequest; switch (sCommand) { case "parse": case "parseAndSpellcheck": case "parseAndSpellcheck1": case "getListOfTokens": oRequest.dInfo.iReturnPort = iPortId; // we pass the id of the return port to receive answer xGCEWorker.postMessage(oRequest); break; case "openURL": browser.tabs.create({url: dParam.sURL}); break; default: console.log("[background] Unknown command: " + sCommand); console.log(oRequest); } }); xPort.postMessage({sActionDone: "newId", result: iPortId}); } browser.runtime.onConnect.addListener(handleConnexion); |
︙ | ︙ |
Modified gc_lang/fr/webext/content_scripts/gc_content.css from [4b3a10c0f7] to [40500349b4].
︙ | ︙ | |||
158 159 160 161 162 163 164 | font-style: normal; text-align: center; } #grammalecte_tooltip_message { font-size: 15px; margin: 0 0 5px 0; } | | > | | | > > | | | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | font-style: normal; text-align: center; } #grammalecte_tooltip_message { font-size: 15px; margin: 0 0 5px 0; } #grammalecte_tooltip_ignore { display: inline-block; padding: 2px 5px; background-color: hsla(30, 30%, 40%, 1); color: hsla(30, 0%, 96%, 1); border-radius: 2px; cursor: pointer; text-decoration: none; } #grammalecte_tooltip_ignore:hover { background-color: hsla(30, 30%, 50%, 1); color: hsla(0, 0%, 100%, 1); text-shadow: 0 0 3px hsl(30, 30%, 60%); } #grammalecte_tooltip_url { display: inline-block; margin: 0 0 0 10px; padding: 2px 5px; background-color: hsla(210, 50%, 50%, 1); color: hsla(210, 0%, 96%, 1); border-radius: 2px; cursor: pointer; text-decoration: none; } #grammalecte_tooltip_url:hover { background-color: hsla(210, 50%, 60%, 1); color: hsla(0, 0%, 100%, 1); text-shadow: 0 0 3px hsl(210, 30%, 60%); } #grammalecte_tooltip_sugg_title { padding: 0 10px; background-color: hsl(210, 10%, 90%); |
︙ | ︙ |
Modified gc_lang/fr/webext/content_scripts/gc_content.js from [caf52bce8a] to [69ff038986].
︙ | ︙ | |||
14 15 16 17 18 19 20 | oGrammalecte.oGCPanel.recheckParagraph(parseInt(xElem.dataset.para_num)); } else if (xElem.id.startsWith("grammalecte_hide")) { xElem.parentNode.parentNode.style.display = "none"; } else if (xElem.tagName === "U" && xElem.id.startsWith("grammalecte_err") && xElem.className !== "corrected" && xElem.className !== "ignored") { oGrammalecte.oGCPanel.oTooltip.show(xElem.id); } else if (xElem.id === "grammalecte_tooltip_url") { | | < < | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | oGrammalecte.oGCPanel.recheckParagraph(parseInt(xElem.dataset.para_num)); } else if (xElem.id.startsWith("grammalecte_hide")) { xElem.parentNode.parentNode.style.display = "none"; } else if (xElem.tagName === "U" && xElem.id.startsWith("grammalecte_err") && xElem.className !== "corrected" && xElem.className !== "ignored") { oGrammalecte.oGCPanel.oTooltip.show(xElem.id); } else if (xElem.id === "grammalecte_tooltip_url") { oGrammalecte.oGCPanel.openURL(xElem.dataset.url); } else { oGrammalecte.oGCPanel.oTooltip.hide(); } } else { oGrammalecte.oGCPanel.oTooltip.hide(); } } catch (e) { showError(e); } |
︙ | ︙ | |||
250 251 252 253 254 255 256 | xEvent.stopImmediatePropagation(); xEvent.preventDefault(); xEvent.clipboardData.setData("text/plain", sText); }; document.addEventListener("copy", setClipboardData, true); document.execCommand("copy"); | < > < > > > > > > > > > | > > | | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | xEvent.stopImmediatePropagation(); xEvent.preventDefault(); xEvent.clipboardData.setData("text/plain", sText); }; document.addEventListener("copy", setClipboardData, true); document.execCommand("copy"); } copyTextToClipboard () { this.startWaitIcon(); try { let xClipboardButton = document.getElementById("grammalecte_clipboard_button"); xClipboardButton.textContent = "->>"; let sText = ""; for (let xNode of document.getElementsByClassName("grammalecte_paragraph")) { sText += xNode.textContent + "\n"; } this._copyToClipboard(sText); xClipboardButton.textContent = "OK"; window.setTimeout(function() { xClipboardButton.textContent = "∑"; } , 2000); } catch (e) { showError(e); } this.stopWaitIcon(); } openURL (sURL) { xPort.postMessage({ sCommand: "openURL", dParam: {"sURL": sURL}, dInfo: {} }); } } class GrammalecteTooltip { constructor (xContentNode) { this.xTooltip = createNode("div", {id: "grammalecte_tooltip"}); this.xTooltipArrow = createNode("img", { id: "grammalecte_tooltip_arrow", src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAECAYAAACzzX7wAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xNkRpr/UAAAAlSURBVBhXY/j//z8cq/kW/wdhZDEMSXRFWCVhGKwAmwQCF/8HAGUkScGH4cM8AAAAAElFTkSuQmCC", alt: "^" }); this.xTooltipSuggBlock = createNode("div", {id: "grammalecte_tooltip_sugg_block"}); let xMessageBlock = createNode("div", {id: "grammalecte_tooltip_message_block"}); xMessageBlock.appendChild(createNode("p", {id: "grammalecte_tooltip_rule_id"})); xMessageBlock.appendChild(createNode("p", {id: "grammalecte_tooltip_message", textContent: "Erreur."})); let xActions = xMessageBlock.appendChild(createNode("div", {id: "grammalecte_tooltip_actions"})); xActions.appendChild(createNode("div", {id: "grammalecte_tooltip_ignore", textContent: "Ignorer"})); xActions.appendChild(createNode("div", {id: "grammalecte_tooltip_url", textContent: "Voulez-vous en savoir plus ?…"}, {url: ""})); xMessageBlock.appendChild(xActions); this.xTooltip.appendChild(xMessageBlock); this.xTooltip.appendChild(createNode("div", {id: "grammalecte_tooltip_sugg_title", textContent: "SUGGESTIONS :"})); this.xTooltip.appendChild(this.xTooltipSuggBlock); xContentNode.appendChild(this.xTooltip); xContentNode.appendChild(this.xTooltipArrow); } |
︙ | ︙ | |||
315 316 317 318 319 320 321 | document.getElementById("grammalecte_tooltip_rule_id").textContent = "Règle : " + xNodeErr.dataset.gc_message.slice(n+2); document.getElementById("grammalecte_tooltip_rule_id").style.display = "block"; } else { document.getElementById("grammalecte_tooltip_message").textContent = xNodeErr.dataset.gc_message; document.getElementById("grammalecte_tooltip_rule_id").style.display = "none"; } if (xNodeErr.dataset.gc_url != "") { | | | > | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | document.getElementById("grammalecte_tooltip_rule_id").textContent = "Règle : " + xNodeErr.dataset.gc_message.slice(n+2); document.getElementById("grammalecte_tooltip_rule_id").style.display = "block"; } else { document.getElementById("grammalecte_tooltip_message").textContent = xNodeErr.dataset.gc_message; document.getElementById("grammalecte_tooltip_rule_id").style.display = "none"; } if (xNodeErr.dataset.gc_url != "") { document.getElementById("grammalecte_tooltip_url").dataset.url = xNodeErr.dataset.gc_url; document.getElementById("grammalecte_tooltip_url").style.display = "inline"; } else { document.getElementById("grammalecte_tooltip_url").dataset.url = ""; document.getElementById("grammalecte_tooltip_url").style.display = "none"; } document.getElementById("grammalecte_tooltip_ignore").dataset.error_id = xNodeErr.dataset.error_id; let iSugg = 0; let xGCSugg = document.getElementById("grammalecte_tooltip_sugg_block"); xGCSugg.textContent = ""; if (xNodeErr.dataset.suggestions.length > 0) { |
︙ | ︙ |