1.4.0 • Published 6 years ago

octopinion v1.4.0

Weekly downloads
2
License
ISC
Repository
-
Last release
6 years ago

WHAT IS IT

octopinion is a very basic and simple npm package that will help you integrating Octopinion in your website. Octopinon is a tool designed to analyse reviews in your web and retrieve very useful information from them.

HOW TO USE

  • Install the package.
  • Genrate the source file from product key.
  • Use generated js file in the client.

Install the package

npm install --save octopinion
// package.json
{
  "dependencies": {
    "octo-npm": "^1.**"
  }
}

Import it in the server.

  • Using ES6
import Octo from 'octopinion';
  • Using ES5
var Octo = require("octopinion");

MAKE IT AVAILABLE IN THE BROWSER

Generate source file from product key, so that you make octopinion available for the browser.

The following code needs to be run in the serve and will generate the source file used in the client. Place it within your project.

new Octo('key','username', 'path');
  • param key -> Find the key in your Octopinion user dashboard.
  • param username -> Your username in Octopinion.
  • param path -> a relative path. For example './' where the file is going to be built. './' will generate the js client file in the same directory where you are executing the function.

Now import the js in your html:

<script src="./bundleBuild.js"></script>

<script>
    
    octoClient ...
</script>

USING TYPESCRIPT

When running the Octo constructor you will also have available the client. Hence, export the client to in order be available in client side.

//Get an instance of Octo in the server side and export only the client.
const octo = new Octo('key','username', 'path');
...
//set options
...
export default octoClient = octopinion.octoClient;
//Import the client and use it
import octoClient from 'the above ts file';

NOTE: Look at the typings in octopinon typings package

Insert reviews built box where ever.

Have a look into test/test.html in order see an example.

   /*
    * Pass the element where you want to inject the reviews box and the section where you want to link new reviews.
    */
    octoClient.insertInto(document.getElementById('where'), 'some_product_section');

CHANGE PARAMETERS

  • userKey -> Key identifying the logged user.
    /**
     * Add the user that is loggged in your web. 
     * If you have a user logged, should be this one.
     * Default value is annonymous.
     */
    octoClient.setUserLoggedKey('user-logged-name');
  • pageSize -> Number of reviews per page.
    /**
     * Change the page size. Default page size is 20 elements.
     */
    octoClient.setPageSize(3);
  • insertLastReviews -> If last reviews have to be displayed.
    /**
     * Insert last reviews box. 
     * Default value is true.
     */
    octoClient.setInsertLastReviews(true);
  • hideWhenNotLogged -> It will hide the textarea to set reviews when userkey is not set.
    /**
     * Hides the textarea when userkey is not set
     */
    octoClient.setHideWhenNotLogged(true);
  • disableWhenNotLogged -> It will disable the textarea to set reviews when userkey is not set. If the property above is set to true it will override this one, hence, it will not show the textarea if the user key is not set.
    /**
     * Disables the textarea when userkey is not set.
     */
    octoClient.setDisableWhenNotLogged(true);
  • dateFormat -> Change the date format for the reviews list. The default is 'DD MMM YYYY'
    octoClient.setDateFormat('DD MM YYYY');
  • showMoreApproach -> The dafault uses this approach. When set to fasle it will render four buttons. First, next, previous, last.
    octoClient.setShowMoreApproach(true);
  • It is possible to change all properties above usin setOptions function.
    /**
     * Change all properties above.
     */
    octoClient.setOptions({pageSize: 3, insertLastReviews: true, userKey: 'logged-user-name', disableWhenNotLogged: true, hideWhenNotLogged: true, dateFormat: 'DD MM YYYY', showMoreApproach: true});
  • callback -> Callback function to be executed when a new review has been analised.
    /**
     * Function to be executed when a new review has been analized.
     * 
     * interface Founds {
     *   word: string; //Word might be empty if no noun is related to the positive/negative.
     * }
     * 
     * interface AnalizedResponse {
     *  status: string;
     *  message: string;
     *  positiveFound: Founds[];
     *  negativeFound: Founds[];
     *  processedText: string;
     * }
     */
    octoClient.setCallback(function(data){console.log('Analized response', data);});

Note: Have a look at the examples in test/test.html

LIMITATIONS

  • Paginating only with next, previous, last and first buttons or using a showmore button.
  • Using icons from font-awesome.
  • CSS classes are not changeable.
  • Only working for ES6
1.4.0

6 years ago

1.3.9

6 years ago

1.3.8

6 years ago

1.3.7

6 years ago

1.3.6

6 years ago

1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.9

7 years ago

1.2.8

7 years ago

1.2.7

7 years ago

1.2.6

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago