Commit e20ffb39 authored by Marco Flowers's avatar Marco Flowers

Added apidocs to describe the api

Added the apidocs module and comments in app.js to describe
the different api endpoints.
parent 4f6c0fa2
define({ "api": [ { "type": "get", "url": "/formats/", "title": "Get a list of Formats", "name": "GetFormats", "group": "Formats", "success": { "fields": { "Success 200": [ { "group": "Success 200", "type": "<p>List</p> ", "optional": false, "field": "-", "description": "<p>List of formats</p> " } ] }, "examples": [ { "title": "Success-Response:", "content": "HTTP/1.1 200 OK\n[\n {\"val\":\"Vorbis\"},\n {\"val\":\"MP3\"}\n]", "type": "json" } ] }, "version": "0.0.0", "filename": "./app.js", "groupTitle": "Formats" }, { "type": "get", "url": "/genres/", "title": "Get a list of Genres", "name": "GetGenres", "group": "Genres", "success": { "fields": { "Success 200": [ { "group": "Success 200", "type": "<p>List</p> ", "optional": false, "field": "-", "description": "<p>List of genres</p> " } ] }, "examples": [ { "title": "Success-Response:", "content": "HTTP/1.1 200 OK\n[\n {\"val\":\"Rock\"},\n {\"val\":\"Pop\"}\n]", "type": "json" } ] }, "version": "0.0.0", "filename": "./app.js", "groupTitle": "Genres" }, { "type": "get", "url": "/streams/:id", "title": "Get Individual Stream", "name": "GetStream", "group": "Streams", "parameter": { "fields": { "Parameter": [ { "group": "Parameter", "type": "<p>Number</p> ", "optional": false, "field": "id", "description": "<p>Stream unique ID.</p> " } ] } }, "success": { "fields": { "Success 200": [ { "group": "Success 200", "type": "<p>Object</p> ", "optional": false, "field": "_", "description": "<p>Describes the stream</p> " } ] }, "examples": [ { "title": "Success-Response:", "content": "HTTP/1.1 200 OK\n{\n \"id\":8,\n \"stream_name\":\"TestStream7\",\n \"stream_type\":\"audio/ogg\",\n \"description\":\"Really Cool Stream\",\n \"songname\":\"TestSong\",\n \"url\":\"http://fake.com\",\n \"avg_listening_time\":null,\n \"codec_sub_types\":[\"Vorbis\"],\n \"bitrate\":128,\n \"hits\":null,\n \"cm\":null,\n \"samplerate\":44100,\n \"channels\":2,\n \"quality\":null,\n \"genres\":[\"Rock\"],\n \"listenurls\":[\"http://fake.com:8000/stream\"],\n \"listeners\":3,\n \"max_listeners\":100\n}", "type": "json" } ] }, "error": { "examples": [ { "title": "Error-Response:", "content": "HTTP/1.1 404 Not Found\n{\n}", "type": "json" } ] }, "version": "0.0.0", "filename": "./app.js", "groupTitle": "Streams" }, { "type": "get", "url": "/streams/", "title": "Get a list of Streams", "name": "GetStreams", "group": "Streams", "parameter": { "fields": { "Parameter": [ { "group": "Parameter", "type": "<p>String</p> ", "optional": false, "field": "format", "description": "<p>Format to search by.</p> " }, { "group": "Parameter", "type": "<p>String</p> ", "optional": false, "field": "genre", "description": "<p>Genre to seach by.</p> " }, { "group": "Parameter", "type": "<p>String</p> ", "optional": false, "field": "q", "description": "<p>Search string.</p> " }, { "group": "Parameter", "type": "<p>Number</p> ", "allowedValues": [ "-1", "0", "1" ], "optional": false, "field": "order", "description": "<p>-1=Random order 0=Descending 1=Ascending.</p> " }, { "group": "Parameter", "type": "<p>Number</p> ", "optional": false, "field": "limit", "description": "<p>Number of results to return.</p> " }, { "group": "Parameter", "type": "<p>Number</p> ", "optional": false, "field": "starting_after", "description": "<p>ID of stream to return results after(Requires order, cannot have ending_before).</p> " }, { "group": "Parameter", "type": "<p>Number</p> ", "optional": false, "field": "ending_before", "description": "<p>ID of stream to return results before(Requires order, cannot have starting_after).</p> " } ] } }, "success": { "fields": { "Success 200": [ { "group": "Success 200", "type": "<p>List</p> ", "optional": false, "field": "streams", "description": "<p>List of stream objects(See get individual stream for an example)</p> " }, { "group": "Success 200", "type": "<p>Object</p> ", "optional": false, "field": "data", "description": "<p>Contains starting_after and ending_before urls for this data</p> " } ] }, "examples": [ { "title": "Success-Response:", "content": "HTTP/1.1 200 OK\n{\n \"streams\":[],\n \"data\":{\"starting_after\":\"/streams?limit=2&starting_after=20\"},\n}\nView getting a single stream to see what the stream data will look like", "type": "json" } ] }, "error": { "fields": { "Error 4xx": [ { "group": "Error 4xx", "type": "<p>String</p> ", "optional": false, "field": "error", "description": "<p>Contains an error message describing the issue</p> " } ] }, "examples": [ { "title": "Error-Response:", "content": "HTTP/1.1 400 Bad Request\n{\n \"error\":\"error message describing issue\"\n}", "type": "json" } ] }, "version": "0.0.0", "filename": "./app.js", "groupTitle": "Streams" }, { "success": { "fields": { "Success 200": [ { "group": "Success 200", "optional": false, "field": "varname1", "description": "<p>No type.</p> " }, { "group": "Success 200", "type": "<p>String</p> ", "optional": false, "field": "varname2", "description": "<p>With type.</p> " } ] } }, "type": "", "url": "", "version": "0.0.0", "filename": "./apidoc/main.js", "group": "_Users_marcof_Documents_icecast_directory_apidoc_main_js", "groupTitle": "_Users_marcof_Documents_icecast_directory_apidoc_main_js", "name": "" }] });
\ No newline at end of file
[ { "type": "get", "url": "/formats/", "title": "Get a list of Formats", "name": "GetFormats", "group": "Formats", "success": { "fields": { "Success 200": [ { "group": "Success 200", "type": "<p>List</p> ", "optional": false, "field": "-", "description": "<p>List of formats</p> " } ] }, "examples": [ { "title": "Success-Response:", "content": "HTTP/1.1 200 OK\n[\n {\"val\":\"Vorbis\"},\n {\"val\":\"MP3\"}\n]", "type": "json" } ] }, "version": "0.0.0", "filename": "./app.js", "groupTitle": "Formats" }, { "type": "get", "url": "/genres/", "title": "Get a list of Genres", "name": "GetGenres", "group": "Genres", "success": { "fields": { "Success 200": [ { "group": "Success 200", "type": "<p>List</p> ", "optional": false, "field": "-", "description": "<p>List of genres</p> " } ] }, "examples": [ { "title": "Success-Response:", "content": "HTTP/1.1 200 OK\n[\n {\"val\":\"Rock\"},\n {\"val\":\"Pop\"}\n]", "type": "json" } ] }, "version": "0.0.0", "filename": "./app.js", "groupTitle": "Genres" }, { "type": "get", "url": "/streams/:id", "title": "Get Individual Stream", "name": "GetStream", "group": "Streams", "parameter": { "fields": { "Parameter": [ { "group": "Parameter", "type": "<p>Number</p> ", "optional": false, "field": "id", "description": "<p>Stream unique ID.</p> " } ] } }, "success": { "fields": { "Success 200": [ { "group": "Success 200", "type": "<p>Object</p> ", "optional": false, "field": "_", "description": "<p>Describes the stream</p> " } ] }, "examples": [ { "title": "Success-Response:", "content": "HTTP/1.1 200 OK\n{\n \"id\":8,\n \"stream_name\":\"TestStream7\",\n \"stream_type\":\"audio/ogg\",\n \"description\":\"Really Cool Stream\",\n \"songname\":\"TestSong\",\n \"url\":\"http://fake.com\",\n \"avg_listening_time\":null,\n \"codec_sub_types\":[\"Vorbis\"],\n \"bitrate\":128,\n \"hits\":null,\n \"cm\":null,\n \"samplerate\":44100,\n \"channels\":2,\n \"quality\":null,\n \"genres\":[\"Rock\"],\n \"listenurls\":[\"http://fake.com:8000/stream\"],\n \"listeners\":3,\n \"max_listeners\":100\n}", "type": "json" } ] }, "error": { "examples": [ { "title": "Error-Response:", "content": "HTTP/1.1 404 Not Found\n{\n}", "type": "json" } ] }, "version": "0.0.0", "filename": "./app.js", "groupTitle": "Streams" }, { "type": "get", "url": "/streams/", "title": "Get a list of Streams", "name": "GetStreams", "group": "Streams", "parameter": { "fields": { "Parameter": [ { "group": "Parameter", "type": "<p>String</p> ", "optional": false, "field": "format", "description": "<p>Format to search by.</p> " }, { "group": "Parameter", "type": "<p>String</p> ", "optional": false, "field": "genre", "description": "<p>Genre to seach by.</p> " }, { "group": "Parameter", "type": "<p>String</p> ", "optional": false, "field": "q", "description": "<p>Search string.</p> " }, { "group": "Parameter", "type": "<p>Number</p> ", "allowedValues": [ "-1", "0", "1" ], "optional": false, "field": "order", "description": "<p>-1=Random order 0=Descending 1=Ascending.</p> " }, { "group": "Parameter", "type": "<p>Number</p> ", "optional": false, "field": "limit", "description": "<p>Number of results to return.</p> " }, { "group": "Parameter", "type": "<p>Number</p> ", "optional": false, "field": "starting_after", "description": "<p>ID of stream to return results after(Requires order, cannot have ending_before).</p> " }, { "group": "Parameter", "type": "<p>Number</p> ", "optional": false, "field": "ending_before", "description": "<p>ID of stream to return results before(Requires order, cannot have starting_after).</p> " } ] } }, "success": { "fields": { "Success 200": [ { "group": "Success 200", "type": "<p>List</p> ", "optional": false, "field": "streams", "description": "<p>List of stream objects(See get individual stream for an example)</p> " }, { "group": "Success 200", "type": "<p>Object</p> ", "optional": false, "field": "data", "description": "<p>Contains starting_after and ending_before urls for this data</p> " } ] }, "examples": [ { "title": "Success-Response:", "content": "HTTP/1.1 200 OK\n{\n \"streams\":[],\n \"data\":{\"starting_after\":\"/streams?limit=2&starting_after=20\"},\n}\nView getting a single stream to see what the stream data will look like", "type": "json" } ] }, "error": { "fields": { "Error 4xx": [ { "group": "Error 4xx", "type": "<p>String</p> ", "optional": false, "field": "error", "description": "<p>Contains an error message describing the issue</p> " } ] }, "examples": [ { "title": "Error-Response:", "content": "HTTP/1.1 400 Bad Request\n{\n \"error\":\"error message describing issue\"\n}", "type": "json" } ] }, "version": "0.0.0", "filename": "./app.js", "groupTitle": "Streams" }, { "success": { "fields": { "Success 200": [ { "group": "Success 200", "optional": false, "field": "varname1", "description": "<p>No type.</p> " }, { "group": "Success 200", "type": "<p>String</p> ", "optional": false, "field": "varname2", "description": "<p>With type.</p> " } ] } }, "type": "", "url": "", "version": "0.0.0", "filename": "./apidoc/main.js", "group": "_Users_marcof_Documents_icecast_directory_apidoc_main_js", "groupTitle": "_Users_marcof_Documents_icecast_directory_apidoc_main_js", "name": "" }]
\ No newline at end of file
define({ "name": "Icecast Stream Directory API", "version": "0.0.0", "description": "Stream directory api", "title": "Icecast Stream Directory API", "url": "", "order": [ "Streams", "Genres", "Formats" ], "sampleUrl": false, "apidoc": "0.2.0", "generator": { "name": "apidoc", "time": "2015-08-11T07:35:10.997Z", "url": "http://apidocjs.com", "version": "0.13.1" }});
\ No newline at end of file
{ "name": "Icecast Stream Directory API", "version": "0.0.0", "description": "Stream directory api", "title": "Icecast Stream Directory API", "url": "", "order": [ "Streams", "Genres", "Formats" ], "sampleUrl": false, "apidoc": "0.2.0", "generator": { "name": "apidoc", "time": "2015-08-11T07:35:10.997Z", "url": "http://apidocjs.com", "version": "0.13.1" }}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
define({
de: {
'Allowed values:' : 'Erlaubte Werte:',
'Compare all with predecessor': 'Vergleiche alle mit ihren Vorgängern',
'compare changes to:' : 'vergleiche Änderungen mit:',
'compared to' : 'verglichen mit',
'Default value:' : 'Standardwert:',
'Description' : 'Beschreibung',
'Field' : 'Feld',
'General' : 'Allgemein',
'Generated with' : 'Erstellt mit',
'Name' : 'Name',
'No response values.' : 'Keine Rückgabewerte.',
'optional' : 'optional',
'Parameter' : 'Parameter',
'Permission:' : 'Berechtigung:',
'Response' : 'Antwort',
'Send' : 'Senden',
'Send a Sample Request' : 'Eine Beispielanfrage senden',
'show up to version:' : 'zeige bis zur Version:',
'Size range:' : 'Größenbereich:',
'Type' : 'Typ',
'url' : 'url'
}
});
define({
fr: {
'Allowed values:' : 'Valeurs autorisées :',
'Compare all with predecessor': 'Tout comparer avec ...',
'compare changes to:' : 'comparer les changements à :',
'compared to' : 'comparer à',
'Default value:' : 'Valeur par défaut :',
'Description' : 'Description',
'Field' : 'Champ',
'General' : 'Général',
'Generated with' : 'Généré avec',
'Name' : 'Nom',
'No response values.' : 'Aucune valeur de réponse.',
'optional' : 'optionel',
'Parameter' : 'Paramètre',
'Permission:' : 'Permission :',
'Response' : 'Réponse',
'Send' : 'Envoyer',
'Send a Sample Request' : 'Envoyer une requête représentative',
'show up to version:' : 'Montrer à partir de la version :',
'Size range:' : 'Ordre de grandeur :',
'Type' : 'Type',
'url' : 'url'
}
});
\ No newline at end of file
define([
'./locales/de.js',
'./locales/fr.js',
'./locales/nl.js',
'./locales/pl.js',
'./locales/pt_br.js',
'./locales/ru.js',
'./locales/zh.js'
], function() {
var langId = (navigator.language || navigator.userLanguage).toLowerCase();
var language = langId.substr(0, 2);
var locales = {};
for (index in arguments) {
for (property in arguments[index])
locales[property] = arguments[index][property];
}
if ( ! locales['en'])
locales['en'] = {};
if ( ! locales[langId] && ! locales[language])
language = 'en';
var locale = (locales[langId] ? locales[langId] : locales[language]);
function __(text) {
var index = locale[text];
if (index === undefined)
return text;
return index;
};
function setLanguage(language) {
locale = locales[language];
}
return {
__ : __,
locales : locales,
locale : locale,
setLanguage: setLanguage
};
});
define({
nl: {
'Allowed values:' : 'Toegestane waarden:',
'Compare all with predecessor': 'Vergelijk alle met voorgaande versie',
'compare changes to:' : 'vergelijk veranderingen met:',
'compared to' : 'vergelijk met',
'Default value:' : 'Standaard waarde:',
'Description' : 'Omschrijving',
'Field' : 'Veld',
'General' : 'Algemeen',
'Generated with' : 'Gegenereerd met',
'Name' : 'Naam',
'No response values.' : 'Geen response waardes.',
'optional' : 'optioneel',
'Parameter' : 'Parameter',
'Permission:' : 'Permissie:',
'Response' : 'Antwoorden',
'Send' : 'Sturen',
'Send a Sample Request' : 'Stuur een sample aanvragen',
'show up to version:' : 'toon tot en met versie:',
'Size range:' : 'Maatbereik:',
'Type' : 'Type',
'url' : 'url'
}
});
define({
pl: {
'Allowed values:' : 'Dozwlone wartości:',
'Compare all with predecessor': 'Porównaj z poprzednimi wersjami',
'compare changes to:' : 'porównaj zmiany do:',
'compared to' : 'porównaj do:',
'Default value:' : 'Wartość domyślna:',
'Description' : 'Opis',
'Field' : 'Pole',
'General' : 'Generalnie',
'Generated with' : 'Wygenerowano z',
'Name' : 'Nazwa',
'No response values.' : 'Brak odpowiedzi.',
'optional' : 'opcjonalny',
'Parameter' : 'Parametr',
'Permission:' : 'Uprawnienia:',
'Response' : 'Odpowiedź',
'Send' : 'Wyślij',
'Send a Sample Request' : 'Wyślij przykładowe żądanie',
'show up to version:' : 'pokaż do wersji:',
'Size range:' : 'Zakres rozmiaru:',
'Type' : 'Typ',
'url' : 'url'
}
});
define({
'pt_br': {
'Allowed values:' : 'Valores permitidos:',
'Compare all with predecessor': 'Compare todos com antecessores',
'compare changes to:' : 'comparar alterações com:',
'compared to' : 'comparado com',
'Default value:' : 'Valor padrão:',
'Description' : 'Descrição',
'Field' : 'Campo',
'General' : 'Geral',
'Generated with' : 'Gerado com',
'Name' : 'Nome',
'No response values.' : 'Sem valores de resposta.',
'optional' : 'opcional',
'Parameter' : 'Parâmetro',
'Permission:' : 'Permissão:',
'Response' : 'Resposta',
'Send' : 'Enviar',
'Send a Sample Request' : 'Enviar um Exemplo de Pedido',
'show up to version:' : 'aparecer para a versão:',
'Size range:' : 'Faixa de tamanho:',
'Type' : 'Tipo',
'url' : 'url'
}
});
define({
ru: {
'Allowed values:' : 'Допустимые значения:',
'Compare all with predecessor': 'Сравнить с предыдущей версией',
'compare changes to:' : 'сравнить с:',
'compared to' : 'в сравнении с',
'Default value:' : 'По умолчанию:',
'Description' : 'Описание',
'Field' : 'Название',
'General' : 'Общая информация',
'Generated with' : 'Сгенерировано с помощью',
'Name' : 'Название',
'No response values.' : 'Нет значений для ответа.',
'optional' : 'необязательный',
'Parameter' : 'Параметр',
'Permission:' : 'Разрешено:',
'Response' : 'Ответ',
'Send' : 'Отправить',
'Send a Sample Request' : 'Отправить тестовый запрос',
'show up to version:' : 'показать версию:',
'Size range:' : 'Ограничения:',
'Type' : 'Тип',
'url' : 'URL'
}
});
define({
zh: {
'Allowed values:' : '允許值:',
'Compare all with predecessor': '预先比较所有',
'compare changes to:' : '比较变更:',
'compared to' : '对比',
'Default value:' : '默认值:',
'Description' : '描述',
'Field' : '字段',
'General' : '概括',
'Generated with' : '生成工具',
'Name' : '名称',
'No response values.' : '无响应值.',
'optional' : '选项',
'Parameter' : '参数',
'Permission:' : '允许:',
'Response' : '響應',
'Send' : '發送',
'Send a Sample Request' : '發送樣品申請',
'show up to version:' : '显示到版本:',
'Size range:' : '尺寸範圍:',
'Type' : '类型',
'url' : '網址'
}
});
This diff is collapsed.
define([
'locales',
'handlebars',
'diffMatchPatch'
], function(locale, Handlebars, DiffMatchPatch) {
/**
* start/stop timer for simple performance check.
*/
var timer;
Handlebars.registerHelper('startTimer', function(text) {
timer = new Date();
return '';
});
Handlebars.registerHelper('stopTimer', function(text) {
console.log(new Date() - timer);
return '';
});
/**
* Return localized Text.
* @param string text
*/
Handlebars.registerHelper('__', function(text) {
return locale.__(text);
});
/**
* Console log.
* @param mixed obj
*/
Handlebars.registerHelper('cl', function(obj) {
console.log(obj);
return '';
});
/**
* Replace underscore with space.
* @param string text
*/
Handlebars.registerHelper('underscoreToSpace', function(text) {
return text.replace(/(_+)/g, ' ');
});
/**
*
*/
Handlebars.registerHelper('assign', function(name) {
if(arguments.length > 0) {
var type = typeof(arguments[1]);
var arg = null;
if(type === 'string' || type === 'number' || type === 'boolean') arg = arguments[1];
Handlebars.registerHelper(name, function() { return arg; });
}
return '';
});
/**
*
*/
Handlebars.registerHelper('nl2br', function(text) {
return _handlebarsNewlineToBreak(text);
});
/**
*
*/
Handlebars.registerHelper('if_eq', function(context, options) {
var compare = context;
// Get length if context is an object
if (context instanceof Object && ! (options.hash.compare instanceof Object))
compare = Object.keys(context).length;
if (compare === options.hash.compare)
return options.fn(this);
return options.inverse(this);
});
/**
*
*/
Handlebars.registerHelper('if_gt', function(context, options) {
var compare = context;
// Get length if context is an object
if (context instanceof Object && ! (options.hash.compare instanceof Object))
compare = Object.keys(context).length;
if(compare > options.hash.compare)
return options.fn(this);
return options.inverse(this);
});
/**
*
*/
var templateCache = {};
Handlebars.registerHelper('subTemplate', function(name, sourceContext) {
if ( ! templateCache[name])
templateCache[name] = Handlebars.compile($('#template-' + name).html());
var template = templateCache[name];
var templateContext = $.extend({}, this, sourceContext.hash);
return new Handlebars.SafeString( template(templateContext) );
});
/**
*
*/
Handlebars.registerHelper('toLowerCase', function(value) {
return (value && typeof value === 'string') ? value.toLowerCase() : '';
});
/**
*
*/
Handlebars.registerHelper('splitFill', function(value, splitChar, fillChar) {
var splits = value.split(splitChar);
return new Array(splits.length).join(fillChar) + splits[splits.length - 1];
});
/**
* Convert Newline to HTML-Break (nl2br).
*
* @param {String} text
* @returns {String}
*/
function _handlebarsNewlineToBreak(text) {
return ('' + text).replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + '<br>' + '$2');
}
/**
*
*/
Handlebars.registerHelper('each_compare_list_field', function(source, compare, options) {
var fieldName = options.hash.field;
var newSource = [];
if (source) {
source.forEach(function(entry) {
var values = entry;
values['key'] = entry[fieldName];
newSource.push(values);
});
}
var newCompare = [];
if (compare) {
compare.forEach(function(entry) {
var values = entry;
values['key'] = entry[fieldName];
newCompare.push(values);
});
}
return _handlebarsEachCompared('key', newSource, newCompare, options);
});
/**
*
*/
Handlebars.registerHelper('each_compare_keys', function(source, compare, options) {
var newSource = [];
if (source) {
var sourceFields = Object.keys(source);
sourceFields.forEach(function(name) {
var values = {};
values['value'] = source[name];
values['key'] = name;
newSource.push(values);
});
}
var newCompare = [];
if (compare) {
var compareFields = Object.keys(compare);
compareFields.forEach(function(name) {
var values = {};
values['value'] = compare[name];
values['key'] = name;
newCompare.push(values);
});
}
return _handlebarsEachCompared('key', newSource, newCompare, options);
});
/**
*
*/
Handlebars.registerHelper('each_compare_field', function(source, compare, options) {
return _handlebarsEachCompared('field', source, compare, options);
});
/**
*
*/
Handlebars.registerHelper('each_compare_title', function(source, compare, options) {
return _handlebarsEachCompared('title', source, compare, options);
});
/**
*
*/
Handlebars.registerHelper('showDiff', function(source, compare, options) {
var ds = '';
if(source === compare) {
ds = source;
} else {
if( ! source)
return compare;
if( ! compare)
return source;
var d = diffMatchPatch.diff_main(compare, source);
diffMatchPatch.diff_cleanupSemantic(d);
ds = diffMatchPatch.diff_prettyHtml(d);
ds = ds.replace(/&para;/gm, '');
}
if(options === 'nl2br')
ds = _handlebarsNewlineToBreak(ds);
return ds;
});
/**
*
*/
function _handlebarsEachCompared(fieldname, source, compare, options)
{
var dataList = [];
var index = 0;
if(source) {
source.forEach(function(sourceEntry) {
var found = false;
if (compare) {
compare.forEach(function(compareEntry) {
if(sourceEntry[fieldname] === compareEntry[fieldname]) {
var data = {
typeSame: true,
source: sourceEntry,
compare: compareEntry,
index: index
};
dataList.push(data);
found = true;
index++;
}
});
}
if ( ! found) {
var data = {
typeIns: true,
source: sourceEntry,
index: index
};
dataList.push(data);
index++;
}
});
}
if (compare) {
compare.forEach(function(compareEntry) {
var found = false;
if (source) {
source.forEach(function(sourceEntry) {
if(sourceEntry[fieldname] === compareEntry[fieldname])
found = true;
});
}
if ( ! found) {
var data = {
typeDel: true,
compare: compareEntry,
index: index
};
dataList.push(data);
index++;
}
});
}
var ret = '';
var length = dataList.length;
for (var index in dataList) {
if(index == (length - 1))
dataList[index]['_last'] = true;
ret = ret + options.fn(dataList[index]);
}
return ret;
}
var diffMatchPatch = new DiffMatchPatch();
/**
* Overwrite Colors
*/
DiffMatchPatch.prototype.diff_prettyHtml = function(diffs) {
var html = [];
var pattern_amp = /&/g;
var pattern_lt = /</g;
var pattern_gt = />/g;
var pattern_para = /\n/g;
for (var x = 0; x < diffs.length; x++) {
var op = diffs[x][0]; // Operation (insert, delete, equal)
var data = diffs[x][1]; // Text of change.
var text = data.replace(pattern_amp, '&amp;').replace(pattern_lt, '&lt;')
.replace(pattern_gt, '&gt;').replace(pattern_para, '&para;<br>');
switch (op) {
case DIFF_INSERT:
html[x] = '<ins>' + text + '</ins>';
break;
case DIFF_DELETE:
html[x] = '<del>' + text + '</del>';
break;
case DIFF_EQUAL:
html[x] = '<span>' + text + '</span>';
break;
}
}
return html.join('');
};
// Exports
return Handlebars;
});