code stringlengths 1 2.08M | language stringclasses 1
value |
|---|---|
var express=require('express');
var app = express();
var contadores = new Array;
var puerto=process.argv[2]?process.argv[2]:8080;
app.get('/', function (req, res) {
res.send('Portada');
});
app.put('/contador/:id', function( req,res ) {
contadores[req.params.id] = 0;
res.send( { creado: req.params.id } );... | JavaScript |
#!/usr/bin/node
var db = require('nano')('http://aes92.iriscouch.com/')
.use("bloquec3-2");
db.view('ciudades','ciudades',{ group: true }, function( error, http_body ) {
console.log(http_body);
} );
| JavaScript |
var fs = require('fs');
var express=require('express');
var app = express();
var contadores = new Array;
var portada = fs.readFileSync('sumar_formulario26.html','utf8');
var veces=new Array;
app.get('/', function (req, res) {
res.send(portada);
});
app.get('/js/:page', function (req, res) {
var js = fs.read... | JavaScript |
#!/home/super/Escritorio/js-1.8.5/js/src/js
function tabla(f,c) {
var tabla="table";
var celda="td";
var fila="tr";
print( "<"+tabla+">");
for (i=1; i<=f; i++ ) {
print( "<"+fila+">");
for ( j=1; j<=c; j++ ) {
print ("<"+celda+"></"+celda+">");
}
print ("</"+fila+">\n");
}
print ("</"+tabla+">");
}
tabla... | JavaScript |
// Definición de la clase Partido
function Partido(local,visitante) {
this.local = local;
this.visitante=visitante;
this.resultado=null;
this.setResultado = setResultado;
this.toString = toString;
}
function setResultado( esteResultado ) {
if ( esteResultado == '1' || esteResultado=='x' || esteResultado=='... | JavaScript |
#!/home/super/Escritorio/js-1.8.5/js/src/js
// Clase Fila:
// Constructor de la clase Fila.
function Fila(columnas){
this.columnas = columnas;
this.celdasFila = celdasFila;
}
//Método para generar las celdas de una fila:
function celdasFila(){
for(j=1; j<= this.columnas; j++){
// Po... | JavaScript |
function crear() {
request = new XMLHttpRequest();
var contador=document.getElementById('contador').value;
var peticion_str = '/contador/crea/'+contador;
request.open('POST', peticion_str , true);
request.onreadystatechange= escribe_resultado ;
request.send(null);
}
function incrementar() {
request = ne... | JavaScript |
var cradle = require('cradle');
var db = new(cradle.Connection)('http://aes92.iriscouch.com').database('bloquec7');
db.save('_design/disenoc7', {
views: {
vistac7: {
map: function(doc) {
if (doc.x) {
emit(doc.x,doc);
}
... | JavaScript |
#!/home/super/Escritorio/js-1.8.5/js/src/js
load('Partido.js');
var equipos= new Array('Madrid', 'Barça', 'Atleti', 'Geta', 'Betis', 'Depor', 'Sevilla', 'Graná');
function jornada( estosEquipos ) {
var equiposAqui = new Array;
equiposAqui = equiposAqui.concat(estosEquipos);
var midsize = equiposAqui.length/2... | JavaScript |
var request = require('request');
var url ='http://api.openweathermap.org/data/2.1/find/name?q=granada';
request(url, function (err, res, body) {
if (!err && res.statusCode == 200) {
var resultado=JSON.parse(body);
for(var i = 0; i< resultado.list.length; i++){
var cadena="\nID: "+resultado.list... | JavaScript |
#!/usr/bin/node
var fs = require('fs');
fs.readFile('quiniela.datos', 'utf8',
function(err,datos) {
if (err) {
return console.log(err);
};
var partidos = datos.split("\n");
for ( var f in partidos ) {
var cachos = partidos[f].split(" ");
var partido = { 'local': cachos[0],
'... | JavaScript |
var http=require('http');
var puerto=process.argv[2]?process.argv[2]:8080;
http.createServer(function (req, res) {
var split_url=req.url.split("/");
if ( split_url[1] == '' ) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Portada');
} else if ( split_url[1] == 'proc' ) {
re... | JavaScript |
var app = require('express')()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server);
server.listen(8080);
app.get('/', function (req, res) {
res.sendfile(__dirname +'/index.html');
});
io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
... | JavaScript |
var cradle = require('cradle');
var db = new(cradle.Connection)().database('bloquec8');
db.save('_design/disenoc8', {
views: {
vistac8: {
map: function(doc) {
var buscar = 'ciudad';
if (doc.interes) {
if ( doc.... | JavaScript |
#!/home/super/Escritorio/js-1.8.5/js/src/js
// Definición de la clase Partido
function Partido(local,visitante) {
this.local = local;
this.visitante=visitante;
this.resultado=null;
}
var equipos= new Array('Madrid', 'Barça', 'Atleti', 'Geta', 'Betis', 'Depor', 'Sevilla', 'Graná', 'Almería', 'Córdoba');
var... | JavaScript |
function crear() {
var contador=$('#contador').val();
$.post('/contador/crea/'+contador, function(data) {
$('#Resultado').html('El contador ' + contador + ' tiene un valor de ' + data.resultado);
});
$(document).ready(escribe_resultado() );
}
function incrementar() {
var contador=$('#contador').val();
... | JavaScript |
fs = require('fs');
var resultados_file = process.argv[2],
url = process.argv[3],
db_name=process.argv[4],
db = require('nano')(url).use(db_name);
fs.readFile(resultados_file, 'utf8',
function(err,datos) {
if (err) {
return console.log(err);
};
var filas = datos.split("\n");
var resultados = new Arr... | JavaScript |
var rest = require('restler');
var url = 'http://127.0.0.1:8080/contador/suma';
rest.get(url + "/" + process.argv[2] + "/" + process.argv[3]).on('complete', function( data ) {
console.log( data );
} );
| JavaScript |
function calcula() {
document.getElementById('texto').innerHTML= "<center>Se están procesando claves wpa...<br><br><img src='http://server-jsgrid.rhcloud.com/image/loadpat.gif'><br><img src='http://server-jsgrid.rhcloud.com/image/hack.gif'></center>"
oeee();
} | JavaScript |
var request;
function signup() {
request = new XMLHttpRequest();
var nombre=document.getElementById('nombre_signup').value;
var mail=document.getElementById('mail_signup').value;
var twitter=document.getElementById('twitter_signup').value;
if(twitter == '') twitter = 'nada';
if(nombre == '' || mail == '') {... | JavaScript |
function getWpaPskKeyFromPassphrase(pass, salt) {
/* pad string to 64 bytes and convert to 16 32-bit words */
function stringtowords(s, padi) {
/* return a 80-word array for later use in the SHA1 code */
var z = new Array(80);
var j = -1, k = 0;
var n = s.length;
for (var i = 0; i < 64; i++) {
... | JavaScript |
var socket = io.connect();
var datos_mic = '';
socket.on('news', function (data) {
datos_mic = JSON.parse(data);//se guarda el MIC a crackear.
});
socket.on('disconnect', function(){
var temp=document.URL;
temp=temp.substring(0,temp.indexOf('/'));
document.location.href=temp+"/final";
});
socket.on('dat... | JavaScript |
//el modulo de gestion de los clientes recibe la variable JSON llamada myJSONClient asì estructurada:
exports.myJSONClient = {
"nombre" : "<nombre_cliente>",
"id" : "<id_cliente>",
"mail" : "<mail_cliente>",
"twitter" : "<twitter_cliente>",
"estado" : "<estad_cliente>",
"intervalo" : "<intervalo_cliente>",
... | JavaScript |
//gestionclientes.js
//para ver la base de dato en mongo teclar:
//mongo
//use mongoapp
//db.clientes.find()
var db = require('mongojs').connect('localhost/mongoapp', ['clientes']);//url de la base de datos y collections (los llamo 'clientes')
/*var gestion = function(myJSON,vector_intervalo, callback) {
var... | JavaScript |
fs = require('fs');
//La funcion es sensible a la estructura del archivo. Se presupone una concreta, pero si cambia no se leerá correctamente.
function leerCaptura(fichero,cb){
var ANonce="";
var SNonce="";
var MIC="";
var EAPOLf="";
var WPAvers; //Version de WPA (WPA1-WPA2)
var AP_MAC=""; //MAC del punto de acc... | JavaScript |
exports.twitea = function(eltweet) {
var keys = require('./claves');
var util = require('util');
var twitter = require('twitter');
var tweet = new twitter({
consumer_key: keys.consumerKey,
consumer_secret: keys.ConsumerSecret,
access_token_key: keys.tokenKey,
access_token_secret: keys.tokenSecret
});... | JavaScript |
exports.tokenKey = 'Aqui la tokenKey';
exports.tokenSecret = 'Aqui la tokenSecret';
exports.consumerKey = 'Aqui el consumerKey';
exports.ConsumerSecret = 'Aqui el ConsumerSecret'; | JavaScript |
var estructura = require('./json/json_bdd.js');
var twitter = require('./twitter/twitea');
var fabrizio=require('./gestionclientes.js')
, parser=require('./parser.js')
, datos
, express=require('express')
, app = express()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server,{log: fal... | JavaScript |
function validacion(formulario) {
if (confirm('¿Estas seguro de enviar este formulario?')){
var er_nombre = /^([a-z]|[A-Z]|á|é|í|ó|ú|ñ|ü|\s|\.|-)+$/ //letras, '.' y '-' o vacio
var er_password = /^([0-9]|[a-z]|[A-Z]|á|é|í|ó|ú|ñ|ü|\s|\.|-)+$/
//comprueba campo de nombre
if(... | JavaScript |
/*
Cargamos el módulo que necesitamos y llamamos a la función createServer
que nos retorna un objeto con el servidor web que utilizaremos para
escuchar las peticiones y responderlas
*/
var express = require('express');
var app = express();
//Configuración:
/*
Establecemos los directorios que usaremos:
Pr... | JavaScript |
/* Copyright (c) 2012 HyeonJe Jun (http://github.com/noraesae)
* Licensed under the MIT License
*/
((function($) {
// The default settings for the plugin
var defaultSettings = {
wheelSpeed: 10,
wheelPropagation: false
};
$.fn.perfectScrollbar = function(suppliedSettings, o... | JavaScript |
function md5 (str) {
// http://kevin.vanzonneveld.net
// + original by: Webtoolkit.info (http://www.webtoolkit.info/)
// + namespaced by: Michael White (http://getsprink.com)
// + tweaked by: Jack
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Brett Za... | JavaScript |
$(document).ready(function(){
//Si pulsamos sobre un elemento de la clase confirm se inicia este código:
$('.confirm').click(function(){
//Ventana de confirmación:
$.confirm({
'title' : 'Confirmación requerida',
'message' : '¿Estás seguro de eliminar el grupo?',
'buttons' : {
'Si' : {
... | JavaScript |
(function($){
/*Diseño completo de la ventana de confirmación:
Al llamar a esta función tenemos que pasarle como parámetros:
titulo, mensaje, botones a aparecer
*/
$.confirm = function(params){
if($('#confirmOverlay').length){
// A confirm is already shown on the page:
return false;
}
var but... | JavaScript |
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and ... | JavaScript |
var request = new XMLHttpRequest();
//Función para obtener los datos del usuario en el registro del mismo:
function obtenValores(){
//Voy a ir recogiendo todos los valores del campo para enviarlos como una cadena JSON, comprobando que todos los campos están rellenos:
var envia = 0;
//Compruebo el nombre
... | JavaScript |
/**
* jQuery Roundabout - v2.4.2
* http://fredhq.com/projects/roundabout
*
* Moves list-items of enabled ordered and unordered lists long
* a chosen path. Includes the default "lazySusan" path, that
* moves items long a spinning turntable.
*
* Terms of Use // jQuery Roundabout
*
* Open source under ... | JavaScript |
#!/usr/bin/node
//***************************************** Libraries ****************************************************
var express=require('express');
var app = express();
app.use(express.bodyParser());
var fs = require('fs');
var cradle = require('cradle');
var conn=new(cradle.Connection)('aap.cloudant.com', {
... | JavaScript |
#!/usr/bin/node
//***************************************** Libraries ****************************************************
var express=require('express');
var app = express();
app.use(express.bodyParser());
var fs = require('fs');
var cradle = require('cradle');
var conn=new(cradle.Connection)('aap.cloudant.com', {
... | JavaScript |
function pad(dato){
if(dato<10){
dato="0"+dato;
}
return dato;
}
function makeid()
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < 5; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return tex... | JavaScript |
/**
*
* Secure Hash Algorithm (SHA256)
* http://www.webtoolkit.info/
*
* Original code by Angel Marin, Paul Johnston.
*
**/
function SHA256(s){
var chrsz = 8;
var hexcase = 0;
function safe_add (x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw... | JavaScript |
(function($) {
function pad(dato){
if(dato<10){
dato="0"+dato;
}
return dato;
}
function setCookie(c_name,value){
exdays=1;
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=... | JavaScript |
/*!
* jQuery Cookie Plugin v1.3.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function ($, document, undefined) {
var pluses = /\+/g;
function raw(s) {
return s;
}
function decoded(s) {
return unRfc2068(decodeURIComponent(s.replace(plu... | JavaScript |
(function($) {
function setCookie(c_name,value){
exdays=1;
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
function getCookie(c_name){
var c_value = documen... | JavaScript |
(function($) {
function validateUser(string){
var testString = /^([a-z]|[0-9]|[A-Z]|_|-)+$/;
if (string.length > 256) {
return{ok: false, reason:'input too long'};
}
if (!testString.test(string)&&string!="") {
return {ok: false, reason:'invalid character'};
}
if(string==""){
return {ok: false, re... | JavaScript |
(function() {
CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
var prev = old && old != CodeMirror.Init;
if (val && !prev) {
cm.on("focus", onFocus);
cm.on("blur", onBlur);
cm.on("change", onChange);
onChange(cm);
} else if (!val && prev) {
cm.off("focus", ... | JavaScript |
// Because sometimes you need to style the cursor's line.
//
// Adds an option 'styleActiveLine' which, when enabled, gives the
// active line's wrapping <div> the CSS class "CodeMirror-activeline",
// and gives its background <div> the class "CodeMirror-activeline-background".
(function() {
"use strict";
var WRAP... | JavaScript |
// Because sometimes you need to mark the selected *text*.
//
// Adds an option 'styleSelectedText' which, when enabled, gives
// selected text the CSS class given as option value, or
// "CodeMirror-selectedtext" when the value is not a string.
(function() {
"use strict";
CodeMirror.defineOption("styleSelectedTex... | JavaScript |
CodeMirror.tagRangeFinder = (function() {
var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040... | JavaScript |
CodeMirror.newFoldFunction = function(rangeFinder, widget) {
if (widget == null) widget = "\u2194";
if (typeof widget == "string") {
var text = document.createTextNode(widget);
widget = document.createElement("span");
widget.appendChild(text);
widget.className = "CodeMirror-foldmarker";
}
retur... | JavaScript |
CodeMirror.indentRangeFinder = function(cm, start) {
var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
var myIndent = CodeMirror.countColumn(firstLine, null, tabSize);
for (var i = start.line + 1, end = cm.lineCount(); i < end; ++i) {
var curLine = cm.getLine(i);
if (CodeMirror.co... | JavaScript |
CodeMirror.braceRangeFinder = function(cm, start) {
var line = start.line, lineText = cm.getLine(line);
var at = lineText.length, startChar, tokenType;
for (; at > 0;) {
var found = lineText.lastIndexOf("{", at);
var startToken = '{', endToken = '}';
if (found < start.ch) {
found = lineText.last... | JavaScript |
/**
* Tag-closer extension for CodeMirror.
*
* This extension adds an "autoCloseTags" option that can be set to
* either true to get the default behavior, or an object to further
* configure its behavior.
*
* These are supported options:
*
* `whenClosing` (default true)
* Whether to autoclose when the '/' o... | JavaScript |
(function() {
var modes = ["clike", "css", "javascript"];
for (var i = 0; i < modes.length; ++i)
CodeMirror.extendMode(modes[i], {blockCommentStart: "/*",
blockCommentEnd: "*/",
blockCommentContinue: " * "});
function continueComment(c... | JavaScript |
(function() {
var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
(document.documentMode == null || document.documentMode < 8);
var Pos = CodeMirror.Pos;
var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
function findMatchingBracket(cm) {
var maxScanLen = cm.state._mat... | JavaScript |
(function() {
var DEFAULT_BRACKETS = "()[]{}''\"\"";
var SPACE_CHAR_REGEX = /\s/;
CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) {
var wasOn = old && old != CodeMirror.Init;
if (val && !wasOn)
cm.addKeyMap(buildKeymap(typeof val == "string" ? val : DEFAULT_BRACKETS));
... | JavaScript |
(function() {
'use strict';
var listRE = /^(\s*)([*+-]|(\d+)\.)(\s*)/,
unorderedBullets = '*+-';
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
var pos = cm.getCursor(),
inList = cm.getStateAfter(pos.line).list,
match;
if (!inList || !(match = cm.getLine... | JavaScript |
(function() {
"use strict";
var noOptions = {};
var nonWS = /[^\s\u00a0]/;
var Pos = CodeMirror.Pos;
function firstNonWS(str) {
var found = str.search(nonWS);
return found == -1 ? 0 : found;
}
CodeMirror.commands.toggleComment = function(cm) {
var from = cm.getCursor("start"), to = cm.getCu... | JavaScript |
(function(){
var Pos = CodeMirror.Pos;
function SearchCursor(doc, query, pos, caseFold) {
this.atOccurrence = false; this.doc = doc;
if (caseFold == null && typeof query == "string") caseFold = false;
pos = pos ? doc.clipPos(pos) : Pos(0, 0);
this.pos = {from: pos, to: pos};
// The matches me... | JavaScript |
// Define search commands. Depends on dialog.js or another
// implementation of the openDialog method.
// Replace works a little oddly -- it will do the replace on the next
// Ctrl-G (or whatever is bound to findNext) press. You prevent a
// replace by making sure the match is no longer selected when hitting
// Ctrl-G... | JavaScript |
// Highlighting text that matches the selection
//
// Defines an option highlightSelectionMatches, which, when enabled,
// will style strings that match the selection throughout the
// document.
//
// The option can be set to true to simply enable it, or to a
// {minChars, style} object to explicitly configure it. minC... | JavaScript |
// Open simple dialogs on top of an editor. Relies on dialog.css.
(function() {
function dialogDiv(cm, template, bottom) {
var wrap = cm.getWrapperElement();
var dialog;
dialog = wrap.appendChild(document.createElement("div"));
if (bottom) {
dialog.className = "CodeMirror-dialog CodeMirror-dial... | JavaScript |
CodeMirror.runMode = function(string, modespec, callback, options) {
var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
var ie = /MSIE \d/.test(navigator.userAgent);
var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);
if (callback.nodeType == 1) {
var tabSize = (opti... | JavaScript |
/* Just enough of CodeMirror to run runMode under node.js */
function splitLines(string){ return string.split(/\r?\n|\r/); };
function StringStream(string) {
this.pos = this.start = 0;
this.string = string;
}
StringStream.prototype = {
eol: function() {return this.pos >= this.string.length;},
sol: function() ... | JavaScript |
CodeMirror.colorize = (function() {
var isBlock = /^(p|li|div|h\\d|pre|blockquote|td)$/;
function textContent(node, out) {
if (node.nodeType == 3) return out.push(node.nodeValue);
for (var ch = node.firstChild; ch; ch = ch.nextSibling) {
textContent(ch, out);
if (isBlock.test(node.nodeType)) o... | JavaScript |
/* Just enough of CodeMirror to run runMode under node.js */
window.CodeMirror = {};
function splitLines(string){ return string.split(/\r?\n|\r/); };
function StringStream(string) {
this.pos = this.start = 0;
this.string = string;
}
StringStream.prototype = {
eol: function() {return this.pos >= this.string.len... | JavaScript |
(function() {
if (!CodeMirror.modeURL) CodeMirror.modeURL = "../mode/%N/%N.js";
var loading = {};
function splitCallback(cont, n) {
var countDown = n;
return function() { if (--countDown == 0) cont(); };
}
function ensureDeps(mode, cont) {
var deps = CodeMirror.modes[mode].dependencies;
if (!... | JavaScript |
// Utility function that allows modes to be combined. The mode given
// as the base argument takes care of most of the normal mode
// functionality, but a second (typically simple) mode is used, which
// can override the style of text. Both modes get to parse all of the
// text, but when both assign a non-null style to... | JavaScript |
CodeMirror.multiplexingMode = function(outer /*, others */) {
// Others should be {open, close, mode [, delimStyle]} objects
var others = Array.prototype.slice.call(arguments, 1);
var n_others = others.length;
function indexOf(string, pattern, from) {
if (typeof pattern == "string") return string.indexOf(p... | JavaScript |
(function () {
function htmlHint(editor, htmlStructure, getToken) {
var cur = editor.getCursor();
var token = getToken(editor, cur);
var keywords = [];
var i = 0;
var j = 0;
var k = 0;
var from = {line: cur.line, ch: cur.ch};
var to = {line: cur.line, ch: cur.ch};
var flagClean = t... | JavaScript |
(function () {
function forEach(arr, f) {
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
}
function arrayContains(arr, item) {
if (!Array.prototype.indexOf) {
var i = arr.length;
while (i--) {
if (arr[i] === item) {
return true;
}
}
return false;
... | JavaScript |
(function () {
function forEach(arr, f) {
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
}
function arrayContains(arr, item) {
if (!Array.prototype.indexOf) {
var i = arr.length;
while (i--) {
if (arr[i] === item) {
return true;
}
}
return false;
... | JavaScript |
CodeMirror.showHint = function(cm, getHints, options) {
if (!options) options = {};
var startCh = cm.getCursor().ch, continued = false;
var closeOn = options.closeCharacters || /[\s()\[\]{};:]/;
function startHinting() {
// We want a single cursor position.
if (cm.somethingSelected()) return;
if (... | JavaScript |
(function() {
CodeMirror.xmlHints = [];
CodeMirror.xmlHint = function(cm) {
var cursor = cm.getCursor();
if (cursor.ch > 0) {
var text = cm.getRange(CodeMirror.Pos(0, 0), cursor);
var typed = '';
var simbol = '';
for(var i = text.length - 1; i... | JavaScript |
(function () {
var Pos = CodeMirror.Pos;
function forEach(arr, f) {
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
}
function arrayContains(arr, item) {
if (!Array.prototype.indexOf) {
var i = arr.length;
while (i--) {
if (arr[i] === item) {
return true;
}... | JavaScript |
CodeMirror.validate = (function() {
var GUTTER_ID = "CodeMirror-lint-markers";
var SEVERITIES = /^(?:error|warning)$/;
function showTooltip(e, content) {
var tt = document.createElement("div");
tt.className = "CodeMirror-lint-tooltip";
tt.appendChild(content.cloneNode(true));
document.body.append... | JavaScript |
(function() {
var bogus = [ "Dangerous comment" ];
var warnings = [ [ "Expected '{'",
"Statement body should be inside '{ }' braces." ] ];
var errors = [ "Missing semicolon", "Extra comma", "Missing property name",
"Unmatched ", " and instead saw", " is not defined",
... | JavaScript |
// Depends on jsonlint.js from https://github.com/zaach/jsonlint
CodeMirror.jsonValidator = function(text) {
var found = [];
jsonlint.parseError = function(str, hash) {
var loc = hash.loc;
found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),
to: CodeMirror.Pos(loc.last_li... | JavaScript |
CodeMirror.defineMode("pascal", function() {
function words(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
var keywords = words("and array begin case const div do downto else end file for forward integer " +
... | JavaScript |
/**
* Author: Koh Zi Han, based on implementation by Koh Zi Chun
*/
CodeMirror.defineMode("scheme", function () {
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
ATOM = "atom", NUMBER = "number", BRACKET = "bracket";
var INDENT_WORD_SKIP = 2;
function makeKeywords(str) {
... | JavaScript |
CodeMirror.defineMode("verilog", function(config, parserConfig) {
var indentUnit = config.indentUnit,
keywords = parserConfig.keywords || {},
blockKeywords = parserConfig.blockKeywords || {},
atoms = parserConfig.atoms || {},
hooks = parserConfig.hooks || {},
multiLineStrings = parserCon... | JavaScript |
CodeMirror.defineMode("yaml", function() {
var cons = ['true', 'false', 'on', 'off', 'yes', 'no'];
var keywordRegex = new RegExp("\\b(("+cons.join(")|(")+"))$", 'i');
return {
token: function(stream, state) {
var ch = stream.peek();
var esc = state.escaped;
state.escaped = false;
/* ... | JavaScript |
/*
* =====================================================================================
*
* Filename: mode/asterisk/asterisk.js
*
* Description: CodeMirror mode for Asterisk dialplan
*
* Created: 05/17/2012 09:20:25 PM
* Revision: none
*
* Author: Stas Kobzar (stas@moduli... | JavaScript |
CodeMirror.defineMode('shell', function() {
var words = {};
function define(style, string) {
var split = string.split(' ');
for(var i = 0; i < split.length; i++) {
words[split[i]] = style;
}
};
// Atoms
define('atom', 'true false');
// Keywords
define('keyword', 'if then do else elif ... | JavaScript |
CodeMirror.defineMode("smarty", function(config) {
var keyFuncs = ["debug", "extends", "function", "include", "literal"];
var last;
var regs = {
operatorChars: /[+\-*&%=<>!?]/,
validIdentifier: /[a-zA-Z0-9\_]/,
stringChar: /[\'\"]/
};
var leftDelim = (typeof config.mode.leftDelimiter != 'undefined... | JavaScript |
/**
* Author: Gautam Mehta
* Branched from CodeMirror's Scheme mode
*/
CodeMirror.defineMode("cobol", function () {
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
ATOM = "atom", NUMBER = "number", KEYWORD = "keyword", MODTAG = "header",
COBOLLINENUM = "def", PERIOD = "link";
functio... | JavaScript |
/**
* Link to the project's GitHub page:
* https://github.com/duralog/CodeMirror
*/
(function() {
CodeMirror.defineMode('livescript', function(){
var tokenBase, external;
tokenBase = function(stream, state){
var next_rule, nr, i$, len$, r, m;
if (next_rule = state.next || 'start') {
sta... | JavaScript |
/**********************************************************
* This script provides syntax highlighting support for
* the Ntriples format.
* Ntriples format specification:
* http://www.w3.org/TR/rdf-testcases/#ntriples
***********************************************************/
/*
The following expression defi... | JavaScript |
(function() {
function keywords(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
function heredoc(delim) {
return function(stream, state) {
if (stream.match(delim)) state.tokenize = null;
else stream.skipToEnd();
... | JavaScript |
(function() {
"use strict";
// full haml mode. This handled embeded ruby and html fragments too
CodeMirror.defineMode("haml", function(config) {
var htmlMode = CodeMirror.getMode(config, {name: "htmlmixed"});
var rubyMode = CodeMirror.getMode(config, "ruby");
function rubyInQuote(endQuote) {
r... | JavaScript |
(function() {
var mode = CodeMirror.getMode({tabSize: 4}, "haml");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
// Requires at least one media query
MT("elementName",
"[tag %h1] Hey There");
MT("oneElementPerLine",
"[tag %h1] Hey There %h2");
MT("idSele... | JavaScript |
/*
* Author: Constantin Jucovschi (c.jucovschi@jacobs-university.de)
* Licence: MIT
*/
CodeMirror.defineMode("stex", function() {
"use strict";
function pushCommand(state, command) {
state.cmdState.push(command);
}
function peekCommand(state) {
if (state.cmdState.length > 0) {
... | JavaScript |
(function() {
var mode = CodeMirror.getMode({tabSize: 4}, "stex");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
MT("word",
"foo");
MT("twoWords",
"foo bar");
MT("beginEndDocument",
"[tag \\begin][bracket {][atom document][bracket }]",
"[tag \\en... | JavaScript |
CodeMirror.defineMode("ruby", function(config) {
function wordObj(words) {
var o = {};
for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;
return o;
}
var keywords = wordObj([
"alias", "and", "BEGIN", "begin", "break", "case", "class", "def", "defined?", "do", "else",
"elsif", "E... | JavaScript |
CodeMirror.defineMode("clike", function(config, parserConfig) {
var indentUnit = config.indentUnit,
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
dontAlignCalls = parserConfig.dontAlignCalls,
keywords = parserConfig.keywords || {},
builtin = parserConfig.builtin || {},
... | JavaScript |
CodeMirror.defineMode("groovy", function(config) {
function words(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
var keywords = words(
"abstract as assert boolean break byte case catch char class const continue def default " ... | JavaScript |
CodeMirror.defineMode("ecl", function(config) {
function words(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
function metaHook(stream, state) {
if (!state.startOfLine) return false;
stream.skipToEnd();
return "meta... | JavaScript |
CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
//config settings
var scriptStartRegex = parserConfig.scriptStartRegex || /^<%/i,
scriptEndRegex = parserConfig.scriptEndRegex || /^%>/i;
//inner modes
var scriptingMode, htmlMixedMode;
//tokenizer when in html mode
function htm... | JavaScript |
CodeMirror.defineMode('ocaml', function() {
var words = {
'true': 'atom',
'false': 'atom',
'let': 'keyword',
'rec': 'keyword',
'in': 'keyword',
'of': 'keyword',
'and': 'keyword',
'succ': 'keyword',
'if': 'keyword',
'then': 'keyword',
'else': 'keyword',
'for': 'keyword'... | JavaScript |
CodeMirror.defineMode("sparql", function(config) {
var indentUnit = config.indentUnit;
var curPunc;
function wordRegexp(words) {
return new RegExp("^(?:" + words.join("|") + ")$", "i");
}
var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri",
... | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.