diff --git a/src/index-angular-app.html b/src/index-angular-app.html index 8257d7c..d4d9899 100644 --- a/src/index-angular-app.html +++ b/src/index-angular-app.html @@ -31,7 +31,11 @@
Menu: + Download tags (current page) | + Download all tags (domain) | + Delete tags from current page +
Mark one or two words on the page to the right. And we'll supply you with possible definitions. Select a definition and the
diff --git a/src/index.interfaces.ts b/src/index.interfaces.ts
index 6d20015..fbaa9d4 100644
--- a/src/index.interfaces.ts
+++ b/src/index.interfaces.ts
@@ -35,5 +35,6 @@ module tagIt {
wordThatWasTagged: string;
serializedSelectionRange: string;
deserializedRange?: Range;
+ urlOfPageThatWasTagged: string;
}
}
diff --git a/src/menu/menu.controller.ts b/src/menu/menu.controller.ts
index 0377443..1f97198 100644
--- a/src/menu/menu.controller.ts
+++ b/src/menu/menu.controller.ts
@@ -39,7 +39,7 @@ module tagIt {
});
// Reload existing tags
- var tagsToLoad = this.tagStorageService.loadTags();
+ var tagsToLoad = this.tagStorageService.loadTagsForCurrentPage();
this.$log.debug('these tags were found in storage');
this.$log.debug(tagsToLoad);
@@ -58,11 +58,13 @@ module tagIt {
//initialize and save the new tag
var senseTag = this.webPageService.initializeNewTag(sense);
this.tagStorageService.saveTag(senseTag);
- this.backendService.sendTaggedDataToServer(senseTag);
+
+ // deactivate backendService for now.
+ // this.backendService.sendTaggedDataToServer(senseTag);
//re-add tags, with new tag. Clear menu options.
this.webPageService.readdTagsToPage(
- this.tagStorageService.loadTags()
+ this.tagStorageService.loadTagsForCurrentPage()
);
this.clearMenuVariables();
});
@@ -71,13 +73,31 @@ module tagIt {
/**
* Enables a clickable button to download tags as a json file.
*/
- downloadTags() {
+ downloadTagsForPage() {
if (typeof chrome === 'undefined') {
this.$log.debug('Did not find chrome facilities. Can\'t download.')
return; //do nothing
}
- var tags : ISenseTag[] = this.tagStorageService.loadTags();
- this.fileService.saveFile(tags);
+ this.fileService.saveFile(this.tagStorageService.loadTagsForCurrentPage());
+ }
+
+ downloadAllTagsForDomain() {
+ if (typeof chrome === 'undefined') {
+ this.$log.debug('Did not find chrome facilities. Can\'t download.')
+ return; //do nothing
+ }
+ this.fileService.saveFile(this.tagStorageService.loadAllTagsInLocalStorage());
+ }
+
+ /**
+ * Enables clickable link for removing tags.
+ */
+ removeTagsFromLocalStorage() {
+ if (confirm('Really delete tags from the current page?')) {
+ this.webPageService.removeAllTagsFromPage(() => {
+ this.tagStorageService.deleteTagsFromCurrentPage()
+ })
+ }
}
onWordSelectedEvent = (newWord: string) => {
@@ -93,7 +113,7 @@ module tagIt {
this.backendService.callServer(newWord)
.then((synsets: any) => {
this.$log.debug(synsets);
- this.senses = synsets.data.senses;;
+ this.senses = synsets.data.senses;
});
}
@@ -112,10 +132,5 @@ module tagIt {
this.senses = [];
}
- deleteTags() {
- this.tagStorageService.deleteTags();
- location.reload();
- }
-
}
}
diff --git a/src/plugin-specific/manifest.json b/src/plugin-specific/manifest.json
index b1f3497..bc26b98 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.8",
+ "version": "0.0.9",
"manifest_version": 2,
"icons": {
"16": "icon16.png",
diff --git a/src/services/file.service.ts b/src/services/file.service.ts
index 412a6c9..a572cd3 100644
--- a/src/services/file.service.ts
+++ b/src/services/file.service.ts
@@ -5,25 +5,30 @@
//Responsible for saving.
module tagIt {
- export class FileService {
+ export class FileService {
- $log: ng.ILogService;
+ $log: ng.ILogService;
+
+ /* @ngInject */
+ constructor($log: ng.ILogService) {
+ this.$log = $log;
+ }
+
+ saveFile(content: ISenseTag[]) {
+ var json = JSON.stringify(content, null, 2);
+ var blob = new Blob([json], { type: "application/json" });
+ var url = URL.createObjectURL(blob);
+ var a =