From cac01d555e1bfeaceca38a28404a66197389ffd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Norman=20Hauk=C3=A5s?= Date: Sun, 27 Sep 2015 20:47:23 +0200 Subject: [PATCH] is now able to get senses. Updated readme --- .gitignore | 1 - README.md | 7 +++++-- content_script.js | 26 ++++++++++++++++---------- example1.html | 30 ++++++++++++++++++++++++++++++ example1.menu.html | 25 +++++++++---------------- style.css | 17 +++++++++++------ 6 files changed, 71 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index 1e501e3..b512c09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -bower_components node_modules \ No newline at end of file diff --git a/README.md b/README.md index 135a957..6644250 100644 --- a/README.md +++ b/README.md @@ -4,5 +4,8 @@ A chrome extension for tagging words with semantic information. ## Development 1. To try it out, just [download this plugin](https://github.com/nilsnh/tag-youre-it/archive/master.zip). -2. Go inside chrome (or chromium) settings -> extensions. -3. Click "load unpacked extension" and add the unzipped project folder. \ No newline at end of file +2. You'll need to have installed [node.js](https://nodejs.org/en/). +3. Go inside the unzipped folder and run `npm install && npm install -g gulp`. In addition to installing development dependencies it will also install Gulp which is useful for active development. +4. Running `gulp serve` should show you the active prototype. + +**Important** A [workaround for CORS](https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?utm_source=chrome-app-launcher-info-dialog) is currently needed to communicate with the server. diff --git a/content_script.js b/content_script.js index 2344b30..111e086 100644 --- a/content_script.js +++ b/content_script.js @@ -20,14 +20,21 @@ $(document).ready(function () { } if (selectedText) { currentlySelectedWord = selectedText; - console.log(selectedText); - queryServer(selectedText); - } else { - currentlySelectedWord = ""; + displaySelectedWord(currentlySelectedWord); + getSensesFromServer(currentlySelectedWord); } } - function queryServer (word) { + function displaySelectedWord (word) { + $('#js-selected-word') + .replaceWith('' + word + ''); + } + + function getSensesFromServer (word) { + if (!word) { + return; + }; + var serverUrl = 'http://lexitags.dyndns.org/server/lexitags2/Semtags?data={"word":"QUERYTOREPLACE"}' $.get(serverUrl.replace('QUERYTOREPLACE', word), function (serverResponse) { console.log(serverResponse); @@ -37,7 +44,7 @@ $(document).ready(function () { function updateList (serverResponse) { var senses = serverResponse.senses; senses.reverse(); - var listTemplate = '
  • WORD. EXPLANATION
  • ' + var listTemplate = '
  • WORD. EXPLANATION
  • ' var htmlList = []; for (var i = senses.length - 1; i >= 0; i--) { htmlList.push(listTemplate @@ -50,8 +57,6 @@ $(document).ready(function () { htmlList.join('') + ''; - // debugger; - $('#senses').replaceWith(htmlList); } @@ -89,8 +94,9 @@ $(document).ready(function () { isMenuShown = false; } + // Beware order is significant + $('#js-show-menu').click(addMenu); addMenu(); - - // $('#js-show-menu').click(addMenu); + isMenuShown = true; }); \ No newline at end of file diff --git a/example1.html b/example1.html index e69341d..49c0016 100644 --- a/example1.html +++ b/example1.html @@ -36,6 +36,36 @@

    Rome has the status of a global city.[10][11][12] Rome ranked in 2014 as the 14th-most-visited city in the world, 3rd most visited in the European Union, and the most popular tourist attraction in Italy.[13] Its historic centre is listed by UNESCO as a World Heritage Site.[14] Monuments and museums such as the Vatican Museums and the Colosseum are among the world's most visited tourist destinations with both locations receiving millions of tourists a year. Rome hosted the 1960 Summer Olympics and is the seat of United Nations' Food and Agriculture Organization (FAO).

    +

    + The Triumph of Cleopatra, also known as Cleopatra's Arrival in Cilicia[1] and The Arrival of Cleopatra in Cilicia,[2] is an oil painting by English artist William Etty. It was first exhibited in 1821, and is now in the Lady Lever Art Gallery in Port Sunlight across the River Mersey from Liverpool. During the 1810s Etty had become widely respected among staff and students at the Royal Academy of Arts, in particular for his use of colour and ability to paint realistic flesh tones. Despite having exhibited at every Summer Exhibition since 1811 he attracted little commercial or critical interest. In 1820 he exhibited The Coral Finder, which showed nude figures on a gilded boat. This painting attracted the attention of Sir Francis Freeling, who commissioned a similar painting on a more ambitious scale. +

    +

    + Rome's history spans more than two and a half thousand years. While Roman mythology dates the founding of Rome at only around 753 BC, the site has been inhabited for much longer, making it one of the oldest continuously occupied sites in Europe.[5] The city's early population originated from a mix of Latins, Etruscans and Sabines. Eventually, the city successively became the capital of the Roman Kingdom, the Roman Republic and the Roman Empire, and is regarded as one of the birthplaces of Western civilization and as the first ever metropolis.[6] It is referred to as "Roma Aeterna" (The Eternal City) [7] and "Caput Mundi" (Capital of the World), two central notions in ancient Roman culture. +

    +

    + After the fall of the Western Empire, which marked the beginning of the Middle Ages, Rome slowly fell under the political control of the Papacy, which had settled in the city since the 1st century AD, until in the 8th century it became the capital of the Papal States, which lasted until 1870. +

    +

    + Beginning with the Renaissance, almost all the popes since Nicholas V (1422–55) pursued coherently along four hundred years an architectonic and urbanistic program aimed to make of the city the world's artistic and cultural center.[8] Due to that, Rome became first one of the major centers of the Italian Renaissance,[9] and then the birthplace of both the Baroque style and Neoclassicism. Famous artists, painters, sculptors and architects made Rome the center of their activity, creating masterpieces throughout the city. In 1871 Rome became the capital of the Kingdom of Italy, and in 1946 that of the Italian Republic. +

    +

    + Rome has the status of a global city.[10][11][12] Rome ranked in 2014 as the 14th-most-visited city in the world, 3rd most visited in the European Union, and the most popular tourist attraction in Italy.[13] Its historic centre is listed by UNESCO as a World Heritage Site.[14] Monuments and museums such as the Vatican Museums and the Colosseum are among the world's most visited tourist destinations with both locations receiving millions of tourists a year. Rome hosted the 1960 Summer Olympics and is the seat of United Nations' Food and Agriculture Organization (FAO). +

    +

    + The Triumph of Cleopatra, also known as Cleopatra's Arrival in Cilicia[1] and The Arrival of Cleopatra in Cilicia,[2] is an oil painting by English artist William Etty. It was first exhibited in 1821, and is now in the Lady Lever Art Gallery in Port Sunlight across the River Mersey from Liverpool. During the 1810s Etty had become widely respected among staff and students at the Royal Academy of Arts, in particular for his use of colour and ability to paint realistic flesh tones. Despite having exhibited at every Summer Exhibition since 1811 he attracted little commercial or critical interest. In 1820 he exhibited The Coral Finder, which showed nude figures on a gilded boat. This painting attracted the attention of Sir Francis Freeling, who commissioned a similar painting on a more ambitious scale. +

    +

    + Rome's history spans more than two and a half thousand years. While Roman mythology dates the founding of Rome at only around 753 BC, the site has been inhabited for much longer, making it one of the oldest continuously occupied sites in Europe.[5] The city's early population originated from a mix of Latins, Etruscans and Sabines. Eventually, the city successively became the capital of the Roman Kingdom, the Roman Republic and the Roman Empire, and is regarded as one of the birthplaces of Western civilization and as the first ever metropolis.[6] It is referred to as "Roma Aeterna" (The Eternal City) [7] and "Caput Mundi" (Capital of the World), two central notions in ancient Roman culture. +

    +

    + After the fall of the Western Empire, which marked the beginning of the Middle Ages, Rome slowly fell under the political control of the Papacy, which had settled in the city since the 1st century AD, until in the 8th century it became the capital of the Papal States, which lasted until 1870. +

    +

    + Beginning with the Renaissance, almost all the popes since Nicholas V (1422–55) pursued coherently along four hundred years an architectonic and urbanistic program aimed to make of the city the world's artistic and cultural center.[8] Due to that, Rome became first one of the major centers of the Italian Renaissance,[9] and then the birthplace of both the Baroque style and Neoclassicism. Famous artists, painters, sculptors and architects made Rome the center of their activity, creating masterpieces throughout the city. In 1871 Rome became the capital of the Kingdom of Italy, and in 1946 that of the Italian Republic. +

    +

    + Rome has the status of a global city.[10][11][12] Rome ranked in 2014 as the 14th-most-visited city in the world, 3rd most visited in the European Union, and the most popular tourist attraction in Italy.[13] Its historic centre is listed by UNESCO as a World Heritage Site.[14] Monuments and museums such as the Vatican Museums and the Colosseum are among the world's most visited tourist destinations with both locations receiving millions of tourists a year. Rome hosted the 1960 Summer Olympics and is the seat of United Nations' Food and Agriculture Organization (FAO). +

    \ No newline at end of file diff --git a/example1.menu.html b/example1.menu.html index cf34ea3..a78413e 100644 --- a/example1.menu.html +++ b/example1.menu.html @@ -1,30 +1,23 @@
    -
    - -

    Tag you're it

    Select a word to tag with a semantic tag.

    -

    Currently selected word:

    +

    + Currently selected word: +

    + + +
    \ No newline at end of file diff --git a/style.css b/style.css index 3530f06..c1b9b78 100644 --- a/style.css +++ b/style.css @@ -1,12 +1,8 @@ -.u-add-margin-top { - margin-top: 20px; -} - .tagit-body { width: 70%; position: absolute; right: 0; - padding-left: 5px; + padding: 10px; } .tagit-menu { @@ -21,7 +17,16 @@ } .tagit-menu ul { - padding-left: 15px; + padding-left: 0px; margin-top: 10px; } +.tagit-menu li { + padding: 5px; +} + +.tagit-menu li:hover { + background-color: #eee; + cursor: pointer; +} +