# HG changeset patch # User Sonny Piers # Date 1342185978 -7200 # Node ID 5cb4733c5189bdabaf9c0dd0df03e61ee9db6869 # Parent 704ce44c1a22c9dbdfc58c32f709af289fc2be78 many api changes diff --git a/.hgignore b/.hgignore new file mode 100644 --- /dev/null +++ b/.hgignore @@ -0,0 +1,1 @@ +.DS_Store diff --git a/console/console.css b/console/console.css --- a/console/console.css +++ b/console/console.css @@ -36,6 +36,7 @@ body { } #input input { width: 65px; + -webkit-appearance: none; } #input > * { display: inline-block; diff --git a/console/console.js b/console/console.js --- a/console/console.js +++ b/console/console.js @@ -1,100 +1,109 @@ 'use strict'; -var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; - -if(!Lightstring) - var Lightstring = {}; - -Lightstring.console = { - invertedScroll: true, - log: function(aLog) { - var stanza = vkbeautify.xml(aLog.data, 2, ' '); - var entry = document.createElement('div'); - entry.classList.add('entry'); - entry.classList.add(aLog.dir); - var header = document.createElement('header'); - //FIXME date? should come from the origin? - header.textContent = aLog.dir + ': '; - entry.appendChild(header) - var pre = document.createElement('pre'); - pre.textContent = stanza; - entry.appendChild(pre); - var entriesEl = document.querySelector('#entries') - entriesEl.appendChild(entry); - }, - filter: function(aFilter) { - var entries = document.querySelectorAll('.entry pre'); - for (var i = 0, length = entries.length; i < length; i++) { - var entry = entries[i]; - if (!entry.textContent.match(aFilter)) - entry.parentNode.hidden = true; - else - entry.parentNode.hidden = false; - - //FIXME use the Mutation Observer? get back to the previous scroll state? - this.scrollToBottom(); - } - }, - send: function(aData) { - Lightstring.console.source.postMessage({ - 'send': aData}, document.location.protocol + '//' + document.location.host); - }, - scrollToBottom: function() { - this.entriesEl.scrollTop = (this.entriesEl.scrollHeight - this.entriesEl.clientHeight); - } -}; - (function() { - document.addEventListener('DOMContentLoaded', function() { - - var entriesEl = document.getElementById('entries'); - entriesEl.addEventListener('scroll', function(e) { - if (entriesEl.scrollTop === (entriesEl.scrollHeight - entriesEl.clientHeight)) - Lightstring.console.invertedScroll = true; - else - Lightstring.console.invertedScroll = false; - }) - - new MutationObserver(function(mutations) { - if(Lightstring.console.invertedScroll === true) - Lightstring.console.scrollToBottom(); - }).observe(entriesEl, { - childList: true, - // attributes: false, - // characterData: false - }); - - Lightstring.console.entriesEl = entriesEl; - if (Lightstring.console.invertedScroll) - Lightstring.console.scrollToBottom(); - - window.addEventListener("message", function(e) { - if(!Lightstring.console.source) - Lightstring.console.source = e.source; + var Console = { + holder: [], + invertedScroll: true, + log: function(aLog) { + if (document.readyState !== 'complete') { + this.holder.push(aLog); + return; + } + //beautify + var stanza = vkbeautify.xml(aLog.data, 2, ' '); + var entry = document.createElement('div'); + entry.classList.add('entry'); + entry.classList.add(aLog.dir); + var header = document.createElement('header'); + var date = new Date(); + var hours = (date.getHours() < 10 ? '0' : '') + date.getHours(); + var minutes = (date.getMinutes() < 10 ? '0' : '') + date.getMinutes(); + var seconds = (date.getSeconds() < 10 ? '0' : '') + date.getSeconds(); + var timestamp = hours + ':' + minutes + ':' + seconds + '.' + date.getMilliseconds(); + header.textContent = aLog.dir + ': ' + timestamp; + entry.appendChild(header) + var pre = document.createElement('pre'); + pre.textContent = stanza; + entry.appendChild(pre); + //highlight + hljs.highlightBlock(entry.children[1], null, false); + var entriesEl = document.querySelector('#entries') - Lightstring.console.log(e.data); - }, false); + var child = entriesEl.firstChild; + if(child) + entriesEl.insertBefore(entry, child); + else + entriesEl.appendChild(entry) + }, + filter: function(aFilter) { + var entries = document.querySelectorAll('.entry pre'); + for (var i = 0, length = entries.length; i < length; i++) { + var entry = entries[i]; + if (!entry.textContent.match(aFilter)) + entry.parentNode.hidden = true; + else + entry.parentNode.hidden = false; + } + }, + send: function(aData) { + //C'mon you can do better + Lightstring.connections[0].send(aData) + }, + init: function() { + if (Lightstring.Connection) { + Lightstring.Connection.prototype.on('stanza', function(stanza) { + Lightstring.console.log({dir: 'in', data: stanza.toString()}); + }); + Lightstring.Connection.prototype.on('out', function(stanza) { + Lightstring.console.log({dir: 'out', data: stanza.toString()}); + }); + } + if (document.readyState === 'complete') + return this.initView(); + + document.addEventListener('DOMContentLoaded', this.initView); + }, + initView: function() { + Lightstring.console.holder.forEach(function(log) { + Lightstring.console.log(log); + }); - document.getElementById('input').addEventListener('submit', function(e) { - e.preventDefault(); - Lightstring.console.send(this.elements['field'].value) - }); - document.getElementById('clear').addEventListener('click', function(e) { - Lightstring.console.entriesEl.innerHTML = ''; - }); - //FIXME allow xpath, xquery, E4X, whatever XML query syntax - document.getElementById('filter').addEventListener('input', function(e) { - Lightstring.console.filter(this.value); - }); - document.getElementById('input').addEventListener('keypress', function(e) { - if (e.keyCode === 13) { - if (e.shiftKey) { - e.preventDefault(); - var event = document.createEvent('Event'); - event.initEvent('submit', true, true); - this.dispatchEvent(event); + + var entriesEl = document.getElementById('entries'); + Console.entriesEl = entriesEl; + + document.getElementById('input').addEventListener('submit', function(e) { + e.preventDefault(); + Lightstring.console.send(this.elements['field'].value) + }); + document.getElementById('clear').addEventListener('click', function(e) { + Lightstring.console.entriesEl.innerHTML = ''; + }); + //FIXME allow xpath, xquery, E4X, whatever XML query syntax + document.getElementById('filter').addEventListener('input', function(e) { + Lightstring.console.filter(this.value); + }); + document.getElementById('input').addEventListener('keypress', function(e) { + if (e.keyCode === 13) { + if (e.shiftKey) { + e.preventDefault(); + var event = document.createEvent('Event'); + event.initEvent('submit', true, true); + this.dispatchEvent(event); + } } - } - }); - }); + }); + } + }; + + //Lightstring is defined in the parent window context + if (window.frameElement && window.parent.Lightstring) { + window.Lightstring = window.parent.Lightstring; + Lightstring.console = Console; + Lightstring.console.init(); + } + else { + //TODO: link to a doc? + console.error('You must embed this in a iframe.'); + } })(); \ No newline at end of file diff --git a/console/console.xhtml b/console/console.xhtml --- a/console/console.xhtml +++ b/console/console.xhtml @@ -3,19 +3,23 @@ Lightstring Console + + + + +``` + +This will highlight all code on the page marked up as `
 .. 
`. +If you use different markup or need to apply highlighting dynamically, read +"Custom initialization" below. + +- You can download your own customized version of "highlight.pack.js" or + use the hosted one as described on the download page: + + +- Style themes are available in the download package or as hosted files. + To create a custom style for your site see the class reference in the file + [classref.txt][cr] from the downloaded package. + +[cr]: http://github.com/isagalaev/highlight.js/blob/master/classref.txt + + +## Tab replacement + +You can replace TAB ('\x09') characters used for indentation in your code +with some fixed number of spaces or with a `` to give them special +styling: + +```html + +``` + +## Custom initialization + +If you use different markup for code blocks you can initialize them manually +with `highlightBlock(code, tabReplace, useBR)` function. It takes a DOM element +containing the code to highlight and optionally a string with which to replace +TAB characters. + +Initialization using, for example, jQuery might look like this: + +```javascript +$(document).ready(function() { + $('pre code').each(function(i, e) {hljs.highlightBlock(e)}); +}); +``` + +You can use `highlightBlock` to highlight blocks dynamically inserted into +the page. Just make sure you don't do it twice for already highlighted +blocks. + +If your code container relies on `
` tags instead of line breaks (i.e. if +it's not `
`) pass `true` into the third parameter of `highlightBlock`
+to make highlight.js use `
` in the output: + +```javascript +$('div.code').each(function(i, e) {hljs.highlightBlock(e, null, true)}); +``` + + +## Heuristics + +Autodetection of a code's language is done using a simple heuristic: +the program tries to highlight a fragment with all available languages and +counts all syntactic structures that it finds along the way. The language +with greatest count wins. + +This means that in short fragments the probability of an error is high +(and it really happens sometimes). In this cases you can set the fragment's +language explicitly by assigning a class to the `` element: + +```html +
...
+``` + +You can use class names recommended in HTML5: "language-html", +"language-php". Classes also can be assigned to the `
` element.
+
+To disable highlighting of a fragment altogether use "no-highlight" class:
+
+```html
+
...
+``` + + +## Export + +File export.html contains a little program that allows you to paste in a code +snippet and then copy and paste the resulting HTML code generated by the +highlighter. This is useful in situations when you can't use the script itself +on a site. + + +## Meta + +- Version: 7.0 +- URL: http://softwaremaniacs.org/soft/highlight/en/ +- Author: Ivan Sagalaev () + +For the license terms see LICENSE files. +For the list of contributors see AUTHORS.en.txt file. diff --git a/console/lib/highlight/README.ru.md b/console/lib/highlight/README.ru.md new file mode 100644 --- /dev/null +++ b/console/lib/highlight/README.ru.md @@ -0,0 +1,125 @@ +# Highlight.js + +Highlight.js нужен для подсветки синтаксиса в примерах кода в блогах, +форумах и вообще на любых веб-страницах. Пользоваться им очень просто, +потому что работает он автоматически: сам находит блоки кода, сам +определяет язык, сам подсвечивает. + +Автоопределением языка можно управлять, когда оно не справляется само (см. +дальше "Эвристика"). + + +## Простое использование + +Подключите библиотеку и стиль на страницу и повесть вызов подсветки на +загрузку страницы: + +```html + + + +``` + +Весь код на странице, обрамлённый в теги `
 .. 
` +будет автоматически подсвечен. Если вы используете другие теги или хотите +подсвечивать блоки кода динамически, читайте "Инициализацию вручную" ниже. + +- Вы можете скачать собственную версию "highlight.pack.js" или сослаться + на захостенный файл, как описано на странице загрузки: + + +- Стилевые темы можно найти в загруженном архиве или также использовать + захостенные. Чтобы сделать собственный стиль для своего сайта, вам + будет полезен справочник классов в файле [classref.txt][cr], который тоже + есть в архиве. + +[cr]: http://github.com/isagalaev/highlight.js/blob/master/classref.txt + + +## Замена TABов + +Также вы можете заменить символы TAB ('\x09'), используемые для отступов, на +фиксированное количество пробелов или на отдельный ``, чтобы задать ему +какой-нибудь специальный стиль: + +```html + +``` + + +## Инициализация вручную + +Если вы используете другие теги для блоков кода, вы можете инициализировать их +явно с помощью функции `highlightBlock(code, tabReplace, useBR)`. Она принимает +DOM-элемент с текстом расцвечиваемого кода и опционально - строчку для замены +символов TAB. + +Например с использованием jQuery код инициализации может выглядеть так: + +```javascript +$(document).ready(function() { + $('pre code').each(function(i, e) {hljs.highlightBlock(e)}); +}); +``` + +`highlightBlock` можно также использовать, чтобы подсветить блоки кода, +добавленные на страницу динамически. Только убедитесь, что вы не делаете этого +повторно для уже раскрашенных блоков. + +Если ваш блок кода использует `
` вместо переводов строки (т.е. если это не +`
`), передайте `true` третьим параметром в `highlightBlock`:
+
+```javascript
+$('div.code').each(function(i, e) {hljs.highlightBlock(e, null, true)});
+```
+
+
+## Эвристика
+
+Определение языка, на котором написан фрагмент, делается с помощью
+довольно простой эвристики: программа пытается расцветить фрагмент всеми
+языками подряд, и для каждого языка считает количество подошедших
+синтаксически конструкций и ключевых слов. Для какого языка нашлось больше,
+тот и выбирается.
+
+Это означает, что в коротких фрагментах высока вероятность ошибки, что
+периодически и случается. Чтобы указать язык фрагмента явно, надо написать
+его название в виде класса к элементу ``:
+
+```html
+
...
+``` + +Можно использовать рекомендованные в HTML5 названия классов: +"language-html", "language-php". Также можно назначать классы на элемент +`
`.
+
+Чтобы запретить расцветку фрагмента вообще, используется класс "no-highlight":
+
+```html
+
...
+``` + + +## Экспорт + +В файле export.html находится небольшая программка, которая показывает и дает +скопировать непосредственно HTML-код подсветки для любого заданного фрагмента кода. +Это может понадобится например на сайте, на котором нельзя подключить сам скрипт +highlight.js. + + +## Координаты + +- Версия: 7.0 +- URL: http://softwaremaniacs.org/soft/highlight/ +- Автор: Иван Сагалаев () + +Лицензионное соглашение читайте в файле LICENSE. +Список соавторов читайте в файле AUTHORS.ru.txt diff --git a/console/lib/highlight/classref.txt b/console/lib/highlight/classref.txt new file mode 100644 --- /dev/null +++ b/console/lib/highlight/classref.txt @@ -0,0 +1,544 @@ +This is a full list of available classes corresponding to languages' +syntactic structures. The parentheses after language name contain identifiers +used as class names in `` element. + +Python ("python"): + + keyword keyword + built_in built-in objects (None, False, True and Ellipsis) + number number + string string (of any type) + comment comment + decorator @-decorator for functions + function function header "def some_name(...):" + class class header "class SomeName(...):" + title name of a function or a class inside a header + params everything inside parentheses in a function's or class' header + +Python profiler results ("profile"): + + number number + string string + builtin builtin function entry + filename filename in an entry + summary profiling summary + header header of table of results + keyword column header + function function name in an entry (including parentheses) + title actual name of a function in an entry (excluding parentheses) + +Ruby ("ruby"): + + keyword keyword + string string + subst in-string substitution (#{...}) + comment comment + yardoctag YARD tag + function function header "def some_name(...):" + class class header "class SomeName(...):" + title name of a function or a class inside a header + parent name of a parent class + symbol symbol + instancevar instance variable + +Perl ("perl"): + + keyword keyword + comment comment + number number + string string + regexp regular expression + sub subroutine header (from "sub" till "{") + variable variable starting with "$", "%", "@" + operator operator + pod plain old doc + +PHP ("php"): + + keyword keyword + number number + string string (of any type) + comment comment + phpdoc phpdoc params in comments + variable variable starting with "$" + preprocessor preprocessor marks: "" + +Scala ("scala"): + + keyword keyword + number number + string string + comment comment + annotaion annotation + javadoc javadoc comment + javadoctag @-tag in javadoc + class class header + title class name inside a header + params everything in parentheses inside a class header + inheritance keywords "extends" and "with" inside class header + +Go language ("go"): + comment comment + string string constant + number number + keyword language keywords + constant true false nil iota + typename built-in plain types (int, string etc.) + built_in built-in functions + +XML ("xml"): + + tag any tag from "<" till ">" + comment comment + pi processing instruction () + cdata CDATA section + attribute attribute + value attribute's value + +HTML ("html"): + + keyword HTML tag + tag any tag from "<" till ">" + comment comment + doctype declaration + attribute tag's attribute with or without value + value attribute's value + +CSS ("css"): + + tag HTML tag in selectors + id #some_name in selectors + class .some_name in selectors + at_rule @-rule till first "{" or ";" + attr_selector attribute selector (square brackets in a[href^=http://]) + pseudo pseudo classes and elemens (:after, ::after etc.) + comment comment + rules everything from "{" till "}" + property property name inside a rule + value property value inside a rule, from ":" till ";" or + till the end of rule block + number number within a value + string string within a value + hexcolor hex color (#FFFFFF) within a value + function CSS function within a value + params everything between "(" and ")" within a function + important "!important" symbol + +Markdown ("markdown"): + + header header + bullet list bullet + emphasis emphasis + strong strong emphasis + blockquote blockquote + code code + horizontal_rule horizontal rule + link_label link label + link_url link url + +Django ("django"): + + keyword HTML tag in HTML, default tags and default filters in templates + tag any tag from "<" till ">" + comment comment + doctype declaration + attribute tag's attribute with or withou value + value attribute's value + template_tag template tag {% .. %} + variable template variable {{ .. }} + template_comment template comment, both {# .. #} and {% comment %} + filter filter from "|" till the next filter or the end of tag + argument filter argument + +JSON ("json"): + + number number + literal "true", "false" and "null" + string string value + attribute name of an object property + value value of an object property + +JavaScript ("javascript"): + + keyword keyword + comment comment + number number + literal special literal: "true", "false" and "null" + string string + regexp regular expression + function header of a function + title name of a function inside a header + params parentheses and everything inside them in a function's header + +CoffeeScript ("coffeescript"): + + keyword keyword + comment comment + number number + literal special literal: "true", "false" and "null" + string string + regexp regular expression + function header of a function + title name of a function variable inside a header + params parentheses and everything inside them in a function's header + +ActionScript ("actionscript"): + + comment comment + string string + number number + keyword keywords + literal literal + reserved reserved keyword + title name of declaration (package, class or function) + preprocessor preprocessor directive (import, include) + type type of returned value (for functions) + package package (named or not) + class class/interface + function function + param params of function + rest_arg rest argument of function + +VBScript ("vbscript"): + + keyword keyword + number number + string string + comment comment + built_in built-in function + +HTTP ("http"): + + request first line of a request + status first line of a response + attribute header name + string header value or query string in a request line + number status code + +Lua ("lua"): + + keyword keyword + number number + string string + comment comment + built_in built-in operator + function header of a function + title name of a function inside a header + params everything inside parentheses in a function's header + long_brackets multiline string in [=[ .. ]=] + +Delphi ("delphi"): + + keyword keyword + comment comment (of any type) + number number + string string + function header of a function, procedure, constructor and destructor + title name of a function, procedure, constructor or destructor + inside a header + params everything inside parentheses in a function's header + class class' body from "= class" till "end;" + +Java ("java"): + + keyword keyword + number number + string string + comment commment + annotaion annotation + javadoc javadoc comment + class class header from "class" till "{" + title class name inside a header + params everything in parentheses inside a class header + inheritance keywords "extends" and "implements" inside class header + +C++ ("cpp"): + + keyword keyword + number number + string string and character + comment comment + preprocessor preprocessor directive + stl_container instantiation of STL containers ("vector<...>") + +Objective C ("objectivec"): + keyword keyword + built_in Cocoa/Cocoa Touch constants and classes + number number + string string + comment comment + preprocessor preprocessor directive + class interface/implementation, protocol and forward class declaration + variable properties and struct accesors + +Vala ("vala"): + + keyword keyword + number number + string string + comment comment + class class definitions + title in class definition + constant ALL_UPPER_CASE + +C# ("cs"): + + keyword keyword + number number + string string + comment commment + xmlDocTag xmldoc tag ("///", "", "<..>") + +D language ("d"): + + comment comment + string string constant + number number + keyword language keywords (including @attributes) + constant true false null + built_in built-in plain types (int, string etc.) + +RenderMan RSL ("rsl"): + + keyword keyword + number number + string string (including @"..") + comment comment + preprocessor preprocessor directive + shader sahder keywords + shading shading keywords + built_in built-in function + +RenderMan RIB ("rib"): + + keyword keyword + number number + string string + comment comment + commands command + +Maya Embedded Language ("mel"): + + keyword keyword + number number + string string + comment comment + variable variable + +SQL ("sql"): + + keyword keyword (mostly SQL'92 and SQL'99) + number number + string string (of any type: "..", '..', `..`) + comment comment + aggregate aggregate function + +Smalltalk ("smalltalk"): + + keyword keyword + number number + string string + comment commment + symbol symbol + array array + class name of a class + char char + localvars block of local variables + +Lisp ("lisp"): + + keyword keyword + number number + string string + comment commment + variable variable + literal b, t and nil + list non-quoted list + title first symbol in a non-quoted list + body remainder of the non-quoted list + quoted quoted list, both "(quote .. )" and "'(..)" + +Ini ("ini"): + + title title of a section + value value of a setting of any type + string string + number number + keyword boolean value keyword + +Apache ("apache"): + + keyword keyword + number number + comment commment + literal On and Off + sqbracket variables in rewrites "%{..}" + cbracket options in rewrites "[..]" + tag begin and end of a configuration section + +Nginx ("nginx"): + + title directive title + string string + number number + comment comment + built_in built-in constant + variable $-variable + regexp regexp + +Diff ("diff"): + + header file header + chunk chunk header within a file + addition added lines + deletion deleted lines + change changed lines + +DOS ("dos"): + + keyword keyword + flow batch control keyword + stream DOS special files ("con", "prn", ...) + winutils some commands (see dos.js specifically) + envvar environment variables + +Bash ("bash"): + + keyword keyword + string string + number number + comment comment + literal special literal: "true" и "false" + variable variable + shebang script interpreter header + +CMake ("cmake") + + keyword keyword + number number + string string + comment commment + envvar $-variable + +Axapta ("axapta"): + + keyword keyword + number number + string string + comment commment + class class header from "class" till "{" + title class name inside a header + params everything in parentheses inside a class header + inheritance keywords "extends" and "implements" inside class header + preprocessor preprocessor directive + +1C ("1c"): + + keyword keyword + number number + date date + string string + comment commment + function header of function or procudure + title function name inside a header + params everything in parentheses inside a function header + preprocessor preprocessor directive + +AVR assembler ("avrasm"): + + keyword keyword + built_in pre-defined register + number number + string string + comment commment + label label + preprocessor preprocessor directive + localvars substitution in .macro + +VHDL ("vhdl") + + keyword keyword + number number + string string + comment commment + literal signal logical value + typename typename + attribute signal attribute + +Parser3 ("parser3"): + + keyword keyword + number number + comment commment + variable variable starting with "$" + preprocessor preprocessor directive + title user-defined name starting with "@" + +TeX ("tex"): + + comment comment + number number + command command + parameter parameter + formula formula + special special symbol + +Haskell ("haskell"): + + keyword keyword + number number + string string + comment comment + class type classes and other data types + title function name + type type class name + typedef definition of types (type, newtype, data) + +Erlang ("erlang"): + + comment comment + string string + number number + keyword keyword + record_name record access (#record_name) + title name of declaration function + variable variable (starts with capital letter or with _) + pp.keywords module's attribute (-attribute) + function_name atom or atom:atom in case of function call + +Rust ("rust"): + + comment comment + string string + number number + keyword keyword + title name of declaration + preprocessor preprocessor directive + +Matlab ("matlab"): + + comment comment + string string + number number + keyword keyword + title function name + function function + param params of function + +R ("r"): + + comment comment + string string constant + number number + keyword language keywords (function, if) plus "structural" + functions (attach, require, setClass) + literal special literal: TRUE, FALSE, NULL, NA, etc. + +OpenGL Shading Language ("glsl"): + + comment comment + number number + preprocessor preprocessor directive + keyword keyword + built_in GLSL built-in functions and variables + literal true false diff --git a/console/lib/highlight/highlight.pack.js b/console/lib/highlight/highlight.pack.js new file mode 100644 --- /dev/null +++ b/console/lib/highlight/highlight.pack.js @@ -0,0 +1,1 @@ +var hljs=new function(){function m(p){return p.replace(/&/gm,"&").replace(/"}while(y.length||w.length){var v=u().splice(0,1)[0];z+=m(x.substr(q,v.offset-q));q=v.offset;if(v.event=="start"){z+=t(v.node);s.push(v.node)}else{if(v.event=="stop"){var p,r=s.length;do{r--;p=s[r];z+=("")}while(p!=v.node);s.splice(r,1);while(r'+N[0]+""}else{r+=N[0]}P=Q.lR.lastIndex;N=Q.lR.exec(M)}return r+M.substr(P)}function B(M,N){var r;if(N.sL==""){r=g(M)}else{r=d(N.sL,M)}if(N.r>0){y+=r.keyword_count;C+=r.r}return''+r.value+""}function K(r,M){if(M.sL&&e[M.sL]||M.sL==""){return B(r,M)}else{return G(r,M)}}function J(N,r){var M=N.cN?'':"";if(N.rB){z+=M;N.buffer=""}else{if(N.eB){z+=m(r)+M;N.buffer=""}else{z+=M;N.buffer=r}}p.push(N);C+=N.r}function H(O,N,R){var S=p[p.length-1];if(R){z+=K(S.buffer+O,S);return false}var Q=s(N,S);if(Q){z+=K(S.buffer+O,S);J(Q,N);return Q.rB}var M=w(p.length-1,N);if(M){var P=S.cN?"":"";if(S.rE){z+=K(S.buffer+O,S)+P}else{if(S.eE){z+=K(S.buffer+O,S)+P+m(N)}else{z+=K(S.buffer+O+N,S)+P}}while(M>1){P=p[p.length-2].cN?"":"";z+=P;M--;p.length--}var r=p[p.length-1];p.length--;p[p.length-1].buffer="";if(r.starts){J(r.starts,"")}return S.rE}if(x(N,S)){throw"Illegal"}}var F=e[D];var p=[F.dM];var C=0;var y=0;var z="";try{var t,v=0;F.dM.buffer="";do{t=q(E,v);var u=H(t[0],t[1],t[2]);v+=t[0].length;if(!u){v+=t[1].length}}while(!t[2]);return{r:C,keyword_count:y,value:z,language:D}}catch(I){if(I=="Illegal"){return{r:0,keyword_count:0,value:m(E)}}else{throw I}}}function g(t){var p={keyword_count:0,r:0,value:m(t)};var r=p;for(var q in e){if(!e.hasOwnProperty(q)){continue}var s=d(q,t);s.language=q;if(s.keyword_count+s.r>r.keyword_count+r.r){r=s}if(s.keyword_count+s.r>p.keyword_count+p.r){r=p;p=s}}if(r.language){p.second_best=r}return p}function i(r,q,p){if(q){r=r.replace(/^((<[^>]+>|\t)+)/gm,function(t,w,v,u){return w.replace(/\t/g,q)})}if(p){r=r.replace(/\n/g,"
")}return r}function n(t,w,r){var x=h(t,r);var v=a(t);var y,s;if(v=="no-highlight"){return}if(v){y=d(v,x)}else{y=g(x);v=y.language}var q=c(t);if(q.length){s=document.createElement("pre");s.innerHTML=y.value;y.value=k(q,c(s),x)}y.value=i(y.value,w,r);var u=t.className;if(!u.match("(\\s|^)(language-)?"+v+"(\\s|$)")){u=u?(u+" "+v):v}if(/MSIE [678]/.test(navigator.userAgent)&&t.tagName=="CODE"&&t.parentNode.tagName=="PRE"){s=t.parentNode;var p=document.createElement("div");p.innerHTML="
"+y.value+"
";t=p.firstChild.firstChild;p.firstChild.cN=s.cN;s.parentNode.replaceChild(p.firstChild,s)}else{t.innerHTML=y.value}t.className=u;t.result={language:v,kw:y.keyword_count,re:y.r};if(y.second_best){t.second_best={language:y.second_best.language,kw:y.second_best.keyword_count,re:y.second_best.r}}}function o(){if(o.called){return}o.called=true;var r=document.getElementsByTagName("pre");for(var p=0;p|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\.",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(r,s){var p={};for(var q in r){p[q]=r[q]}if(s){for(var q in s){p[q]=s[q]}}return p}}();hljs.LANGUAGES.xml=function(a){var c="[A-Za-z0-9\\._:-]+";var b={eW:true,c:[{cN:"attribute",b:c,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,dM:{c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"|$)",e:">",k:{title:"style"},c:[b],starts:{e:"",rE:true,sL:"css"}},{cN:"tag",b:"|$)",e:">",k:{title:"script"},c:[b],starts:{e:"<\/script>",rE:true,sL:"javascript"}},{b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"",c:[{cN:"title",b:"[^ />]+"},b]}]}}}(hljs); \ No newline at end of file diff --git a/console/lib/highlight/styles/arta.css b/console/lib/highlight/styles/arta.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/arta.css @@ -0,0 +1,153 @@ +/* +Date: 17.V.2011 +Author: pumbur +*/ + +pre code +{ + display: block; padding: 0.5em; + background: #222; +} + +pre .profile .header *, +pre .ini .title, +pre .nginx .title +{ + color: #fff; +} + +pre .comment, +pre .javadoc, +pre .preprocessor, +pre .preprocessor .title, +pre .shebang, +pre .profile .summary, +pre .diff, +pre .pi, +pre .doctype, +pre .tag, +pre .template_comment, +pre .css .rules, +pre .tex .special +{ + color: #444; +} + +pre .string, +pre .symbol, +pre .diff .change, +pre .regexp, +pre .xml .attribute, +pre .smalltalk .char, +pre .xml .value, +pre .ini .value +{ + color: #ffcc33; +} + +pre .number, +pre .addition +{ + color: #00cc66; +} + +pre .built_in, +pre .literal, +pre .vhdl .typename, +pre .go .constant, +pre .go .typename, +pre .ini .keyword, +pre .lua .title, +pre .perl .variable, +pre .php .variable, +pre .mel .variable, +pre .django .variable, +pre .css .funtion, +pre .smalltalk .method, +pre .hexcolor, +pre .important, +pre .flow, +pre .inheritance, +pre .parser3 .variable +{ + color: #32AAEE; +} + +pre .keyword, +pre .tag .title, +pre .css .tag, +pre .css .class, +pre .css .id, +pre .css .pseudo, +pre .css .attr_selector, +pre .lisp .title, +pre .winutils, +pre .tex .command, +pre .request, +pre .status +{ + color: #6644aa; +} + +pre .title, +pre .ruby .constant, +pre .vala .constant, +pre .parent, +pre .deletion, +pre .template_tag, +pre .css .keyword, +pre .objectivec .class .id, +pre .smalltalk .class, +pre .lisp .keyword, +pre .apache .tag, +pre .nginx .variable, +pre .envvar, +pre .bash .variable, +pre .go .built_in, +pre .vbscript .built_in, +pre .lua .built_in, +pre .rsl .built_in, +pre .tail, +pre .avrasm .label, +pre .tex .formula, +pre .tex .formula * +{ + color: #bb1166; +} + +pre .yardoctag, +pre .phpdoc, +pre .profile .header, +pre .ini .title, +pre .apache .tag, +pre .parser3 .title +{ + font-weight: bold; +} + +pre .coffeescript .javascript, +pre .xml .javascript, +pre .xml .css, +pre .xml .cdata +{ + opacity: 0.6; +} + +pre code, +pre .javascript, +pre .css, +pre .xml, +pre .subst, +pre .diff .chunk, +pre .css .value, +pre .css .attribute, +pre .lisp .string, +pre .lisp .number, +pre .tail .params, +pre .container, +pre .haskell *, +pre .erlang *, +pre .erlang_repl * +{ + color: #aaa; +} diff --git a/console/lib/highlight/styles/ascetic.css b/console/lib/highlight/styles/ascetic.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/ascetic.css @@ -0,0 +1,49 @@ +/* + +Original style from softwaremaniacs.org (c) Ivan Sagalaev + +*/ + +pre code { + display: block; padding: 0.5em; + background: white; color: black; +} + +pre .string, +pre .tag .value, +pre .filter .argument, +pre .addition, +pre .change, +pre .apache .tag, +pre .apache .cbracket, +pre .nginx .built_in, +pre .tex .formula { + color: #888; +} + +pre .comment, +pre .template_comment, +pre .shebang, +pre .doctype, +pre .pi, +pre .javadoc, +pre .deletion, +pre .apache .sqbracket { + color: #CCC; +} + +pre .keyword, +pre .tag .title, +pre .ini .title, +pre .lisp .title, +pre .http .title, +pre .nginx .title, +pre .css .tag, +pre .winutils, +pre .flow, +pre .apache .tag, +pre .tex .command, +pre .request, +pre .status { + font-weight: bold; +} diff --git a/console/lib/highlight/styles/brown_paper.css b/console/lib/highlight/styles/brown_paper.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/brown_paper.css @@ -0,0 +1,104 @@ +/* + +Brown Paper style from goldblog.com.ua (c) Zaripov Yura + +*/ + +pre code { + display: block; padding: 0.5em; + background:#b7a68e url(./brown_papersq.png); +} + +pre .keyword, +pre .literal, +pre .change, +pre .winutils, +pre .flow, +pre .lisp .title, +pre .nginx .title, +pre .tex .special, +pre .request, +pre .status { + color:#005599; + font-weight:bold; +} + +pre code, +pre .ruby .subst, +pre .tag .keyword { + color: #363C69; +} + +pre .string, +pre .title, +pre .haskell .type, +pre .tag .value, +pre .css .rules .value, +pre .preprocessor, +pre .ruby .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .ruby .instancevar, +pre .ruby .class .parent, +pre .built_in, +pre .sql .aggregate, +pre .django .template_tag, +pre .django .variable, +pre .smalltalk .class, +pre .javadoc, +pre .ruby .string, +pre .django .filter .argument, +pre .smalltalk .localvars, +pre .smalltalk .array, +pre .attr_selector, +pre .pseudo, +pre .addition, +pre .stream, +pre .envvar, +pre .apache .tag, +pre .apache .cbracket, +pre .tex .number { + color: #2C009F; +} + +pre .comment, +pre .java .annotation, +pre .python .decorator, +pre .template_comment, +pre .pi, +pre .doctype, +pre .deletion, +pre .shebang, +pre .apache .sqbracket, +pre .nginx .built_in, +pre .tex .formula { + color: #802022; +} + +pre .keyword, +pre .literal, +pre .css .id, +pre .phpdoc, +pre .title, +pre .haskell .type, +pre .vbscript .built_in, +pre .sql .aggregate, +pre .rsl .built_in, +pre .smalltalk .class, +pre .diff .header, +pre .chunk, +pre .winutils, +pre .bash .variable, +pre .apache .tag, +pre .tex .command { + font-weight: bold; +} + +pre .coffeescript .javascript, +pre .xml .css, +pre .xml .javascript, +pre .xml .vbscript, +pre .tex .formula { + opacity: 0.8; +} diff --git a/console/lib/highlight/styles/brown_papersq.png b/console/lib/highlight/styles/brown_papersq.png new file mode 100644 index 0000000000000000000000000000000000000000..3813903dbf9fa7b1fb5bd11d9534c06667d9056f GIT binary patch literal 18198 zc${pzRajh0)GgXbr}kGi@z?iq@(;B2bp$9lc-c8Js(IKtJL);wIt2SnJ4yop zDs^f~3I;(x4hPq=xYe@goQ|D5J%^N)oPG{`|Gt3$pvyDSvyZ+Rl4nPcXO=;CV)`lw zrBb z0Xq4yGB!6b^k~`qQE%_yQsFxkiA>p`&?oosc%9ns*O1j0Lo`aY6z~W~ilA>^-{?!F z?F5xA?CWR72867K$q5$~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Jz5@xAr70iuT*v5|G@u&{{#OA{tx^g_&@OfZSgPv z)$jjTYz`J4=zpJ_1o{c?rFBhVnu@N)U-9iu$_R?brd6%>eYKm_?Cce$X*7*q@Nhu# z1cz=f73Y!GdRgr1Y*RPjsfm%`U}9V_tusE(fKl?)_rowO?B=zK%J`fwO9lR}S5oCh zD5!wFRmIXKNG6irX6f6J(oGt@!gMScy zkz6;q&9NAb4Yz6E>@-bTNtAS|U;}nB^k+~e`~>W)YkNsHhQz^vRUbcoJfBX8|JT=- zIvWUp8@dy~7P6lxs+tOT7a%SKN5+;sXyZt;&Dr zcXRqZz4PBp62XO4@D6uI{36SY<1H1bZ+nUz(Sib-*vT4QQEaEK6T8X7e$D+hf`MlB zSfQ(?uJjpOtN5ZK4-?oQFK1x>^QRwEv?|wmrRdllf~E5qkkx;R^>C_b2do7|(=DqK zQebHX(`bGTz>X1Y9tguyVStCJEUBhXu#fH^fZ)^c& zbrYre!BYb}1f=(_?K-1t;4=ZgJ4gv<8nyKR%WuoZI-wL#4;N2G_@Za!O$7Ji1SF;M zEZIy~3u@_uy}{R!4ZPrfwrQIztz%hQRBOXjT=E45>^E$+WYLw~;26)t701SoQUFyzVa<8MvLDV!4KJ^+9886Xo!8bF zlFi+lR%0dJrz~US8B4MP=?BERuE!dwtm#D4oOT!RbVS1aIs$z|cR4?Pz?!jgq&6%Y za2#(pNtvN~vlfrW-q{=iNX*u6R4J{bVHCwZv5i5;fD0|C-t+TgL$aHRD_d=fm)9@1 z`x}zt`TPJ2-|p8Asii-$8-oq+6yr=;qDWW9ah5OQS>;w}See{caHQ}GH-Xe6OXi`< ziFIRiB~vS~flPNkT`Eo~TY2bX7i3IU;-wOyMbgVeX0se>FxlpInc;jSo03Dh!1$9V y!IcO85BwkaKk$Fx|G@u&{{#Qu7XSaB00RIj=@DmjqN}I?0000 + +*/ + +pre code { + display: block; padding: 0.5em; + background: #444; +} + +pre .keyword, +pre .literal, +pre .change, +pre .winutils, +pre .flow, +pre .lisp .title, +pre .nginx .title, +pre .tex .special { + color: white; +} + +pre code, +pre .ruby .subst { + color: #DDD; +} + +pre .string, +pre .title, +pre .haskell .type, +pre .ini .title, +pre .tag .value, +pre .css .rules .value, +pre .preprocessor, +pre .ruby .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .ruby .instancevar, +pre .ruby .class .parent, +pre .built_in, +pre .sql .aggregate, +pre .django .template_tag, +pre .django .variable, +pre .smalltalk .class, +pre .javadoc, +pre .ruby .string, +pre .django .filter .argument, +pre .smalltalk .localvars, +pre .smalltalk .array, +pre .attr_selector, +pre .pseudo, +pre .addition, +pre .stream, +pre .envvar, +pre .apache .tag, +pre .apache .cbracket, +pre .tex .command, +pre .input_number { + color: #D88; +} + +pre .comment, +pre .java .annotation, +pre .python .decorator, +pre .template_comment, +pre .pi, +pre .doctype, +pre .deletion, +pre .shebang, +pre .apache .sqbracket, +pre .tex .formula { + color: #777; +} + +pre .keyword, +pre .literal, +pre .title, +pre .css .id, +pre .phpdoc, +pre .haskell .type, +pre .vbscript .built_in, +pre .sql .aggregate, +pre .rsl .built_in, +pre .smalltalk .class, +pre .diff .header, +pre .chunk, +pre .winutils, +pre .bash .variable, +pre .apache .tag, +pre .tex .special, +pre .request, +pre .status { + font-weight: bold; +} + +pre .coffeescript .javascript, +pre .xml .css, +pre .xml .javascript, +pre .xml .vbscript, +pre .tex .formula { + opacity: 0.5; +} diff --git a/console/lib/highlight/styles/default.css b/console/lib/highlight/styles/default.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/default.css @@ -0,0 +1,133 @@ +/* + +Original style from softwaremaniacs.org (c) Ivan Sagalaev + +*/ + +pre code { + display: block; padding: 0.5em; + background: #F0F0F0; +} + +pre code, +pre .ruby .subst, +pre .tag .title, +pre .lisp .title, +pre .nginx .title { + color: black; +} + +pre .string, +pre .title, +pre .constant, +pre .parent, +pre .tag .value, +pre .rules .value, +pre .rules .value .number, +pre .preprocessor, +pre .ruby .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .instancevar, +pre .aggregate, +pre .template_tag, +pre .django .variable, +pre .smalltalk .class, +pre .addition, +pre .flow, +pre .stream, +pre .bash .variable, +pre .apache .tag, +pre .apache .cbracket, +pre .tex .command, +pre .tex .special, +pre .erlang_repl .function_or_atom, +pre .markdown .header { + color: #800; +} + +pre .comment, +pre .annotation, +pre .template_comment, +pre .diff .header, +pre .chunk, +pre .markdown .blockquote { + color: #888; +} + +pre .number, +pre .date, +pre .regexp, +pre .literal, +pre .smalltalk .symbol, +pre .smalltalk .char, +pre .go .constant, +pre .change, +pre .markdown .bullet, +pre .markdown .link_url { + color: #080; +} + +pre .label, +pre .javadoc, +pre .ruby .string, +pre .decorator, +pre .filter .argument, +pre .localvars, +pre .array, +pre .attr_selector, +pre .important, +pre .pseudo, +pre .pi, +pre .doctype, +pre .deletion, +pre .envvar, +pre .shebang, +pre .apache .sqbracket, +pre .nginx .built_in, +pre .tex .formula, +pre .erlang_repl .reserved, +pre .input_number, +pre .markdown .link_label, +pre .vhdl .attribute { + color: #88F +} + +pre .keyword, +pre .id, +pre .phpdoc, +pre .title, +pre .built_in, +pre .aggregate, +pre .css .tag, +pre .javadoctag, +pre .phpdoc, +pre .yardoctag, +pre .smalltalk .class, +pre .winutils, +pre .bash .variable, +pre .apache .tag, +pre .go .typename, +pre .tex .command, +pre .markdown .strong, +pre .request, +pre .status { + font-weight: bold; +} + +pre .markdown .emphasis { + font-style: italic; +} + +pre .nginx .built_in { + font-weight: normal; +} + +pre .coffeescript .javascript, +pre .xml .css, +pre .xml .javascript, +pre .xml .vbscript, +pre .tex .formula { + opacity: 0.5; +} diff --git a/console/lib/highlight/styles/far.css b/console/lib/highlight/styles/far.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/far.css @@ -0,0 +1,110 @@ +/* + +FAR Style (c) MajestiC + +*/ + +pre code { + display: block; padding: 0.5em; + background: #000080; +} + +pre code, +.ruby .subst { + color: #0FF; +} + +pre .string, +pre .ruby .string, +pre .haskell .type, +pre .tag .value, +pre .css .rules .value, +pre .css .rules .value .number, +pre .preprocessor, +pre .ruby .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .built_in, +pre .sql .aggregate, +pre .django .template_tag, +pre .django .variable, +pre .smalltalk .class, +pre .addition, +pre .apache .tag, +pre .apache .cbracket, +pre .tex .command { + color: #FF0; +} + +pre .keyword, +pre .css .id, +pre .title, +pre .haskell .type, +pre .vbscript .built_in, +pre .sql .aggregate, +pre .rsl .built_in, +pre .smalltalk .class, +pre .xml .tag .title, +pre .winutils, +pre .flow, +pre .change, +pre .envvar, +pre .bash .variable, +pre .tex .special { + color: #FFF; +} + +pre .comment, +pre .phpdoc, +pre .javadoc, +pre .java .annotation, +pre .template_comment, +pre .deletion, +pre .apache .sqbracket, +pre .tex .formula { + color: #888; +} + +pre .number, +pre .date, +pre .regexp, +pre .literal, +pre .smalltalk .symbol, +pre .smalltalk .char { + color: #0F0; +} + +pre .python .decorator, +pre .django .filter .argument, +pre .smalltalk .localvars, +pre .smalltalk .array, +pre .attr_selector, +pre .pseudo, +pre .xml .pi, +pre .diff .header, +pre .chunk, +pre .shebang, +pre .nginx .built_in, +pre .input_number { + color: #008080; +} + +pre .keyword, +pre .css .id, +pre .title, +pre .haskell .type, +pre .vbscript .built_in, +pre .sql .aggregate, +pre .rsl .built_in, +pre .smalltalk .class, +pre .winutils, +pre .flow, +pre .apache .tag, +pre .nginx .built_in, +pre .tex .command, +pre .tex .special, +pre .request, +pre .status { + font-weight: bold; +} diff --git a/console/lib/highlight/styles/github.css b/console/lib/highlight/styles/github.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/github.css @@ -0,0 +1,133 @@ +/* + +github.com style (c) Vasily Polovnyov + +*/ + +pre code { + display: block; padding: 0.5em; + color: #000; + background: #f8f8ff +} + +pre .comment, +pre .template_comment, +pre .diff .header, +pre .javadoc { + color: #998; + font-style: italic +} + +pre .keyword, +pre .css .rule .keyword, +pre .winutils, +pre .javascript .title, +pre .lisp .title, +pre .nginx .title, +pre .subst, +pre .request, +pre .status { + color: #000; + font-weight: bold +} + +pre .number, +pre .hexcolor { + color: #40a070 +} + +pre .string, +pre .tag .value, +pre .phpdoc, +pre .tex .formula { + color: #d14 +} + +pre .title, +pre .id { + color: #900; + font-weight: bold +} + +pre .javascript .title, +pre .lisp .title, +pre .subst { + font-weight: normal +} + +pre .class .title, +pre .haskell .type, +pre .vhdl .literal, +pre .tex .command { + color: #458; + font-weight: bold +} + +pre .tag, +pre .tag .title, +pre .rules .property, +pre .django .tag .keyword { + color: #000080; + font-weight: normal +} + +pre .attribute, +pre .variable, +pre .instancevar, +pre .lisp .body { + color: #008080 +} + +pre .regexp { + color: #009926 +} + +pre .class { + color: #458; + font-weight: bold +} + +pre .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .lisp .keyword, +pre .tex .special, +pre .input_number { + color: #990073 +} + +pre .builtin, +pre .built_in, +pre .lisp .title { + color: #0086b3 +} + +pre .preprocessor, +pre .pi, +pre .doctype, +pre .shebang, +pre .cdata { + color: #999; + font-weight: bold +} + +pre .deletion { + background: #fdd +} + +pre .addition { + background: #dfd +} + +pre .diff .change { + background: #0086b3 +} + +pre .chunk { + color: #aaa +} + +pre .tex .formula { + opacity: 0.5; +} diff --git a/console/lib/highlight/styles/googlecode.css b/console/lib/highlight/styles/googlecode.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/googlecode.css @@ -0,0 +1,143 @@ +/* + +Google Code style (c) Aahan Krish + +*/ + +pre code { + display: block; padding: 0.5em; + background: white; color: black; +} + +pre .comment, +pre .template_comment, +pre .javadoc, +pre .comment * { + color: #800; +} + +pre .keyword, +pre .method, +pre .list .title, +pre .nginx .title, +pre .tag .title, +pre .setting .value, +pre .winutils, +pre .tex .command, +pre .http .title, +pre .request, +pre .status { + color: #008; +} + +pre .envvar, +pre .tex .special { + color: #660; +} + +pre .string, +pre .tag .value, +pre .cdata, +pre .filter .argument, +pre .attr_selector, +pre .apache .cbracket, +pre .date, +pre .regexp { + color: #080; +} + +pre .sub .identifier, +pre .pi, +pre .tag, +pre .tag .keyword, +pre .decorator, +pre .ini .title, +pre .shebang, +pre .input_number, +pre .hexcolor, +pre .rules .value, +pre .css .value .number, +pre .literal, +pre .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .number, +pre .css .function { + color: #066; +} + +pre .class .title, +pre .haskell .type, +pre .smalltalk .class, +pre .javadoctag, +pre .yardoctag, +pre .phpdoc, +pre .typename, +pre .tag .attribute, +pre .doctype, +pre .class .id, +pre .built_in, +pre .setting, +pre .params, +pre .variable { + color: #606; +} + +pre .css .tag, +pre .rules .property, +pre .pseudo, +pre .subst { + color: #000; +} + +pre .css .class, pre .css .id { + color: #9B703F; +} + +pre .value .important { + color: #ff7700; + font-weight: bold; +} + +pre .rules .keyword { + color: #C5AF75; +} + +pre .annotation, +pre .apache .sqbracket, +pre .nginx .built_in { + color: #9B859D; +} + +pre .preprocessor, +pre .preprocessor * { + color: #444; +} + +pre .tex .formula { + background-color: #EEE; + font-style: italic; +} + +pre .diff .header, +pre .chunk { + color: #808080; + font-weight: bold; +} + +pre .diff .change { + background-color: #BCCFF9; +} + +pre .addition { + background-color: #BAEEBA; +} + +pre .deletion { + background-color: #FFC8BD; +} + +pre .comment .yardoctag { + font-weight: bold; +} diff --git a/console/lib/highlight/styles/idea.css b/console/lib/highlight/styles/idea.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/idea.css @@ -0,0 +1,122 @@ +/* + +Intellij Idea-like styling (c) Vasily Polovnyov + +*/ + +pre code { + display: block; padding: 0.5em; + color: #000; + background: #fff; +} + +pre .subst, +pre .title { + font-weight: normal; + color: #000; +} + +pre .comment, +pre .template_comment, +pre .javadoc, +pre .diff .header { + color: #808080; + font-style: italic; +} + +pre .annotation, +pre .decorator, +pre .preprocessor, +pre .doctype, +pre .pi, +pre .chunk, +pre .shebang, +pre .apache .cbracket, +pre .input_number, +pre .http .title { + color: #808000; +} + +pre .tag, +pre .pi { + background: #efefef; +} + +pre .tag .title, +pre .id, +pre .attr_selector, +pre .pseudo, +pre .literal, +pre .keyword, +pre .hexcolor, +pre .css .function, +pre .ini .title, +pre .css .class, +pre .list .title, +pre .nginx .title, +pre .tex .command, +pre .request, +pre .status { + font-weight: bold; + color: #000080; +} + +pre .attribute, +pre .rules .keyword, +pre .number, +pre .date, +pre .regexp, +pre .tex .special { + font-weight: bold; + color: #0000ff; +} + +pre .number, +pre .regexp { + font-weight: normal; +} + +pre .string, +pre .value, +pre .filter .argument, +pre .css .function .params, +pre .apache .tag { + color: #008000; + font-weight: bold; +} + +pre .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .char, +pre .tex .formula { + color: #000; + background: #d0eded; + font-style: italic; +} + +pre .phpdoc, +pre .yardoctag, +pre .javadoctag { + text-decoration: underline; +} + +pre .variable, +pre .envvar, +pre .apache .sqbracket, +pre .nginx .built_in { + color: #660e7a; +} + +pre .addition { + background: #baeeba; +} + +pre .deletion { + background: #ffc8bd; +} + +pre .diff .change { + background: #bccff9; +} diff --git a/console/lib/highlight/styles/ir_black.css b/console/lib/highlight/styles/ir_black.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/ir_black.css @@ -0,0 +1,99 @@ +/* + IR_Black style (c) Vasily Mikhailitchenko +*/ + +pre code { + display: block; padding: 0.5em; + background: #000; color: #f8f8f8; +} + +pre .shebang, +pre .comment, +pre .template_comment, +pre .javadoc { + color: #7c7c7c; +} + +pre .keyword, +pre .tag, +pre .tex .command, +pre .request, +pre .status { + color: #96CBFE; +} + +pre .sub .keyword, +pre .method, +pre .list .title, +pre .nginx .title { + color: #FFFFB6; +} + +pre .string, +pre .tag .value, +pre .cdata, +pre .filter .argument, +pre .attr_selector, +pre .apache .cbracket, +pre .date { + color: #A8FF60; +} + +pre .subst { + color: #DAEFA3; +} + +pre .regexp { + color: #E9C062; +} + +pre .title, +pre .sub .identifier, +pre .pi, +pre .decorator, +pre .tex .special, +pre .haskell .type, +pre .constant, +pre .smalltalk .class, +pre .javadoctag, +pre .yardoctag, +pre .phpdoc, +pre .nginx .built_in { + color: #FFFFB6; +} + +pre .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .number, +pre .variable, +pre .vbscript, +pre .literal { + color: #C6C5FE; +} + +pre .css .tag { + color: #96CBFE; +} + +pre .css .rules .property, +pre .css .id { + color: #FFFFB6; +} + +pre .css .class { + color: #FFF; +} + +pre .hexcolor { + color: #C6C5FE; +} + +pre .number { + color:#FF73FD; +} + +pre .tex .formula { + opacity: 0.7; +} diff --git a/console/lib/highlight/styles/magula.css b/console/lib/highlight/styles/magula.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/magula.css @@ -0,0 +1,120 @@ +/* +Description: Magula style for highligh.js +Author: Ruslan Keba +Website: http://rukeba.com/ +Version: 1.0 +Date: 2009-01-03 +Music: Aphex Twin / Xtal +*/ + +pre code { + display: block; padding: 0.5em; + background-color: #f4f4f4; +} + +pre code, +pre .ruby .subst, +pre .lisp .title { + color: black; +} + +pre .string, +pre .title, +pre .parent, +pre .tag .value, +pre .rules .value, +pre .rules .value .number, +pre .preprocessor, +pre .ruby .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .instancevar, +pre .aggregate, +pre .template_tag, +pre .django .variable, +pre .smalltalk .class, +pre .addition, +pre .flow, +pre .stream, +pre .bash .variable, +pre .apache .cbracket { + color: #050; +} + +pre .comment, +pre .annotation, +pre .template_comment, +pre .diff .header, +pre .chunk { + color: #777; +} + +pre .number, +pre .date, +pre .regexp, +pre .literal, +pre .smalltalk .symbol, +pre .smalltalk .char, +pre .change, +pre .tex .special { + color: #800; +} + +pre .label, +pre .javadoc, +pre .ruby .string, +pre .decorator, +pre .filter .argument, +pre .localvars, +pre .array, +pre .attr_selector, +pre .pseudo, +pre .pi, +pre .doctype, +pre .deletion, +pre .envvar, +pre .shebang, +pre .apache .sqbracket, +pre .nginx .built_in, +pre .tex .formula, +pre .input_number { + color: #00e; +} + +pre .keyword, +pre .id, +pre .phpdoc, +pre .title, +pre .built_in, +pre .aggregate, +pre .smalltalk .class, +pre .winutils, +pre .bash .variable, +pre .apache .tag, +pre .xml .tag, +pre .tex .command, +pre .request, +pre .status { + font-weight: bold; + color: navy; +} + +pre .nginx .built_in { + font-weight: normal; +} + +pre .coffeescript .javascript, +pre .xml .css, +pre .xml .javascript, +pre .xml .vbscript, +pre .tex .formula { + opacity: 0.5; +} + +/* --- */ +pre .apache .tag { + font-weight: bold; + color: blue; +} + diff --git a/console/lib/highlight/styles/monokai.css b/console/lib/highlight/styles/monokai.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/monokai.css @@ -0,0 +1,116 @@ +/* +Monokai style - ported by Luigi Maselli - http://grigio.org +*/ + +pre code { + display: block; padding: 0.5em; + background: #272822; +} + +pre .params .identifier .keymethods { + color: #FD971F; +} + +pre .tag, +pre .tag .title, +pre .keyword, +pre .literal, +pre .change, +pre .winutils, +pre .flow, +pre .lisp .title, +pre .nginx .title, +pre .tex .special { + color: #F92672; +} + +pre code { + color: #DDD; +} + +pre code .constant { + color: #66D9EF; +} + +pre .class .title { + color: white; +} + +pre .attribute, +pre .symbol, +pre .value, +pre .regexp { + color: #BF79DB; +} + +pre .tag .value, +pre .string, +pre .ruby .subst, +pre .title, +pre .haskell .type, +pre .preprocessor, +pre .ruby .instancevar, +pre .ruby .class .parent, +pre .built_in, +pre .sql .aggregate, +pre .django .template_tag, +pre .django .variable, +pre .smalltalk .class, +pre .javadoc, +pre .ruby .string, +pre .django .filter .argument, +pre .smalltalk .localvars, +pre .smalltalk .array, +pre .attr_selector, +pre .pseudo, +pre .addition, +pre .stream, +pre .envvar, +pre .apache .tag, +pre .apache .cbracket, +pre .tex .command, +pre .input_number { + color: #A6E22E; +} + +pre .comment, +pre .java .annotation, +pre .python .decorator, +pre .template_comment, +pre .pi, +pre .doctype, +pre .deletion, +pre .shebang, +pre .apache .sqbracket, +pre .tex .formula { + color: #75715E; +} + +pre .keyword, +pre .literal, +pre .css .id, +pre .phpdoc, +pre .title, +pre .haskell .type, +pre .vbscript .built_in, +pre .sql .aggregate, +pre .rsl .built_in, +pre .smalltalk .class, +pre .diff .header, +pre .chunk, +pre .winutils, +pre .bash .variable, +pre .apache .tag, +pre .tex .special, +pre .request, +pre .status { + font-weight: bold; +} + +pre .coffeescript .javascript, +pre .xml .css, +pre .xml .javascript, +pre .xml .vbscript, +pre .tex .formula { + opacity: 0.5; +} diff --git a/console/lib/highlight/styles/pojoaque.css b/console/lib/highlight/styles/pojoaque.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/pojoaque.css @@ -0,0 +1,106 @@ +/* + +Pojoaque Style by Jason Tate +http://web-cms-designs.com/ftopict-10-pojoaque-style-for-highlight-js-code-highlighter.html +Based on Solarized Style from http://ethanschoonover.com/solarized + +*/ + +pre code { + display: block; padding: 0.5em; + color: #DCCF8F; + background: url(./pojoaque.jpg) repeat scroll left top #181914; +} + +pre .comment, +pre .template_comment, +pre .diff .header, +pre .doctype, +pre .lisp .string, +pre .javadoc { + color: #586e75; + font-style: italic; +} + +pre .keyword, +pre .css .rule .keyword, +pre .winutils, +pre .javascript .title, +pre .method, +pre .addition, +pre .css .tag, +pre .lisp .title, +pre .nginx .title { + color: #B64926; +} + +pre .number, +pre .command, +pre .string, +pre .tag .value, +pre .phpdoc, +pre .tex .formula, +pre .regexp, +pre .hexcolor { + color: #468966; +} + +pre .title, +pre .localvars, +pre .function .title, +pre .chunk, +pre .decorator, +pre .builtin, +pre .built_in, +pre .lisp .title, +pre .identifier, +pre .title .keymethods, +pre .id { + color: #FFB03B; +} + +pre .attribute, +pre .variable, +pre .instancevar, +pre .lisp .body, +pre .smalltalk .number, +pre .constant, +pre .class .title, +pre .parent, +pre .haskell .type { + color: #b58900; +} + +pre .css .attribute { + color: #b89859; +} + +pre .css .number,pre .css .hexcolor{ + color: #DCCF8F; +} + +pre .css .class { + color: #d3a60c; +} + +pre .preprocessor, +pre .pi, +pre .shebang, +pre .symbol, +pre .diff .change, +pre .special, +pre .keymethods, +pre .attr_selector, +pre .important, +pre .subst, +pre .cdata { + color: #cb4b16; +} + +pre .deletion { + color: #dc322f; +} + +pre .tex .formula { + background: #073642; +} diff --git a/console/lib/highlight/styles/pojoaque.jpg b/console/lib/highlight/styles/pojoaque.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9c07d4ab40b6d77e90ff69f0012bcd33b21d31c3 GIT binary patch literal 1186 zc${UDc}$aM9LJyM?fLeC7uq6K0+TR=f*W)M(6Uft z<*+!%Sbzx%)UoN9KrL~yQY5Q^0b3M`fGv|L%LrEtp&aX8ShDl;{P%tGyONK?;;;ed zgt#Md03rZn;14+F0Txq`o?QeWAOZjcc(edmQ5lM~cR_{`PoQHGlmnDZCR4~Lg@Q7v z6e`n+j-qrYjKy+du`rCu!eL?8=(5x^{usVpo@ z%{_DIJvGQDmipfFu_!^0x=FU%*m?^|HR_Hp1U4yD&YK;>o=L$9#63ve zl0h_;-Pj1NOgHPo?x-Zj_Pj27JRFVfARf}^agLc3+OBnp6(l_#P;?4(FH$px5&M>l zbzDi0vPOWc+);nKM_6f~ji{N?VB>q${Kv5&g;1C?6&PPX%g+SfF~1BH_0F5FJW^j1 zYO#naA2w;kC^10cU=7u09I}N0Fj0Vkj%|bKjtrFU_{=}ykT0ciC zFjs{4iMIqhH(V{^91GR2kZ!EX#mgGzAQI5#g?za#=iak(s^8q5yJ(|ZeI=iqUI}cX zdfUT?h*B0j?Q(xA9Z}Rmk#we9QXF5A{+xW_pqm@>>%IW1jmht1*%{4u4ef=Xt43-Q z#aE<(lnHuru3!B4hF6IEu3@om=}_;&EBYaV?&38)S(#^0vGuQs@I9MuEcLzbe7}Jr z?r6RBBvDz0XV{$hFv+tl>pA)M^kC}Hkt7EoPX?nYGx@9B4u8A$<+DU(>XMIzQ!N!x z&J>+J%CpE@JMaN;aWc#zd(`9pID8PPmS7C{OG_YBF zd*VFq5KS7st1zb_p^p9Aw6VK)w*G0J$+OnI|JU!CHsq*@fAOk3a%`*7STJJKg{i-y z>A<#}{Y@1okOwJ~p%<>pg=WSFP4%;dtNTkoQ}JV@te^iB2^fTBi5WX4K{25O+fY8} z63r10X42!$vQmn~%-C_Wy2dIy_j%A{Bt5cAwQPE|N=3~+^<-G^_6ku_%2#~k=Y7o% l0tRuZ&q>xv_g0m~b95c1)=*m${OsvbHf{s2lt#R>ob diff --git a/console/lib/highlight/styles/school_book.css b/console/lib/highlight/styles/school_book.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/school_book.css @@ -0,0 +1,111 @@ +/* + +School Book style from goldblog.com.ua (c) Zaripov Yura + +*/ + +pre code { + display: block; padding: 15px 0.5em 0.5em 30px; + font-size: 11px !important; + line-height:16px !important; +} + +pre{ + background:#f6f6ae url(./school_book.png); + border-top: solid 2px #d2e8b9; + border-bottom: solid 1px #d2e8b9; +} + +pre .keyword, +pre .literal, +pre .change, +pre .winutils, +pre .flow, +pre .lisp .title, +pre .nginx .title, +pre .tex .special { + color:#005599; + font-weight:bold; +} + +pre code, +pre .ruby .subst, +pre .tag .keyword { + color: #3E5915; +} + +pre .string, +pre .title, +pre .haskell .type, +pre .tag .value, +pre .css .rules .value, +pre .preprocessor, +pre .ruby .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .ruby .instancevar, +pre .ruby .class .parent, +pre .built_in, +pre .sql .aggregate, +pre .django .template_tag, +pre .django .variable, +pre .smalltalk .class, +pre .javadoc, +pre .ruby .string, +pre .django .filter .argument, +pre .smalltalk .localvars, +pre .smalltalk .array, +pre .attr_selector, +pre .pseudo, +pre .addition, +pre .stream, +pre .envvar, +pre .apache .tag, +pre .apache .cbracket, +pre .nginx .built_in, +pre .tex .command { + color: #2C009F; +} + +pre .comment, +pre .java .annotation, +pre .python .decorator, +pre .template_comment, +pre .pi, +pre .doctype, +pre .deletion, +pre .shebang, +pre .apache .sqbracket { + color: #E60415; +} + +pre .keyword, +pre .literal, +pre .css .id, +pre .phpdoc, +pre .title, +pre .haskell .type, +pre .vbscript .built_in, +pre .sql .aggregate, +pre .rsl .built_in, +pre .smalltalk .class, +pre .xml .tag .title, +pre .diff .header, +pre .chunk, +pre .winutils, +pre .bash .variable, +pre .apache .tag, +pre .tex .command, +pre .request, +pre .status { + font-weight: bold; +} + +pre .coffeescript .javascript, +pre .xml .css, +pre .xml .javascript, +pre .xml .vbscript, +pre .tex .formula { + opacity: 0.5; +} diff --git a/console/lib/highlight/styles/school_book.png b/console/lib/highlight/styles/school_book.png new file mode 100644 index 0000000000000000000000000000000000000000..956e9790a0e2c079b3d568348ff3accd1d9cac30 GIT binary patch literal 486 zc%17D@N?(olHy`uVBq!ia0y~yV7?7x3vjRjNjAS6Ga$v1?&#~tz_9*=IcwKTAYZb? zHKHUqKdq!Zu_%?nF(p4KRlzeiF+DXXH8G{K@MNkD0|R4)r;B4q#jQ7Ycl#YS5MfK$ z?b^fh#qmaEhFDxvyThwfhdfkOPApt1lr{NA;Vr%uzxJuVIyzm(ed_%V>YHpeb6{N>kw8yDVvD4BRsdcT_1{f;>KrGzq0>ui9%_wxQ1-Z?i1be12{{3vd6gZ!=H!#ca6t ztb1!<_v>BHJMQkQH=M-z>-UB$x4nJeu3kLBH0qb`R&V2D>(44m9n*NL9-R1RRMJYD@<);T3K F0RZDd%A^1Q diff --git a/console/lib/highlight/styles/solarized_dark.css b/console/lib/highlight/styles/solarized_dark.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/solarized_dark.css @@ -0,0 +1,90 @@ +/* + +Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull + +*/ + +pre code { + display: block; padding: 0.5em; + background: #002b36; color: #839496; +} + +pre .comment, +pre .template_comment, +pre .diff .header, +pre .doctype, +pre .pi, +pre .lisp .string, +pre .javadoc { + color: #586e75; + font-style: italic; +} + +pre .keyword, +pre .winutils, +pre .method, +pre .addition, +pre .css .tag, +pre .request, +pre .status, +pre .nginx .title { + color: #859900; +} + +pre .number, +pre .command, +pre .string, +pre .tag .value, +pre .phpdoc, +pre .tex .formula, +pre .regexp, +pre .hexcolor { + color: #2aa198; +} + +pre .title, +pre .localvars, +pre .chunk, +pre .decorator, +pre .builtin, +pre .built_in, +pre .identifier, +pre .title .keymethods, +pre .vhdl .literal, +pre .id { + color: #268bd2; +} + +pre .attribute, +pre .variable, +pre .instancevar, +pre .lisp .body, +pre .smalltalk .number, +pre .constant, +pre .class .title, +pre .parent, +pre .haskell .type { + color: #b58900; +} + +pre .preprocessor, +pre .preprocessor .keyword, +pre .shebang, +pre .symbol, +pre .diff .change, +pre .special, +pre .keymethods, +pre .attr_selector, +pre .important, +pre .subst, +pre .cdata { + color: #cb4b16; +} + +pre .deletion { + color: #dc322f; +} + +pre .tex .formula { + background: #073642; +} diff --git a/console/lib/highlight/styles/solarized_light.css b/console/lib/highlight/styles/solarized_light.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/solarized_light.css @@ -0,0 +1,90 @@ +/* + +Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull + +*/ + +pre code { + display: block; padding: 0.5em; + background: #fdf6e3; color: #657b83; +} + +pre .comment, +pre .template_comment, +pre .diff .header, +pre .doctype, +pre .pi, +pre .lisp .string, +pre .javadoc { + color: #93a1a1; + font-style: italic; +} + +pre .keyword, +pre .winutils, +pre .method, +pre .addition, +pre .css .tag, +pre .request, +pre .status, +pre .nginx .title { + color: #859900; +} + +pre .number, +pre .command, +pre .string, +pre .tag .value, +pre .phpdoc, +pre .tex .formula, +pre .regexp, +pre .hexcolor { + color: #2aa198; +} + +pre .title, +pre .localvars, +pre .chunk, +pre .decorator, +pre .builtin, +pre .built_in, +pre .identifier, +pre .title .keymethods, +pre .vhdl .literal, +pre .id { + color: #268bd2; +} + +pre .attribute, +pre .variable, +pre .instancevar, +pre .lisp .body, +pre .smalltalk .number, +pre .constant, +pre .class .title, +pre .parent, +pre .haskell .type { + color: #b58900; +} + +pre .preprocessor, +pre .preprocessor .keyword, +pre .shebang, +pre .symbol, +pre .diff .change, +pre .special, +pre .keymethods, +pre .attr_selector, +pre .important, +pre .subst, +pre .cdata { + color: #cb4b16; +} + +pre .deletion { + color: #dc322f; +} + +pre .tex .formula { + background: #eee8d5; +} diff --git a/console/lib/highlight/styles/sunburst.css b/console/lib/highlight/styles/sunburst.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/sunburst.css @@ -0,0 +1,149 @@ +/* + +Sunburst-like style (c) Vasily Polovnyov + +*/ + +pre code { + display: block; padding: 0.5em; + background: #000; color: #f8f8f8; +} + +pre .comment, +pre .template_comment, +pre .javadoc { + color: #aeaeae; + font-style: italic; +} + +pre .keyword, +pre .ruby .function .keyword, +pre .request, +pre .status, +pre .nginx .title { + color: #E28964; +} + +pre .function .keyword, +pre .sub .keyword, +pre .method, +pre .list .title { + color: #99CF50; +} + +pre .string, +pre .tag .value, +pre .cdata, +pre .filter .argument, +pre .attr_selector, +pre .apache .cbracket, +pre .date, +pre .tex .command { + color: #65B042; +} + +pre .subst { + color: #DAEFA3; +} + +pre .regexp { + color: #E9C062; +} + +pre .title, +pre .sub .identifier, +pre .pi, +pre .tag, +pre .tag .keyword, +pre .decorator, +pre .shebang, +pre .input_number { + color: #89BDFF; +} + +pre .class .title, +pre .haskell .type, +pre .smalltalk .class, +pre .javadoctag, +pre .yardoctag, +pre .phpdoc { + text-decoration: underline; +} + +pre .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .number { + color: #3387CC; +} + +pre .params, +pre .variable { + color: #3E87E3; +} + +pre .css .tag, +pre .rules .property, +pre .pseudo, +pre .tex .special { + color: #CDA869; +} + +pre .css .class { + color: #9B703F; +} + +pre .rules .keyword { + color: #C5AF75; +} + +pre .rules .value { + color: #CF6A4C; +} + +pre .css .id { + color: #8B98AB; +} + +pre .annotation, +pre .apache .sqbracket, +pre .nginx .built_in { + color: #9B859D; +} + +pre .preprocessor { + color: #8996A8; +} + +pre .hexcolor, +pre .css .value .number { + color: #DD7B3B; +} + +pre .css .function { + color: #DAD085; +} + +pre .diff .header, +pre .chunk, +pre .tex .formula { + background-color: #0E2231; + color: #F8F8F8; + font-style: italic; +} + +pre .diff .change { + background-color: #4A410D; + color: #F8F8F8; +} + +pre .addition { + background-color: #253B22; + color: #F8F8F8; +} + +pre .deletion { + background-color: #420E09; + color: #F8F8F8; +} diff --git a/console/lib/highlight/styles/vs.css b/console/lib/highlight/styles/vs.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/vs.css @@ -0,0 +1,85 @@ +/* + +Visual Studio-like style based on original C# coloring by Jason Diamond + +*/ +pre code { + display: block; padding: 0.5em; +} + +pre .comment, +pre .annotation, +pre .template_comment, +pre .diff .header, +pre .chunk, +pre .apache .cbracket { + color: rgb(0, 128, 0); +} + +pre .keyword, +pre .id, +pre .built_in, +pre .smalltalk .class, +pre .winutils, +pre .bash .variable, +pre .tex .command, +pre .request, +pre .status, +pre .nginx .title { + color: rgb(0, 0, 255); +} + +pre .string, +pre .title, +pre .parent, +pre .tag .value, +pre .rules .value, +pre .rules .value .number, +pre .ruby .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .instancevar, +pre .aggregate, +pre .template_tag, +pre .django .variable, +pre .addition, +pre .flow, +pre .stream, +pre .apache .tag, +pre .date, +pre .tex .formula { + color: rgb(163, 21, 21); +} + +pre .ruby .string, +pre .decorator, +pre .filter .argument, +pre .localvars, +pre .array, +pre .attr_selector, +pre .pseudo, +pre .pi, +pre .doctype, +pre .deletion, +pre .envvar, +pre .shebang, +pre .preprocessor, +pre .userType, +pre .apache .sqbracket, +pre .nginx .built_in, +pre .tex .special, +pre .input_number { + color: rgb(43, 145, 175); +} + +pre .phpdoc, +pre .javadoc, +pre .xmlDocTag { + color: rgb(128, 128, 128); +} + +pre .vhdl .typename { font-weight: bold; } +pre .vhdl .string { color: #666666; } +pre .vhdl .literal { color: rgb(163, 21, 21); } +pre .vhdl .attribute { color: #00B0E8; } diff --git a/console/lib/highlight/styles/xcode.css b/console/lib/highlight/styles/xcode.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/xcode.css @@ -0,0 +1,153 @@ +/* + +XCode style (c) Angel Garcia + +*/ + +pre code { + display: block; padding: 0.5em; + background: #fff; color: black; +} + +pre .comment, +pre .template_comment, +pre .javadoc, +pre .comment * { + color: rgb(0,106,0); +} + +pre .keyword, +pre .literal, +pre .nginx .title { + color: rgb(170,13,145); +} +pre .method, +pre .list .title, +pre .tag .title, +pre .setting .value, +pre .winutils, +pre .tex .command, +pre .http .title, +pre .request, +pre .status { + color: #008; +} + +pre .envvar, +pre .tex .special { + color: #660; +} + +pre .string { + color: rgb(196,26,22); +} +pre .tag .value, +pre .cdata, +pre .filter .argument, +pre .attr_selector, +pre .apache .cbracket, +pre .date, +pre .regexp { + color: #080; +} + +pre .sub .identifier, +pre .pi, +pre .tag, +pre .tag .keyword, +pre .decorator, +pre .ini .title, +pre .shebang, +pre .input_number, +pre .hexcolor, +pre .rules .value, +pre .css .value .number, +pre .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .number, +pre .css .function { + color: rgb(28,0,207); +} + +pre .class .title, +pre .haskell .type, +pre .smalltalk .class, +pre .javadoctag, +pre .yardoctag, +pre .phpdoc, +pre .typename, +pre .tag .attribute, +pre .doctype, +pre .class .id, +pre .built_in, +pre .setting, +pre .params { + color: rgb(92,38,153); +} + +pre .variable { + color: rgb(63,110,116); +} +pre .css .tag, +pre .rules .property, +pre .pseudo, +pre .subst { + color: #000; +} + +pre .css .class, pre .css .id { + color: #9B703F; +} + +pre .value .important { + color: #ff7700; + font-weight: bold; +} + +pre .rules .keyword { + color: #C5AF75; +} + +pre .annotation, +pre .apache .sqbracket, +pre .nginx .built_in { + color: #9B859D; +} + +pre .preprocessor, +pre .preprocessor * { + color: rgb(100,56,32); +} + +pre .tex .formula { + background-color: #EEE; + font-style: italic; +} + +pre .diff .header, +pre .chunk { + color: #808080; + font-weight: bold; +} + +pre .diff .change { + background-color: #BCCFF9; +} + +pre .addition { + background-color: #BAEEBA; +} + +pre .deletion { + background-color: #FFC8BD; +} + +pre .comment .yardoctag { + font-weight: bold; +} + +pre .method .id { + color: #000; +} diff --git a/console/lib/highlight/styles/zenburn.css b/console/lib/highlight/styles/zenburn.css new file mode 100644 --- /dev/null +++ b/console/lib/highlight/styles/zenburn.css @@ -0,0 +1,115 @@ +/* + +Zenburn style from voldmar.ru (c) Vladimir Epifanov +based on dark.css by Ivan Sagalaev + +*/ + +pre code { + display: block; padding: 0.5em; + background: #3F3F3F; + color: #DCDCDC; +} + +pre .keyword, +pre .tag, +pre .css .class, +pre .css .id, +pre .lisp .title, +pre .nginx .title, +pre .request, +pre .status { + color: #E3CEAB; +} + +pre .django .template_tag, +pre .django .variable, +pre .django .filter .argument { + color: #DCDCDC; +} + +pre .number, +pre .date { + color: #8CD0D3; +} + +pre .dos .envvar, +pre .dos .stream, +pre .variable, +pre .apache .sqbracket { + color: #EFDCBC; +} + +pre .dos .flow, +pre .diff .change, +pre .python .exception, +pre .python .built_in, +pre .literal, +pre .tex .special { + color: #EFEFAF; +} + +pre .diff .chunk, +pre .ruby .subst { + color: #8F8F8F; +} + +pre .dos .keyword, +pre .python .decorator, +pre .title, +pre .haskell .type, +pre .diff .header, +pre .ruby .class .parent, +pre .apache .tag, +pre .nginx .built_in, +pre .tex .command, +pre .input_number { + color: #efef8f; +} + +pre .dos .winutils, +pre .ruby .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .ruby .string, +pre .ruby .instancevar { + color: #DCA3A3; +} + +pre .diff .deletion, +pre .string, +pre .tag .value, +pre .preprocessor, +pre .built_in, +pre .sql .aggregate, +pre .javadoc, +pre .smalltalk .class, +pre .smalltalk .localvars, +pre .smalltalk .array, +pre .css .rules .value, +pre .attr_selector, +pre .pseudo, +pre .apache .cbracket, +pre .tex .formula { + color: #CC9393; +} + +pre .shebang, +pre .diff .addition, +pre .comment, +pre .java .annotation, +pre .template_comment, +pre .pi, +pre .doctype { + color: #7F9F7F; +} + +pre .coffeescript .javascript, +pre .xml .css, +pre .xml .javascript, +pre .xml .vbscript, +pre .tex .formula { + opacity: 0.5; +} + diff --git a/lib/vkbeautify.0.97.00.beta.js b/console/lib/vkbeautify.0.97.00.beta.js rename from lib/vkbeautify.0.97.00.beta.js rename to console/lib/vkbeautify.0.97.00.beta.js diff --git a/jid.js b/jid.js --- a/jid.js +++ b/jid.js @@ -16,14 +16,28 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +//https://tools.ietf.org/html/rfc6122 + +(function() { + + + if (typeof define !== 'undefined') { + define(function() { + //return an object to define the "my/shirt" module. + return JID; + }); +} +else { + Lightstring.JID = JID; +} /** * @constructor Creates a new JID object. * @param {String} [aJID] The host, bare or full JID. * @memberOf Lightstring */ -Lightstring.JID = function(aJID) { - this.node = null; +var JID = function(aJID) { + this.local = null; this.domain = null; this.resource = null; @@ -33,7 +47,7 @@ Lightstring.JID = function(aJID) { //TODO: use a stringprep library to validate the input. }; -Lightstring.JID.prototype = { +JID.prototype = { toString: function() { return this.full; }, @@ -42,7 +56,7 @@ Lightstring.JID.prototype = { if (!(aJID instanceof Lightstring.JID)) aJID = new Lightstring.JID(aJID); - return (this.node === aJID.node && + return (this.local === aJID.local && this.domain === aJID.domain && this.resource === aJID.resource) }, @@ -51,8 +65,8 @@ Lightstring.JID.prototype = { if (!this.domain) return null; - if (this.node) - return this.node + '@' + this.domain; + if (this.local) + return this.local + '@' + this.domain; return this.domain; }, @@ -67,10 +81,10 @@ Lightstring.JID.prototype = { s = aJID.indexOf('@'); if (s == -1) { - this.node = null; + this.local = null; this.domain = aJID; } else { - this.node = aJID.substring(0, s); + this.local = aJID.substring(0, s); this.domain = aJID.substring(s+1); } }, @@ -81,8 +95,8 @@ Lightstring.JID.prototype = { var full = this.domain; - if (this.node) - full = this.node + '@' + full; + if (this.local) + full = this.local + '@' + full; if (this.resource) full = full + '/' + this.resource; @@ -105,11 +119,13 @@ Lightstring.JID.prototype = { s = aJID.indexOf('@'); if (s == -1) { - this.node = null; + this.local = null; this.domain = aJID; } else { - this.node = aJID.substring(0, s); + this.local = aJID.substring(0, s); this.domain = aJID.substring(s+1); } } }; +})(); + diff --git a/lib/require.js b/lib/require.js new file mode 100644 --- /dev/null +++ b/lib/require.js @@ -0,0 +1,35 @@ +/* + RequireJS 2.0.2 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. + Available via the MIT or new BSD license. + see: http://github.com/jrburke/requirejs for details +*/ +var requirejs,require,define; +(function(Z){function w(b){return J.call(b)==="[object Function]"}function G(b){return J.call(b)==="[object Array]"}function q(b,d){if(b){var f;for(f=0;f-1;f-=1)if(b[f]&&d(b[f],f,b))break}}function x(b,d){for(var f in b)if(b.hasOwnProperty(f)&&d(b[f],f))break}function K(b,d,f,g){d&&x(d,function(d,k){if(f||!b.hasOwnProperty(k))g&&typeof d!=="string"?(b[k]||(b[k]={}),K(b[k],d,f,g)):b[k]=d});return b}function s(b, +d){return function(){return d.apply(b,arguments)}}function $(b){if(!b)return b;var d=Z;q(b.split("."),function(b){d=d[b]});return d}function aa(b,d,f){return function(){var g=ga.call(arguments,0),e;if(f&&w(e=g[g.length-1]))e.__requireJsBuild=!0;g.push(d);return b.apply(null,g)}}function ba(b,d,f){q([["toUrl"],["undef"],["defined","requireDefined"],["specified","requireSpecified"]],function(g){var e=g[1]||g[0];b[g[0]]=d?aa(d[e],f):function(){var b=t[O];return b[e].apply(b,arguments)}})}function H(b, +d,f,g){d=Error(d+"\nhttp://requirejs.org/docs/errors.html#"+b);d.requireType=b;d.requireModules=g;if(f)d.originalError=f;return d}function ha(){if(I&&I.readyState==="interactive")return I;N(document.getElementsByTagName("script"),function(b){if(b.readyState==="interactive")return I=b});return I}var ia=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ja=/require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,ca=/\.js$/,ka=/^\.\//,J=Object.prototype.toString,y=Array.prototype,ga=y.slice,la=y.splice,u=!!(typeof window!== +"undefined"&&navigator&&document),da=!u&&typeof importScripts!=="undefined",ma=u&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,O="_",S=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",t={},p={},P=[],L=!1,k,v,C,z,D,I,E,ea,fa;if(typeof define==="undefined"){if(typeof requirejs!=="undefined"){if(w(requirejs))return;p=requirejs;requirejs=void 0}typeof require!=="undefined"&&!w(require)&&(p=require,require=void 0);k=requirejs=function(b,d,f,g){var e=O,r;!G(b)&& +typeof b!=="string"&&(r=b,G(d)?(b=d,d=f,f=g):b=[]);if(r&&r.context)e=r.context;(g=t[e])||(g=t[e]=k.s.newContext(e));r&&g.configure(r);return g.require(b,d,f)};k.config=function(b){return k(b)};require||(require=k);k.version="2.0.2";k.jsExtRegExp=/^\/|:|\?|\.js$/;k.isBrowser=u;y=k.s={contexts:t,newContext:function(b){function d(a,c,l){var A=c&&c.split("/"),b=m.map,i=b&&b["*"],h,d,f,e;if(a&&a.charAt(0)===".")if(c){A=m.pkgs[c]?[c]:A.slice(0,A.length-1);c=a=A.concat(a.split("/"));for(h=0;c[h];h+=1)if(d= +c[h],d===".")c.splice(h,1),h-=1;else if(d==="..")if(h===1&&(c[2]===".."||c[0]===".."))break;else h>0&&(c.splice(h-1,2),h-=2);h=m.pkgs[c=a[0]];a=a.join("/");h&&a===c+"/"+h.main&&(a=c)}else a.indexOf("./")===0&&(a=a.substring(2));if(l&&(A||i)&&b){c=a.split("/");for(h=c.length;h>0;h-=1){f=c.slice(0,h).join("/");if(A)for(d=A.length;d>0;d-=1)if(l=b[A.slice(0,d).join("/")])if(l=l[f]){e=l;break}!e&&i&&i[f]&&(e=i[f]);if(e){c.splice(0,h,e);a=c.join("/");break}}}return a}function f(a){u&&q(document.getElementsByTagName("script"), +function(c){if(c.getAttribute("data-requiremodule")===a&&c.getAttribute("data-requirecontext")===j.contextName)return c.parentNode.removeChild(c),!0})}function g(a){var c=m.paths[a];if(c&&G(c)&&c.length>1)return f(a),c.shift(),j.undef(a),j.require([a]),!0}function e(a,c,l,b){var T=a?a.indexOf("!"):-1,i=null,h=c?c.name:null,f=a,e=!0,g="",k,m;a||(e=!1,a="_@r"+(N+=1));T!==-1&&(i=a.substring(0,T),a=a.substring(T+1,a.length));i&&(i=d(i,h,b),m=o[i]);a&&(i?g=m&&m.normalize?m.normalize(a,function(a){return d(a, +h,b)}):d(a,h,b):(g=d(a,h,b),k=j.nameToUrl(a,null,c)));a=i&&!m&&!l?"_unnormalized"+(O+=1):"";return{prefix:i,name:g,parentMap:c,unnormalized:!!a,url:k,originalName:f,isDefine:e,id:(i?i+"!"+g:g)+a}}function r(a){var c=a.id,l=n[c];l||(l=n[c]=new j.Module(a));return l}function p(a,c,l){var b=a.id,d=n[b];if(o.hasOwnProperty(b)&&(!d||d.defineEmitComplete))c==="defined"&&l(o[b]);else r(a).on(c,l)}function B(a,c){var l=a.requireModules,b=!1;if(c)c(a);else if(q(l,function(c){if(c=n[c])c.error=a,c.events.error&& +(b=!0,c.emit("error",a))}),!b)k.onError(a)}function v(){P.length&&(la.apply(F,[F.length-1,0].concat(P)),P=[])}function t(a,c,l){a=a&&a.map;c=aa(l||j.require,a,c);ba(c,j,a);c.isBrowser=u;return c}function y(a){delete n[a];q(M,function(c,l){if(c.map.id===a)return M.splice(l,1),c.defined||(j.waitCount-=1),!0})}function z(a,c){var l=a.map.id,b=a.depMaps,d;if(a.inited){if(c[l])return a;c[l]=!0;q(b,function(a){if(a=n[a.id])return!a.inited||!a.enabled?(d=null,delete c[l],!0):d=z(a,K({},c))});return d}}function C(a, +c,b){var d=a.map.id,e=a.depMaps;if(a.inited&&a.map.isDefine){if(c[d])return o[d];c[d]=a;q(e,function(i){var i=i.id,h=n[i];!Q[i]&&h&&(!h.inited||!h.enabled?b[d]=!0:(h=C(h,c,b),b[i]||a.defineDepById(i,h)))});a.check(!0);return o[d]}}function D(a){a.check()}function E(){var a=m.waitSeconds*1E3,c=a&&j.startTime+a<(new Date).getTime(),b=[],d=!1,e=!0,i,h,k;if(!U){U=!0;x(n,function(a){i=a.map;h=i.id;if(a.enabled&&!a.error)if(!a.inited&&c)g(h)?d=k=!0:(b.push(h),f(h));else if(!a.inited&&a.fetched&&i.isDefine&& +(d=!0,!i.prefix))return e=!1});if(c&&b.length)return a=H("timeout","Load timeout for modules: "+b,null,b),a.contextName=j.contextName,B(a);e&&(q(M,function(a){if(!a.defined){var a=z(a,{}),c={};a&&(C(a,c,{}),x(c,D))}}),x(n,D));if((!c||k)&&d)if((u||da)&&!V)V=setTimeout(function(){V=0;E()},50);U=!1}}function W(a){r(e(a[0],null,!0)).init(a[1],a[2])}function J(a){var a=a.currentTarget||a.srcElement,c=j.onScriptLoad;a.detachEvent&&!S?a.detachEvent("onreadystatechange",c):a.removeEventListener("load",c, +!1);c=j.onScriptError;a.detachEvent&&!S||a.removeEventListener("error",c,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}var m={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},shim:{}},n={},X={},F=[],o={},R={},N=1,O=1,M=[],U,Y,j,Q,V;Q={require:function(a){return t(a)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports=o[a.map.id]={}},module:function(a){return a.module={id:a.map.id,uri:a.map.url,config:function(){return m.config&&m.config[a.map.id]||{}},exports:o[a.map.id]}}}; +Y=function(a){this.events=X[a.id]||{};this.map=a;this.shim=m.shim[a.id];this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};Y.prototype={init:function(a,c,b,d){d=d||{};if(!this.inited){this.factory=c;if(b)this.on("error",b);else this.events.error&&(b=s(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.depMaps.rjsSkipMap=a.rjsSkipMap;this.errback=b;this.inited=!0;this.ignore=d.ignore;d.enabled||this.enabled?this.enable():this.check()}},defineDepById:function(a, +c){var b;q(this.depMaps,function(c,d){if(c.id===a)return b=d,!0});return this.defineDep(b,c)},defineDep:function(a,c){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=c)},fetch:function(){if(!this.fetched){this.fetched=!0;j.startTime=(new Date).getTime();var a=this.map;if(this.shim)t(this,!0)(this.shim.deps||[],s(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=this.map.url;R[a]|| +(R[a]=!0,j.load(this.map.id,a))},check:function(a){if(this.enabled&&!this.enabling){var c=this.map.id,b=this.depExports,d=this.exports,e=this.factory,i;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(this.depCount<1&&!this.defined){if(w(e)){if(this.events.error)try{d=j.execCb(c,e,b,d)}catch(h){i=h}else d=j.execCb(c,e,b,d);if(this.map.isDefine)if((b=this.module)&&b.exports!==void 0&&b.exports!==this.exports)d=b.exports;else if(d===void 0&&this.usingExports)d= +this.exports;if(i)return i.requireMap=this.map,i.requireModules=[this.map.id],i.requireType="define",B(this.error=i)}else d=e;this.exports=d;if(this.map.isDefine&&!this.ignore&&(o[c]=d,k.onResourceLoad))k.onResourceLoad(j,this.map,this.depMaps);delete n[c];this.defined=!0;j.waitCount-=1;j.waitCount===0&&(M=[])}this.defining=!1;if(!a&&this.defined&&!this.defineEmitted)this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0}}else this.fetch()}},callPlugin:function(){var a= +this.map,c=a.id,b=e(a.prefix,null,!1,!0);p(b,"defined",s(this,function(b){var l=this.map.name,i=this.map.parentMap?this.map.parentMap.name:null;if(this.map.unnormalized){if(b.normalize&&(l=b.normalize(l,function(a){return d(a,i,!0)})||""),b=e(a.prefix+"!"+l,this.map.parentMap,!1,!0),p(b,"defined",s(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),b=n[b.id]){if(this.events.error)b.on("error",s(this,function(a){this.emit("error",a)}));b.enable()}}else l=s(this,function(a){this.init([], +function(){return a},null,{enabled:!0})}),l.error=s(this,function(a){this.inited=!0;this.error=a;a.requireModules=[c];x(n,function(a){a.map.id.indexOf(c+"_unnormalized")===0&&y(a.map.id)});B(a)}),l.fromText=function(a,c){var b=L;b&&(L=!1);r(e(a));k.exec(c);b&&(L=!0);j.completeLoad(a)},b.load(a.name,t(a.parentMap,!0,function(a,c){a.rjsSkipMap=!0;return j.require(a,c)}),l,m)}));j.enable(b,this);this.pluginMaps[b.id]=b},enable:function(){this.enabled=!0;if(!this.waitPushed)M.push(this),j.waitCount+= +1,this.waitPushed=!0;this.enabling=!0;q(this.depMaps,s(this,function(a,c){var b,d;if(typeof a==="string"){a=e(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.depMaps.rjsSkipMap);this.depMaps[c]=a;if(b=Q[a.id]){this.depExports[c]=b(this);return}this.depCount+=1;p(a,"defined",s(this,function(a){this.defineDep(c,a);this.check()}));this.errback&&p(a,"error",this.errback)}b=a.id;d=n[b];!Q[b]&&d&&!d.enabled&&j.enable(a,this)}));x(this.pluginMaps,s(this,function(a){var c=n[a.id];c&&!c.enabled&& +j.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,c){var b=this.events[a];b||(b=this.events[a]=[]);b.push(c)},emit:function(a,c){q(this.events[a],function(a){a(c)});a==="error"&&delete this.events[a]}};return j={config:m,contextName:b,registry:n,defined:o,urlFetched:R,waitCount:0,defQueue:F,Module:Y,makeModuleMap:e,configure:function(a){a.baseUrl&&a.baseUrl.charAt(a.baseUrl.length-1)!=="/"&&(a.baseUrl+="/");var c=m.pkgs,b=m.shim,d=m.paths,f=m.map;K(m,a,!0);m.paths=K(d,a.paths,!0);if(a.map)m.map= +K(f||{},a.map,!0,!0);if(a.shim)x(a.shim,function(a,c){G(a)&&(a={deps:a});if(a.exports&&!a.exports.__buildReady)a.exports=j.makeShimExports(a.exports);b[c]=a}),m.shim=b;if(a.packages)q(a.packages,function(a){a=typeof a==="string"?{name:a}:a;c[a.name]={name:a.name,location:a.location||a.name,main:(a.main||"main").replace(ka,"").replace(ca,"")}}),m.pkgs=c;x(n,function(a,c){a.map=e(c)});if(a.deps||a.callback)j.require(a.deps||[],a.callback)},makeShimExports:function(a){var c;return typeof a==="string"? +(c=function(){return $(a)},c.exports=a,c):function(){return a.apply(Z,arguments)}},requireDefined:function(a,c){var b=e(a,c,!1,!0).id;return o.hasOwnProperty(b)},requireSpecified:function(a,c){a=e(a,c,!1,!0).id;return o.hasOwnProperty(a)||n.hasOwnProperty(a)},require:function(a,c,d,f){var g;if(typeof a==="string"){if(w(c))return B(H("requireargs","Invalid require call"),d);if(k.get)return k.get(j,a,c);a=e(a,c,!1,!0);a=a.id;return!o.hasOwnProperty(a)?B(H("notloaded",'Module name "'+a+'" has not been loaded yet for context: '+ +b)):o[a]}d&&!w(d)&&(f=d,d=void 0);c&&!w(c)&&(f=c,c=void 0);for(v();F.length;)if(g=F.shift(),g[0]===null)return B(H("mismatch","Mismatched anonymous define() module: "+g[g.length-1]));else W(g);r(e(null,f)).init(a,c,d,{enabled:!0});E();return j.require},undef:function(a){var c=e(a,null,!0),b=n[a];delete o[a];delete R[c.url];delete X[a];if(b){if(b.events.defined)X[a]=b.events;y(a)}},enable:function(a){n[a.id]&&r(a).enable()},completeLoad:function(a){var c=m.shim[a]||{},b=c.exports&&c.exports.exports, +d,e;for(v();F.length;){e=F.shift();if(e[0]===null){e[0]=a;if(d)break;d=!0}else e[0]===a&&(d=!0);W(e)}e=n[a];if(!d&&!o[a]&&e&&!e.inited)if(m.enforceDefine&&(!b||!$(b)))if(g(a))return;else return B(H("nodefine","No define call for "+a,null,[a]));else W([a,c.deps||[],c.exports]);E()},toUrl:function(a,b){var d=a.lastIndexOf("."),e=null;d!==-1&&(e=a.substring(d,a.length),a=a.substring(0,d));return j.nameToUrl(a,e,b)},nameToUrl:function(a,b,e){var f,g,i,h,j,a=d(a,e&&e.id,!0);if(k.jsExtRegExp.test(a))b= +a+(b||"");else{f=m.paths;g=m.pkgs;e=a.split("/");for(h=e.length;h>0;h-=1)if(j=e.slice(0,h).join("/"),i=g[j],j=f[j]){G(j)&&(j=j[0]);e.splice(0,h,j);break}else if(i){a=a===i.name?i.location+"/"+i.main:i.location;e.splice(0,h,a);break}b=e.join("/")+(b||".js");b=(b.charAt(0)==="/"||b.match(/^[\w\+\.\-]+:/)?"":m.baseUrl)+b}return m.urlArgs?b+((b.indexOf("?")===-1?"?":"&")+m.urlArgs):b},load:function(a,b){k.load(j,a,b)},execCb:function(a,b,d,e){return b.apply(e,d)},onScriptLoad:function(a){if(a.type=== +"load"||ma.test((a.currentTarget||a.srcElement).readyState))I=null,a=J(a),j.completeLoad(a.id)},onScriptError:function(a){var b=J(a);if(!g(b.id))return B(H("scripterror","Script error",a,[b.id]))}}}};k({});ba(k);if(u&&(v=y.head=document.getElementsByTagName("head")[0],C=document.getElementsByTagName("base")[0]))v=y.head=C.parentNode;k.onError=function(b){throw b;};k.load=function(b,d,f){var g=b&&b.config||{},e;if(u)return e=g.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"): +document.createElement("script"),e.type=g.scriptType||"text/javascript",e.charset="utf-8",e.setAttribute("data-requirecontext",b.contextName),e.setAttribute("data-requiremodule",d),e.attachEvent&&!(e.attachEvent.toString&&e.attachEvent.toString().indexOf("[native code")<0)&&!S?(L=!0,e.attachEvent("onreadystatechange",b.onScriptLoad)):(e.addEventListener("load",b.onScriptLoad,!1),e.addEventListener("error",b.onScriptError,!1)),e.src=f,E=e,C?v.insertBefore(e,C):v.appendChild(e),E=null,e;else da&&(importScripts(f), +b.completeLoad(d))};u&&N(document.getElementsByTagName("script"),function(b){if(!v)v=b.parentNode;if(z=b.getAttribute("data-main")){D=z.split("/");ea=D.pop();fa=D.length?D.join("/")+"/":"./";if(!p.baseUrl)p.baseUrl=fa;z=ea.replace(ca,"");p.deps=p.deps?p.deps.concat(z):[z];return!0}});define=function(b,d,f){var g,e;typeof b!=="string"&&(f=d,d=b,b=null);G(d)||(f=d,d=[]);!d.length&&w(f)&&f.length&&(f.toString().replace(ia,"").replace(ja,function(b,e){d.push(e)}),d=(f.length===1?["require"]:["require", +"exports","module"]).concat(d));if(L&&(g=E||ha()))b||(b=g.getAttribute("data-requiremodule")),e=t[g.getAttribute("data-requirecontext")];(e?e.defQueue:P).push([b,d,f])};define.amd={jQuery:!0};k.exec=function(b){return eval(b)};k(p)}})(this); diff --git a/lightstring.js b/lightstring.js --- a/lightstring.js +++ b/lightstring.js @@ -16,307 +16,276 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +(function() { + define(['./jid', './stanza', './transports/websocket.js', './transports/bosh.js'], function(JID, Stanza, WebSocketTransport, BOSHTransport) { + Lightstring.JID = JID; + Lightstring.Stanza = Stanza.stanza; + Lightstring.IQ = Stanza.iq; + Lightstring.doc = Stanza.doc; + Lightstring.Presence = Stanza.presence; + Lightstring.Message = Stanza.message; + Lightstring.BOSHTransport = BOSHTransport; + Lightstring.WebSocketTransport = WebSocketTransport; + return Lightstring; + }); -var Lightstring = { - /** - * @namespace Holds XMPP namespaces. - * @description http://xmpp.org/xmpp-protocols/protocol-namespaces - */ - ns: { - streams: 'http://etherx.jabber.org/streams', - jabber_client: 'jabber:client', - xmpp_stanzas: 'urn:ietf:params:xml:ns:xmpp-stanzas' - }, - /** - * @namespace Holds XMPP stanza builders. - */ - stanzas: { - stream: { - open: function(aService) { - return ""; + var Lightstring = { + /* + * @namespace Holds XMPP namespaces. + * @description http://xmpp.org/xmpp-protocols/protocol-namespaces + */ + ns: { + streams: 'http://etherx.jabber.org/streams', + jabber_client: 'jabber:client', + xmpp_stanzas: 'urn:ietf:params:xml:ns:xmpp-stanzas' + }, + /** + * @namespace Holds XMPP stanza builders. + */ + stanzas: { + stream: { + open: function(aService) { + return ""; + }, + close: function() { + return ""; + } }, - close: function() { - return ""; + errors: { + iq: function(from, id, type, error) { + return "" + + "" + + "<" + error + " xmlns='" + Lightstring.ns['xmpp_stanzas'] + "'/>" + //TODO: allow text content. + //TODO: allow text and payload. + "" + + ""; + } } }, - errors: { - iq: function(from, id, type, error) { - return "" + - "" + - "<" + error + " xmlns='" + Lightstring.ns['xmpp_stanzas'] + "'/>" + //TODO: allow text content. - //TODO: allow text and payload. - "" + - ""; - } + /** + * @namespace Holds Lightstring plugins + */ + plugins: {}, + /** + * @private Holds the connections + */ + connections: [], + /** + * @function Returns a new unique identifier. + * @param {String} [aPrefix] Prefix to put before the identifier. + * @return {String} Identifier. + */ + id: function(aPrefix) { + return (aPrefix || '') + Date.now(); } - }, - /** - * @namespace Holds Lightstring plugins - */ - plugins: {}, - /** - * @private - */ - parser: new DOMParser(), - /** - * @private - */ - serializer: new XMLSerializer(), + }; + /** - * @function Transforms a XML string to a DOM object. - * @param {String} aString XML string. - * @return {Object} Domified XML. - */ - parse: function(aString) { - var el = null; - //FIXME webkit doesn't throw an error when the parsing fails - try { - el = this.parser.parseFromString(aString, 'text/xml').documentElement; - } - catch (e) { - //TODO: error - } - finally { - return el; - }; - }, - /** - * @function Transforms a DOM object to a XML string. - * @param {Object} aString DOM object. - * @return {String} Stringified DOM. - */ - serialize: function(aElement) { - var string = null; - try { - string = this.serializer.serializeToString(aElement); - } - catch (e) { - //TODO: error - } - finally { - return string; - }; - }, - /** - * @function Get an unique identifier. - * @param {String} [aString] Prefix to put before the identifier. - * @return {String} Identifier. + * @constructor Creates a new Lightstring connection + * @param {String} [aService] The connection manager URL. + * @memberOf Lightstring */ - newId: (function() { - var id = 1024; - return function(prefix) { - if (typeof prefix === 'string') - return prefix + id++; - return '' + id++; - }; - })() -}; + Lightstring.Connection = function(aService) { + if (aService) + this.service = aService; + /** + * @namespace Holds connection events handlers + */ + this.handlers = {}; + /** + * @namespace Holds connection iq callbacks + */ + this.callbacks = {}; + + Lightstring.connections.push(this); + }; + Lightstring.Connection.prototype = new EventEmitter(); + Lightstring.Connection.prototype.onTransportLoaded = function() { + this.transport.open(); + + var that = this; + + this.transport.once('open', function() { + that.emit('open'); + }); + this.transport.on('out', function(stanza) { + setTimeout(function() { + that.emit('out', stanza); + }, 0); + }); + this.transport.on('in', function(stanza) { + //FIXME: node-xmpp-bosh sends a self-closing stream:stream tag; it is wrong! + that.emit('stanza', stanza); + + if (!stanza.el) + return; + + var el = stanza.el; -/** - * @constructor Creates a new Lightstring connection - * @param {String} [aService] The connection manager URL. - * @memberOf Lightstring - */ -Lightstring.Connection = function(aService) { - var that = this; - window.addEventListener('message', function(e) { - that.send(e.data.send) - }); - if (aService) - this.service = aService; + //Authentication + //FIXME SASL mechanisms and XMPP features can be both in a stream:features + if (el.localName === 'features') { + var children = el.childNodes; + for (var i = 0, length = children.length; i < length; i++) { + //SASL mechanisms + if(children[i].localName === 'mechanisms') { + stanza.mechanisms = []; + var nodes = el.getElementsByTagName('mechanism'); + for (var i = 0; i < nodes.length; i++) + stanza.mechanisms.push(nodes[i].textContent); + that.emit('mechanisms', stanza); + return; + } + } + //XMPP features + // else { + //TODO: stanza.features + that.emit('features', stanza); + // } + } + else if (el.localName === 'challenge') { + that.emit('challenge', stanza); + } + else if (el.localName === 'failure') { + that.emit('failure', stanza); + } + else if (el.localName === 'success') { + that.emit('success', stanza); + } + + //Iq callbacks + else if (el.localName === 'iq') { + var payload = el.firstChild; + if (payload) + that.emit('iq/' + payload.namespaceURI + ':' + payload.localName, stanza); + + var id = el.getAttribute('id'); + if (!(id && id in that.callbacks)) + return; + + var type = el.getAttribute('type'); + if (type !== 'result' && type !== 'error') + return; //TODO: warning + + var callback = that.callbacks[id]; + if (type === 'result' && callback.success) + callback.success.call(that, stanza); + else if (type === 'error' && callback.error) + callback.error.call(that, stanza); + + delete that.callbacks[id]; + } + + else if (el.localName === 'presence' || el.localName === 'message') { + that.emit(name, stanza); + } + }); + }; /** - * @namespace Holds connection events handlers - */ - this.handlers = {}; - /** - * @namespace Holds connection iq callbacks + * @function Create and open a websocket then go though the XMPP authentification process. + * @param {String} [aJid] The JID (Jabber id) to use. + * @param {String} [aPassword] The associated password. */ - this.callbacks = {}; -}; -Lightstring.Connection.prototype = new EventEmitter(); -/** - * @function Create and open a websocket then go though the XMPP authentification process. - * @param {String} [aJid] The JID (Jabber id) to use. - * @param {String} [aPassword] The associated password. - */ -Lightstring.Connection.prototype.connect = function(aJid, aPassword) { - this.emit('connecting'); - this.jid = new Lightstring.JID(aJid); - if (aPassword) - this.password = aPassword; + Lightstring.Connection.prototype.connect = function(aJid, aPassword) { + this.emit('connecting'); + this.jid = new Lightstring.JID(aJid); + if (aPassword) + this.password = aPassword; - if (!this.jid.bare) - return; //TODO: error - if (!this.service) - return; //TODO: error + if (!this.jid.bare) + return; //TODO: error + if (!this.service) + return; //TODO: error + + function getProtocol(aURL) { + var a = document.createElement('a'); + a.href = aURL; + return a.protocol.replace(':', ''); + } + var protocol = getProtocol(this.service); - function getProtocol(aURL) { - var a = document.createElement('a'); - a.href = aURL; - return a.protocol.replace(':', ''); - } - var protocol = getProtocol(this.service); - - if (protocol.match('http')) - this.connection = new Lightstring.BOSHConnection(this.service, this.jid); - else if (protocol.match('ws')) - this.connection = new Lightstring.WebSocketConnection(this.service, this.jid); - - this.connection.open(); + if (protocol.match('http')) + this.transport = new Lightstring.BOSHTransport(this.service, this.jid); + else if (protocol.match('ws')) + this.transport = new Lightstring.WebSocketTransport(this.service, this.jid); - var that = this; + this.onTransportLoaded(); + }; + /** + * @function Send a message. + * @param {String|Object} aStanza The message to send. + * @param {Function} [aCallback] Executed on answer. (stanza must be iq) + */ + Lightstring.Connection.prototype.send = function(aStanza, aOnSuccess, aOnError) { + if (!(aStanza instanceof Lightstring.Stanza)) + var stanza = new Lightstring.Stanza(aStanza); + else + var stanza = aStanza; - this.connection.once('open', function() { - that.emit('open'); - }); - this.connection.on('out', function(stanza) { - that.emit('out', stanza); - }); - this.connection.on('in', function(stanza) { - //FIXME: node-xmpp-bosh sends a self-closing stream:stream tag; it is wrong! - that.emit('stanza', stanza); - - if (!stanza.el) + if (!stanza) return; - var el = stanza.el; + if (stanza.name === 'iq') { + var type = stanza.type; + if (type !== 'get' || type !== 'set') + ; //TODO: error - //Authentication - //FIXME SASL mechanisms and XMPP features can be both in a stream:features - if (el.localName === 'features') { - var children = el.childNodes; - for (var i = 0, length = children.length; i < length; i++) { - //SASL mechanisms - if(children[i].localName === 'mechanisms') { - stanza.mechanisms = []; - var nodes = el.getElementsByTagName('mechanism'); - for (var i = 0; i < nodes.length; i++) - stanza.mechanisms.push(nodes[i].textContent); - that.emit('mechanisms', stanza); - return; - } - } - //XMPP features - // else { - //TODO: stanza.features - that.emit('features', stanza); - // } - } - else if (el.localName === 'challenge') { - that.emit('challenge', stanza); - } - else if (el.localName === 'failure') { - that.emit('failure', stanza); - } - else if (el.localName === 'success') { - that.emit('success', stanza); - } + var callback = {success: aOnSuccess, error: aOnError}; - //Iq callbacks - else if (el.localName === 'iq') { - var payload = el.firstChild; - if (payload) - that.emit('iq/' + payload.namespaceURI + ':' + payload.localName, stanza); - - var id = el.getAttribute('id'); - if (!(id && id in that.callbacks)) - return; + var id = stanza.id; + if (!id) + stanza.id = Lightstring.id(); - var type = el.getAttribute('type'); - if (type !== 'result' && type !== 'error') - return; //TODO: warning - - var callback = that.callbacks[id]; - if (type === 'result' && callback.success) - callback.success.call(that, stanza); - else if (type === 'error' && callback.error) - callback.error.call(that, stanza); - - delete that.callbacks[id]; - } - - else if (el.localName === 'presence' || el.localName === 'message') { - that.emit(name, stanza); + this.callbacks[stanza.id] = callback; } - }); -}; -/** - * @function Send a message. - * @param {String|Object} aStanza The message to send. - * @param {Function} [aCallback] Executed on answer. (stanza must be iq) - */ -Lightstring.Connection.prototype.send = function(aStanza, aSuccess, aError) { - if (!(aStanza instanceof Lightstring.Stanza)) - var stanza = new Lightstring.Stanza(aStanza); - else - var stanza = aStanza; - - if (!stanza) - return; + else if (aOnSuccess || aOnError) + ; //TODO: warning (no callback without iq) - if (stanza.el.tagName === 'iq') { - var type = stanza.el.getAttribute('type'); - if (type !== 'get' || type !== 'set') - ; //TODO: error - - var callback = {success: aSuccess, error: aError}; + this.transport.send(stanza.toString()); + }; + /** + * @function Closes the XMPP stream and the socket. + */ + Lightstring.Connection.prototype.disconnect = function() { + this.emit('disconnecting'); + var stream = Lightstring.stanzas.stream.close(); + this.transport.send(stream); + this.emit('out', stream); + this.transport.close(); + }; + Lightstring.Connection.prototype.load = function() { + for (var i = 0; i < arguments.length; i++) { + var name = arguments[i]; + if (!(name in Lightstring.plugins)) + continue; //TODO: error - var id = stanza.el.getAttribute('id'); - if (!id) { - var id = Lightstring.newId('sendiq:'); - stanza.el.setAttribute('id', id); - } - - this.callbacks[id] = callback; - - } - else if (aSuccess || aError) - ; //TODO: warning (no callback without iq) + var plugin = Lightstring.plugins[name]; - this.connection.send(stanza.toString()); -}; -/** - * @function Closes the XMPP stream and the socket. - */ -Lightstring.Connection.prototype.disconnect = function() { - this.emit('disconnecting'); - var stream = Lightstring.stanzas.stream.close(); - this.socket.send(stream); - this.emit('out', stream); - this.socket.close(); -}; -Lightstring.Connection.prototype.load = function() { - for (var i = 0; i < arguments.length; i++) { - var name = arguments[i]; - if (!(name in Lightstring.plugins)) - continue; //TODO: error + //Namespaces + for (var ns in plugin.namespaces) + Lightstring.ns[ns] = plugin.namespaces[ns]; - var plugin = Lightstring.plugins[name]; + //Stanzas + Lightstring.stanzas[name] = {}; + for (var stanza in plugin.stanzas) + Lightstring.stanzas[name][stanza] = plugin.stanzas[stanza]; - //Namespaces - for (var ns in plugin.namespaces) - Lightstring.ns[ns] = plugin.namespaces[ns]; - - //Stanzas - Lightstring.stanzas[name] = {}; - for (var stanza in plugin.stanzas) - Lightstring.stanzas[name][stanza] = plugin.stanzas[stanza]; + //Handlers + for (var handler in plugin.handlers) + this.on(handler, plugin.handlers[handler]); - //Handlers - for (var handler in plugin.handlers) - this.on(handler, plugin.handlers[handler]); + //Methods + this[name] = {}; + for (var method in plugin.methods) + this[name][method] = plugin.methods[method].bind(this); - //Methods - this[name] = {}; - for (var method in plugin.methods) - this[name][method] = plugin.methods[method].bind(this); - - if (plugin.init) - plugin.init.apply(this); - } -}; \ No newline at end of file + if (plugin.init) + plugin.init.apply(this); + } + }; +})(); \ No newline at end of file diff --git a/plugins/PLAIN.js b/plugins/PLAIN.js --- a/plugins/PLAIN.js +++ b/plugins/PLAIN.js @@ -33,12 +33,13 @@ Lightstring.plugins['PLAIN'] = { return; var token = btoa( - this.jid + + this.jid.bare + '\u0000' + - this.jid.node + + this.jid.local + '\u0000' + this.password ); + this.send( "" + token + "" @@ -56,7 +57,7 @@ Lightstring.plugins['PLAIN'] = { var Conn = this; //TODO check if bind supported var bind = - "" + + "" + "" + (this.jid.resource? "" + this.jid.resource + "": "") + "" + @@ -68,7 +69,7 @@ Lightstring.plugins['PLAIN'] = { //Session http://xmpp.org/rfcs/rfc3921.html#session Conn.jid = new Lightstring.JID(stanza.el.textContent); Conn.send( - "" + + "" + "" + "", function() { diff --git a/plugins/delay.js b/plugins/delay.js new file mode 100644 --- /dev/null +++ b/plugins/delay.js @@ -0,0 +1,41 @@ +'use strict'; + +/** + Copyright (c) 2011, Sonny Piers + Copyright (c) 2012, Emmanuel Gil Peyrot + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +//////////// +//Presence// http://xmpp.org/rfcs/rfc6121.html#presence +//////////// +(function() { + Object.defineProperty(Lightstring.Stanza.prototype, "delay", { + get : function(){ + var delayEl = this.el.querySelector('delay'); + if (!delayEl) + return null; + + var delay = { + stamp: delayEl.getAttribute('stamp'), + from: delayEl.getAttribute('from'), + reason: delayEl.textContent + } + return delay; + }, + // set : function(newValue){ bValue = newValue; }, + enumerable : true, + configurable : true + }); +})(); diff --git a/plugins/events.js b/plugins/events.js new file mode 100755 --- /dev/null +++ b/plugins/events.js @@ -0,0 +1,28 @@ +'use strict'; + +/** + Copyright (c) 2012, Sonny Piers + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +Lightstring.plugins['events'] = { + handlers: { + 'input': function callback(stanza) { + + }, + //~ 'output': function callback(stanza) { + //~ alert('output'); + //~ } + } +}; diff --git a/plugins/im.js b/plugins/im.js --- a/plugins/im.js +++ b/plugins/im.js @@ -45,21 +45,31 @@ Lightstring.plugins['im'] = { return message; }, - received: function(aTo, aId) { - var message = Lightstring.parse( - "" + - "" + - "" - ); - return message; - }, - read: function(aTo, aId) { - var message = Lightstring.parse( - "" + - "" + - "" - ); - return message; - }, } }; +Object.defineProperties(Lightstring.Stanza.prototype, { + 'body': { + get : function(){ + var bodyEl = this.el.querySelector('body'); + if (!bodyEl) + return null; + + return bodyEl.textContent; + }, + // set : function(newValue){ bValue = newValue; }, + enumerable : true, + configurable : true + }, + 'subject': { + get : function(){ + var subjectEl = this.el.querySelector('subject'); + if (!subjectEl) + return null; + + return subjectEl.textContent; + }, + // set : function(newValue){ bValue = newValue; }, + enumerable : true, + configurable : true + } +}); \ No newline at end of file diff --git a/plugins/ping.js b/plugins/ping.js --- a/plugins/ping.js +++ b/plugins/ping.js @@ -49,3 +49,19 @@ Lightstring.plugins['ping'] = { } } } +Object.defineProperties(Lightstring.Stanza.prototype, { + 'ping': { + get : function() { + return !!(this.el.querySelector('ping')); + }, + set: function(aBool) { + if (this.ping) + return; + + var pingEl = Lightstring.doc.createElementNS(Lightstring.ns.ping, 'ping'); + this.el.appendChild(pingEl); + }, + enumerable : true, + configurable : true + }, +}); diff --git a/plugins/presence.js b/plugins/presence.js --- a/plugins/presence.js +++ b/plugins/presence.js @@ -40,6 +40,9 @@ if (object.type && legal_types.indexOf(object.type) !== -1) attributs += " type='" + object.type + "'"; + if (object.to) + attributs += " to='" + object.to + "'"; + if (object.priority) payloads += "" + object.priority + ""; @@ -65,6 +68,30 @@ send: function(aObject) { this.send(Lightstring.stanzas.presence.out(aObject)); } - } + }, }; + + Object.defineProperties(Lightstring.Stanza.prototype, { + 'show': { + get : function() { + return this.el.getAttribute('show'); + }, + enumerable : true, + configurable : true + }, + 'priority': { + get : function() { + return this.el.getAttribute('priority'); + }, + enumerable : true, + configurable : true + }, + 'status': { + get : function() { + return this.el.getAttribute('status'); + }, + enumerable : true, + configurable : true + }, + }) })(); diff --git a/plugins/receipts.js b/plugins/receipts.js new file mode 100644 --- /dev/null +++ b/plugins/receipts.js @@ -0,0 +1,115 @@ +'use strict'; + +/** + Copyright (c) 2011, Sonny Piers + Copyright (c) 2012, Emmanuel Gil Peyrot + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +///////////////////////////////////////////////////////////////////////////////// +//XEP-0184: Message Delivery Receipts http://xmpp.org/extensions/xep-0184.html // +///////////////////////////////////////////////////////////////////////////////// +(function () { + +var ns = 'urn:xmpp:receipts'; +Lightstring.plugins['receipts'] = { + namespaces: { + receipts: ns + }, + // features: [ns], + // methods: { + // 'received': function(aOnSuccess, aOnError) { + // } + // } +}; +Object.defineProperties(Lightstring.Stanza.prototype, { + 'receipt': { + get : function() { + var receiptEl; + for (var i = 0, length = this.el.childNodes.length; i < length; i++) { + if (this.el.childNodes[i].namespaceURI === ns) { + receiptEl = this.el.childNodes[i]; + break; + } + } + if (!receiptEl) + return null; + + var receipt = {name: receiptEl.localName}; + + var id = receiptEl.getAttribute('id'); + if (id) + receipt.id = id; + + return receipt; + }, + set: function(aProps) { + var receipt = Lightstring.doc.createElementNS(ns, aProps.name); + if (aProps.id) + receipt.setAttribute('id', aProps.id); + + var receiptEl; + for (var i = 0, length = this.el.childNodes.length; i < length; i++) { + if (this.el.childNodes[i].namespaceURI === ns) { + receiptEl = this.el.childNodes[i]; + break; + } + } + if (receiptEl) + this.el.removeChild(receiptEl); + + this.el.appendChild(receipt); + }, + enumerable : true, + configurable : true + }, + 'request': { + get : function() { + var receipt = this.receipt; + if (!receipt || (receipt.name !== 'request')) + return null; + + return receipt; + }, + set: function(aBool) { + this.receipt = {name: 'request'} + if (!this.id) + this.id = Lightstring.id(); + }, + enumerable : true, + configurable : true + }, + 'received': { + get : function() { + var receipt = this.receipt; + if (!receipt || (receipt.name !== 'received')) + return null; + + return receipt; + }, + set: function(aId) { + this.receipt = {name: 'received', id: aId} + }, + enumerable : true, + configurable : true + }, +}); +Lightstring.Stanza.prototype.replyWithReceived = function(aProps) { + var reply = this.reply(aProps); + reply.received = this.id; + + return reply; +}; + +})(); \ No newline at end of file diff --git a/plugins/roster.js b/plugins/roster.js --- a/plugins/roster.js +++ b/plugins/roster.js @@ -73,6 +73,10 @@ Lightstring.plugins['roster'] = { if (subscription) contact.subscription = subscription; + var ask = item.getAttribute('ask'); + if (ask) + contact.ask = ask; + var groups = item.getElementsByTagName('group'); if(groups) { contact.groups = []; diff --git a/stanza.js b/stanza.js --- a/stanza.js +++ b/stanza.js @@ -16,53 +16,246 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +(function() { + +if (typeof define !== 'undefined') { + define(function() { + return { + 'stanza': Stanza, + 'presence': Presence, + 'iq': IQ, + 'message': Message, + 'doc': doc, + }; + }); +} +else { + Lightstirng.Stanza = Stanza; + Lightstirng.Presence = Presence; + Lightstirng.IQ = IQ; + Lightstirng.Message = Message; + Lightstirng.doc = doc; +} + +/** + * @private + */ +var doc = document.implementation.createDocument(null, 'dummy', null); +/** + * @private + */ +var parser = new DOMParser(); +/** + * @private + */ +var serializer = new XMLSerializer(); +/** + * @function Transforms a XML string to a DOM object. + * @param {String} aString XML string. + * @return {Object} Domified XML. + */ +var parse = function(aString) { + var el = parser.parseFromString(aString, 'text/xml').documentElement; + if (el.tagName === 'parsererror') + ;//do something + return el; +}; +/** + * @function Transforms a DOM object to a XML string. + * @param {Object} aString DOM object. + * @return {String} Stringified DOM. + */ +var serialize = function(aElement) { + var string = null; + try { + string = serializer.serializeToString(aElement); + } + catch (e) { + //TODO: error + } + finally { + return string; + }; +}; + /** * @constructor Creates a new Stanza object. * @param {String|Object} [aStanza] The XML or DOM content of the stanza - * @memberOf Lightstring + */ +var Stanza = function(aStanza) { + this.createEl(aStanza); +}; +/** + * @constructor Creates a new Message stanza object. + * @param {String|Object} [aStanza] The XML or DOM content of the stanza + */ + var Message = function(aStanza) { + if ((typeof aStanza === 'object') && (!(aStanza instanceof Element))) + aStanza.name = 'message'; + this.createEl(aStanza); +}; +Message.prototype = Stanza.prototype; +/** + * @constructor Creates a new IQ stanza object. + * @param {String|Object} [aStanza] The XML or DOM content of the stanza */ -Lightstring.Stanza = function(aStanza) { - if (typeof aStanza === 'string') - this.el = Lightstring.parse(aStanza); +var IQ = function(aStanza) { + if ((typeof aStanza === 'object') && (!(aStanza instanceof Element))) + aStanza.name = 'iq'; + this.createEl(aStanza); +}; +IQ.prototype = Stanza.prototype; +/** + * @constructor Creates a new Presence stanza object. + * @param {String|Object} [aStanza] The XML or DOM content of the stanza + */ +var Presence = function(aStanza) { + if ((typeof aStanza === 'object') && (!(aStanza instanceof Element))) + aStanza.name = 'presence'; + this.createEl(aStanza); +}; +Presence.prototype = Stanza.prototype; +Stanza.prototype.createEl = function(aStanza) { + if (typeof aStanza === 'string') { + this.el = parse(aStanza); + } else if (aStanza instanceof Element) this.el = aStanza; + else if (typeof aStanza === 'object') { + var el = doc.createElement(aStanza.name); + this.el = el; + delete aStanza.name; + for (var i in aStanza) { + this[i] = aStanza[i]; + } + } else this.el = null;//TODO error }; -Lightstring.Stanza.prototype.toString = function() { - return Lightstring.serialize(this.el); +Stanza.prototype.toString = function() { + return serialize(this.el); +}; +Stanza.prototype.reply = function(aProps) { + var props = aProps || {}; + + props.name = this.name; + var reply = new Stanza(props); + + if (this.from) + reply.to = this.from; + + + if (reply.name !== 'iq') + return reply; + + if (this.id) + reply.id = this.id; + + reply.type = 'result'; + + return reply; }; -Object.defineProperty(Lightstring.Stanza.prototype, "from", { +//from attribute +Object.defineProperty(Stanza.prototype, "from", { get : function(){ return this.el.getAttribute('from'); }, + set : function(aString) { + this.el.setAttribute('from', aString); + }, + enumerable : true, + configurable : true +}); +//stanza tag name +Object.defineProperty(Stanza.prototype, "name", { + get : function(){ + return this.el.localName; + }, + //FIXME // set : function(newValue){ bValue = newValue; }, enumerable : true, configurable : true }); -Object.defineProperty(Lightstring.Stanza.prototype, "name", { - get : function(){ - return this.el.localName; - }, - // set : function(newValue){ bValue = newValue; }, - enumerable : true, - configurable : true -}); -Object.defineProperty(Lightstring.Stanza.prototype, "id", { +//id attribute +Object.defineProperty(Stanza.prototype, "id", { get : function(){ return this.el.getAttribute('id'); }, - // set : function(newValue){ bValue = newValue; }, + set : function(aString) { + this.el.setAttribute('id', aString); + }, + enumerable : true, + configurable : true +}); +//to attribute +Object.defineProperty(Stanza.prototype, "to", { + get : function(){ + return this.el.getAttribute('to'); + }, + set : function(aString) { + this.el.setAttribute('to', aString); + }, + enumerable : true, + configurable : true +}); +//type attribute +Object.defineProperty(Stanza.prototype, "type", { + get : function(){ + return this.el.getAttribute('type'); + }, + set : function(aString) { + this.el.setAttribute('type', aString); + }, enumerable : true, configurable : true }); -Object.defineProperty(Lightstring.Stanza.prototype, "to", { +//body +Object.defineProperty(Stanza.prototype, "body", { get : function(){ - return this.el.getAttribute('to'); - }, - // set : function(newValue){ bValue = newValue; }, + var bodyEl = this.el.querySelector('body').textContent; + if (!bodyEl) + return null; + else + return bodyEl.textContent; + }, + set : function(aString) { + var bodyEl = this.el.querySelector('body'); + if (!bodyEl) { + bodyEl = doc.createElement('body'); + bodyEl = this.el.appendChild(bodyEl); + } + bodyEl.textContent = aString; + }, enumerable : true, configurable : true -}); \ No newline at end of file +}); +//subject +Object.defineProperty(Stanza.prototype, "subject", { + get : function(){ + var subjectEl = this.el.querySelector('subject').textContent; + if (!subjectEl) + return null; + else + return subjectEl.textContent; + }, + set : function(aString) { + var subjectEl = this.el.querySelector('subject'); + if (!subjectEl) { + subjectEl = doc.createElement('subject'); + subjectEl = this.el.appendChild(subjectEl); + } + subjectEl.textContent = aString; + }, + enumerable : true, + configurable : true +}); +Stanza.prototype.replyWithSubscribed = function(aProps) { + var reply = this.reply(aProps); + reply.type = 'subscribed'; + + return reply; +}; + +})(); \ No newline at end of file diff --git a/transports/bosh.js b/transports/bosh.js --- a/transports/bosh.js +++ b/transports/bosh.js @@ -1,74 +1,79 @@ 'use strict'; (function() { - Lightstring.BOSHConnection = function(aService) { + + if (typeof define !== 'undefined') { + define(function() { + return BOSHTransport; + }); + } + else { + Lightstring.BOSHTransport = BOSHTransport; + } + + var BOSHTransport = function(aService, aJID) { this.service = aService; this.rid = 1337; + this.jid = aJID; this.currentRequests = 0; this.maxHTTPRetries = 5; this.maxRequests = 2; this.queue = []; }; - Lightstring.BOSHConnection.prototype = new EventEmitter(); - Lightstring.BOSHConnection.prototype.open = function() { + BOSHTransport.prototype = new EventEmitter(); + BOSHTransport.prototype.open = function() { var that = this; var attrs = { wait: '60', hold: '1', - to: 'yuilop', + to: this.jid.domain, content: 'text/xml; charset=utf-8', ver: '1.6', 'xmpp:version': '1.0', 'xmlns:xmpp': 'urn:xmpp:xbosh', }; - this.request(attrs, null, function(data) { + this.request(attrs, [], function(data) { that.emit('open'); that.sid = data.getAttribute('sid'); that.maxRequests = data.getAttribute('maxRequests') || that.maxRequests; + if (!data.getElementsByTagNameNS('http://etherx.jabber.org/streams', 'features')[0]) { + that.request(); + } }); this.on('in', function(stanza) { - if (stanza.localName === 'success') { + if (stanza.name === 'success') { that.request({ + 'to': that.jid.domain, 'xmpp:restart': 'true', 'xmlns:xmpp': 'urn:xmpp:xbosh' }) } }) }; - Lightstring.BOSHConnection.prototype.request = function(attrs, children, aOnSuccess, aOnError, aRetry) { - // if (children && children[0] && children[0].name === 'body') { - // var body = children[0]; - // } - // else { - // var body = new ltx.Element('body'); - // if (children) { - // if(util.isArray(children)) - // for (var k in children) - // body.cnode(children[k]); - // else - // body.cnode(children); - // } - // } + BOSHTransport.prototype.request = function(attrs, children, aOnSuccess, aOnError, aRetry) { + if (!children) + children = []; - var body = new Lightstring.Stanza(''); + var body = Lightstring.doc.createElement('body'); + body.setAttribute('rid', this.rid++); + body.setAttribute('xmlns', 'http://jabber.org/protocol/httpbind'); //sid if (this.sid) - body.el.setAttribute('sid', this.sid); + body.setAttribute('sid', this.sid); //attributes on body for (var i in attrs) - body.el.setAttribute(i, attrs[i]); + body.setAttribute(i, attrs[i]); //children - for (var i in children) - body.el.appendChild(children[i]); - - + for (var i = 0, length = children.length; i < length; i++) { + body.appendChild(children[i]); + }; var retry = aRetry || 0; @@ -87,7 +92,6 @@ // req.addEventListener("abort", transferCanceled, false); var that = this; - // req.responseType = 'document'; req.addEventListener("load", function() { if (req.status < 200 || req.status >= 400) { that.emit('error', "HTTP status " + req.status); @@ -99,7 +103,7 @@ var body = this.response; that.emit('rawin', body); var bodyEl = Lightstring.parse(body); - that.processResponse(bodyEl) + that.processResponse(bodyEl); if (aOnSuccess) aOnSuccess(bodyEl); @@ -116,18 +120,21 @@ // } // }); // this.emit('rawout', body.toString()); - if (body.children) { - for(var i = 0; i < body.children.length; i++) { - var child = body.children[i]; - that.emit('out', child); + if (body.childNodes) { + for(var i = 0; i < body.childNodes.length; i++) { + var child = body.childNodes[i]; + that.emit('out', new Lightstring.Stanza(child)); } } - this.emit('rawout', body); + + var bodyStr = Lightstring.serialize(body); - req.send(Lightstring.serialize(body)); + this.emit('rawout', bodyStr); + + req.send(bodyStr); this.currentRequests++; }; - Lightstring.BOSHConnection.prototype.send = function(aData) { + BOSHTransport.prototype.send = function(aData) { if (!aData) { var el = ''; } @@ -152,7 +159,7 @@ setTimeout(this.mayRequest.bind(this), 0) }; - Lightstring.BOSHConnection.prototype.end = function(stanzas) { + BOSHTransport.prototype.end = function(stanzas) { var that = this; stanzas = stanzas || []; @@ -168,21 +175,23 @@ delete that.sid; }); }; - Lightstring.BOSHConnection.prototype.processResponse = function(bodyEl) { - if (bodyEl && bodyEl.children) { - for(var i = 0; i < bodyEl.children.length; i++) { - var child = bodyEl.children[i]; - this.emit('in', child); + BOSHTransport.prototype.processResponse = function(bodyEl) { + var children = bodyEl.childNodes + if (children.length) { + for(var i = 0; i < children.length; i++) { + var child = children[i]; + var stanza = new Lightstring.Stanza(child); + this.emit('in', stanza); } } - if (bodyEl && bodyEl.getAttribute('type') === 'terminate') { + else if (bodyEl.getAttribute('type') === 'terminate') { var condition = bodyEl.getAttribute('condition'); this.emit('error', new Error(condition || "Session terminated")); this.emit('close'); } }; - Lightstring.BOSHConnection.prototype.mayRequest = function() { + BOSHTransport.prototype.mayRequest = function() { var canRequest = this.sid && (this.currentRequests === 0 || ((this.queue.length > 0 && this.currentRequests < this.maxRequests)) ); @@ -192,7 +201,6 @@ var stanzas = this.queue; this.queue = []; - //~ this.rid++; var that = this; this.request({}, stanzas, @@ -200,12 +208,12 @@ function(data) { //if (data) //that.processResponse(data); - setTimeout(that.mayRequest.bind(that), 0); }, //error function(error) { + console.log('error') that.emit('error', error); that.emit('close'); delete that.sid; diff --git a/transports/websocket.js b/transports/websocket.js --- a/transports/websocket.js +++ b/transports/websocket.js @@ -1,23 +1,33 @@ 'use strict'; (function() { - Lightstring.WebSocket = WebSocket || MozWebSocket || undefined; - Lightstring.WebSocketConnection = function(aService, aJid) { + var WebSocket = window.WebSocket || window.MozWebSocket || undefined; + + if (typeof define !== 'undefined') { + define(function() { + return WebSocketTransport; + }); + } + else { + Lightstring.WebSocketTransport = WebSocketTransport; + } + + var WebSocketTransport = function(aService, aJid) { this.service = aService; this.jid = aJid; }; - Lightstring.WebSocketConnection.prototype = new EventEmitter(); - Lightstring.WebSocketConnection.prototype.open = function() { - if(!Lightstring.WebSocket) + WebSocketTransport.prototype = new EventEmitter(); + WebSocketTransport.prototype.open = function() { + if(!WebSocket) return; //TODO: error this.socket = new WebSocket(this.service, 'xmpp'); var that = this; this.socket.addEventListener('open', function() { - //FIXME: Opera/Safari WebSocket implementation doesn't support sub-protocol mechanism. - //if (this.protocol !== 'xmpp') - //return; //TODO: error + if (this.protocol !== 'xmpp') + ; //TODO: warning (Opera and Safari doesn't support this property) + that.emit('open'); var stream = Lightstring.stanzas.stream.open(that.jid.domain); @@ -39,8 +49,9 @@ that.emit('in', stanza); }); }; - Lightstring.WebSocketConnection.prototype.send = function(aStanza) { + WebSocketTransport.prototype.send = function(aStanza) { this.emit('out', aStanza); this.socket.send(aStanza.toString()); }; + })(); \ No newline at end of file