diff --git a/etc/config/c++.amazon.properties b/etc/config/c++.amazon.properties index f97ff1662..1b43143fb 100644 --- a/etc/config/c++.amazon.properties +++ b/etc/config/c++.amazon.properties @@ -97,7 +97,7 @@ compiler.clang390.name=x86-64 clang 3.9.0 compiler.clang391.exe=/opt/compiler-explorer/clang-3.9.1/bin/clang++ compiler.clang391.name=x86-64 clang 3.9.1 compiler.clang400.exe=/opt/compiler-explorer/clang-4.0.0/bin/clang++ -compiler.clang400.name=x86-64 clang 4.0.0 (rc4) +compiler.clang400.name=x86-64 clang 4.0.0 compiler.clang_trunk.exe=/opt/compiler-explorer/clang-trunk/bin/clang++ compiler.clang_trunk.name=x86-64 clang (trunk) diff --git a/static/compiler.js b/static/compiler.js index ed35b077b..21f663847 100644 --- a/static/compiler.js +++ b/static/compiler.js @@ -131,7 +131,7 @@ define(function (require) { contextMenuGroupId: 'help', contextMenuOrder: 1.5, run: function (ed) { - // .getTargetAtClientPoint(ed.getPosition().column, ed.getPosition().lineNumber); not useful. We always returns null (Not a model?) + // .getTargetAtClientPoint(ed.getPosition().column, ed.getPosition().lineNumber); not useful. It always returns null (Not a model?) var token = ""; var targetLine = ed.getValue().split('\n')[ed.getPosition().lineNumber-1]; var l = ed.getPosition().column; @@ -159,38 +159,7 @@ define(function (require) { } }); - - - this.outputEditor.onMouseMove(function (e) { - if (e === null || e.target === null || e.target.position === null) return; - if (self.settings.hoverShowSource === true && !self.assembly) { - var desiredLine = e.target.position.lineNumber - 1; - if (!self.assembly[desiredLine]) { - // We check that we actually have something to show at this point! - self.eventHub.emit('editorSetDecoration', self.sourceEditorId, self.assembly[desiredLine].source); - } - } - if (e.target.element !== null && $.isNumeric(e.target.element.textContent)) { - var elementContent = e.target.element.textContent; - self.rawDecorations[0] = { - range: e.target.range, - options: { - isWholeLine: false, - hoverMessage: [ - parseInt(elementContent,16).toString(16) === elementContent.toLowerCase() ? // Is Hex? - '0x' + parseInt(elementContent).toString(16) - : - (parseInt(elementContent,10) === elementContent ? // Is Decimal - parseInt(elementContent).toString(10) - : // Else ... Show both - ('0x' + parseInt(elementContent, 16).toString() + ' (' + parseInt(elementContent, 10).toString() + ')')) - - ] - } - }; - self.decorations = self.outputEditor.deltaDecorations(self.decorations, self.rawDecorations); - } - }); + this.outputEditor.onMouseMove(_.throttle(_.bind(this.onMouseMove, this)), 250); this.fontScale = new FontScale(this.domRoot, state, this.outputEditor); this.fontScale.on('change', _.bind(function () { @@ -598,6 +567,34 @@ define(function (require) { } }; + var hexLike = /^([$]|0x)([0-9a-fA-F]+)$/; + + function getToolTip(value) { + var match = hexLike.exec(value); + if (match) return parseInt(match[2], 16).toString(); + if ($.isNumeric(value)) return '0x' + parseInt(value).toString(16); + return null; + } + + Compiler.prototype.onMouseMove = function (e) { + if (e === null || e.target === null || e.target.position === null) return; + if (this.settings.hoverShowSource === true && this.assembly) { + var desiredLine = e.target.position.lineNumber - 1; + if (this.assembly[desiredLine]) { + // We check that we actually have something to show at this point! + this.eventHub.emit('editorSetDecoration', this.sourceEditorId, this.assembly[desiredLine].source); + } + } + var numericToolTip = e.target.element ? getToolTip(e.target.element.textContent) : null; + if (numericToolTip) { + this.rawDecorations[0] = { + range: e.target.range, + options: {isWholeLine: false, hoverMessage: [numericToolTip]} + }; + this.decorations = this.outputEditor.deltaDecorations(this.decorations, this.rawDecorations); + } + }; + return { Compiler: Compiler }; diff --git a/static/sharing.js b/static/sharing.js index e801b6cce..d4bda798c 100644 --- a/static/sharing.js +++ b/static/sharing.js @@ -118,11 +118,12 @@ define(function (require) { } }); - // Dismiss on any click that isn't either in the opening element, or inside - // the popover. + // Dismiss on any click that isn't either in the opening element, inside + // the popover or on any alert $(document).on('click.editable', function (e) { var target = $(e.target); - if (!target.is(getLink) && getLink.has(target).length === 0 && target.closest('.popover').length === 0) + if (!target.is(getLink) && getLink.has(target).length === 0 && target.closest('.popover').length === 0 && + $('#alert').has(target).length === 0) getLink.popover("hide"); }); } diff --git a/static/urlshorten-google.js b/static/urlshorten-google.js index b5a353a0b..bf780728d 100644 --- a/static/urlshorten-google.js +++ b/static/urlshorten-google.js @@ -26,6 +26,7 @@ define(function (require) { "use strict"; var options = require('options'); + var Alert = require('alert'); function googleJSClientLoaded() { gapi.client.setApiKey(options.gapiKey); @@ -51,6 +52,7 @@ define(function (require) { } done(id); }, function () { + new Alert().alert('Could not shorten your URL', 'The current url probaly exceeds the Google Url Shortener length limits.'); done(url); }); }