From 8004eea37d7cc91b8ec565662974bf2e7e26a571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Norman=20Hauk=C3=A5s?= Date: Sat, 20 Feb 2016 12:51:23 +0100 Subject: [PATCH] Switched out the backend server url. Also ensured that the backendservice won't make the same query twice which is a challenge with people double clicking to select a word. --- src/index.appConfig.ts | 3 ++- src/menu/menu.controller.ts | 2 +- src/plugin-specific/manifest.json | 4 ++-- src/services/backend.service.ts | 26 ++++++++++++++++++-------- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/index.appConfig.ts b/src/index.appConfig.ts index 05b27e0..b723115 100644 --- a/src/index.appConfig.ts +++ b/src/index.appConfig.ts @@ -8,7 +8,8 @@ module tagIt { } export class AppConfigService { - serverUrl = 'http://lexitags.dyndns.org/server/lexitags2/Semtags?data='; + // serverUrl = 'http://lexitags.dyndns.org/server/lexitags2/Semtags?data='; + serverUrl = 'https://imdb.uib.no/lexitags/lexitags/'; } } diff --git a/src/menu/menu.controller.ts b/src/menu/menu.controller.ts index e92a6f9..f2015e5 100644 --- a/src/menu/menu.controller.ts +++ b/src/menu/menu.controller.ts @@ -26,7 +26,7 @@ module tagIt { this.tagStorageService = TagStorageService; this.$scope.$on('wordWasSelected', (event, selectedWord) => { - this.$log.debug('a word was selected' + selectedWord); + this.$log.debug(`Menucontroller received wordWasSelected event for: ${selectedWord}`); this.onWordSelectedEvent(selectedWord); }); diff --git a/src/plugin-specific/manifest.json b/src/plugin-specific/manifest.json index 8bf27d9..7c7b6e9 100644 --- a/src/plugin-specific/manifest.json +++ b/src/plugin-specific/manifest.json @@ -1,7 +1,7 @@ { "name": "Tag you're it", "description": "A browser tool for tagging words with exact definitions.", - "version": "0.0.5", + "version": "0.0.6", "manifest_version": 2, "icons": { "16": "icon16.png", @@ -11,7 +11,7 @@ "permissions": [ "storage", "activeTab", - "http://lexitags.dyndns.org/" + "https://imdb.uib.no/" ], "background": { "persistent": false, diff --git a/src/services/backend.service.ts b/src/services/backend.service.ts index d4563d7..82eb53e 100644 --- a/src/services/backend.service.ts +++ b/src/services/backend.service.ts @@ -3,26 +3,40 @@ 'use strict'; +/** + * Service that is responsible for talking to the + * backend server. + */ module tagIt { export class BackendService { $http : ng.IHttpService; $log : ng.ILogService; + $q: ng.IQService; private serverUrl : string = null; + private previousCall: string; /* @ngInject */ - constructor($http: ng.IHttpService, $log: ng.ILogService, AppConfigService: AppConfigService) { + constructor($http: ng.IHttpService, $q: ng.IQService, $log: ng.ILogService, AppConfigService: AppConfigService) { this.$http = $http; this.$log = $log; + this.$q = $q; this.serverUrl = AppConfigService.serverUrl; } callServer (word: string) { if (!word) { - return; - }; - return this.$http.get(this.serverUrl + this.createQuery(word)); + return this.$q.reject('no use calling server, there is no queryword.') + } else if (this.previousCall === word) { + var errMsg = `callServer has already been called with word: ${word}`; + this.$log.debug(errMsg) + return this.$q.reject(errMsg); + } + + //alright let's make this query! + this.previousCall = word; + return this.$http.get(this.serverUrl + word); } sendTaggedDataToServer (senseTag: ISenseTag) { @@ -43,9 +57,5 @@ module tagIt { // }); } - private createQuery (word: string) { - return '{"word":"QUERYTOREPLACE"}' - .replace(/QUERYTOREPLACE/, word); - } } } \ No newline at end of file