コード例 #1
0
ファイル: basil.js プロジェクト: IvoVargas/devkit
// Display the glorious SDK header.
function displayHeader () {
	var opts = [
		"Mobile social platform html5 javascript multiplayer game platform!",
		"camelCase or __score__?",
		"absolutely no jquery (only sizzle).",
		"First games. Then freeways. Then the USA.",
		"Building a time machine, one function at a time.",
		"Monkey see monkey do...",
		"Coffee and cheerios.",
		"Did you run submodule update? Sometimes that fixes it.",
		"Like fireworks in a shed.",
		"throw new NotAndWillNeverBeImplementedException()",
		"Now we know. Noooow we know. We know now.",
		"Hate the game.",
		"Syms and shims",
		"Zoinks!",
		"Using DHTML technologies",
		"Life is squill.Pane",
		"Needs more ketchup."
	].sort(function () { return Math.random() - 0.5; });

	var version = common.sdkVersion.toString();
	var versionLength = version.length; //clc adds escape chars
	version = clc.yellow(version);

	var colouredGCText = clc.whiteBright("{{") + clc.cyanBright(" Game Closure SDK ") + clc.whiteBright("}}");
	console.log([
		"============================================================",
		"                   " + colouredGCText + "                   ",
		"                                                            ".substr(0, (60-versionLength)/2) + version,
		"                                                            ".substr(0, (60-opts[0].length)/2) + opts[0],
		"------------------------------------------------------------",
		""].join('\n'));
}
コード例 #2
0
ファイル: client.js プロジェクト: Pomax/mahjong
 this.players.forEach(player => {
   let wind = Tiles.getPositionWind(player.position);
   let information = [ colors.whiteBright.bgBlue('${wind}') + colors.whiteBright(':')];
   if (player.position === this.currentGame.position) {
     information.push( colors.yellowBright('${player.name}') + colors.whiteBright(':'));
     information = information.concat(this.getOurTileSituation());
   } else {
     information.push( colors.green('${player.name}') + colors.whiteBright(':'));
     information = information.concat(this.getTheirTileSituation(player));
   }
   tileSituation = tileSituation.concat(information.join(' '));
 });
コード例 #3
0
ファイル: index.js プロジェクト: royhersh/oyLog
 function _printErrorToScreen() {
     var d = new Date();
     var now = d.toLocaleTimeString();
     switch (arguments.length) {
         case 1:
              var msg = arguments[0];
              var toLog = msg;
              break;
         case 2:
              var msg = arguments[0];
              var inPurple = arguments[1];
              var toLog = msg + color.magentaBright(inPurple);
     }
     console.log (color.whiteBright('[') + color.blackBright(now) + color.whiteBright('] ') + color.whiteBright.bgRed("ERROR") + ' ' + color.cyanBright(self.config.appName + ": ") + toLog);
 }    
コード例 #4
0
ファイル: index.js プロジェクト: royhersh/oyLog
 function _printToScreen() {
     var d = new Date();
     var now = d.toLocaleTimeString();
     switch (arguments.length) {
         case 1:
              var msg = arguments[0];
              var toLog = color.white(msg);
              break;
         case 2:
              var action = arguments[0];
              var msg = arguments[1];
              var toLog = color.greenBright(""+ action +": ") + color.white(msg);
     }
     console.log (color.whiteBright('[') + color.blackBright(now) + color.whiteBright('] ') + color.cyanBright(self.config.appName + ": ") + toLog);
 }
コード例 #5
0
ファイル: Chat.js プロジェクト: cookiezeater/Mikuia
		client.on('message#', function(nick, to, text, message) {
			Mikuia.Chat.handleMessage(nick, to, text)
			if(nick == Mikuia.settings.plugins.base.admin.toLowerCase()) {
				Mikuia.Log.info('(' + cli.greenBright(to) + ') ' + cli.cyan(nick) + ': ' + cli.whiteBright(text))
			} else {
				Mikuia.Log.info('(' + cli.greenBright(to) + ') ' + cli.yellowBright(nick) + ': ' + cli.whiteBright(text))
			}
		})
コード例 #6
0
        longSentences.forEach(function(longSentence) {

          // print each long sentence on a new line
          console.log(clc.whiteBright(longSentence));

          console.log(' ');

        });
コード例 #7
0
ファイル: controller.js プロジェクト: aurodionov/jstalk
	this.onStanzaHandler = function (stanza) {
		try {

			for (var i = 0; i < self.handlers.length; i++) {
				var handler = self.handlers[i];
				if (handler.handleStanza(stanza)) {
					return;
				}
			}

			// initial feature response:
			var query = stanza.getChild('query');
			if (query && query.attrs.xmlns === 'http://jabber.org/protocol/disco#info') {
				var features = query.getChildren('feature');
				var identity = query.getChild('identity');
				// server identity:
				if (identity) {
					console.log('Welcome to ' + identity.attrs.name);
					console.log('Server has following features:');
					for (var i=0; i<features.length; i++) {
						var featureName = features[i].attrs.var;
						emitter.emit('feature', featureName);
						self.handleFeature(featureName);
						console.log('  ' + featureName);
					}
					return;
				} else {
					// service discovery:
					var from = stanza.attrs.from;
					var id = stanza.attrs.id;
					var r = new Client.Stanza('iq', {
						type: 'result',
						from: self.jid,
						to: from,
						id: id
					});
					var q = r.c('query', {xmlns:'http://jabber.org/protocol/disco#info'});
					q.c('identity', {category:'automation', type:'rpc'});
					q.c('feature', {'var':'jabber:iq:rpc'});
					self.xmpp.send(r);
					return;
				}
			}
	
		} catch (e) {
			console.log(clc.red(e.stack));
		}
		// show unhandled stanzas:
		var attString = "";
		for (var s in stanza.attrs) {
			if (!stanza.attrs.hasOwnProperty(s)) continue;
			attString += ' ' + s + '=' + stanza[s];
		}
		self.log(clc.whiteBright('['+stanza.name+']') + attString);
		self.logXml(stanza.toString());
	}
コード例 #8
0
ファイル: client.js プロジェクト: Pomax/mahjong
  constructor(name, uuid, port, afterBinding) {
    super(name, uuid, port, afterBinding);

    console.log('');
    console.log(colors.yellowBright('  ███╗   ███╗ █████╗ ██╗  ██╗     ██╗ ██████╗ ███╗   ██╗ ██████╗ '));
    console.log(colors.yellowBright('  ████╗ ████║██╔══██╗██║  ██║     ██║██╔═══██╗████╗  ██║██╔════╝ '));
    console.log(colors.yellowBright('  ██╔████╔██║███████║███████║     ██║██║   ██║██╔██╗ ██║██║  ███╗'));
    console.log(colors.yellowBright('  ██║╚██╔╝██║██╔══██║██╔══██║██   ██║██║   ██║██║╚██╗██║██║   ██║'));
    console.log(colors.yellowBright('  ██║ ╚═╝ ██║██║  ██║██║  ██║╚█████╔╝╚██████╔╝██║ ╚████║╚██████╔╝'));
    console.log(colors.yellowBright('  ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚════╝  ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝ '));
    console.log(colors.whiteBright('                                                  Version ${version}\n'));
  }
コード例 #9
0
const formatValue = (value) => (
    `${color.whiteBright(value.toLocaleString().padStart(8))}\n`
);
コード例 #10
0
ファイル: cli.js プロジェクト: joeromero/quickstart
module.exports = function(argv) {

  var root = argv.root;

  if (argv.config == null) argv.config = pathogen.resolve(root, './quickstart.json');

  if (argv.o != null) {
    argv.output = argv.o;
    delete argv.o;
  }

  if (argv.parsers) {
    var parsers = {};
    if (!isArray(argv.parsers)) argv.parsers = [argv.parsers];
    argv.parsers.forEach(function(parser) {
      var parts = parser.split('=');
      parsers[parts[0].trim()] = parts[1].trim();
    });
    argv.parsers = parsers;
  }

  if (argv.transforms) {
    if (!isArray(argv.transforms)) argv.transforms = [argv.transforms];
  }

  var jsonConf;

  if (/\.json$/.test(argv.config)) try {
    jsonConf = requireRelative(pathogen(argv.config), root);
  } catch(e) {}

  var options = {};

  // augment options with config file, if specified and valid
  if (jsonConf) mixIn(options, jsonConf);

  // augment options with argv
  forIn(argv, function(value, name) {
    if (name.length > 1 && name !== 'config' && name !== 'version' && name !== 'help') {
      options[camelCase(name)] = value;
    }
  });

  if (!options.parsers) options.parsers = {};
  if (!options.transforms) options.transforms = [];

  // set warnings to true by default
  if (options.warnings == null) options.warnings = true;

  // clean up options.output
  if (options.output == null) options.output = true;

  // # help konsole

  var help = new Konsole('log');

  var logo = 'QuickStart ' + clc.white('v' + manifest.version);

  help.group(logo);
  help.write('');

  help.write(clc.green('--self       '),
    'compile quickstart for browser compilation. defaults to', clc.red('false'));

  help.write(clc.green('--root       '),
    'use this as the root of each path. defaults to', clc.blue(pathogen.cwd()));

  help.write(clc.green('--main       '),
    'override the default entry point. defaults to', clc.red('false'));

  help.write(clc.green('--output, -o '),
    'output the compiled source to a file or STDOUT. defaults to', clc.blue('STDOUT'));

  help.write(clc.green('--source-map '),
    'output the source map to a file, STDOUT or inline. defaults to', clc.red('false'));

  help.write(clc.green('--ast        '),
    'output the Esprima generated AST to a file or STDOUT. defaults to', clc.red('false'));

  help.write(clc.green('--optimize   '),
    'feed transforms with an optimized ast. defaults to', clc.red('false'));

  help.write(clc.green('--compress   '),
    'compress the resulting AST using esmangle. defaults to', clc.red('false'));

  help.write(clc.green('--runtime    '),
    'specify a custom runtime. defaults to', clc.red('false'));

  help.write(clc.green('--config     '),
    'specify a configuration json file to augment command line options. defaults to', clc.red('false'));

  help.write(clc.green('--warnings   '),
    'display warning messages. defaults to', clc.blue('true'));

  help.write(clc.green('--help, -h   '),
    'display this help screen');

  help.write(clc.green('--version, -v'),
    'display the current version');

  help.write('');

  help.groupEnd(); // QuickStart

  // # help command

  var printOptions = {
    last: clc.whiteBright('└─'),
    item: clc.whiteBright('├─'),
    join: clc.whiteBright('  '),
    line: clc.whiteBright('│'),
    spcr: clc.whiteBright(' ')
  };

  if (argv.help || argv.h) {
    help.print(' ');
    process.exit(0);
  }

  // # version command

  if (argv.version || argv.v) {
    console.log('v' + manifest.version);
    process.exit(0);
  }

  // # beep beep

  var beep = function() {
    process.stderr.write('\x07'); // beep!
  };

  // # format messages

  function format(type, statement) {

    if (type === 'group' || type === 'groupCollapsed') {
      if ((/warning/i).test(statement)) {
        if (options.warnings) konsole.group(clc.yellow(statement));
      } else if ((/error/i).test(statement)) {
        konsole.group(clc.red(statement));
      } else {
        konsole.group(statement);
      }
      return;
    }

    if (type === 'groupEnd') {
      konsole.groupEnd();
      return;
    }

    var message, source, line, column, id;

    message = statement.message;

    id = statement.id;

    source = statement.source;
    line = statement.line;
    column = statement.column;

    if (source != null) {
      source = clc.green(pathogen.resolve(root, source));
      if (line != null) {
        source += ' on line ' + line;
        if (column != null) {
          source += ', column' + column;
        }
      }
      message = message ? [message, source].join(' ') : source;
    }

    switch (type) {
      case 'error':
        konsole.write(clc.red(id + ': ') + message);
      break;
      case 'warn':
        if (options.warnings) konsole.write(clc.yellow(id + ': ') + message);
      break;
      case 'time':
        konsole.write(clc.blue(id + ': ') + message);
      break;
      default:
        konsole.write(id + ': ' + message);
      break;
    }

  }

  var messages = new Messages(logo);
  var konsole = new Konsole('error');

  var compilation = messages.group('Compilation');
  compilation.time('time');

  var optionsGroup = messages.group('Options');
  forIn(options, function(value, key) {
    var string = JSON.stringify(value);
    if (string) optionsGroup.log({ id: key, message: string });
  });

  compile(options, messages).then(function(compiled) {

    var ast = compiled.ast;
    var source = compiled.source;
    var sourceMap = compiled.sourceMap;

    if (source) source = '/* compiled with ' + manifest.name + '@' + manifest.version + ' */' + source;

    if (options.output && options.sourceMap === true) {
      sourceMap = JSON.stringify(sourceMap);
      source += '\n//# sourceMappingURL=data:application/json;base64,' + new Buffer(sourceMap).toString('base64');
      compilation.log({ id: 'source map', message: 'embedded' });
    }

    if (isString(options.sourceMap)) {
      var sourceMapPath = pathogen.resolve(root, options.sourceMap);
      fs.writeFileSync(pathogen.sys(sourceMapPath), JSON.stringify(sourceMap));
      if (options.output) source += '\n//# sourceMappingURL=' + pathogen.relative(root, sourceMapPath);

      compilation.log({ id: 'sourceMap', message: 'file written', source: pathogen.relative(root, sourceMapPath) });
    }

    if (isString(options.output)) {
      var sourcePath = pathogen.sys(pathogen.resolve(root, options.output));
      fs.writeFileSync(sourcePath, source);
      compilation.log({ id: 'source', message: 'file written', source: pathogen.relative(root, sourcePath) });
    }

    if (isString(options.ast)) {
      var astPath = pathogen.sys(pathogen.resolve(root, options.ast));
      fs.writeFileSync(astPath, JSON.stringify(ast));

      compilation.log({ id: 'ast', message: 'file written', source: pathogen.relative(root, astPath) });
    }

    if (options.ast === true) {
      console.log(JSON.stringify(ast));

      compilation.log({ id: 'ast', message: 'stdout' });
    } else if (options.output === true) {
      console.log(source);

      compilation.log({ id: 'source', message: 'stdout' });
    } else if (options.sourceMap === true) {
      console.log(sourceMap);

      compilation.log({ id: 'sourceMap', message: 'stdout' });
    }

    compilation.timeEnd('time', options.self ? 'compiled itself in' : 'compiled in', true, true);

    messages.print(format);
    konsole.print(printOptions);
    messages.reset();

    beep();

  }).catch(function(error) {

    messages.print(format);
    konsole.print(printOptions);

    beep(); beep(); // beepbeep!
    process.nextTick(function() {
      throw error;
    });
    return;
  });

};
コード例 #11
0
ファイル: index.js プロジェクト: austinsc/sails-raven
GLOBAL.peek4 = function peek4(val) {
  console.log(clic.whiteBright(look(val)));
};
コード例 #12
0
ファイル: gettext.js プロジェクト: Vlad-OnNet/binary-static
const formatValue = (value, comment, sign) => (
    `${sign ? color.cyan(` ${sign} `) : ''}${color.whiteBright(value.toLocaleString().padStart(sign ? 5 : 8))} ${` (${comment})\n`}`
);
コード例 #13
0
ファイル: print.js プロジェクト: BenBBear/Zeta
var notice = function(s) {
    console.log('[' + clc.blue('notice') + ']  ' + clc.whiteBright(s));
};
コード例 #14
0
ファイル: Chat.js プロジェクト: cookiezeater/Mikuia
		rateLimiter.removeTokens(1, function(err, remainingRequests) {
			client.say(target, message)
			Mikuia.Log.info('(' + cli.greenBright(target) + ') ' + cli.magentaBright('mikuia') + ' (' + cli.magenta(Math.round(remainingRequests)) + '): ' + cli.whiteBright(message))
		})
コード例 #15
0
  function (err, window) {

    // declare vars
    var allSentences = [];
    var allWords = [];
    var allSyllables = 0;
    var longWords = [];
    var longSentences = [];

    // get an array of all paragraphs in the resource
    var paragraphs = [].slice
                       .call(window.document.querySelectorAll('p'))

    // iterate over the paragraphs array
    paragraphs.forEach(function(paragraph) {

      // sentence regex
      var reg = /(?!Mrs?\.|Jr\.|Dr\.|Sr\.|Prof\.)(\b\S+[.?!]["']?)\s/g;

      // dividing the text content into sentences
      var sentences = paragraph.textContent
                               .replace(reg, '$1#').split(/#/);

      // iterate over the sentences array
      sentences.forEach(function(sentence) {

        // add each sentence to the master sentences array
        allSentences.push(sentence);

        // divide the sentence into a words array
        var words = sentence.replace(/([,:;.?!—])/g, " ")
                            .split(' ');

        if (words.length > 35) {

          longSentences.push(sentence);

        }

        // interate over the words
        words.forEach(function(word) {

          // add each word to the master words array
          allWords.push(word);

          // count the syllables of the word
          allSyllables += syllable(word);

          // if there's more than three syllables...
          if (syllable(word) > 4) {

            // add the word to the long words array
            longWords.push(word);

          }

        });

      });

    });

    // get the average sentence length
    var ASL = allWords.length / allSentences.length;
    // get the average number of syllables per word
    var ASW = allSyllables / allWords.length;
    // use the Flesch Reading Ease formula to get the score
    var score = 206.835 - (1.015 * ASL) - (84.6 * ASW);

    // Declare notes var
    var notes;

    // choose note from en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests
    if (score) {
        notes = 'Very difficult to read. Best understood by university graduates.';
    }

    if (score > 30) {
        notes = 'Difficult to read.';
    }

    if (score > 50) {
        notes = 'Fairly difficult to read.';
    }

    if (score > 60) {
        notes = 'Plain English. Easily understood by 13 to 15-year-old students.';
    }

    if (score > 70) {
        notes = 'Fairly easy to read.';
    }

    if (score > 80) {
        notes = 'Easy to read. Conversational English for consumers.';
    }

    if (score > 90) {
        notes = 'Very easy to read. Easily understood by an average 11-year-old student.';
    }

    if (score > 90) {
        notes = 'Very easy to read. Easily understood by an average 11-year-old student.';
    }


    // output results
    console.log(' ');
    console.log(clc.yellowBright('✎✎✎✎✎✎✎✎✎✎ Readability ✎✎✎✎✎✎✎✎✎✎'));

    if (isNaN(score)) {

      console.log(' ');

      console.log(clc.redBright('Error: The content could not be tested. Check the file or URL you supplied.'));

      console.log(' ');

    } else {

      console.log(' ');

      console.log(clc.blueBright('Flesch Reading Ease:'), clc.whiteBright(Math.round(score)+'/100'));

      console.log(' ');

      console.log(clc.blueBright('Notes:'), clc.whiteBright(notes));

      console.log(' ');

      if (longWords.length) {

        console.log(clc.blueBright('Long words:'), clc.whiteBright(longWords.join(', ')));

      }

      console.log(' ');

      // if there are any long sentences
      if (longSentences.length) {

        console.log(clc.blueBright('Long sentences:'));

        longSentences.forEach(function(longSentence) {

          // print each long sentence on a new line
          console.log(clc.whiteBright(longSentence));

          console.log(' ');

        });
      }
    }

    console.log(clc.yellowBright('✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎✎'));

    console.log(' ');

  }