diff --git a/Gulpfile.js b/Gulpfile.js index fb1a75c..bd360a9 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -29,7 +29,7 @@ gulp.task('tmp', ['scripts', 'dist-node-modules'], function () { return gulp.src([ 'src/**/*.html', 'src/**/*.css', - 'src/content_script_web.js' + 'src/load-menu-for-web-testing.js' ], {base: 'src'}) .pipe($.flatten()) .pipe($.fileInclude({ @@ -44,7 +44,7 @@ gulp.task('dist', ['tmp'], function () { var tmp = gulp.src([ 'tmp/**/*', '!tmp/index.html', - '!tmp/content_script_web.js' + '!tmp/load-menu-for-web-testing.js' ], {base: 'tmp'}); var imageAssets = gulp.src('src/plugin-specific/*.png').pipe($.flatten()); var chromePluginResources = gulp.src([ diff --git a/src/content_script_web.js b/src/content_script_web.js deleted file mode 100644 index f56f70d..0000000 --- a/src/content_script_web.js +++ /dev/null @@ -1,12 +0,0 @@ -// used for local web testing - -@@include('content_script_include.js') - -injectScripts(); //found in the included file - -document.addEventListener("DOMContentLoaded", function(event) { - document.getElementById('js-show-menu') - .addEventListener('click', function () { - if (!document.getElementById('tagit-menu')) injectScripts(); - }); -}); diff --git a/src/index.html b/src/index.html index d9b4781..7484b02 100644 --- a/src/index.html +++ b/src/index.html @@ -8,7 +8,7 @@ - + diff --git a/src/index.ts b/src/index.ts index f2d74a5..446e601 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,7 +26,7 @@ module tagIt { if(chrome && chrome.extension) { return chrome.extension.getURL(relativeUrl); } else { - relativeUrl; + return relativeUrl; } } } diff --git a/src/content_script_include.js b/src/load-menu-for-web-testing.js similarity index 74% rename from src/content_script_include.js rename to src/load-menu-for-web-testing.js index f993eee..f1d2be4 100644 --- a/src/content_script_include.js +++ b/src/load-menu-for-web-testing.js @@ -1,4 +1,13 @@ -// Code used by both the local web prototype as well as the plugin. + +// Script loader for local web page testing +injectScripts(); + +document.addEventListener("DOMContentLoaded", function(event) { + document.getElementById('js-show-menu') + .addEventListener('click', function () { + if (!document.getElementById('tagit-menu')) injectScripts(); + }); +}); function injectScripts () { @@ -33,16 +42,8 @@ function injectScripts () { } function loadScript (relativeScriptPath, callback) { - function translateToPluginPath (relativeScriptPath) { - // if "chrome" present, we deduce that we're running as a plugin - if (chrome && chrome.extension) { - return chrome.extension.getURL(relativeScriptPath); - } else { - return relativeScriptPath; - } - } var s = document.createElement('script'); - s.src = translateToPluginPath(relativeScriptPath); + s.src = relativeScriptPath; s.onload = function() { this.parentNode.removeChild(this); if (callback) callback(); diff --git a/src/menu/menu.controller.ts b/src/menu/menu.controller.ts index f6fbb4a..82671aa 100644 --- a/src/menu/menu.controller.ts +++ b/src/menu/menu.controller.ts @@ -31,7 +31,7 @@ module tagIt { onSenseSelect (sense: ISense) { this.webPageService.addTagToPage(sense); - this.backendService.storeTaggingInformation( + this.backendService.sendTaggedDataToServer( sense, this.webPageService.currentSelectionRange, this.selectedWord, diff --git a/src/plugin-specific/background.js b/src/plugin-specific/background.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/plugin-specific/content_script.js b/src/plugin-specific/content_script.js deleted file mode 100644 index bc36bd4..0000000 --- a/src/plugin-specific/content_script.js +++ /dev/null @@ -1,13 +0,0 @@ -// used for chrome plugin, injected by popup.js - -@@include('../content_script_include.js') - -log('content script was added!'); - -injectScripts(); - -// todo wire up listeners - -function log (msg) { - console.log(msg); -} \ No newline at end of file diff --git a/src/services/backend.service.ts b/src/services/backend.service.ts index 7f5c91d..e621eb4 100644 --- a/src/services/backend.service.ts +++ b/src/services/backend.service.ts @@ -27,10 +27,9 @@ module tagIt { return synsets.data.senses; } - // save tagging information - // Params: email, tagging, sentence - storeTaggingInformation (sense: ISense, range: Range, selectedWord: string, userEmail: string) { - this.$log.debug('storeTaggingInformation() was called'); + sendTaggedDataToServer (sense: ISense, range: Range, + selectedWord: string, userEmail: string) { + this.$log.debug('sendTaggedDataToServer() was called'); var messageToSendToServer = { sense: sense, range: range,