/mad-news

Dramatic news generator

Primary LanguageTypeScriptCreative Commons Zero v1.0 UniversalCC0-1.0

Mad-News Downloads NPM version

Dramatic news generator

How to use it:

HTML:

  <script type="text/javascript" src="https://unpkg.com/mad-news/lib/index.js"></script>
  var navigatorLang = navigator.language || navigator.userLanguage || '';
  var language = navigatorLang.toLowerCase().indexOf('ru') > -1 ? 'ru' : 'en';
  
  document.addEventListener('DOMContentLoaded', function (event) {
      var madness = new MadNews(language);
      document.querySelector('.person').innerText = madness.person;
      document.querySelector('.action').innerText = madness.action;
      document.querySelector('.conclusion').innerText = madness.conclusion;
  });

Node.js (or modern frontend):

  npm install mad-news
  const navigatorLang = navigator.language || navigator.userLanguage || '';
  const language = navigatorLang.toLowerCase().indexOf('ru') > -1 ? 'ru' : 'en';
  
  const MadNews = require('mad-news');
  const madness = new MadNews(language);
  
  console.log(madness.person);
  console.log(madness.action);
  console.log(madness.conclusion);
  // or
  console.log(madness.fullString);
  
  // Generate new Madness:
  madness.generate();

Typescript (with "esModuleInterop": true):

  import MadNews from 'mad-news';
  
  const language = 'en'; // currently there are only 'ru' and 'en' dictionaries
  const madness = new MadNews(language);
  
  console.log(madness.person);
  console.log(madness.action);
  console.log(madness.conclusion);
  // or
  console.log(madness.fullString);
  
  // Generate new Madness:
  madness.generate();