This commit is contained in:
92
iris-web/source/app/static/assets/js/atlantis.min.js
vendored
Normal file
92
iris-web/source/app/static/assets/js/atlantis.min.js
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
'use strict';
|
||||
|
||||
$(document).ready(function(){
|
||||
$('.nav-search .input-group > input').focus(function (a) {
|
||||
$(this).parent().addClass('focus');
|
||||
}).blur(function (a) {
|
||||
$(this).parent().removeClass('focus');
|
||||
}), $(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
}), $(document).ready(function () {
|
||||
$('.btn-refresh-card').on('click', function () {
|
||||
var a = $(this).parents('.card');
|
||||
a.length && (a.addClass('is-loading'), setTimeout(function () {
|
||||
a.removeClass('is-loading');
|
||||
}, 3000));
|
||||
});
|
||||
var a = $('.sidebar .scrollbar');
|
||||
a.length > 0 && a.scrollbar();
|
||||
var e = $('.main-panel .content-scroll');
|
||||
e.length > 0 && e.scrollbar();
|
||||
var s = $('.messages-scroll');
|
||||
s.length > 0 && s.scrollbar();
|
||||
var o = $('.tasks-scroll');
|
||||
o.length > 0 && o.scrollbar();
|
||||
var i = $('.quick-scroll');
|
||||
i.length > 0 && i.scrollbar();
|
||||
var n = $('.message-notif-scroll');
|
||||
n.length > 0 && n.scrollbar();
|
||||
var r = $('.notif-scroll');
|
||||
r.length > 0 && r.scrollbar();
|
||||
var l = $('.quick-actions-scroll');
|
||||
l.length > 0 && l.scrollbar();
|
||||
var t = $('.dropdown-user-scroll');
|
||||
t.length > 0 && t.scrollbar(), $('.scroll-bar').draggable(), $('#search-nav').on('shown.bs.collapse', function () {
|
||||
$('.nav-search .form-control').focus();
|
||||
});
|
||||
|
||||
var c = !1, d = !1, g = !1, p = !1, h = 0, m = 0, u = 0, f = 0, b = 0;
|
||||
if (!c) {
|
||||
(C = $('.sidenav-toggler')).on('click', function () {
|
||||
1 == h ? ($('html').removeClass('nav_open'), C.removeClass('toggled'), h = 0) : ($('html').addClass('nav_open'), C.addClass('toggled'), h = 1);
|
||||
}), c = !0;
|
||||
}
|
||||
if (!m) {
|
||||
var C = $('.quick-sidebar-toggler');
|
||||
C.on('click', function () {
|
||||
1 == h ? ($('html').removeClass('quick_sidebar_open'), $('.quick-sidebar-overlay').remove(), C.removeClass('toggled'), m = 0) : ($('html').addClass('quick_sidebar_open'), C.addClass('toggled'), m = 1);
|
||||
}), $('.wrapper').mouseup(function (a) {
|
||||
var e = $('.quick-sidebar');
|
||||
a.target.className == e.attr('class') || e.has(a.target).length || ($('html').removeClass('quick_sidebar_open'), $('.quick-sidebar-toggler').removeClass('toggled'), $('.quick-sidebar-overlay').remove(), m = 0);
|
||||
}), $('.close-quick-sidebar').on('click', function () {
|
||||
$('html').removeClass('quick_sidebar_open'), $('.quick-sidebar-toggler').removeClass('toggled'), $('.quick-sidebar-overlay').remove(), m = 0;
|
||||
}), m = !0;
|
||||
}
|
||||
if (!d) {
|
||||
var w = $('.topbar-toggler');
|
||||
w.on('click', function () {
|
||||
1 == u ? ($('html').removeClass('topbar_open'), w.removeClass('toggled'), u = 0) : ($('html').addClass('topbar_open'), w.addClass('toggled'), u = 1);
|
||||
}), d = !0;
|
||||
}
|
||||
if (!p) {
|
||||
var _ = $('.page-sidebar-toggler');
|
||||
_.on('click', function () {
|
||||
1 == f ? ($('html').removeClass('pagesidebar_open'), _.removeClass('toggled'), f = 0) : ($('html').addClass('pagesidebar_open'), _.addClass('toggled'), f = 1);
|
||||
});
|
||||
$('.page-sidebar .back').on('click', function () {
|
||||
$('html').removeClass('pagesidebar_open'), _.removeClass('toggled'), f = 0;
|
||||
}), p = !0;
|
||||
}
|
||||
var y = $('.sidenav-overlay-toggler');
|
||||
$('.wrapper').hasClass('is-show') && (b = 1, y.addClass('toggled'), y.html('<i class="icon-options-vertical"></i>')), y.on('click', function () {
|
||||
1 == b ? ($('.wrapper').removeClass('is-show'), y.removeClass('toggled'), y.html('<i class="icon-menu"></i>'), b = 0) : ($('.wrapper').addClass('is-show'), y.addClass('toggled'), y.html('<i class="icon-options-vertical"></i>'), b = 1), $(window).resize();
|
||||
}), g = !0, $('.sidebar').hover(function () {
|
||||
$('.wrapper').hasClass('sidebar_minimize') && $('.wrapper').addClass('sidebar_minimize_hover');
|
||||
}, function () {
|
||||
$('.wrapper').hasClass('sidebar_minimize') && $('.wrapper').removeClass('sidebar_minimize_hover');
|
||||
}), $('.nav-item a').on('click', function () {
|
||||
$(this).parent().find('.collapse').hasClass('show') ? $(this).parent().removeClass('submenu') : $(this).parent().addClass('submenu');
|
||||
}), $('.messages-contact .user a').on('click', function () {
|
||||
$('.tab-chat').addClass('show-chat');
|
||||
}), $('.messages-wrapper .return').on('click', function () {
|
||||
$('.tab-chat').removeClass('show-chat');
|
||||
}), $('[data-select="checkbox"]').change(function () {
|
||||
var a = $(this).attr('data-target');
|
||||
$(a).prop('checked', $(this).prop('checked'));
|
||||
}), $('.form-group-default .form-control').focus(function () {
|
||||
$(this).parent().addClass('active');
|
||||
}).blur(function () {
|
||||
$(this).parent().removeClass('active');
|
||||
});
|
||||
});
|
||||
});
|
||||
474
iris-web/source/app/static/assets/js/core/bootstrap-datetimepicker.min.js
vendored
Normal file
474
iris-web/source/app/static/assets/js/core/bootstrap-datetimepicker.min.js
vendored
Normal file
@@ -0,0 +1,474 @@
|
||||
/* =========================================================
|
||||
* bootstrap-datepicker.js
|
||||
* http://www.eyecon.ro/bootstrap-datepicker
|
||||
* =========================================================
|
||||
* Copyright 2012 Stefan Petre
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ========================================================= */
|
||||
|
||||
!function( $ ) {
|
||||
|
||||
// Picker object
|
||||
|
||||
var Datepicker = function(element, options){
|
||||
this.element = $(element);
|
||||
this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');
|
||||
this.picker = $(DPGlobal.template)
|
||||
.appendTo('body')
|
||||
.on({
|
||||
click: $.proxy(this.click, this)//,
|
||||
//mousedown: $.proxy(this.mousedown, this)
|
||||
});
|
||||
this.isInput = this.element.is('input');
|
||||
this.component = this.element.is('.date') ? this.element.find('.add-on') : false;
|
||||
|
||||
if (this.isInput) {
|
||||
this.element.on({
|
||||
focus: $.proxy(this.show, this),
|
||||
//blur: $.proxy(this.hide, this),
|
||||
keyup: $.proxy(this.update, this)
|
||||
});
|
||||
} else {
|
||||
if (this.component){
|
||||
this.component.on('click', $.proxy(this.show, this));
|
||||
} else {
|
||||
this.element.on('click', $.proxy(this.show, this));
|
||||
}
|
||||
}
|
||||
|
||||
this.minViewMode = options.minViewMode||this.element.data('date-minviewmode')||0;
|
||||
if (typeof this.minViewMode === 'string') {
|
||||
switch (this.minViewMode) {
|
||||
case 'months':
|
||||
this.minViewMode = 1;
|
||||
break;
|
||||
case 'years':
|
||||
this.minViewMode = 2;
|
||||
break;
|
||||
default:
|
||||
this.minViewMode = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.viewMode = options.viewMode||this.element.data('date-viewmode')||0;
|
||||
if (typeof this.viewMode === 'string') {
|
||||
switch (this.viewMode) {
|
||||
case 'months':
|
||||
this.viewMode = 1;
|
||||
break;
|
||||
case 'years':
|
||||
this.viewMode = 2;
|
||||
break;
|
||||
default:
|
||||
this.viewMode = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.startViewMode = this.viewMode;
|
||||
this.weekStart = options.weekStart||this.element.data('date-weekstart')||0;
|
||||
this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
|
||||
this.onRender = options.onRender;
|
||||
this.fillDow();
|
||||
this.fillMonths();
|
||||
this.update();
|
||||
this.showMode();
|
||||
};
|
||||
|
||||
Datepicker.prototype = {
|
||||
constructor: Datepicker,
|
||||
|
||||
show: function(e) {
|
||||
this.picker.show();
|
||||
this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
|
||||
this.place();
|
||||
$(window).on('resize', $.proxy(this.place, this));
|
||||
if (e ) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
if (!this.isInput) {
|
||||
}
|
||||
var that = this;
|
||||
$(document).on('mousedown', function(ev){
|
||||
if ($(ev.target).closest('.datepicker').length == 0) {
|
||||
that.hide();
|
||||
}
|
||||
});
|
||||
this.element.trigger({
|
||||
type: 'show',
|
||||
date: this.date
|
||||
});
|
||||
},
|
||||
|
||||
hide: function(){
|
||||
this.picker.hide();
|
||||
$(window).off('resize', this.place);
|
||||
this.viewMode = this.startViewMode;
|
||||
this.showMode();
|
||||
if (!this.isInput) {
|
||||
$(document).off('mousedown', this.hide);
|
||||
}
|
||||
//this.set();
|
||||
this.element.trigger({
|
||||
type: 'hide',
|
||||
date: this.date
|
||||
});
|
||||
},
|
||||
|
||||
set: function() {
|
||||
var formated = DPGlobal.formatDate(this.date, this.format);
|
||||
if (!this.isInput) {
|
||||
if (this.component){
|
||||
this.element.find('input').prop('value', formated);
|
||||
}
|
||||
this.element.data('date', formated);
|
||||
} else {
|
||||
this.element.prop('value', formated);
|
||||
}
|
||||
},
|
||||
|
||||
setValue: function(newDate) {
|
||||
if (typeof newDate === 'string') {
|
||||
this.date = DPGlobal.parseDate(newDate, this.format);
|
||||
} else {
|
||||
this.date = new Date(newDate);
|
||||
}
|
||||
this.set();
|
||||
this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
|
||||
this.fill();
|
||||
},
|
||||
|
||||
place: function(){
|
||||
var offset = this.component ? this.component.offset() : this.element.offset();
|
||||
this.picker.css({
|
||||
top: offset.top + this.height,
|
||||
left: offset.left
|
||||
});
|
||||
},
|
||||
|
||||
update: function(newDate){
|
||||
this.date = DPGlobal.parseDate(
|
||||
typeof newDate === 'string' ? newDate : (this.isInput ? this.element.prop('value') : this.element.data('date')),
|
||||
this.format
|
||||
);
|
||||
this.viewDate = new Date(this.date.getFullYear(), this.date.getMonth(), 1, 0, 0, 0, 0);
|
||||
this.fill();
|
||||
},
|
||||
|
||||
fillDow: function(){
|
||||
var dowCnt = this.weekStart;
|
||||
var html = '<tr>';
|
||||
while (dowCnt < this.weekStart + 7) {
|
||||
html += '<th class="dow">'+DPGlobal.dates.daysMin[(dowCnt++)%7]+'</th>';
|
||||
}
|
||||
html += '</tr>';
|
||||
this.picker.find('.datepicker-days thead').append(html);
|
||||
},
|
||||
|
||||
fillMonths: function(){
|
||||
var html = '';
|
||||
var i = 0
|
||||
while (i < 12) {
|
||||
html += '<span class="month">'+DPGlobal.dates.monthsShort[i++]+'</span>';
|
||||
}
|
||||
this.picker.find('.datepicker-months td').append(html);
|
||||
},
|
||||
|
||||
fill: function() {
|
||||
var d = new Date(this.viewDate),
|
||||
year = d.getFullYear(),
|
||||
month = d.getMonth(),
|
||||
currentDate = this.date.valueOf();
|
||||
this.picker.find('.datepicker-days th:eq(1)')
|
||||
.text(DPGlobal.dates.months[month]+' '+year);
|
||||
var prevMonth = new Date(year, month-1, 28,0,0,0,0),
|
||||
day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());
|
||||
prevMonth.setDate(day);
|
||||
prevMonth.setDate(day - (prevMonth.getDay() - this.weekStart + 7)%7);
|
||||
var nextMonth = new Date(prevMonth);
|
||||
nextMonth.setDate(nextMonth.getDate() + 42);
|
||||
nextMonth = nextMonth.valueOf();
|
||||
var html = [];
|
||||
var clsName,
|
||||
prevY,
|
||||
prevM;
|
||||
while(prevMonth.valueOf() < nextMonth) {
|
||||
if (prevMonth.getDay() === this.weekStart) {
|
||||
html.push('<tr>');
|
||||
}
|
||||
clsName = this.onRender(prevMonth);
|
||||
prevY = prevMonth.getFullYear();
|
||||
prevM = prevMonth.getMonth();
|
||||
if ((prevM < month && prevY === year) || prevY < year) {
|
||||
clsName += ' old';
|
||||
} else if ((prevM > month && prevY === year) || prevY > year) {
|
||||
clsName += ' new';
|
||||
}
|
||||
if (prevMonth.valueOf() === currentDate) {
|
||||
clsName += ' active';
|
||||
}
|
||||
html.push('<td class="day '+clsName+'">'+prevMonth.getDate() + '</td>');
|
||||
if (prevMonth.getDay() === this.weekEnd) {
|
||||
html.push('</tr>');
|
||||
}
|
||||
prevMonth.setDate(prevMonth.getDate()+1);
|
||||
}
|
||||
this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
|
||||
var currentYear = this.date.getFullYear();
|
||||
|
||||
var months = this.picker.find('.datepicker-months')
|
||||
.find('th:eq(1)')
|
||||
.text(year)
|
||||
.end()
|
||||
.find('span').removeClass('active');
|
||||
if (currentYear === year) {
|
||||
months.eq(this.date.getMonth()).addClass('active');
|
||||
}
|
||||
|
||||
html = '';
|
||||
year = parseInt(year/10, 10) * 10;
|
||||
var yearCont = this.picker.find('.datepicker-years')
|
||||
.find('th:eq(1)')
|
||||
.text(year + '-' + (year + 9))
|
||||
.end()
|
||||
.find('td');
|
||||
year -= 1;
|
||||
for (var i = -1; i < 11; i++) {
|
||||
html += '<span class="year'+(i === -1 || i === 10 ? ' old' : '')+(currentYear === year ? ' active' : '')+'">'+year+'</span>';
|
||||
year += 1;
|
||||
}
|
||||
yearCont.html(html);
|
||||
},
|
||||
|
||||
click: function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var target = $(e.target).closest('span, td, th');
|
||||
if (target.length === 1) {
|
||||
switch(target[0].nodeName.toLowerCase()) {
|
||||
case 'th':
|
||||
switch(target[0].className) {
|
||||
case 'switch':
|
||||
this.showMode(1);
|
||||
break;
|
||||
case 'prev':
|
||||
case 'next':
|
||||
this.viewDate['set'+DPGlobal.modes[this.viewMode].navFnc].call(
|
||||
this.viewDate,
|
||||
this.viewDate['get'+DPGlobal.modes[this.viewMode].navFnc].call(this.viewDate) +
|
||||
DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1)
|
||||
);
|
||||
this.fill();
|
||||
this.set();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'span':
|
||||
if (target.is('.month')) {
|
||||
var month = target.parent().find('span').index(target);
|
||||
this.viewDate.setMonth(month);
|
||||
} else {
|
||||
var year = parseInt(target.text(), 10)||0;
|
||||
this.viewDate.setFullYear(year);
|
||||
}
|
||||
if (this.viewMode !== 0) {
|
||||
this.date = new Date(this.viewDate);
|
||||
this.element.trigger({
|
||||
type: 'changeDate',
|
||||
date: this.date,
|
||||
viewMode: DPGlobal.modes[this.viewMode].clsName
|
||||
});
|
||||
}
|
||||
this.showMode(-1);
|
||||
this.fill();
|
||||
this.set();
|
||||
break;
|
||||
case 'td':
|
||||
if (target.is('.day') && !target.is('.disabled')){
|
||||
var day = parseInt(target.text(), 10)||1;
|
||||
var month = this.viewDate.getMonth();
|
||||
if (target.is('.old')) {
|
||||
month -= 1;
|
||||
} else if (target.is('.new')) {
|
||||
month += 1;
|
||||
}
|
||||
var year = this.viewDate.getFullYear();
|
||||
this.date = new Date(year, month, day,0,0,0,0);
|
||||
this.viewDate = new Date(year, month, Math.min(28, day),0,0,0,0);
|
||||
this.fill();
|
||||
this.set();
|
||||
this.element.trigger({
|
||||
type: 'changeDate',
|
||||
date: this.date,
|
||||
viewMode: DPGlobal.modes[this.viewMode].clsName
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mousedown: function(e){
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
showMode: function(dir) {
|
||||
if (dir) {
|
||||
this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
|
||||
}
|
||||
this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.datepicker = function ( option, val ) {
|
||||
return this.each(function () {
|
||||
var $this = $(this),
|
||||
data = $this.data('datepicker'),
|
||||
options = typeof option === 'object' && option;
|
||||
if (!data) {
|
||||
$this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options))));
|
||||
}
|
||||
if (typeof option === 'string') data[option](val);
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.datepicker.defaults = {
|
||||
onRender: function(date) {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
$.fn.datepicker.Constructor = Datepicker;
|
||||
|
||||
var DPGlobal = {
|
||||
modes: [
|
||||
{
|
||||
clsName: 'days',
|
||||
navFnc: 'Month',
|
||||
navStep: 1
|
||||
},
|
||||
{
|
||||
clsName: 'months',
|
||||
navFnc: 'FullYear',
|
||||
navStep: 1
|
||||
},
|
||||
{
|
||||
clsName: 'years',
|
||||
navFnc: 'FullYear',
|
||||
navStep: 10
|
||||
}],
|
||||
dates:{
|
||||
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
||||
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
||||
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
||||
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
||||
},
|
||||
isLeapYear: function (year) {
|
||||
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
|
||||
},
|
||||
getDaysInMonth: function (year, month) {
|
||||
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
|
||||
},
|
||||
parseFormat: function(format){
|
||||
var separator = format.match(/[.\/\-\s].*?/),
|
||||
parts = format.split(/\W+/);
|
||||
if (!separator || !parts || parts.length === 0){
|
||||
throw new Error("Invalid date format.");
|
||||
}
|
||||
return {separator: separator, parts: parts};
|
||||
},
|
||||
parseDate: function(date, format) {
|
||||
var parts = date.split(format.separator),
|
||||
date = new Date(),
|
||||
val;
|
||||
date.setHours(0);
|
||||
date.setMinutes(0);
|
||||
date.setSeconds(0);
|
||||
date.setMilliseconds(0);
|
||||
if (parts.length === format.parts.length) {
|
||||
var year = date.getFullYear(), day = date.getDate(), month = date.getMonth();
|
||||
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
|
||||
val = parseInt(parts[i], 10)||1;
|
||||
switch(format.parts[i]) {
|
||||
case 'dd':
|
||||
case 'd':
|
||||
day = val;
|
||||
date.setDate(val);
|
||||
break;
|
||||
case 'mm':
|
||||
case 'm':
|
||||
month = val - 1;
|
||||
date.setMonth(val - 1);
|
||||
break;
|
||||
case 'yy':
|
||||
year = 2000 + val;
|
||||
date.setFullYear(2000 + val);
|
||||
break;
|
||||
case 'yyyy':
|
||||
year = val;
|
||||
date.setFullYear(val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
date = new Date(year, month, day, 0 ,0 ,0);
|
||||
}
|
||||
return date;
|
||||
},
|
||||
formatDate: function(date, format){
|
||||
var val = {
|
||||
d: date.getDate(),
|
||||
m: date.getMonth() + 1,
|
||||
yy: date.getFullYear().toString().substring(2),
|
||||
yyyy: date.getFullYear()
|
||||
};
|
||||
val.dd = (val.d < 10 ? '0' : '') + val.d;
|
||||
val.mm = (val.m < 10 ? '0' : '') + val.m;
|
||||
var date = [];
|
||||
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
|
||||
date.push(val[format.parts[i]]);
|
||||
}
|
||||
return date.join(format.separator);
|
||||
},
|
||||
headTemplate: '<thead>'+
|
||||
'<tr>'+
|
||||
'<th class="prev">‹</th>'+
|
||||
'<th colspan="5" class="switch"></th>'+
|
||||
'<th class="next">›</th>'+
|
||||
'</tr>'+
|
||||
'</thead>',
|
||||
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>'
|
||||
};
|
||||
DPGlobal.template = '<div class="datepicker dropdown-menu">'+
|
||||
'<div class="datepicker-days">'+
|
||||
'<table class=" table-condensed">'+
|
||||
DPGlobal.headTemplate+
|
||||
'<tbody></tbody>'+
|
||||
'</table>'+
|
||||
'</div>'+
|
||||
'<div class="datepicker-months">'+
|
||||
'<table class="table-condensed">'+
|
||||
DPGlobal.headTemplate+
|
||||
DPGlobal.contTemplate+
|
||||
'</table>'+
|
||||
'</div>'+
|
||||
'<div class="datepicker-years">'+
|
||||
'<table class="table-condensed">'+
|
||||
DPGlobal.headTemplate+
|
||||
DPGlobal.contTemplate+
|
||||
'</table>'+
|
||||
'</div>'+
|
||||
'</div>';
|
||||
|
||||
}( window.jQuery );
|
||||
6
iris-web/source/app/static/assets/js/core/bootstrap.min.js
vendored
Normal file
6
iris-web/source/app/static/assets/js/core/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
20
iris-web/source/app/static/assets/js/core/charts.js
Normal file
20
iris-web/source/app/static/assets/js/core/charts.js
Normal file
File diff suppressed because one or more lines are too long
712
iris-web/source/app/static/assets/js/core/crypto.core.js
Normal file
712
iris-web/source/app/static/assets/js/core/crypto.core.js
Normal file
@@ -0,0 +1,712 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/**
|
||||
* CryptoJS core components.
|
||||
*/
|
||||
var CryptoJS = CryptoJS || (function (Math, undefined) {
|
||||
/**
|
||||
* CryptoJS namespace.
|
||||
*/
|
||||
var C = {};
|
||||
|
||||
/**
|
||||
* Library namespace.
|
||||
*/
|
||||
var C_lib = C.lib = {};
|
||||
|
||||
/**
|
||||
* Base object for prototypal inheritance.
|
||||
*/
|
||||
var Base = C_lib.Base = (function () {
|
||||
function F() {}
|
||||
|
||||
return {
|
||||
/**
|
||||
* Creates a new object that inherits from this object.
|
||||
*
|
||||
* @param {Object} overrides Properties to copy into the new object.
|
||||
*
|
||||
* @return {Object} The new object.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var MyType = CryptoJS.lib.Base.extend({
|
||||
* field: 'value',
|
||||
*
|
||||
* method: function () {
|
||||
* }
|
||||
* });
|
||||
*/
|
||||
extend: function (overrides) {
|
||||
// Spawn
|
||||
F.prototype = this;
|
||||
var subtype = new F();
|
||||
|
||||
// Augment
|
||||
if (overrides) {
|
||||
subtype.mixIn(overrides);
|
||||
}
|
||||
|
||||
// Create default initializer
|
||||
if (!subtype.hasOwnProperty('init')) {
|
||||
subtype.init = function () {
|
||||
subtype.$super.init.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
// Initializer's prototype is the subtype object
|
||||
subtype.init.prototype = subtype;
|
||||
|
||||
// Reference supertype
|
||||
subtype.$super = this;
|
||||
|
||||
return subtype;
|
||||
},
|
||||
|
||||
/**
|
||||
* Extends this object and runs the init method.
|
||||
* Arguments to create() will be passed to init().
|
||||
*
|
||||
* @return {Object} The new object.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var instance = MyType.create();
|
||||
*/
|
||||
create: function () {
|
||||
var instance = this.extend();
|
||||
instance.init.apply(instance, arguments);
|
||||
|
||||
return instance;
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes a newly created object.
|
||||
* Override this method to add some logic when your objects are created.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var MyType = CryptoJS.lib.Base.extend({
|
||||
* init: function () {
|
||||
* // ...
|
||||
* }
|
||||
* });
|
||||
*/
|
||||
init: function () {
|
||||
},
|
||||
|
||||
/**
|
||||
* Copies properties into this object.
|
||||
*
|
||||
* @param {Object} properties The properties to mix in.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* MyType.mixIn({
|
||||
* field: 'value'
|
||||
* });
|
||||
*/
|
||||
mixIn: function (properties) {
|
||||
for (var propertyName in properties) {
|
||||
if (properties.hasOwnProperty(propertyName)) {
|
||||
this[propertyName] = properties[propertyName];
|
||||
}
|
||||
}
|
||||
|
||||
// IE won't copy toString using the loop above
|
||||
if (properties.hasOwnProperty('toString')) {
|
||||
this.toString = properties.toString;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a copy of this object.
|
||||
*
|
||||
* @return {Object} The clone.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var clone = instance.clone();
|
||||
*/
|
||||
clone: function () {
|
||||
return this.init.prototype.extend(this);
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
||||
/**
|
||||
* An array of 32-bit words.
|
||||
*
|
||||
* @property {Array} words The array of 32-bit words.
|
||||
* @property {number} sigBytes The number of significant bytes in this word array.
|
||||
*/
|
||||
var WordArray = C_lib.WordArray = Base.extend({
|
||||
/**
|
||||
* Initializes a newly created word array.
|
||||
*
|
||||
* @param {Array} words (Optional) An array of 32-bit words.
|
||||
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.lib.WordArray.create();
|
||||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
|
||||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
|
||||
*/
|
||||
init: function (words, sigBytes) {
|
||||
words = this.words = words || [];
|
||||
|
||||
if (sigBytes != undefined) {
|
||||
this.sigBytes = sigBytes;
|
||||
} else {
|
||||
this.sigBytes = words.length * 4;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts this word array to a string.
|
||||
*
|
||||
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
|
||||
*
|
||||
* @return {string} The stringified word array.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var string = wordArray + '';
|
||||
* var string = wordArray.toString();
|
||||
* var string = wordArray.toString(CryptoJS.enc.Utf8);
|
||||
*/
|
||||
toString: function (encoder) {
|
||||
return (encoder || Hex).stringify(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Concatenates a word array to this word array.
|
||||
*
|
||||
* @param {WordArray} wordArray The word array to append.
|
||||
*
|
||||
* @return {WordArray} This word array.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* wordArray1.concat(wordArray2);
|
||||
*/
|
||||
concat: function (wordArray) {
|
||||
// Shortcuts
|
||||
var thisWords = this.words;
|
||||
var thatWords = wordArray.words;
|
||||
var thisSigBytes = this.sigBytes;
|
||||
var thatSigBytes = wordArray.sigBytes;
|
||||
|
||||
// Clamp excess bits
|
||||
this.clamp();
|
||||
|
||||
// Concat
|
||||
if (thisSigBytes % 4) {
|
||||
// Copy one byte at a time
|
||||
for (var i = 0; i < thatSigBytes; i++) {
|
||||
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
||||
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
|
||||
}
|
||||
} else if (thatWords.length > 0xffff) {
|
||||
// Copy one word at a time
|
||||
for (var i = 0; i < thatSigBytes; i += 4) {
|
||||
thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
|
||||
}
|
||||
} else {
|
||||
// Copy all words at once
|
||||
thisWords.push.apply(thisWords, thatWords);
|
||||
}
|
||||
this.sigBytes += thatSigBytes;
|
||||
|
||||
// Chainable
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes insignificant bits.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* wordArray.clamp();
|
||||
*/
|
||||
clamp: function () {
|
||||
// Shortcuts
|
||||
var words = this.words;
|
||||
var sigBytes = this.sigBytes;
|
||||
|
||||
// Clamp
|
||||
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
|
||||
words.length = Math.ceil(sigBytes / 4);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a copy of this word array.
|
||||
*
|
||||
* @return {WordArray} The clone.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var clone = wordArray.clone();
|
||||
*/
|
||||
clone: function () {
|
||||
var clone = Base.clone.call(this);
|
||||
clone.words = this.words.slice(0);
|
||||
|
||||
return clone;
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a word array filled with random bytes.
|
||||
*
|
||||
* @param {number} nBytes The number of random bytes to generate.
|
||||
*
|
||||
* @return {WordArray} The random word array.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.lib.WordArray.random(16);
|
||||
*/
|
||||
random: function (nBytes) {
|
||||
var words = [];
|
||||
for (var i = 0; i < nBytes; i += 4) {
|
||||
words.push((Math.random() * 0x100000000) | 0);
|
||||
}
|
||||
|
||||
return new WordArray.init(words, nBytes);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Encoder namespace.
|
||||
*/
|
||||
var C_enc = C.enc = {};
|
||||
|
||||
/**
|
||||
* Hex encoding strategy.
|
||||
*/
|
||||
var Hex = C_enc.Hex = {
|
||||
/**
|
||||
* Converts a word array to a hex string.
|
||||
*
|
||||
* @param {WordArray} wordArray The word array.
|
||||
*
|
||||
* @return {string} The hex string.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
|
||||
*/
|
||||
stringify: function (wordArray) {
|
||||
// Shortcuts
|
||||
var words = wordArray.words;
|
||||
var sigBytes = wordArray.sigBytes;
|
||||
|
||||
// Convert
|
||||
var hexChars = [];
|
||||
for (var i = 0; i < sigBytes; i++) {
|
||||
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
||||
hexChars.push((bite >>> 4).toString(16));
|
||||
hexChars.push((bite & 0x0f).toString(16));
|
||||
}
|
||||
|
||||
return hexChars.join('');
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts a hex string to a word array.
|
||||
*
|
||||
* @param {string} hexStr The hex string.
|
||||
*
|
||||
* @return {WordArray} The word array.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
|
||||
*/
|
||||
parse: function (hexStr) {
|
||||
// Shortcut
|
||||
var hexStrLength = hexStr.length;
|
||||
|
||||
// Convert
|
||||
var words = [];
|
||||
for (var i = 0; i < hexStrLength; i += 2) {
|
||||
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
|
||||
}
|
||||
|
||||
return new WordArray.init(words, hexStrLength / 2);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Latin1 encoding strategy.
|
||||
*/
|
||||
var Latin1 = C_enc.Latin1 = {
|
||||
/**
|
||||
* Converts a word array to a Latin1 string.
|
||||
*
|
||||
* @param {WordArray} wordArray The word array.
|
||||
*
|
||||
* @return {string} The Latin1 string.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
|
||||
*/
|
||||
stringify: function (wordArray) {
|
||||
// Shortcuts
|
||||
var words = wordArray.words;
|
||||
var sigBytes = wordArray.sigBytes;
|
||||
|
||||
// Convert
|
||||
var latin1Chars = [];
|
||||
for (var i = 0; i < sigBytes; i++) {
|
||||
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
||||
latin1Chars.push(String.fromCharCode(bite));
|
||||
}
|
||||
|
||||
return latin1Chars.join('');
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts a Latin1 string to a word array.
|
||||
*
|
||||
* @param {string} latin1Str The Latin1 string.
|
||||
*
|
||||
* @return {WordArray} The word array.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
|
||||
*/
|
||||
parse: function (latin1Str) {
|
||||
// Shortcut
|
||||
var latin1StrLength = latin1Str.length;
|
||||
|
||||
// Convert
|
||||
var words = [];
|
||||
for (var i = 0; i < latin1StrLength; i++) {
|
||||
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
|
||||
}
|
||||
|
||||
return new WordArray.init(words, latin1StrLength);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* UTF-8 encoding strategy.
|
||||
*/
|
||||
var Utf8 = C_enc.Utf8 = {
|
||||
/**
|
||||
* Converts a word array to a UTF-8 string.
|
||||
*
|
||||
* @param {WordArray} wordArray The word array.
|
||||
*
|
||||
* @return {string} The UTF-8 string.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
|
||||
*/
|
||||
stringify: function (wordArray) {
|
||||
try {
|
||||
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
|
||||
} catch (e) {
|
||||
throw new Error('Malformed UTF-8 data');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts a UTF-8 string to a word array.
|
||||
*
|
||||
* @param {string} utf8Str The UTF-8 string.
|
||||
*
|
||||
* @return {WordArray} The word array.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
|
||||
*/
|
||||
parse: function (utf8Str) {
|
||||
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Abstract buffered block algorithm template.
|
||||
*
|
||||
* The property blockSize must be implemented in a concrete subtype.
|
||||
*
|
||||
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
|
||||
*/
|
||||
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
|
||||
/**
|
||||
* Resets this block algorithm's data buffer to its initial state.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* bufferedBlockAlgorithm.reset();
|
||||
*/
|
||||
reset: function () {
|
||||
// Initial values
|
||||
this._data = new WordArray.init();
|
||||
this._nDataBytes = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds new data to this block algorithm's buffer.
|
||||
*
|
||||
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* bufferedBlockAlgorithm._append('data');
|
||||
* bufferedBlockAlgorithm._append(wordArray);
|
||||
*/
|
||||
_append: function (data) {
|
||||
// Convert string to WordArray, else assume WordArray already
|
||||
if (typeof data == 'string') {
|
||||
data = Utf8.parse(data);
|
||||
}
|
||||
|
||||
// Append
|
||||
this._data.concat(data);
|
||||
this._nDataBytes += data.sigBytes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Processes available data blocks.
|
||||
*
|
||||
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
|
||||
*
|
||||
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
|
||||
*
|
||||
* @return {WordArray} The processed data.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var processedData = bufferedBlockAlgorithm._process();
|
||||
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
|
||||
*/
|
||||
_process: function (doFlush) {
|
||||
// Shortcuts
|
||||
var data = this._data;
|
||||
var dataWords = data.words;
|
||||
var dataSigBytes = data.sigBytes;
|
||||
var blockSize = this.blockSize;
|
||||
var blockSizeBytes = blockSize * 4;
|
||||
|
||||
// Count blocks ready
|
||||
var nBlocksReady = dataSigBytes / blockSizeBytes;
|
||||
if (doFlush) {
|
||||
// Round up to include partial blocks
|
||||
nBlocksReady = Math.ceil(nBlocksReady);
|
||||
} else {
|
||||
// Round down to include only full blocks,
|
||||
// less the number of blocks that must remain in the buffer
|
||||
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
||||
}
|
||||
|
||||
// Count words ready
|
||||
var nWordsReady = nBlocksReady * blockSize;
|
||||
|
||||
// Count bytes ready
|
||||
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
|
||||
|
||||
// Process blocks
|
||||
if (nWordsReady) {
|
||||
for (var offset = 0; offset < nWordsReady; offset += blockSize) {
|
||||
// Perform concrete-algorithm logic
|
||||
this._doProcessBlock(dataWords, offset);
|
||||
}
|
||||
|
||||
// Remove processed words
|
||||
var processedWords = dataWords.splice(0, nWordsReady);
|
||||
data.sigBytes -= nBytesReady;
|
||||
}
|
||||
|
||||
// Return processed words
|
||||
return new WordArray.init(processedWords, nBytesReady);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a copy of this object.
|
||||
*
|
||||
* @return {Object} The clone.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var clone = bufferedBlockAlgorithm.clone();
|
||||
*/
|
||||
clone: function () {
|
||||
var clone = Base.clone.call(this);
|
||||
clone._data = this._data.clone();
|
||||
|
||||
return clone;
|
||||
},
|
||||
|
||||
_minBufferSize: 0
|
||||
});
|
||||
|
||||
/**
|
||||
* Abstract hasher template.
|
||||
*
|
||||
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
|
||||
*/
|
||||
var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
|
||||
/**
|
||||
* Configuration options.
|
||||
*/
|
||||
cfg: Base.extend(),
|
||||
|
||||
/**
|
||||
* Initializes a newly created hasher.
|
||||
*
|
||||
* @param {Object} cfg (Optional) The configuration options to use for this hash computation.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hasher = CryptoJS.algo.SHA256.create();
|
||||
*/
|
||||
init: function (cfg) {
|
||||
// Apply config defaults
|
||||
this.cfg = this.cfg.extend(cfg);
|
||||
|
||||
// Set initial values
|
||||
this.reset();
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets this hasher to its initial state.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* hasher.reset();
|
||||
*/
|
||||
reset: function () {
|
||||
// Reset data buffer
|
||||
BufferedBlockAlgorithm.reset.call(this);
|
||||
|
||||
// Perform concrete-hasher logic
|
||||
this._doReset();
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates this hasher with a message.
|
||||
*
|
||||
* @param {WordArray|string} messageUpdate The message to append.
|
||||
*
|
||||
* @return {Hasher} This hasher.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* hasher.update('message');
|
||||
* hasher.update(wordArray);
|
||||
*/
|
||||
update: function (messageUpdate) {
|
||||
// Append
|
||||
this._append(messageUpdate);
|
||||
|
||||
// Update the hash
|
||||
this._process();
|
||||
|
||||
// Chainable
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Finalizes the hash computation.
|
||||
* Note that the finalize operation is effectively a destructive, read-once operation.
|
||||
*
|
||||
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
||||
*
|
||||
* @return {WordArray} The hash.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hash = hasher.finalize();
|
||||
* var hash = hasher.finalize('message');
|
||||
* var hash = hasher.finalize(wordArray);
|
||||
*/
|
||||
finalize: function (messageUpdate) {
|
||||
// Final message update
|
||||
if (messageUpdate) {
|
||||
this._append(messageUpdate);
|
||||
}
|
||||
|
||||
// Perform concrete-hasher logic
|
||||
var hash = this._doFinalize();
|
||||
|
||||
return hash;
|
||||
},
|
||||
|
||||
blockSize: 512/32,
|
||||
|
||||
/**
|
||||
* Creates a shortcut function to a hasher's object interface.
|
||||
*
|
||||
* @param {Hasher} hasher The hasher to create a helper for.
|
||||
*
|
||||
* @return {Function} The shortcut function.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
|
||||
*/
|
||||
_createHelper: function (hasher) {
|
||||
return function (message, cfg) {
|
||||
return new hasher.init(cfg).finalize(message);
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a shortcut function to the HMAC's object interface.
|
||||
*
|
||||
* @param {Hasher} hasher The hasher to use in this HMAC helper.
|
||||
*
|
||||
* @return {Function} The shortcut function.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
|
||||
*/
|
||||
_createHmacHelper: function (hasher) {
|
||||
return function (message, key) {
|
||||
return new C_algo.HMAC.init(hasher, key).finalize(message);
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Algorithm namespace.
|
||||
*/
|
||||
var C_algo = C.algo = {};
|
||||
|
||||
return C;
|
||||
}(Math));
|
||||
254
iris-web/source/app/static/assets/js/core/crypto.md5.js
Normal file
254
iris-web/source/app/static/assets/js/core/crypto.md5.js
Normal file
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(function (Math) {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var WordArray = C_lib.WordArray;
|
||||
var Hasher = C_lib.Hasher;
|
||||
var C_algo = C.algo;
|
||||
|
||||
// Constants table
|
||||
var T = [];
|
||||
|
||||
// Compute constants
|
||||
(function () {
|
||||
for (var i = 0; i < 64; i++) {
|
||||
T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
|
||||
}
|
||||
}());
|
||||
|
||||
/**
|
||||
* MD5 hash algorithm.
|
||||
*/
|
||||
var MD5 = C_algo.MD5 = Hasher.extend({
|
||||
_doReset: function () {
|
||||
this._hash = new WordArray.init([
|
||||
0x67452301, 0xefcdab89,
|
||||
0x98badcfe, 0x10325476
|
||||
]);
|
||||
},
|
||||
|
||||
_doProcessBlock: function (M, offset) {
|
||||
// Swap endian
|
||||
for (var i = 0; i < 16; i++) {
|
||||
// Shortcuts
|
||||
var offset_i = offset + i;
|
||||
var M_offset_i = M[offset_i];
|
||||
|
||||
M[offset_i] = (
|
||||
(((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
|
||||
(((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
|
||||
);
|
||||
}
|
||||
|
||||
// Shortcuts
|
||||
var H = this._hash.words;
|
||||
|
||||
var M_offset_0 = M[offset + 0];
|
||||
var M_offset_1 = M[offset + 1];
|
||||
var M_offset_2 = M[offset + 2];
|
||||
var M_offset_3 = M[offset + 3];
|
||||
var M_offset_4 = M[offset + 4];
|
||||
var M_offset_5 = M[offset + 5];
|
||||
var M_offset_6 = M[offset + 6];
|
||||
var M_offset_7 = M[offset + 7];
|
||||
var M_offset_8 = M[offset + 8];
|
||||
var M_offset_9 = M[offset + 9];
|
||||
var M_offset_10 = M[offset + 10];
|
||||
var M_offset_11 = M[offset + 11];
|
||||
var M_offset_12 = M[offset + 12];
|
||||
var M_offset_13 = M[offset + 13];
|
||||
var M_offset_14 = M[offset + 14];
|
||||
var M_offset_15 = M[offset + 15];
|
||||
|
||||
// Working varialbes
|
||||
var a = H[0];
|
||||
var b = H[1];
|
||||
var c = H[2];
|
||||
var d = H[3];
|
||||
|
||||
// Computation
|
||||
a = FF(a, b, c, d, M_offset_0, 7, T[0]);
|
||||
d = FF(d, a, b, c, M_offset_1, 12, T[1]);
|
||||
c = FF(c, d, a, b, M_offset_2, 17, T[2]);
|
||||
b = FF(b, c, d, a, M_offset_3, 22, T[3]);
|
||||
a = FF(a, b, c, d, M_offset_4, 7, T[4]);
|
||||
d = FF(d, a, b, c, M_offset_5, 12, T[5]);
|
||||
c = FF(c, d, a, b, M_offset_6, 17, T[6]);
|
||||
b = FF(b, c, d, a, M_offset_7, 22, T[7]);
|
||||
a = FF(a, b, c, d, M_offset_8, 7, T[8]);
|
||||
d = FF(d, a, b, c, M_offset_9, 12, T[9]);
|
||||
c = FF(c, d, a, b, M_offset_10, 17, T[10]);
|
||||
b = FF(b, c, d, a, M_offset_11, 22, T[11]);
|
||||
a = FF(a, b, c, d, M_offset_12, 7, T[12]);
|
||||
d = FF(d, a, b, c, M_offset_13, 12, T[13]);
|
||||
c = FF(c, d, a, b, M_offset_14, 17, T[14]);
|
||||
b = FF(b, c, d, a, M_offset_15, 22, T[15]);
|
||||
|
||||
a = GG(a, b, c, d, M_offset_1, 5, T[16]);
|
||||
d = GG(d, a, b, c, M_offset_6, 9, T[17]);
|
||||
c = GG(c, d, a, b, M_offset_11, 14, T[18]);
|
||||
b = GG(b, c, d, a, M_offset_0, 20, T[19]);
|
||||
a = GG(a, b, c, d, M_offset_5, 5, T[20]);
|
||||
d = GG(d, a, b, c, M_offset_10, 9, T[21]);
|
||||
c = GG(c, d, a, b, M_offset_15, 14, T[22]);
|
||||
b = GG(b, c, d, a, M_offset_4, 20, T[23]);
|
||||
a = GG(a, b, c, d, M_offset_9, 5, T[24]);
|
||||
d = GG(d, a, b, c, M_offset_14, 9, T[25]);
|
||||
c = GG(c, d, a, b, M_offset_3, 14, T[26]);
|
||||
b = GG(b, c, d, a, M_offset_8, 20, T[27]);
|
||||
a = GG(a, b, c, d, M_offset_13, 5, T[28]);
|
||||
d = GG(d, a, b, c, M_offset_2, 9, T[29]);
|
||||
c = GG(c, d, a, b, M_offset_7, 14, T[30]);
|
||||
b = GG(b, c, d, a, M_offset_12, 20, T[31]);
|
||||
|
||||
a = HH(a, b, c, d, M_offset_5, 4, T[32]);
|
||||
d = HH(d, a, b, c, M_offset_8, 11, T[33]);
|
||||
c = HH(c, d, a, b, M_offset_11, 16, T[34]);
|
||||
b = HH(b, c, d, a, M_offset_14, 23, T[35]);
|
||||
a = HH(a, b, c, d, M_offset_1, 4, T[36]);
|
||||
d = HH(d, a, b, c, M_offset_4, 11, T[37]);
|
||||
c = HH(c, d, a, b, M_offset_7, 16, T[38]);
|
||||
b = HH(b, c, d, a, M_offset_10, 23, T[39]);
|
||||
a = HH(a, b, c, d, M_offset_13, 4, T[40]);
|
||||
d = HH(d, a, b, c, M_offset_0, 11, T[41]);
|
||||
c = HH(c, d, a, b, M_offset_3, 16, T[42]);
|
||||
b = HH(b, c, d, a, M_offset_6, 23, T[43]);
|
||||
a = HH(a, b, c, d, M_offset_9, 4, T[44]);
|
||||
d = HH(d, a, b, c, M_offset_12, 11, T[45]);
|
||||
c = HH(c, d, a, b, M_offset_15, 16, T[46]);
|
||||
b = HH(b, c, d, a, M_offset_2, 23, T[47]);
|
||||
|
||||
a = II(a, b, c, d, M_offset_0, 6, T[48]);
|
||||
d = II(d, a, b, c, M_offset_7, 10, T[49]);
|
||||
c = II(c, d, a, b, M_offset_14, 15, T[50]);
|
||||
b = II(b, c, d, a, M_offset_5, 21, T[51]);
|
||||
a = II(a, b, c, d, M_offset_12, 6, T[52]);
|
||||
d = II(d, a, b, c, M_offset_3, 10, T[53]);
|
||||
c = II(c, d, a, b, M_offset_10, 15, T[54]);
|
||||
b = II(b, c, d, a, M_offset_1, 21, T[55]);
|
||||
a = II(a, b, c, d, M_offset_8, 6, T[56]);
|
||||
d = II(d, a, b, c, M_offset_15, 10, T[57]);
|
||||
c = II(c, d, a, b, M_offset_6, 15, T[58]);
|
||||
b = II(b, c, d, a, M_offset_13, 21, T[59]);
|
||||
a = II(a, b, c, d, M_offset_4, 6, T[60]);
|
||||
d = II(d, a, b, c, M_offset_11, 10, T[61]);
|
||||
c = II(c, d, a, b, M_offset_2, 15, T[62]);
|
||||
b = II(b, c, d, a, M_offset_9, 21, T[63]);
|
||||
|
||||
// Intermediate hash value
|
||||
H[0] = (H[0] + a) | 0;
|
||||
H[1] = (H[1] + b) | 0;
|
||||
H[2] = (H[2] + c) | 0;
|
||||
H[3] = (H[3] + d) | 0;
|
||||
},
|
||||
|
||||
_doFinalize: function () {
|
||||
// Shortcuts
|
||||
var data = this._data;
|
||||
var dataWords = data.words;
|
||||
|
||||
var nBitsTotal = this._nDataBytes * 8;
|
||||
var nBitsLeft = data.sigBytes * 8;
|
||||
|
||||
// Add padding
|
||||
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
||||
|
||||
var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
|
||||
var nBitsTotalL = nBitsTotal;
|
||||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
|
||||
(((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
|
||||
(((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
|
||||
);
|
||||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
|
||||
(((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
|
||||
(((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
|
||||
);
|
||||
|
||||
data.sigBytes = (dataWords.length + 1) * 4;
|
||||
|
||||
// Hash final blocks
|
||||
this._process();
|
||||
|
||||
// Shortcuts
|
||||
var hash = this._hash;
|
||||
var H = hash.words;
|
||||
|
||||
// Swap endian
|
||||
for (var i = 0; i < 4; i++) {
|
||||
// Shortcut
|
||||
var H_i = H[i];
|
||||
|
||||
H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
|
||||
(((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
|
||||
}
|
||||
|
||||
// Return final computed hash
|
||||
return hash;
|
||||
},
|
||||
|
||||
clone: function () {
|
||||
var clone = Hasher.clone.call(this);
|
||||
clone._hash = this._hash.clone();
|
||||
|
||||
return clone;
|
||||
}
|
||||
});
|
||||
|
||||
function FF(a, b, c, d, x, s, t) {
|
||||
var n = a + ((b & c) | (~b & d)) + x + t;
|
||||
return ((n << s) | (n >>> (32 - s))) + b;
|
||||
}
|
||||
|
||||
function GG(a, b, c, d, x, s, t) {
|
||||
var n = a + ((b & d) | (c & ~d)) + x + t;
|
||||
return ((n << s) | (n >>> (32 - s))) + b;
|
||||
}
|
||||
|
||||
function HH(a, b, c, d, x, s, t) {
|
||||
var n = a + (b ^ c ^ d) + x + t;
|
||||
return ((n << s) | (n >>> (32 - s))) + b;
|
||||
}
|
||||
|
||||
function II(a, b, c, d, x, s, t) {
|
||||
var n = a + (c ^ (b | ~d)) + x + t;
|
||||
return ((n << s) | (n >>> (32 - s))) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut function to the hasher's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
*
|
||||
* @return {WordArray} The hash.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hash = CryptoJS.MD5('message');
|
||||
* var hash = CryptoJS.MD5(wordArray);
|
||||
*/
|
||||
C.MD5 = Hasher._createHelper(MD5);
|
||||
|
||||
/**
|
||||
* Shortcut function to the HMAC's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
* @param {WordArray|string} key The secret key.
|
||||
*
|
||||
* @return {WordArray} The HMAC.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hmac = CryptoJS.HmacMD5(message, key);
|
||||
*/
|
||||
C.HmacMD5 = Hasher._createHmacHelper(MD5);
|
||||
}(Math));
|
||||
4
iris-web/source/app/static/assets/js/core/jquery.3.2.1.min.js
vendored
Normal file
4
iris-web/source/app/static/assets/js/core/jquery.3.2.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
iris-web/source/app/static/assets/js/core/jquery.validate.js
vendored
Normal file
4
iris-web/source/app/static/assets/js/core/jquery.validate.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
iris-web/source/app/static/assets/js/core/moments.min.js
vendored
Normal file
1
iris-web/source/app/static/assets/js/core/moments.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5
iris-web/source/app/static/assets/js/core/popper.min.js
vendored
Normal file
5
iris-web/source/app/static/assets/js/core/popper.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
iris-web/source/app/static/assets/js/core/socket.io.js
Normal file
7
iris-web/source/app/static/assets/js/core/socket.io.js
Normal file
File diff suppressed because one or more lines are too long
99
iris-web/source/app/static/assets/js/iris/activities.js
Normal file
99
iris-web/source/app/static/assets/js/iris/activities.js
Normal file
@@ -0,0 +1,99 @@
|
||||
$.each($.find("table"), function(index, element){
|
||||
addFilterFields($(element).attr("id"));
|
||||
});
|
||||
|
||||
|
||||
Table = $("#activities_table").DataTable({
|
||||
dom: 'Blfrtip',
|
||||
aaData: [],
|
||||
bSort: false,
|
||||
aoColumns: [
|
||||
{ "data": "activity_date",
|
||||
"render": $.fn.dataTable.render.text()
|
||||
},
|
||||
{
|
||||
"data": "user_name",
|
||||
"render": $.fn.dataTable.render.text()
|
||||
},
|
||||
{ "data": "case_name",
|
||||
"render": $.fn.dataTable.render.text()
|
||||
},
|
||||
{ "data": "user_input",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
if (data == true){
|
||||
data = "<i class='fas fa-check text-success text-center'></i>";
|
||||
} else {
|
||||
data = "<i class='fas fa-times text-muted'></i>";
|
||||
}
|
||||
}
|
||||
return data;
|
||||
} },
|
||||
{ "data": "is_from_api",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
if (data == true){
|
||||
data = "<i class='fas fa-check text-success'></i>";
|
||||
} else {
|
||||
data = "<i class='fas fa-times text-muted'></i>";
|
||||
}
|
||||
|
||||
}
|
||||
return data;
|
||||
} },
|
||||
{ "data": "activity_desc",
|
||||
"render": $.fn.dataTable.render.text()
|
||||
}
|
||||
],
|
||||
filter: true,
|
||||
info: true,
|
||||
processing: true,
|
||||
retrieve: true,
|
||||
initComplete: function () {
|
||||
tableFiltering(this.api(), 'activities_table');
|
||||
},
|
||||
buttons: [
|
||||
{ "extend": 'csvHtml5', "text":'Export',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
{ "extend": 'copyHtml5', "text":'Copy',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
]
|
||||
});
|
||||
$("#activities_table").css("font-size", 12);
|
||||
|
||||
function refresh_activities() {
|
||||
get_activities ();
|
||||
notify_success('Refreshed');
|
||||
}
|
||||
|
||||
function get_activities () {
|
||||
show_loader();
|
||||
if ($('#non_case_related_act').is(':checked')) {
|
||||
url = '/activities/list-all';
|
||||
} else {
|
||||
url = '/activities/list';
|
||||
}
|
||||
|
||||
get_request_api(url)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data, true)) {
|
||||
jsdata = data;
|
||||
if (jsdata.status == "success") {
|
||||
Table.clear();
|
||||
Table.rows.add(data.data);
|
||||
Table.columns.adjust().draw();
|
||||
Table.buttons().container().appendTo($('#activities_table_info'));
|
||||
hide_loader();
|
||||
}
|
||||
}
|
||||
}).fail((data) => {
|
||||
hide_loader();
|
||||
Table.clear();
|
||||
Table.columns.adjust().draw();
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
get_activities();
|
||||
$('#non_case_related_act').on('change', function() {
|
||||
get_activities();
|
||||
});
|
||||
});
|
||||
2061
iris-web/source/app/static/assets/js/iris/alerts.js
Normal file
2061
iris-web/source/app/static/assets/js/iris/alerts.js
Normal file
File diff suppressed because it is too large
Load Diff
534
iris-web/source/app/static/assets/js/iris/case.asset.js
Normal file
534
iris-web/source/app/static/assets/js/iris/case.asset.js
Normal file
@@ -0,0 +1,534 @@
|
||||
/* reload the asset table */
|
||||
g_asset_id = null;
|
||||
g_asset_desc_editor = null;
|
||||
|
||||
|
||||
function reload_assets() {
|
||||
get_case_assets();
|
||||
}
|
||||
|
||||
function edit_in_asset_desc() {
|
||||
|
||||
if($('#container_asset_desc_content').is(':visible')) {
|
||||
$('#container_asset_description').show(100);
|
||||
$('#container_asset_desc_content').hide(100);
|
||||
$('#asset_edition_btn').hide(100);
|
||||
$('#asset_preview_button').hide(100);
|
||||
} else {
|
||||
$('#asset_preview_button').show(100);
|
||||
$('#asset_edition_btn').show(100);
|
||||
$('#container_asset_desc_content').show(100);
|
||||
$('#container_asset_description').hide(100);
|
||||
}
|
||||
}
|
||||
|
||||
/* Fetch a modal that is compatible with the requested asset type */
|
||||
function add_assets() {
|
||||
url = 'assets/add/modal' + case_param();
|
||||
$('#modal_add_asset_content').load(url, function (response, status, xhr) {
|
||||
hide_minimized_modal_box();
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
g_asset_desc_editor = get_new_ace_editor('asset_description', 'asset_desc_content', 'target_asset_desc',
|
||||
function() {
|
||||
$('#last_saved').addClass('btn-danger').removeClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-exclamation");
|
||||
}, null);
|
||||
g_asset_desc_editor.setOption("minLines", "10");
|
||||
edit_in_asset_desc();
|
||||
|
||||
let headers = get_editor_headers('g_asset_desc_editor', null, 'asset_edition_btn');
|
||||
$('#asset_edition_btn').append(headers);
|
||||
|
||||
$('#ioc_links').select2({});
|
||||
|
||||
$('#submit_new_assets').on("click", function () {
|
||||
|
||||
let assets = $('#assets_name').val();
|
||||
let assets_list = assets.split('\n');
|
||||
for (let index in assets_list) {
|
||||
|
||||
let data = $('#form_new_assets').serializeObject();
|
||||
data['asset_name'] = assets_list[index];
|
||||
delete data['assets_name'];
|
||||
|
||||
if (data['asset_name'] == "" || data['asset_name'] == null || data['asset_name'] == '\n') {
|
||||
continue;
|
||||
}
|
||||
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
if (typeof data["ioc_links"] == "string") {
|
||||
data["ioc_links"] = [data["ioc_links"]]
|
||||
}
|
||||
data['asset_tags'] = $('#asset_tags').val();
|
||||
data['asset_description'] = g_asset_desc_editor.getValue();
|
||||
let ret = get_custom_attributes_fields();
|
||||
let has_error = ret[0].length > 0;
|
||||
let attributes = ret[1];
|
||||
|
||||
if (has_error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data['custom_attributes'] = attributes;
|
||||
|
||||
post_request_api('assets/add', JSON.stringify(data), true, function () {
|
||||
$('#submit_new_assets').text('Saving data..')
|
||||
.attr("disabled", true)
|
||||
.removeClass('bt-outline-success')
|
||||
.addClass('btn-success', 'text-dark');
|
||||
})
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
reload_assets();
|
||||
if (index == (assets_list.length - 1)) {
|
||||
$('#modal_add_asset').modal('hide');
|
||||
notify_success("Assets created");
|
||||
}
|
||||
} else {
|
||||
$('#submit_new_assets').text('Save again');
|
||||
swal("Oh no !", data.message, "error")
|
||||
}
|
||||
})
|
||||
.always(function () {
|
||||
$('#submit_new_assets')
|
||||
.attr("disabled", false)
|
||||
.addClass('bt-outline-success')
|
||||
.removeClass('btn-success', 'text-dark');
|
||||
})
|
||||
.fail(function (error) {
|
||||
$('#submit_new_assets').text('Save');
|
||||
propagate_form_api_errors(error.responseJSON.data);
|
||||
})
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
|
||||
$('#modal_add_asset').modal({ show: true });
|
||||
$('#asset_name').focus();
|
||||
|
||||
});
|
||||
|
||||
$('.dtr-modal').hide();
|
||||
}
|
||||
|
||||
/* Retrieve the list of assets and build a datatable for each type of asset */
|
||||
function get_case_assets() {
|
||||
show_loader();
|
||||
|
||||
get_request_api('/case/assets/list')
|
||||
.done(function (response) {
|
||||
if (response.status == 'success') {
|
||||
if (response.data != null) {
|
||||
jsdata = response.data;
|
||||
if (jsdata.assets.length > 299) {
|
||||
set_page_warning("Backref disabled due to too many assets in the case");
|
||||
} else {
|
||||
set_page_warning("");
|
||||
}
|
||||
Table.clear();
|
||||
Table.rows.add(jsdata.assets);
|
||||
Table.columns.adjust().draw();
|
||||
load_menu_mod_options('asset', Table, delete_asset);
|
||||
|
||||
set_last_state(jsdata.state);
|
||||
hide_loader();
|
||||
Table.responsive.recalc();
|
||||
|
||||
$('[data-toggle="popover"]').popover({html: true, container: 'body'});
|
||||
|
||||
} else {
|
||||
Table.clear().draw();
|
||||
swal("Oh no !", data.message, "error")
|
||||
}
|
||||
} else {
|
||||
Table.clear().draw()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/* Delete an asset */
|
||||
function delete_asset(asset_id) {
|
||||
do_deletion_prompt("You are about to delete asset #" + asset_id)
|
||||
.then((doDelete) => {
|
||||
if (doDelete) {
|
||||
post_request_api('assets/delete/' + asset_id)
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
reload_assets();
|
||||
$('#modal_add_asset').modal('hide');
|
||||
notify_success('Asset deleted');
|
||||
} else {
|
||||
swal("Oh no !", data.message, "error")
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Fetch the details of an asset and allow modification */
|
||||
function asset_details(asset_id) {
|
||||
|
||||
url = 'assets/' + asset_id + '/modal' + case_param();
|
||||
$('#modal_add_asset_content').load(url, function (response, status, xhr) {
|
||||
hide_minimized_modal_box();
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
g_asset_id = asset_id;
|
||||
g_asset_desc_editor = get_new_ace_editor('asset_description', 'asset_desc_content', 'target_asset_desc',
|
||||
function() {
|
||||
$('#last_saved').addClass('btn-danger').removeClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-exclamation");
|
||||
}, null, false, false);
|
||||
|
||||
g_asset_desc_editor.setOption("minLines", "10");
|
||||
preview_asset_description(true);
|
||||
headers = get_editor_headers('g_asset_desc_editor', null, 'asset_edition_btn');
|
||||
|
||||
$('#asset_edition_btn').append(headers);
|
||||
|
||||
$('#ioc_links').select2({});
|
||||
|
||||
|
||||
$('#submit_new_asset').on("click", function () {
|
||||
update_asset(true);
|
||||
return false;
|
||||
})
|
||||
|
||||
load_menu_mod_options_modal(asset_id, 'asset', $("#asset_modal_quick_actions"));
|
||||
$('.dtr-modal').hide();
|
||||
|
||||
$('#modal_add_asset').modal({ show: true });
|
||||
edit_in_asset_desc();
|
||||
});
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function preview_asset_description(no_btn_update) {
|
||||
if(!$('#container_asset_description').is(':visible')) {
|
||||
asset_desc = g_asset_desc_editor.getValue();
|
||||
converter = get_showdown_convert();
|
||||
html = converter.makeHtml(do_md_filter_xss(asset_desc));
|
||||
asset_desc_html = do_md_filter_xss(html);
|
||||
$('#target_asset_desc').html(asset_desc_html);
|
||||
$('#container_asset_description').show();
|
||||
if (!no_btn_update) {
|
||||
$('#asset_preview_button').html('<i class="fa-solid fa-eye-slash"></i>');
|
||||
}
|
||||
$('#container_asset_desc_content').hide();
|
||||
}
|
||||
else {
|
||||
$('#container_asset_description').hide();
|
||||
if (!no_btn_update) {
|
||||
$('#asset_preview_button').html('<i class="fa-solid fa-eye"></i>');
|
||||
}
|
||||
|
||||
$('#asset_preview_button').html('<i class="fa-solid fa-eye"></i>');
|
||||
$('#container_asset_desc_content').show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function save_asset(){
|
||||
$('#submit_new_asset').click();
|
||||
}
|
||||
|
||||
function update_asset(do_close){
|
||||
if(!$('form#form_new_asset').valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var data = $('#form_new_asset').serializeObject();
|
||||
if (typeof data["ioc_links"] === "string") {
|
||||
data["ioc_links"] = [data["ioc_links"]]
|
||||
} else if (typeof data["ioc_links"] === "object") {
|
||||
tmp_data = [];
|
||||
for (ioc_link in data["ioc_links"]) {
|
||||
if (typeof ioc_link === "string") {
|
||||
tmp_data.push(data["ioc_links"][ioc_link]);
|
||||
}
|
||||
}
|
||||
data["ioc_links"] = tmp_data;
|
||||
}
|
||||
else {
|
||||
data["ioc_links"] = [];
|
||||
}
|
||||
data['asset_tags'] = $('#asset_tags').val();
|
||||
data['asset_description'] = g_asset_desc_editor.getValue();
|
||||
|
||||
ret = get_custom_attributes_fields();
|
||||
has_error = ret[0].length > 0;
|
||||
attributes = ret[1];
|
||||
|
||||
if (has_error){return false;}
|
||||
|
||||
data['custom_attributes'] = attributes;
|
||||
|
||||
post_request_api('assets/update/' + g_asset_id, JSON.stringify(data), true)
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
reload_assets();
|
||||
$('#submit_new_asset').text("Saved").addClass('btn-outline-success').removeClass('btn-outline-danger').removeClass('btn-outline-warning');
|
||||
$('#last_saved').removeClass('btn-danger').addClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-check");
|
||||
if (do_close) {
|
||||
$('#modal_add_asset').modal('hide');
|
||||
}
|
||||
notify_success('Asset updated');
|
||||
} else {
|
||||
$('#submit_new_asset').text('Save again');
|
||||
swal("Oh no !", data.message, "error")
|
||||
}
|
||||
})
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function fire_upload_assets() {
|
||||
$('#modal_upload_assets').modal('show');
|
||||
}
|
||||
|
||||
function upload_assets() {
|
||||
|
||||
var file = $("#input_upload_assets").get(0).files[0];
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
fileData = e.target.result
|
||||
var data = new Object();
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
data['CSVData'] = fileData;
|
||||
|
||||
post_request_api('/case/assets/upload', JSON.stringify(data), true)
|
||||
.done((data) => {
|
||||
jsdata = data;
|
||||
if (jsdata.status == "success") {
|
||||
reload_assets();
|
||||
$('#modal_upload_assets').modal('hide');
|
||||
swal("Got news for you", data.message, "success");
|
||||
|
||||
} else {
|
||||
swal("Got bad news for you", data.message, "error");
|
||||
}
|
||||
})
|
||||
|
||||
};
|
||||
reader.readAsText(file)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function generate_sample_csv(){
|
||||
csv_data = "asset_name,asset_type_name,asset_description,asset_ip,asset_domain,asset_tags\n"
|
||||
csv_data += '"My computer","Mac - Computer","Computer of Mme Michu","192.168.15.5","iris.local","Compta|Mac"\n'
|
||||
csv_data += '"XCAS","Windows - Server","Xcas server","192.168.15.48","iris.local",""'
|
||||
download_file("sample_assets.csv", "text/csv", csv_data);
|
||||
}
|
||||
|
||||
/* Page is ready, fetch the assets of the case */
|
||||
$(document).ready(function(){
|
||||
|
||||
/* add filtering fields for each table of the page (must be done before datatable initialization) */
|
||||
$.each($.find("table"), function(index, element){
|
||||
addFilterFields($(element).attr("id"));
|
||||
});
|
||||
|
||||
Table = $("#assets_table").DataTable({
|
||||
dom: '<"container-fluid"<"row"<"col"l><"col"f>>>rt<"container-fluid"<"row"<"col"i><"col"p>>>',
|
||||
aaData: [],
|
||||
aoColumns: [
|
||||
{
|
||||
"data": "asset_name",
|
||||
"className": "dt-nowrap",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' || type === 'filter' || type === 'sort' || type === 'export') {
|
||||
if (row['asset_domain']) {
|
||||
datak = sanitizeHTML(row['asset_domain'])+"\\"+ sanitizeHTML(data);
|
||||
} else {
|
||||
datak = sanitizeHTML(data);
|
||||
}
|
||||
|
||||
if (data.length > 60) {
|
||||
datak = data.slice(0, 60) + " (..)";
|
||||
}
|
||||
if (isWhiteSpace(data)) {
|
||||
datak = '#' + row['asset_id'];
|
||||
}
|
||||
share_link = buildShareLink(row['asset_id']);
|
||||
if (row['asset_compromise_status_id'] == 1) {
|
||||
src_icon = row['asset_icon_compromised'];
|
||||
} else {
|
||||
src_icon = row['asset_icon_not_compromised'];
|
||||
}
|
||||
ret = '<img class="mr-2" title="'+ sanitizeHTML(row['asset_type']) +'" style="width:1.5em;height:1.5em" src=\'/static/assets/img/graph/' + src_icon +
|
||||
'\'> <a href="' + share_link + '" data-selector="true" title="Asset ID #'+ row['asset_id'] +
|
||||
'" onclick="asset_details(\'' + row['asset_id'] + '\');return false;">' + datak +'</a>';
|
||||
|
||||
if (row.link.length > 0) {
|
||||
var has_compro = false;
|
||||
var datacontent = 'data-content="';
|
||||
for (idx in row.link) {
|
||||
if (row.link[idx]['asset_compromise_status_id'] == 1) {
|
||||
has_compro = true;
|
||||
datacontent += `<b><a target='_blank' rel='noopener' href='/case/assets?cid=${row.link[idx]['case_id']}&shared=${row.link[idx]['asset_id']}'>Observed <sup><i class='fa-solid fa-arrow-up-right-from-square ml-1 mr-1 text-muted'></i></sup></a></b> as <b class='text-danger'>compromised</b><br/> on <b><a href='/case?cid=${row.link[idx]['case_id']}'>case #${row.link[idx]['case_id']} <sup><i class='fa-solid fa-arrow-up-right-from-square ml-1 mr-1 text-muted'></i></sup></a></a></b> (${row.link[idx]['case_open_date'].replace('00:00:00 GMT', '')}) for the same customer.<br/><br/>`;
|
||||
} else {
|
||||
|
||||
datacontent += `<b><a target='_blank' rel='noopener' href='/case/assets?cid=${row.link[idx]['case_id']}&shared=${row.link[idx]['asset_id']}'>Observed <sup><i class='fa-solid fa-arrow-up-right-from-square ml-1 mr-1 text-muted'></i></sup></a></b> as <b class='text-success'>not compromised</b><br/> on <b><a href='/case?cid=${row.link[idx]['case_id']}'>case #${row.link[idx]['case_id']} <sup><i class='fa-solid fa-arrow-up-right-from-square ml-1 mr-1 text-muted'></i></sup></a></a></b> (${row.link[idx]['case_open_date'].replace('00:00:00 GMT', '')}) for the same customer.<br/><br/>`;
|
||||
}
|
||||
}
|
||||
if (has_compro) {
|
||||
ret += `<a tabindex="0" class="fas fa-meteor ml-2 text-danger" style="cursor: pointer;" data-html="true"
|
||||
data-toggle="popover" data-trigger="focus" title="Observed in previous case" `;
|
||||
} else {
|
||||
ret += `<a tabindex="0" class="fas fa-info-circle ml-2 text-success" style="cursor: pointer;" data-html="true"
|
||||
data-toggle="popover" data-trigger="focus" title="Observed in previous case" `;
|
||||
}
|
||||
|
||||
ret += datacontent;
|
||||
ret += '"></i>';
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "asset_type",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "asset_description",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
data = sanitizeHTML(data);
|
||||
datas = '<span data-toggle="popover-click-close" style="cursor: pointer;" title="Info" data-trigger="hover" href="#" data-content="' + data + '">' + data.slice(0, 70);
|
||||
|
||||
if (data.length > 70) {
|
||||
datas += ' (..)</span>';
|
||||
} else {
|
||||
datas += '</span>';
|
||||
}
|
||||
return datas;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "asset_ip",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "asset_compromise_status_id",
|
||||
"render": function(data, type, row) {
|
||||
if (data == 0) { ret = '<span class="badge badge-muted">TBD</span>';}
|
||||
else if (data == 1) { ret = '<span class="badge badge-danger">Yes</span>';}
|
||||
else if (data == 2) { ret = '<span class="badge badge-success">No</span>';}
|
||||
else { ret = '<span class="badge badge-warning">Unknown</span>';}
|
||||
return ret;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "ioc_links",
|
||||
"render": function (data, type, row, meta) {
|
||||
if ((type === 'filter' || type === 'display') && data != null) {
|
||||
datas = "";
|
||||
for (ds in data) {
|
||||
datas += '<span class="badge badge-light">' + sanitizeHTML(data[ds]['ioc_value']) + '</span>';
|
||||
}
|
||||
return datas;
|
||||
} else if (type === 'export' && data != null) {
|
||||
let datas = data.map(ds => sanitizeHTML(ds['ioc_value'])).join(',');
|
||||
return datas;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "asset_tags",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null ) {
|
||||
tags = "";
|
||||
de = data.split(',');
|
||||
for (tag in de) {
|
||||
tags += '<span class="badge badge-light ml-2">' + sanitizeHTML(de[tag]) + '</span>';
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "analysis_status",
|
||||
"render": function(data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
if (data == 'To be done') {
|
||||
flag = 'danger';
|
||||
} else if (data == 'Started') {
|
||||
flag = 'warning';
|
||||
} else if (data == 'Done') {
|
||||
flag = 'success';
|
||||
} else {
|
||||
flag = 'muted';
|
||||
}
|
||||
data = '<span class="badge ml-2 badge-'+ flag +'">' + data + '</span>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
],
|
||||
filter: true,
|
||||
info: true,
|
||||
ordering: true,
|
||||
processing: true,
|
||||
responsive: {
|
||||
details: {
|
||||
display: $.fn.dataTable.Responsive.display.childRow,
|
||||
renderer: $.fn.dataTable.Responsive.renderer.tableAll()
|
||||
}
|
||||
},
|
||||
language: {
|
||||
"processing": '<i class="fa fa-spinner fa-spin" style="font-size:24px;color:rgb(75, 183, 245);"></i>'
|
||||
},
|
||||
retrieve: true,
|
||||
buttons: [],
|
||||
orderCellsTop: true,
|
||||
initComplete: function () {
|
||||
tableFiltering(this.api(), 'assets_table');
|
||||
},
|
||||
select: true
|
||||
});
|
||||
$("#assets_table").css("font-size", 12);
|
||||
|
||||
Table.on( 'responsive-resize', function ( e, datatable, columns ) {
|
||||
hide_table_search_input( columns );
|
||||
});
|
||||
|
||||
var buttons = new $.fn.dataTable.Buttons(Table, {
|
||||
buttons: [
|
||||
{ "extend": 'csvHtml5', "text":'<i class="fas fa-cloud-download-alt"></i>',"className": 'btn btn-link text-white'
|
||||
, "titleAttr": 'Download as CSV', "exportOptions": { "columns": ':visible', 'orthogonal': 'export' } } ,
|
||||
{ "extend": 'copyHtml5', "text":'<i class="fas fa-copy"></i>',"className": 'btn btn-link text-white'
|
||||
, "titleAttr": 'Copy', "exportOptions": { "columns": ':visible', 'orthogonal': 'export' } },
|
||||
{ "extend": 'colvis', "text":'<i class="fas fa-eye-slash"></i>',"className": 'btn btn-link text-white'
|
||||
, "titleAttr": 'Toggle columns' }
|
||||
]
|
||||
}).container().appendTo($('#tables_button'));
|
||||
|
||||
get_case_assets();
|
||||
setInterval(function() { check_update('assets/state'); }, 3000);
|
||||
|
||||
shared_id = getSharedLink();
|
||||
if (shared_id) {
|
||||
asset_details(shared_id);
|
||||
}
|
||||
});
|
||||
72
iris-web/source/app/static/assets/js/iris/case.graph.js
Normal file
72
iris-web/source/app/static/assets/js/iris/case.graph.js
Normal file
@@ -0,0 +1,72 @@
|
||||
|
||||
function get_case_graph() {
|
||||
get_request_api('graph/getdata')
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
redrawAll(data.data);
|
||||
hide_loader();
|
||||
} else {
|
||||
$('#submit_new_asset').text('Save again');
|
||||
swal("Oh no !", data.message, "error")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var network;
|
||||
|
||||
function redrawAll(data) {
|
||||
if (data.nodes.length == 0) {
|
||||
$('#card_main_load').show();
|
||||
$('#graph-container').text('No events in graph');
|
||||
hide_loader();
|
||||
return true;
|
||||
}
|
||||
var container = document.getElementById("graph-container");
|
||||
var options = {
|
||||
edges: {
|
||||
smooth: {
|
||||
enabled: true,
|
||||
type: 'continuous',
|
||||
roundness: 0.5
|
||||
}
|
||||
},
|
||||
layout: {
|
||||
randomSeed: 2,
|
||||
improvedLayout: true
|
||||
},
|
||||
interaction: {
|
||||
hideEdgesOnDrag: false
|
||||
},
|
||||
width: (window.innerWidth - 400) + "px",
|
||||
height: (window.innerHeight- 250) + "px",
|
||||
"physics": {
|
||||
"forceAtlas2Based": {
|
||||
"gravitationalConstant": -167,
|
||||
"centralGravity": 0.04,
|
||||
"springLength": 0,
|
||||
"springConstant": 0.02,
|
||||
"damping": 0.9
|
||||
},
|
||||
"minVelocity": 0.41,
|
||||
"solver": "forceAtlas2Based",
|
||||
"timestep": 0.45
|
||||
}
|
||||
};
|
||||
|
||||
nodes = data.nodes;
|
||||
edges = data.edges;
|
||||
|
||||
network = new vis.Network(container, data, options);
|
||||
|
||||
network.on("stabilizationIterationsDone", function () {
|
||||
network.setOptions( { physics: false } );
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Page is ready, fetch the assets of the case */
|
||||
$(document).ready(function(){
|
||||
get_case_graph();
|
||||
});
|
||||
|
||||
478
iris-web/source/app/static/assets/js/iris/case.ioc.js
Normal file
478
iris-web/source/app/static/assets/js/iris/case.ioc.js
Normal file
@@ -0,0 +1,478 @@
|
||||
/* reload the ioc table */
|
||||
var g_ioc_id = null;
|
||||
var g_ioc_desc_editor = null;
|
||||
|
||||
|
||||
function reload_iocs() {
|
||||
get_case_ioc();
|
||||
}
|
||||
|
||||
function edit_in_ioc_desc() {
|
||||
if($('#container_ioc_desc_content').is(':visible')) {
|
||||
$('#container_ioc_description').show(100);
|
||||
$('#container_ioc_desc_content').hide(100);
|
||||
$('#ioc_edition_btn').hide(100);
|
||||
$('#ioc_preview_button').hide(100);
|
||||
} else {
|
||||
$('#ioc_preview_button').show(100);
|
||||
$('#ioc_edition_btn').show(100);
|
||||
$('#container_ioc_desc_content').show(100);
|
||||
$('#container_ioc_description').hide(100);
|
||||
}
|
||||
}
|
||||
|
||||
/* Fetch a modal that is compatible with the requested ioc type */
|
||||
function add_ioc() {
|
||||
url = 'ioc/add/modal' + case_param();
|
||||
|
||||
$('#modal_add_ioc_content').load(url, function (response, status, xhr) {
|
||||
hide_minimized_modal_box();
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
g_ioc_desc_editor = get_new_ace_editor('ioc_description', 'ioc_desc_content', 'target_ioc_desc',
|
||||
function() {
|
||||
$('#last_saved').addClass('btn-danger').removeClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-exclamation");
|
||||
}, null);
|
||||
|
||||
g_ioc_desc_editor.setOption("minLines", "10");
|
||||
edit_in_ioc_desc();
|
||||
|
||||
headers = get_editor_headers('g_ioc_desc_editor', null, 'ioc_edition_btn');
|
||||
$('#ioc_edition_btn').append(headers);
|
||||
|
||||
|
||||
$('#submit_new_ioc').on("click", function () {
|
||||
if(!$('form#form_new_ioc').valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var data = $('#form_new_ioc').serializeObject();
|
||||
data['ioc_tags'] = $('#ioc_tags').val();
|
||||
data['ioc_description'] = g_ioc_desc_editor.getValue();
|
||||
|
||||
ret = get_custom_attributes_fields();
|
||||
has_error = ret[0].length > 0;
|
||||
attributes = ret[1];
|
||||
|
||||
if (has_error){return false;}
|
||||
|
||||
data['custom_attributes'] = attributes;
|
||||
|
||||
id = $('#ioc_id').val();
|
||||
|
||||
if ($('#ioc_one_per_line').is(':checked')) {
|
||||
let iocs_values = $('#ioc_value').val();
|
||||
let iocs_list = iocs_values.split(/\r?\n/);
|
||||
for (let index in iocs_list) {
|
||||
if (iocs_list[index] === '' || iocs_list[index] === '\n') {
|
||||
continue;
|
||||
}
|
||||
|
||||
data['ioc_value'] = iocs_list[index];
|
||||
post_request_api('ioc/add', JSON.stringify(data), true, function () {
|
||||
$('#submit_new_ioc').text('Saving data..')
|
||||
.attr("disabled", true)
|
||||
.removeClass('bt-outline-success')
|
||||
.addClass('btn-success', 'text-dark');
|
||||
})
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
reload_iocs();
|
||||
notify_success(data.message);
|
||||
if (index == (iocs_list.length - 1)) {
|
||||
$('#modal_add_ioc').modal('hide');
|
||||
}
|
||||
} else {
|
||||
$('#submit_new_ioc').text('Save again');
|
||||
swal("Oh no !", data.message, "error")
|
||||
}
|
||||
})
|
||||
.always(function () {
|
||||
$('#submit_new_ioc')
|
||||
.attr("disabled", false)
|
||||
.addClass('bt-outline-success')
|
||||
.removeClass('btn-success', 'text-dark');
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
post_request_api('ioc/add', JSON.stringify(data), true, function () {
|
||||
$('#submit_new_ioc').text('Saving data..')
|
||||
.attr("disabled", true)
|
||||
.removeClass('bt-outline-success')
|
||||
.addClass('btn-success', 'text-dark');
|
||||
})
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
reload_iocs();
|
||||
notify_success(data.message);
|
||||
$('#modal_add_ioc').modal('hide');
|
||||
|
||||
} else {
|
||||
$('#submit_new_ioc').text('Save again');
|
||||
swal("Oh no !", data.message, "error")
|
||||
}
|
||||
})
|
||||
.always(function () {
|
||||
$('#submit_new_ioc')
|
||||
.attr("disabled", false)
|
||||
.addClass('bt-outline-success')
|
||||
.removeClass('btn-success', 'text-dark');
|
||||
})
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#modal_add_ioc').modal({ show: true });
|
||||
$('#ioc_value').focus();
|
||||
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function save_ioc() {
|
||||
$('#submit_new_ioc').click();
|
||||
}
|
||||
|
||||
/* Retrieve the list of iocs and build a datatable for each type of ioc */
|
||||
function get_case_ioc() {
|
||||
show_loader();
|
||||
|
||||
get_request_api("/case/ioc/list")
|
||||
.done(function (response) {
|
||||
if (response.status == 'success') {
|
||||
if (response.data != null) {
|
||||
jsdata = response.data;
|
||||
Table.clear();
|
||||
Table.rows.add(jsdata.ioc);
|
||||
|
||||
set_last_state(jsdata.state);
|
||||
$('#ioc_table_wrapper').on('click', function(e){
|
||||
if($('.popover').length>1)
|
||||
$('.popover').popover('hide');
|
||||
$(e.target).popover('toggle');
|
||||
});
|
||||
|
||||
$('#ioc_table_wrapper').show();
|
||||
$('[data-toggle="popover"]').popover();
|
||||
Table.columns.adjust().draw();
|
||||
load_menu_mod_options('ioc', Table, delete_ioc);
|
||||
hide_loader();
|
||||
Table.responsive.recalc();
|
||||
|
||||
} else {
|
||||
Table.clear().draw();
|
||||
swal("Oh no !", data.message, "error")
|
||||
}
|
||||
} else {
|
||||
Table.clear().draw()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/* Edit an ioc */
|
||||
function edit_ioc(ioc_id) {
|
||||
url = 'ioc/' + ioc_id + '/modal' + case_param();
|
||||
$('#modal_add_ioc_content').load(url, function (response, status, xhr) {
|
||||
hide_minimized_modal_box();
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
g_ioc_id = ioc_id;
|
||||
g_ioc_desc_editor = get_new_ace_editor('ioc_description', 'ioc_desc_content', 'target_ioc_desc',
|
||||
function() {
|
||||
$('#last_saved').addClass('btn-danger').removeClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-exclamation");
|
||||
}, null, false, false);
|
||||
|
||||
g_ioc_desc_editor.setOption("minLines", "10");
|
||||
preview_ioc_description(true);
|
||||
headers = get_editor_headers('g_ioc_desc_editor', null, 'ioc_edition_btn');
|
||||
$('#ioc_edition_btn').append(headers);
|
||||
|
||||
load_menu_mod_options_modal(ioc_id, 'ioc', $("#ioc_modal_quick_actions"));
|
||||
$('.dtr-modal').hide();
|
||||
$('#modal_add_ioc').modal({ show: true });
|
||||
edit_in_ioc_desc();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function preview_ioc_description(no_btn_update) {
|
||||
if(!$('#container_ioc_description').is(':visible')) {
|
||||
ioc_desc = g_ioc_desc_editor.getValue();
|
||||
converter = get_showdown_convert();
|
||||
html = converter.makeHtml(do_md_filter_xss(ioc_desc));
|
||||
ioc_desc_html = do_md_filter_xss(html);
|
||||
$('#target_ioc_desc').html(ioc_desc_html);
|
||||
$('#container_ioc_description').show();
|
||||
if (!no_btn_update) {
|
||||
$('#ioc_preview_button').html('<i class="fa-solid fa-eye-slash"></i>');
|
||||
}
|
||||
$('#container_ioc_desc_content').hide();
|
||||
}
|
||||
else {
|
||||
$('#container_ioc_description').hide();
|
||||
if (!no_btn_update) {
|
||||
$('#ioc_preview_button').html('<i class="fa-solid fa-eye"></i>');
|
||||
}
|
||||
|
||||
$('#ioc_preview_button').html('<i class="fa-solid fa-eye"></i>');
|
||||
$('#container_ioc_desc_content').show();
|
||||
}
|
||||
}
|
||||
|
||||
function update_ioc(ioc_id) {
|
||||
update_ioc_ext(ioc_id, true);
|
||||
}
|
||||
|
||||
/* Update an ioc */
|
||||
function update_ioc_ext(ioc_id, do_close) {
|
||||
if(!$('form#form_new_ioc').valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ioc_id === undefined || ioc_id === null) {
|
||||
ioc_id = g_ioc_id;
|
||||
}
|
||||
|
||||
var data = $('#form_new_ioc').serializeObject();
|
||||
data['ioc_tags'] = $('#ioc_tags').val();
|
||||
ret = get_custom_attributes_fields();
|
||||
has_error = ret[0].length > 0;
|
||||
attributes = ret[1];
|
||||
|
||||
if (has_error){return false;}
|
||||
data['ioc_description'] = g_ioc_desc_editor.getValue();
|
||||
data['custom_attributes'] = attributes;
|
||||
|
||||
post_request_api('ioc/update/' + ioc_id, JSON.stringify(data), true)
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
reload_iocs();
|
||||
|
||||
$('#submit_new_ioc').text("Saved").addClass('btn-outline-success').removeClass('btn-outline-danger').removeClass('btn-outline-warning');
|
||||
$('#last_saved').removeClass('btn-danger').addClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-check");
|
||||
|
||||
if (do_close !== undefined && do_close === true) {
|
||||
$('#modal_add_ioc').modal('hide');
|
||||
}
|
||||
|
||||
notify_success(data.message);
|
||||
|
||||
} else {
|
||||
$('#submit_new_ioc').text('Save again');
|
||||
swal("Oh no !", data.message, "error")
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/* Delete an ioc */
|
||||
function delete_ioc(ioc_id) {
|
||||
do_deletion_prompt("You are about to delete IOC #" + ioc_id)
|
||||
.then((doDelete) => {
|
||||
if (doDelete) {
|
||||
post_request_api('ioc/delete/' + ioc_id)
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
reload_iocs();
|
||||
notify_success(data.message);
|
||||
$('#modal_add_ioc').modal('hide');
|
||||
|
||||
} else {
|
||||
swal("Oh no !", data.message, "error")
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function fire_upload_iocs() {
|
||||
$('#modal_upload_ioc').modal('show');
|
||||
}
|
||||
|
||||
function upload_ioc() {
|
||||
|
||||
var file = $("#input_upload_ioc").get(0).files[0];
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
fileData = e.target.result
|
||||
var data = new Object();
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
data['CSVData'] = fileData;
|
||||
|
||||
post_request_api('/case/ioc/upload', JSON.stringify(data), true)
|
||||
.done((data) => {
|
||||
jsdata = data;
|
||||
if (jsdata.status == "success") {
|
||||
reload_iocs();
|
||||
$('#modal_upload_ioc').modal('hide');
|
||||
swal("Got news for you", data.message, "success");
|
||||
|
||||
} else {
|
||||
swal("Got bad news for you", data.message, "error");
|
||||
}
|
||||
})
|
||||
};
|
||||
reader.readAsText(file)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function generate_sample_csv(){
|
||||
csv_data = "ioc_value,ioc_type,ioc_description,ioc_tags,ioc_tlp\n"
|
||||
csv_data += "1.1.1.1,ip-dst,Cloudflare DNS IP address,Cloudflare|DNS,green\n"
|
||||
csv_data += "wannacry.exe,filename,Wannacry sample found,Wannacry|Malware|PE,amber"
|
||||
download_file("sample_iocs.csv", "text/csv", csv_data);
|
||||
}
|
||||
|
||||
/* Page is ready, fetch the iocs of the case */
|
||||
$(document).ready(function(){
|
||||
|
||||
/* add filtering fields for each table of the page (must be done before datatable initialization) */
|
||||
$.each($.find("table"), function(index, element){
|
||||
addFilterFields($(element).attr("id"));
|
||||
});
|
||||
|
||||
Table = $("#ioc_table").DataTable({
|
||||
dom: '<"container-fluid"<"row"<"col"l><"col"f>>>rt<"container-fluid"<"row"<"col"i><"col"p>>>',
|
||||
fixedHeader: true,
|
||||
aaData: [],
|
||||
aoColumns: [
|
||||
{
|
||||
"data": "ioc_value",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
|
||||
let datak = '';
|
||||
|
||||
if (isWhiteSpace(data) || data === null) {
|
||||
datak = '#' + row['ioc_id'];
|
||||
} else {
|
||||
datak= ellipsis_field(data, 64);
|
||||
}
|
||||
|
||||
share_link = buildShareLink(row['ioc_id']);
|
||||
data = '<a href="' + share_link + '" data-selector="true" title="IOC ID #'+ row['ioc_id'] +'" onclick="edit_ioc(\'' + row['ioc_id'] + '\');return false;">' + datak +'</a>';
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "ioc_type",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "ioc_description",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
datas = '<span data-toggle="popover" style="cursor: pointer;" title="Info" data-trigger="hover" href="#" data-content="' + data + '">' + data.slice(0, 70);
|
||||
|
||||
if (data.length > 70) {
|
||||
datas += ' (..)</span>';
|
||||
} else {
|
||||
datas += '</span>';
|
||||
}
|
||||
return datas;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "ioc_tags",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
tags = "";
|
||||
de = data.split(',');
|
||||
for (tag in de) {
|
||||
tags += '<span class="badge badge-light ml-2">' + sanitizeHTML(de[tag]) + '</span>';
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "link",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
links = "";
|
||||
for (link in data) {
|
||||
links += '<span data-toggle="popover" style="cursor: pointer;" data-trigger="hover" class="text-primary mr-3" href="#" title="Case info" data-content="' + sanitizeHTML(data[link]['case_name']) +
|
||||
' (' + sanitizeHTML(data[link]['client_name']) + ')' + '">#' + data[link]['case_id'] + '</span>'
|
||||
}
|
||||
return links;
|
||||
} else if (type === 'export' && data != null) {
|
||||
return data.map(ds => sanitizeHTML(ds['case_name'])).join(',');
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "tlp_name",
|
||||
"render": function(data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
data = '<span class="badge badge-'+ row['tlp_bscolor'] +' ml-2">tlp:' + data + '</span>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
],
|
||||
filter: true,
|
||||
info: true,
|
||||
ordering: true,
|
||||
processing: true,
|
||||
retrieve: true,
|
||||
responsive: {
|
||||
details: {
|
||||
display: $.fn.dataTable.Responsive.display.childRow,
|
||||
renderer: $.fn.dataTable.Responsive.renderer.tableAll()
|
||||
}
|
||||
},
|
||||
buttons: [],
|
||||
orderCellsTop: true,
|
||||
initComplete: function () {
|
||||
tableFiltering(this.api(), 'ioc_table');
|
||||
},
|
||||
select: true
|
||||
});
|
||||
$("#ioc_table").css("font-size", 12);
|
||||
|
||||
Table.on( 'responsive-resize', function ( e, datatable, columns ) {
|
||||
hide_table_search_input( columns );
|
||||
});
|
||||
|
||||
var buttons = new $.fn.dataTable.Buttons(Table, {
|
||||
buttons: [
|
||||
{ "extend": 'csvHtml5', "text":'<i class="fas fa-cloud-download-alt"></i>',"className": 'btn btn-link text-white'
|
||||
, "titleAttr": 'Download as CSV', "exportOptions": { "columns": ':visible', 'orthogonal': 'export' } } ,
|
||||
{ "extend": 'copyHtml5', "text":'<i class="fas fa-copy"></i>',"className": 'btn btn-link text-white'
|
||||
, "titleAttr": 'Copy', "exportOptions": { "columns": ':visible', 'orthogonal': 'export' } },
|
||||
{ "extend": 'colvis', "text":'<i class="fas fa-eye-slash"></i>',"className": 'btn btn-link text-white'
|
||||
, "titleAttr": 'Toggle columns' }
|
||||
]
|
||||
}).container().appendTo($('#tables_button'));
|
||||
|
||||
get_case_ioc();
|
||||
setInterval(function() { check_update('ioc/state'); }, 3000);
|
||||
|
||||
shared_id = getSharedLink();
|
||||
if (shared_id) {
|
||||
edit_ioc(shared_id);
|
||||
}
|
||||
});
|
||||
179
iris-web/source/app/static/assets/js/iris/case.js
Normal file
179
iris-web/source/app/static/assets/js/iris/case.js
Normal file
@@ -0,0 +1,179 @@
|
||||
function buildShareLink(lookup_id) {
|
||||
current_path = location.protocol + '//' + location.host + location.pathname;
|
||||
current_path = current_path + case_param() + '&shared=' + lookup_id;
|
||||
|
||||
return current_path;
|
||||
}
|
||||
|
||||
function getSharedLink(){
|
||||
queryString = window.location.search;
|
||||
urlParams = new URLSearchParams(queryString);
|
||||
if (Number.isInteger(parseInt(urlParams.get('shared')))) {
|
||||
return urlParams.get('shared')
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function edit_case_info() {
|
||||
$('#case_gen_info_content').hide();
|
||||
$('#case_gen_info_edit').show();
|
||||
$('#cancel_case_info').show();
|
||||
$('#save_case_info').show();
|
||||
$('#case_info').hide();
|
||||
}
|
||||
|
||||
function cancel_case_edit() {
|
||||
$('#case_gen_info_content').show();
|
||||
$('#case_gen_info_edit').hide();
|
||||
$('#cancel_case_info').hide();
|
||||
$('#save_case_info').hide();
|
||||
$('#case_info').show();
|
||||
}
|
||||
|
||||
function save_case_edit(case_id) {
|
||||
|
||||
var data_sent = $('form#form_update_case').serializeObject();
|
||||
var map_protagonists = Object();
|
||||
|
||||
for (e in data_sent) {
|
||||
if (e.startsWith('protagonist_role_')) {
|
||||
map_protagonists[e.replace('protagonist_role_', '')] = {
|
||||
'role': data_sent[e]
|
||||
};
|
||||
delete data_sent[e];
|
||||
}
|
||||
if (e.startsWith('protagonist_name_')) {
|
||||
map_protagonists[e.replace('protagonist_name_', '')]['name'] = data_sent[e];
|
||||
delete data_sent[e];
|
||||
}
|
||||
if (e.startsWith('protagonist_contact_')) {
|
||||
map_protagonists[e.replace('protagonist_contact_', '')]['contact'] = data_sent[e];
|
||||
delete data_sent[e];
|
||||
}
|
||||
if (e.startsWith('protagonist_id_')) {
|
||||
map_protagonists[e.replace('protagonist_id_', '')]['id'] = data_sent[e];
|
||||
delete data_sent[e];
|
||||
}
|
||||
}
|
||||
data_sent['protagonists'] = [];
|
||||
for (e in map_protagonists) {
|
||||
data_sent['protagonists'].push(map_protagonists[e]);
|
||||
}
|
||||
|
||||
data_sent['case_tags'] = $('#case_tags').val();
|
||||
|
||||
ret = get_custom_attributes_fields();
|
||||
has_error = ret[0].length > 0;
|
||||
attributes = ret[1];
|
||||
|
||||
if (has_error){return false;}
|
||||
|
||||
data_sent['custom_attributes'] = attributes;
|
||||
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
post_request_api('/manage/cases/update/' + case_id, JSON.stringify(data_sent), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
case_detail(case_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Remove case function */
|
||||
function remove_case(id) {
|
||||
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "You won't be able to revert this !\nAll associated data will be deleted",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
post_request_api('/manage/cases/delete/' + id)
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data)) {
|
||||
$('#modal_case_detail').modal('hide');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Reopen case function */
|
||||
function reopen_case(id) {
|
||||
post_request_api('/manage/cases/reopen/' + id)
|
||||
.done((data) => {
|
||||
window.location.reload();
|
||||
$('#modal_case_detail').modal('hide');
|
||||
});
|
||||
}
|
||||
|
||||
/* Close case function */
|
||||
function close_case(id) {
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "Case ID " + id + " will be closed",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, close it!'
|
||||
})
|
||||
.then((willClose) => {
|
||||
if (willClose) {
|
||||
post_request_api('/manage/cases/close/' + id)
|
||||
.done((data) => {
|
||||
window.location.reload();
|
||||
$('#modal_case_detail').modal('hide');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function add_protagonist() {
|
||||
random_string = Math.random().toString(36).substring(7);
|
||||
prota_html = $('#protagonist_list_edit_template').html();
|
||||
prota_html = prota_html.replace(/__PROTAGONIST_ID__/g, random_string);
|
||||
$('#protagonist_list_edit').append(prota_html);
|
||||
}
|
||||
|
||||
function remove_protagonist(id) {
|
||||
$('#protagonist_' + id).remove();
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
$(function(){
|
||||
var current = location.pathname;
|
||||
$('#h_nav_tab li').each(function(){
|
||||
var $this = $(this);
|
||||
var child = $this.children();
|
||||
// if the current path is like this link, make it active
|
||||
if(child.attr('href') !== undefined && child.attr('href').split("?")[0] == current){
|
||||
$this.addClass('active');
|
||||
return;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$('#case_quick_status').change(function(){
|
||||
post_request_api('/case/update-status', JSON.stringify({
|
||||
'status_id': $('#case_quick_status').val(),
|
||||
'csrf_token': $('#csrf_token').val()
|
||||
}))
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data)) {
|
||||
window.location.reload();
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
761
iris-web/source/app/static/assets/js/iris/case.notes.js
Normal file
761
iris-web/source/app/static/assets/js/iris/case.notes.js
Normal file
@@ -0,0 +1,761 @@
|
||||
/* Defines the kanban board */
|
||||
let note_editor;
|
||||
let session_id = null ;
|
||||
let collaborator = null ;
|
||||
let collaborator_socket = null ;
|
||||
let buffer_dumped = false ;
|
||||
let last_applied_change = null ;
|
||||
let just_cleared_buffer = null ;
|
||||
let from_sync = null;
|
||||
let is_typing = "";
|
||||
let ppl_viewing = new Map();
|
||||
let timer_socket = 0;
|
||||
let note_id = null;
|
||||
let map_notes = Object();
|
||||
let last_ping = 0;
|
||||
let forceModalClose = false;
|
||||
let wasMiniNote = false;
|
||||
|
||||
const preventFormDefaultBehaviourOnSubmit = (event) => {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
};
|
||||
|
||||
var boardNotes = {
|
||||
init: function init() {
|
||||
this.bindUIActions();
|
||||
},
|
||||
bindUIActions: function bindUIActions() {
|
||||
// event handlers
|
||||
this.handleBoardStyle();
|
||||
this.handleSortable();
|
||||
},
|
||||
byId: function byId(id) {
|
||||
return document.getElementById(id);
|
||||
},
|
||||
handleBoardStyle: function handleBoardStyle() {
|
||||
$(document).on('mouseenter mouseleave', '.kanban-board-header', function (e) {
|
||||
var isHover = e.type === 'mouseenter';
|
||||
$(this).parent().toggleClass('hover', isHover);
|
||||
});
|
||||
},
|
||||
handleSortable: function handleSortable() {
|
||||
var board = this.byId('myKanban');
|
||||
// Multi groups
|
||||
Sortable.create(board, {
|
||||
animation: 150,
|
||||
draggable: '.kanban-board',
|
||||
handle: '.kanban-board-header',
|
||||
filter: '.ignore-sort',
|
||||
forceFallback: true
|
||||
});
|
||||
[].forEach.call(board.querySelectorAll('.kanban-drag'), function (el) {
|
||||
Sortable.create(el, {
|
||||
group: 'tasks',
|
||||
animation: 150,
|
||||
filter: '.ignore-sort',
|
||||
forceFallback: true
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function Collaborator( session_id, note_id ) {
|
||||
this.collaboration_socket = collaborator_socket;
|
||||
|
||||
this.channel = "case-" + session_id + "-notes";
|
||||
|
||||
this.collaboration_socket.on( "change-note", function(data) {
|
||||
if ( data.note_id !== note_id ) return ;
|
||||
let delta = JSON.parse( data.delta ) ;
|
||||
last_applied_change = delta ;
|
||||
$("#content_typing").text(data.last_change + " is typing..");
|
||||
if ( delta !== null && delta !== undefined ) {
|
||||
note_editor.session.getDocument().applyDeltas([delta]);
|
||||
}
|
||||
}.bind()) ;
|
||||
|
||||
this.collaboration_socket.on( "clear_buffer-note", function() {
|
||||
if ( data.note_id !== note_id ) return ;
|
||||
just_cleared_buffer = true ;
|
||||
note_editor.setValue( "" ) ;
|
||||
}.bind() ) ;
|
||||
|
||||
this.collaboration_socket.on( "save-note", function(data) {
|
||||
if ( data.note_id !== note_id ) return ;
|
||||
sync_note(note_id)
|
||||
.then(function () {
|
||||
$("#content_last_saved_by").text("Last saved by " + data.last_saved);
|
||||
$('#btn_save_note').text("Saved").addClass('btn-success').removeClass('btn-danger').removeClass('btn-warning');
|
||||
$('#last_saved').removeClass('btn-danger').addClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-check");
|
||||
});
|
||||
|
||||
}.bind());
|
||||
|
||||
this.collaboration_socket.on('leave-note', function(data) {
|
||||
ppl_viewing.delete(data.user);
|
||||
refresh_ppl_list(session_id, note_id);
|
||||
});
|
||||
|
||||
this.collaboration_socket.on('join-note', function(data) {
|
||||
if ( data.note_id !== note_id ) return ;
|
||||
if ((data.user in ppl_viewing)) return;
|
||||
ppl_viewing.set(filterXSS(data.user), 1);
|
||||
refresh_ppl_list(session_id, note_id);
|
||||
collaborator.collaboration_socket.emit('ping-note', { 'channel': collaborator.channel, 'note_id': note_id });
|
||||
});
|
||||
|
||||
this.collaboration_socket.on('ping-note', function(data) {
|
||||
if ( data.note_id !== note_id ) return ;
|
||||
collaborator.collaboration_socket.emit('pong-note', { 'channel': collaborator.channel, 'note_id': note_id });
|
||||
});
|
||||
|
||||
this.collaboration_socket.on('disconnect', function(data) {
|
||||
ppl_viewing.delete(data.user);
|
||||
refresh_ppl_list(session_id, note_id);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function set_notes_follow(data) {
|
||||
|
||||
if (data.note_id !== null) {
|
||||
if (data.note_id in map_notes ) {
|
||||
map_notes[data.note_id][data.user] = 2;
|
||||
} else {
|
||||
map_notes[data.note_id] = Object();
|
||||
map_notes[data.note_id][data.user] = 2;
|
||||
}
|
||||
}
|
||||
|
||||
for (let notid in map_notes) {
|
||||
for (let key in map_notes[notid]) {
|
||||
if (key !== data.user && data.note_id !== note_id || data.note_id === null) {
|
||||
map_notes[notid][key] -= 1;
|
||||
}
|
||||
if (map_notes[notid][key] < 0) {
|
||||
delete map_notes[notid][key];
|
||||
}
|
||||
}
|
||||
$(`#badge_${notid}`).empty();
|
||||
for (let key in map_notes[notid]) {
|
||||
$(`#badge_${notid}`).append(get_avatar_initials(filterXSS(key), false, undefined, true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Collaborator.prototype.change = function( delta, note_id ) {
|
||||
this.collaboration_socket.emit( "change-note", { 'delta': delta, 'channel': this.channel, 'note_id': note_id } ) ;
|
||||
}
|
||||
|
||||
Collaborator.prototype.clear_buffer = function( note_id ) {
|
||||
this.collaboration_socket.emit( "clear_buffer-note", { 'channel': this.channel, 'note_id': note_id } ) ;
|
||||
}
|
||||
|
||||
Collaborator.prototype.save = function( note_id ) {
|
||||
this.collaboration_socket.emit( "save-note", { 'channel': this.channel, 'note_id': note_id } ) ;
|
||||
}
|
||||
|
||||
Collaborator.prototype.close = function( note_id ) {
|
||||
this.collaboration_socket.emit( "leave-note", { 'channel': this.channel, 'note_id': note_id } ) ;
|
||||
}
|
||||
|
||||
function auto_remove_typing() {
|
||||
if ($("#content_typing").text() == is_typing) {
|
||||
$("#content_typing").text("");
|
||||
} else {
|
||||
is_typing = $("#content_typing").text();
|
||||
}
|
||||
}
|
||||
|
||||
/* Generates a global sequence id for subnotes */
|
||||
let current_id = 0;
|
||||
|
||||
function nextSubNote(element, _item, title) {
|
||||
var newElement = element.clone();
|
||||
var id = current_id + 1;
|
||||
current_id = id;
|
||||
if (id < 10) id = "0" + id;
|
||||
newElement.attr("id", element.attr("id").split("_")[0] + "_" + id);
|
||||
var field = $(newElement).attr("id");
|
||||
$(newElement).attr("id", field.split("_")[0] + "_" + id);
|
||||
$(newElement).find('iris_note').attr('id', 'xqx' + id + 'qxq');
|
||||
$(newElement).find('iris_note').text("New note");
|
||||
var va = $(newElement).find('a');
|
||||
$(newElement).find(va[1]).attr("onclick", 'delete_note("_' + id + '")');
|
||||
newElement.appendTo($('#group-' + _item + "_main"));
|
||||
newElement.show();
|
||||
}
|
||||
|
||||
/* Generates a global sequence id for groups */
|
||||
var current_gid = 0;
|
||||
|
||||
async function get_remote_note(note_id) {
|
||||
return get_request_api("/case/notes/" + note_id);
|
||||
}
|
||||
|
||||
async function sync_note(node_id) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function nextGroupNote(title="", rid=0) {
|
||||
|
||||
if (rid == 0) {
|
||||
console.log("RID is needed to create group");
|
||||
return;
|
||||
}
|
||||
|
||||
var element = $('#group_');
|
||||
var newElement = element.clone();
|
||||
|
||||
if (title == "") {
|
||||
title = "Untitled group";
|
||||
}
|
||||
newElement.attr("id", "group-" + rid);
|
||||
newElement.attr("title", "New group note");
|
||||
|
||||
var fa = $(newElement).find('button')[0];
|
||||
var fb = $(newElement).find('button')[1];
|
||||
var va = $(newElement).find('a');
|
||||
|
||||
$(newElement).find('div.kanban-title-board').text(title);
|
||||
$(newElement).find('div.kanban-title-board').attr("onclick", 'edit_add_save(' + rid + ')');
|
||||
|
||||
$(newElement).find(fa).attr("onclick", 'edit_remote_groupnote(' + rid + ')');
|
||||
$(newElement).find(fb).attr("onclick", 'add_remote_note(' + rid + ')');
|
||||
|
||||
$(newElement).find(va[0]).attr("onclick", 'delete_remote_groupnote(' + rid + ')');
|
||||
|
||||
$(newElement).find('main').attr("id", "group-" + rid + "-main");
|
||||
newElement.appendTo($('#myKanban'));
|
||||
newElement.show();
|
||||
|
||||
return rid;
|
||||
}
|
||||
|
||||
/* Add a subnote to an item */
|
||||
function add_subnote(_item, tr=0, title='', last_up, user) {
|
||||
|
||||
if (tr != 0) {
|
||||
let element = $('#_subnote_');
|
||||
var newElement = element.clone();
|
||||
var id = tr;
|
||||
current_id = id;
|
||||
|
||||
let info = user + " on " + last_up.replace('GMT', '');
|
||||
|
||||
newElement.attr("id", element.attr("id").split("_")[0] + "_" + id);
|
||||
var field = $(newElement).attr("id");
|
||||
$(newElement).attr("id", field.split("_")[0] + "_" + id);
|
||||
$(newElement).attr("title", 'Note #' + id);
|
||||
$(newElement).find('iris_note').attr('id', tr);
|
||||
$(newElement).find('iris_note').text(title);
|
||||
$(newElement).find('a.kanban-title').text(title);
|
||||
$(newElement).find('small.kanban-info').text(info);
|
||||
$(newElement).find('div.kanban-badge').attr('id', 'badge_' + id);
|
||||
newElement.appendTo($('#group-' + _item + "-main"));
|
||||
newElement.show();
|
||||
}
|
||||
}
|
||||
|
||||
/* Add a group to the dashboard */
|
||||
function add_groupnote(title="", rid=0) {
|
||||
return nextGroupNote(title, rid=rid);
|
||||
}
|
||||
|
||||
/* Add a remote note to a group */
|
||||
function add_remote_note(group_id) {
|
||||
let data = Object();
|
||||
data['note_title'] = "Untitled note";
|
||||
data['note_content'] = "";
|
||||
|
||||
data['group_id'] = group_id;
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
post_request_api('/case/notes/add', JSON.stringify(data), false)
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
draw_kanban();
|
||||
} else {
|
||||
if (data.message != "No data to load for dashboard") {
|
||||
swal("Oh no !", data.message, "error");
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/* Add a group note remotely */
|
||||
function add_remote_groupnote() {
|
||||
let data = Object();
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
post_request_api('/case/notes/groups/add', JSON.stringify(data), false)
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
nextGroupNote(data.data.group_title, data.data.group_id);
|
||||
draw_kanban();
|
||||
} else {
|
||||
if (data.message != "No data to load for dashboard") {
|
||||
swal("Oh no !", data.message, "error");
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/* Delete a group of the dashboard */
|
||||
function delete_remote_groupnote(group_id) {
|
||||
|
||||
swal({
|
||||
title: "Attention ",
|
||||
text: "All the notes in this group will be deleted !\nThis cannot be reverted, notes will not be recoverable",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
var data = Object();
|
||||
data['group_id'] = group_id;
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
post_request_api('/case/notes/groups/delete/'+ group_id)
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
swal("Done !", data.message, "success");
|
||||
draw_kanban();
|
||||
} else {
|
||||
if (data.message != "No data to load for dashboard") {
|
||||
swal("Oh no !", data.message, "error");
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* Add a button to save group name */
|
||||
function edit_add_save(group_id) {
|
||||
btn = $("#group-" + group_id).find('button')[0];
|
||||
$(btn).show();
|
||||
}
|
||||
|
||||
/* Delete a group of the dashboard */
|
||||
function edit_remote_groupnote(group_id) {
|
||||
|
||||
var data = Object();
|
||||
data['group_title'] = $("#group-" + group_id).find('div.kanban-title-board').text();
|
||||
data["csrf_token"] = $('#csrf_token').val();
|
||||
|
||||
post_request_api('/case/notes/groups/update/'+ group_id, JSON.stringify(data))
|
||||
.done((data) => {
|
||||
notify_auto_api(data);
|
||||
draw_kanban();
|
||||
})
|
||||
}
|
||||
|
||||
/* Delete a group of the dashboard */
|
||||
function delete_note(_item, cid) {
|
||||
|
||||
var n_id = $("#info_note_modal_content").find('iris_notein').text();
|
||||
|
||||
do_deletion_prompt("You are about to delete note #" + n_id)
|
||||
.then((doDelete) => {
|
||||
if (doDelete) {
|
||||
post_request_api('/case/notes/delete/' + n_id, null, null, cid)
|
||||
.done((data) => {
|
||||
$('#modal_note_detail').modal('hide');
|
||||
notify_auto_api(data);
|
||||
})
|
||||
.fail(function (error) {
|
||||
draw_kanban();
|
||||
swal( 'Oh no :(', error.message, 'error');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* List all the notes on the dashboard */
|
||||
function list_notes() {
|
||||
output = {};
|
||||
$("#myKanban").children().each(function () {
|
||||
|
||||
gid = $(this).attr('id');
|
||||
|
||||
output[gid] = [];
|
||||
|
||||
$(this).find('iris_note').each(function () {
|
||||
output[gid].push(
|
||||
[$(this).attr('id'),
|
||||
$(this).text()
|
||||
]);
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/* Edit one note */
|
||||
function edit_note(event) {
|
||||
|
||||
var nval = $(event).find('iris_note').attr('id');
|
||||
collaborator = null;
|
||||
note_detail(nval);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Fetch the edit modal with content from server */
|
||||
function note_detail(id, cid) {
|
||||
if (cid === undefined ) {
|
||||
cid = case_param()
|
||||
} else {
|
||||
cid = '?cid=' + cid;
|
||||
}
|
||||
|
||||
url = '/case/notes/' + id + "/modal" + cid;
|
||||
$('#info_note_modal_content').load(url, function (response, status, xhr) {
|
||||
$('#form_note').on("submit", preventFormDefaultBehaviourOnSubmit);
|
||||
hide_minimized_modal_box();
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
let timer;
|
||||
let timeout = 10000;
|
||||
$('#form_note').keyup(function(){
|
||||
if(timer) {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
if (ppl_viewing.size <= 1) {
|
||||
timer = setTimeout(save_note, timeout);
|
||||
}
|
||||
});
|
||||
|
||||
note_id = id;
|
||||
|
||||
collaborator = new Collaborator( get_caseid(), id );
|
||||
|
||||
note_editor = get_new_ace_editor('editor_detail', 'note_content', 'targetDiv', function() {
|
||||
$('#last_saved').addClass('btn-danger').removeClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-exclamation");
|
||||
$('#btn_save_note').text("Save").removeClass('btn-success').addClass('btn-warning').removeClass('btn-danger');
|
||||
}, save_note);
|
||||
|
||||
note_editor.focus();
|
||||
|
||||
note_editor.on( "change", function( e ) {
|
||||
// TODO, we could make things more efficient and not likely to conflict by keeping track of change IDs
|
||||
if( last_applied_change != e && note_editor.curOp && note_editor.curOp.command.name) {
|
||||
collaborator.change( JSON.stringify(e), id ) ;
|
||||
}
|
||||
}, false
|
||||
);
|
||||
last_applied_change = null ;
|
||||
just_cleared_buffer = false ;
|
||||
|
||||
load_menu_mod_options_modal(id, 'note', $("#note_modal_quick_actions"));
|
||||
$('#modal_note_detail').modal({ show: true, backdrop: 'static'});
|
||||
|
||||
$('#modal_note_detail').off('hide.bs.modal').on("hide.bs.modal", function (e) {
|
||||
forceModalClose = false;
|
||||
return handle_note_close(id, e);
|
||||
});
|
||||
|
||||
collaborator_socket.emit('ping-note', { 'channel': 'case-' + get_caseid() + '-notes', 'note_id': note_id });
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async function handle_note_close(id, e) {
|
||||
note_id = null;
|
||||
|
||||
if ($("#minimized_modal_box").is(":visible")) {
|
||||
forceModalClose = true;
|
||||
wasMiniNote = true;
|
||||
save_note(null, get_caseid());
|
||||
}
|
||||
|
||||
|
||||
if ($('#btn_save_note').text() === "Save" && !forceModalClose) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "You have unsaved changes!",
|
||||
icon: "warning",
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: "Cancel",
|
||||
value: null,
|
||||
visible: true,
|
||||
},
|
||||
confirm: {
|
||||
text: "Discard changes",
|
||||
value: true,
|
||||
}
|
||||
},
|
||||
dangerMode: true,
|
||||
closeOnEsc: false,
|
||||
allowOutsideClick: false,
|
||||
allowEnterKey: false
|
||||
})
|
||||
.then((willDiscard) => {
|
||||
if (willDiscard) {
|
||||
location.reload();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
forceModalClose = false;
|
||||
if (!wasMiniNote) {
|
||||
if (collaborator) {
|
||||
collaborator.close();
|
||||
}
|
||||
if (note_editor) {
|
||||
note_editor.destroy();
|
||||
}
|
||||
|
||||
if (ppl_viewing) {
|
||||
ppl_viewing.clear();
|
||||
}
|
||||
}
|
||||
collaborator_socket.off('save-note');
|
||||
collaborator_socket.off('leave-note');
|
||||
collaborator_socket.off('join-note');
|
||||
collaborator_socket.off('ping-note');
|
||||
collaborator_socket.off('disconnect');
|
||||
collaborator_socket.off('clear_buffer-note');
|
||||
collaborator_socket.off('change-note');
|
||||
collaborator_socket.emit('ping-note', {'channel': 'case-' + get_caseid() + '-notes', 'note_id': null});
|
||||
wasMiniNote = false;
|
||||
|
||||
await draw_kanban();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function refresh_ppl_list() {
|
||||
$('#ppl_list_viewing').empty();
|
||||
for (let [key, value] of ppl_viewing) {
|
||||
$('#ppl_list_viewing').append(get_avatar_initials(key, false, undefined, true));
|
||||
}
|
||||
}
|
||||
|
||||
function handle_ed_paste(event) {
|
||||
let filename = null;
|
||||
const { items } = event.originalEvent.clipboardData;
|
||||
for (let i = 0; i < items.length; i += 1) {
|
||||
const item = items[i];
|
||||
|
||||
if (item.kind === 'string') {
|
||||
item.getAsString(function (s){
|
||||
filename = $.trim(s.replace(/\t|\n|\r/g, '')).substring(0, 40);
|
||||
});
|
||||
}
|
||||
|
||||
if (item.kind === 'file') {
|
||||
console.log(item.type);
|
||||
const blob = item.getAsFile();
|
||||
|
||||
if (blob !== null) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
notify_success('The file is uploading in background. Don\'t leave the page');
|
||||
|
||||
if (filename === null) {
|
||||
filename = random_filename(25);
|
||||
}
|
||||
|
||||
upload_interactive_data(e.target.result, filename, function(data){
|
||||
url = data.data.file_url + case_param();
|
||||
event.preventDefault();
|
||||
note_editor.insertSnippet(`\n\n`);
|
||||
});
|
||||
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
} else {
|
||||
notify_error('Unsupported direct paste of this item. Use datastore to upload.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Delete a group of the dashboard */
|
||||
function search_notes() {
|
||||
var data = Object();
|
||||
data['search_term'] = $("#search_note_input").val();
|
||||
data['csrf_token'] = $("#csrf_token").val();
|
||||
|
||||
post_request_api('/case/notes/search', JSON.stringify(data))
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
$('#notes_search_list').empty();
|
||||
for (e in data.data) {
|
||||
li = `<li class="list-group-item list-group-item-action">
|
||||
<span class="name" style="cursor:pointer" title="Click to open note" onclick="note_detail(`+ data.data[e]['note_id'] +`);">`+ data.data[e]['note_title'] +`</span>
|
||||
</li>`
|
||||
$('#notes_search_list').append(li);
|
||||
}
|
||||
$('#notes_search_list').show();
|
||||
|
||||
} else {
|
||||
if (data.message != "No data to load for dashboard") {
|
||||
swal("Oh no !", data.message, "error");
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function toggle_max_editor() {
|
||||
if ($('#container_note_content').hasClass('col-md-12')) {
|
||||
$('#container_note_content').removeClass('col-md-12').addClass('col-md-6');
|
||||
$('#ctrd_notesum').removeClass('d-none');
|
||||
$('#btn_max_editor').html('<i class="fa-solid fa-minimize"></i>');
|
||||
} else {
|
||||
$('#container_note_content').removeClass('col-md-6').addClass('col-md-12');
|
||||
$('#ctrd_notesum').addClass('d-none');
|
||||
$('#btn_max_editor').html('<i class="fa-solid fa-maximize"></i>');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Save a note into db */
|
||||
function save_note(this_item, cid) {
|
||||
clear_api_error();
|
||||
var n_id = $("#info_note_modal_content").find('iris_notein').text();
|
||||
|
||||
|
||||
var data_sent = $('#form_note').serializeObject();
|
||||
data_sent['note_content'] = $('#note_content').val();
|
||||
ret = get_custom_attributes_fields();
|
||||
has_error = ret[0].length > 0;
|
||||
attributes = ret[1];
|
||||
|
||||
if (has_error){return false;}
|
||||
|
||||
data_sent['custom_attributes'] = attributes;
|
||||
|
||||
post_request_api('/case/notes/update/'+ n_id, JSON.stringify(data_sent), false, undefined, cid, function() {
|
||||
$('#btn_save_note').text("Error saving!").removeClass('btn-success').addClass('btn-danger').removeClass('btn-danger');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-xmark");
|
||||
$('#last_saved').addClass('btn-danger').removeClass('btn-success');
|
||||
})
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
$('#btn_save_note').text("Saved").addClass('btn-success').removeClass('btn-danger').removeClass('btn-warning');
|
||||
$('#last_saved').removeClass('btn-danger').addClass('btn-success');
|
||||
$("#content_last_saved_by").text('Last saved by you');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-check");
|
||||
collaborator.save(n_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Span for note edition */
|
||||
function edit_innote() {
|
||||
return edit_inner_editor('notes_edition_btn', 'container_note_content', 'ctrd_notesum');
|
||||
}
|
||||
|
||||
/* Load the kanban case data and build the board from it */
|
||||
async function draw_kanban() {
|
||||
/* Empty board */
|
||||
$('#myKanban').empty();
|
||||
show_loader();
|
||||
|
||||
return get_request_api('/case/notes/groups/list')
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data, true)) {
|
||||
gidl = [];
|
||||
if (data.data.groups.length > 0) {
|
||||
$('#empty-set-notes').hide();
|
||||
} else {
|
||||
$('#empty-set-notes').show();
|
||||
}
|
||||
for (idx in data.data.groups) {
|
||||
group = data.data.groups[idx];
|
||||
if (!gidl.includes(group.group_id)) {
|
||||
nextGroupNote(group.group_title, group.group_id);
|
||||
gidl.push(group.group_id);
|
||||
}
|
||||
for (ikd in group.notes) {
|
||||
note = group.notes[ikd];
|
||||
add_subnote(group.group_id,
|
||||
note.note_id,
|
||||
note.note_title,
|
||||
note.note_lastupdate,
|
||||
note.user
|
||||
);
|
||||
}
|
||||
}
|
||||
set_last_state(data.data.state);
|
||||
hide_loader();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function note_interval_pinger() {
|
||||
if (new Date() - last_ping > 2000) {
|
||||
collaborator_socket.emit('ping-note',
|
||||
{ 'channel': 'case-' + get_caseid() + '-notes', 'note_id': note_id });
|
||||
last_ping = new Date();
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
shared_id = getSharedLink();
|
||||
if (shared_id) {
|
||||
note_detail(shared_id);
|
||||
}
|
||||
|
||||
let cid = get_caseid();
|
||||
collaborator_socket = io.connect();
|
||||
collaborator_socket.emit('join-notes-overview', { 'channel': 'case-' + cid + '-notes' });
|
||||
|
||||
collaborator_socket.on('ping-note', function(data) {
|
||||
last_ping = new Date();
|
||||
if ( data.note_id === null || data.note_id !== note_id) {
|
||||
set_notes_follow(data);
|
||||
return;
|
||||
}
|
||||
|
||||
ppl_viewing.set(data.user, 1);
|
||||
for (let [key, value] of ppl_viewing) {
|
||||
if (key !== data.user) {
|
||||
ppl_viewing.set(key, value-1);
|
||||
}
|
||||
if (value < 0) {
|
||||
ppl_viewing.delete(key);
|
||||
}
|
||||
}
|
||||
refresh_ppl_list(session_id, note_id);
|
||||
});
|
||||
|
||||
timer_socket = setInterval( function() {
|
||||
note_interval_pinger();
|
||||
}, 2000);
|
||||
|
||||
collaborator_socket.emit('ping-note', { 'channel': 'case-' + cid + '-notes', 'note_id': note_id });
|
||||
|
||||
setInterval(auto_remove_typing, 1500);
|
||||
|
||||
});
|
||||
149
iris-web/source/app/static/assets/js/iris/case.pipelines.js
Normal file
149
iris-web/source/app/static/assets/js/iris/case.pipelines.js
Normal file
@@ -0,0 +1,149 @@
|
||||
/*************************
|
||||
* Case update section
|
||||
*************************/
|
||||
/* Dropzone creation for update */
|
||||
Dropzone.autoDiscover = false;
|
||||
|
||||
Dropzone.prototype.getErroredFiles = function () {
|
||||
var file, _i, _len, _ref, _results;
|
||||
_ref = this.files;
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
file = _ref[_i];
|
||||
if (file.status === Dropzone.ERROR) {
|
||||
_results.push(file);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
var dropUpdate = new Dropzone("div#files_drop_1", {
|
||||
url: "/manage/cases/upload_files" + case_param(),
|
||||
addRemoveLinks: true,
|
||||
autoProcessQueue: false,
|
||||
parallelUploads: 40,
|
||||
maxFiles: 40,
|
||||
maxFilesize: 10000,
|
||||
timeout: 0,
|
||||
complete: function () {
|
||||
if (this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0 && this.getErroredFiles().length === 0) {
|
||||
$('#submit_update_case').text('Notifying for new import')
|
||||
send_update_case_data();
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, error) {
|
||||
if(error !== null || error !== undefined) {
|
||||
notify_error(error.message);
|
||||
} else {
|
||||
notify_error(jqXHR);
|
||||
ajax_notify_error(jqXHR, this.url);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* Add of field for file upload */
|
||||
dropUpdate.on('sending', function (file, xhr, formData) {
|
||||
formData.append('is_update', true);
|
||||
formData.append('pipeline', $('#update_pipeline_selector').val() );
|
||||
formData.append('csrf_token', $('#csrf_token').val());
|
||||
});
|
||||
|
||||
/* Update case function. start the update task */
|
||||
|
||||
function send_update_case_data() {
|
||||
|
||||
/* Get the pipeline args */
|
||||
var args = Object();
|
||||
$.each($(".update-" + $('#update_pipeline_selector').val()), function(el, k) {
|
||||
args['args_' + k.id] = k.value;
|
||||
});
|
||||
args['pipeline'] = $('#update_pipeline_selector').val();
|
||||
args['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
post_request_api('/manage/cases/trigger-pipeline', JSON.stringify(args), true, function () {
|
||||
$('#submit_update_case').text('Starting pipeline');
|
||||
$('#submit_update_case')
|
||||
.attr("disabled", true)
|
||||
.addClass('bt-outline-success')
|
||||
.removeClass('btn-success', 'text-dark');
|
||||
})
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data, true)) {
|
||||
$('#submit_update_case').text('Saved');
|
||||
swal("That's done !",
|
||||
"Files are being processed in background.\nYou can follow the progress in DIM Tasks",
|
||||
"success",
|
||||
{
|
||||
buttons: {
|
||||
again: {
|
||||
text: "Import files again",
|
||||
value: "again"
|
||||
},
|
||||
dash: {
|
||||
text: "Go to dashboard",
|
||||
value: "dash",
|
||||
}
|
||||
}
|
||||
}
|
||||
).then((value) => {
|
||||
switch (value) {
|
||||
|
||||
case "dash":
|
||||
window.location.replace("/dashboard" + case_param());
|
||||
break;
|
||||
|
||||
case "again":
|
||||
window.location.replace("/case" + case_param());
|
||||
break;
|
||||
|
||||
default:
|
||||
window.location.replace("/case" + case_param());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('#submit_update_case').text('Save');
|
||||
mdata = ""
|
||||
for (element in data.data) {
|
||||
mdata += data.data[element]
|
||||
}
|
||||
$.notify({
|
||||
icon: 'flaticon-error',
|
||||
title: data.message,
|
||||
message: mdata
|
||||
}, {
|
||||
type: 'danger',
|
||||
placement: {
|
||||
from: 'top',
|
||||
align: 'right'
|
||||
},
|
||||
time: 5000,
|
||||
});
|
||||
swal("Oh no !", data.message, "error")
|
||||
}
|
||||
})
|
||||
.fail(() => {
|
||||
$('#submit_new_case_btn').text('Save');
|
||||
})
|
||||
.always(() => {
|
||||
$('#submit_update_case')
|
||||
.attr("disabled", false)
|
||||
.addClass('bt-outline-success')
|
||||
.removeClass('btn-success', 'text-dark');
|
||||
});
|
||||
}
|
||||
|
||||
/* Event listener to process update queue */
|
||||
function submit_update_casefn() {
|
||||
|
||||
var dse = $(".update-" + $('#update_pipeline_selector').val());
|
||||
for (var elm=0; elm < $(dse).length; elm++) {
|
||||
if($(dse[elm]).find('input').attr('required')) {
|
||||
if ( ! $(dse[elm]).find('input').val() ) {
|
||||
notify_error("Required fields are not set");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dropUpdate.processQueue();
|
||||
}
|
||||
367
iris-web/source/app/static/assets/js/iris/case.rfiles.js
Normal file
367
iris-web/source/app/static/assets/js/iris/case.rfiles.js
Normal file
@@ -0,0 +1,367 @@
|
||||
/* reload the rfiles table */
|
||||
function reload_rfiles(notify) {
|
||||
get_case_rfiles();
|
||||
if (notify !== undefined) {
|
||||
notify_success("Refreshed");
|
||||
}
|
||||
}
|
||||
|
||||
function edit_in_evidence_desc() {
|
||||
if($('#container_evidence_desc_content').is(':visible')) {
|
||||
$('#container_evidence_description').show(100);
|
||||
$('#container_evidence_desc_content').hide(100);
|
||||
$('#evidence_edition_btn').hide(100);
|
||||
$('#evidence_preview_button').hide(100);
|
||||
} else {
|
||||
$('#evidence_preview_button').show(100);
|
||||
$('#evidence_edition_btn').show(100);
|
||||
$('#container_evidence_desc_content').show(100);
|
||||
$('#container_evidence_description').hide(100);
|
||||
}
|
||||
}
|
||||
|
||||
function get_hash() {
|
||||
if (document.getElementById("input_autofill").files[0] === undefined) {
|
||||
$('#btn_rfile_proc').text("Please select a file");
|
||||
return;
|
||||
}
|
||||
getMD5(
|
||||
document.getElementById("input_autofill").files[0],
|
||||
prog => $('#btn_rfile_proc').text("Processing "+ (prog * 100).toFixed(2) + "%")
|
||||
).then(
|
||||
res => on_done_hash(res),
|
||||
err => console.error(err)
|
||||
);
|
||||
}
|
||||
|
||||
function on_done_hash(result) {
|
||||
$('#btn_rfile_proc').text('Done processing');
|
||||
$('form#form_edit_rfile #file_hash').val(result);
|
||||
$('form#form_edit_rfile #filename').val(document.getElementById("input_autofill").files[0].name);
|
||||
$('form#form_edit_rfile #file_size').val(document.getElementById("input_autofill").files[0].size);
|
||||
}
|
||||
|
||||
function add_modal_rfile() {
|
||||
url = 'evidences/add/modal' + case_param();
|
||||
$('#modal_add_rfiles_content').load(url, function (response, status, xhr) {
|
||||
hide_minimized_modal_box();
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
g_evidence_desc_editor = get_new_ace_editor('evidence_description', 'evidence_desc_content', 'target_evidence_desc',
|
||||
function() {
|
||||
$('#last_saved').addClass('btn-danger').removeClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-exclamation");
|
||||
}, null);
|
||||
g_evidence_desc_editor.setOption("minLines", "10");
|
||||
edit_in_evidence_desc();
|
||||
|
||||
headers = get_editor_headers('g_evidence_desc_editor', null, 'evidence_edition_btn');
|
||||
$('#evidence_edition_btn').append(headers);
|
||||
|
||||
$('#modal_add_rfiles').modal({ show: true });
|
||||
$('#filename').focus();
|
||||
});
|
||||
}
|
||||
|
||||
function add_rfile() {
|
||||
var data_sent = $('form#form_edit_rfile').serializeObject();
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
data_sent['file_description'] = g_evidence_desc_editor.getValue();
|
||||
ret = get_custom_attributes_fields();
|
||||
has_error = ret[0].length > 0;
|
||||
attributes = ret[1];
|
||||
|
||||
if (has_error){return false;}
|
||||
|
||||
data_sent['custom_attributes'] = attributes;
|
||||
|
||||
post_request_api('/case/evidences/add', JSON.stringify(data_sent), true)
|
||||
.done((data) => {
|
||||
notify_auto_api(data);
|
||||
get_case_rfiles();
|
||||
$('#modal_add_rfiles').modal("hide");
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function readChunked(file, chunkCallback, endCallback) {
|
||||
var fileSize = file.size;
|
||||
var chunkSize = 4 * 1024 * 1024; // 4MB
|
||||
var offset = 0;
|
||||
|
||||
var reader = new FileReader();
|
||||
reader.onload = function() {
|
||||
if (reader.error) {
|
||||
endCallback(reader.error || {});
|
||||
return;
|
||||
}
|
||||
offset += reader.result.length;
|
||||
// callback for handling read chunk
|
||||
// TODO: handle errors
|
||||
chunkCallback(reader.result, offset, fileSize);
|
||||
if (offset >= fileSize) {
|
||||
endCallback(null);
|
||||
return;
|
||||
}
|
||||
readNext();
|
||||
};
|
||||
|
||||
reader.onerror = function(err) {
|
||||
endCallback(err || {});
|
||||
};
|
||||
|
||||
function readNext() {
|
||||
var fileSlice = file.slice(offset, offset + chunkSize);
|
||||
reader.readAsBinaryString(fileSlice);
|
||||
}
|
||||
readNext();
|
||||
}
|
||||
|
||||
function getMD5(blob, cbProgress) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var md5 = CryptoJS.algo.MD5.create();
|
||||
readChunked(blob, (chunk, offs, total) => {
|
||||
md5.update(CryptoJS.enc.Latin1.parse(chunk));
|
||||
if (cbProgress) {
|
||||
cbProgress(offs / total);
|
||||
}
|
||||
}, err => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
// TODO: Handle errors
|
||||
var hash = md5.finalize();
|
||||
var hashHex = hash.toString(CryptoJS.enc.Hex);
|
||||
resolve(hashHex);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* Retrieve the list of rfiles and build a datatable for each type of rfiles */
|
||||
function get_case_rfiles() {
|
||||
|
||||
get_request_api("/case/evidences/list")
|
||||
.done(function (response) {
|
||||
if (response.status == 'success') {
|
||||
if (response.data != null) {
|
||||
jsdata = response.data;
|
||||
Table.clear();
|
||||
Table.rows.add(jsdata.evidences);
|
||||
Table.columns.adjust().draw();
|
||||
|
||||
load_menu_mod_options('evidence', Table, delete_rfile);
|
||||
|
||||
set_last_state(jsdata.state);
|
||||
hide_loader();
|
||||
|
||||
$('#rfiles_table_wrapper').show();
|
||||
Table.responsive.recalc();
|
||||
|
||||
} else {
|
||||
Table.clear().draw();
|
||||
swal("Oh no !", data.message, "error")
|
||||
}
|
||||
} else {
|
||||
Table.clear().draw()
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* Edit an rfiles */
|
||||
function edit_rfiles(rfiles_id) {
|
||||
url = 'evidences/' + rfiles_id + '/modal' + case_param();
|
||||
$('#modal_add_rfiles_content').load(url, function (response, status, xhr) {
|
||||
hide_minimized_modal_box();
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
g_evidence_id = rfiles_id;
|
||||
|
||||
g_evidence_desc_editor = get_new_ace_editor('evidence_description', 'evidence_desc_content', 'target_evidence_desc',
|
||||
function() {
|
||||
$('#last_saved').addClass('btn-danger').removeClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-exclamation");
|
||||
$('#submit_new_evidence').text("Unsaved").removeClass('btn-success').addClass('btn-outline-warning').removeClass('btn-outline-danger');
|
||||
}, null);
|
||||
|
||||
g_evidence_desc_editor.setOption("minLines", "6");
|
||||
preview_evidence_description(true);
|
||||
|
||||
headers = get_editor_headers('g_evidence_desc_editor', null, 'evidence_edition_btn');
|
||||
$('#evidence_edition_btn').append(headers);
|
||||
|
||||
load_menu_mod_options_modal(rfiles_id, 'evidence', $("#evidence_modal_quick_actions"));
|
||||
|
||||
$('#modal_add_rfiles').modal({ show: true });
|
||||
edit_in_evidence_desc();
|
||||
});
|
||||
}
|
||||
|
||||
function preview_evidence_description(no_btn_update) {
|
||||
if(!$('#container_evidence_description').is(':visible')) {
|
||||
evidence_desc = g_evidence_desc_editor.getValue();
|
||||
converter = get_showdown_convert();
|
||||
html = converter.makeHtml(do_md_filter_xss(evidence_desc));
|
||||
evidence_desc_html = do_md_filter_xss(html);
|
||||
$('#target_evidence_desc').html(evidence_desc_html);
|
||||
$('#container_evidence_description').show();
|
||||
if (!no_btn_update) {
|
||||
$('#evidence_preview_button').html('<i class="fa-solid fa-eye-slash"></i>');
|
||||
}
|
||||
$('#container_evidence_desc_content').hide();
|
||||
}
|
||||
else {
|
||||
$('#container_evidence_description').hide();
|
||||
if (!no_btn_update) {
|
||||
$('#evidence_preview_button').html('<i class="fa-solid fa-eye"></i>');
|
||||
}
|
||||
|
||||
$('#evidence_preview_button').html('<i class="fa-solid fa-eye"></i>');
|
||||
$('#container_evidence_desc_content').show();
|
||||
}
|
||||
}
|
||||
|
||||
/* Update an rfiles */
|
||||
function update_rfile(rfiles_id) {
|
||||
var data_sent = $('form#form_edit_rfile').serializeObject();
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
ret = get_custom_attributes_fields();
|
||||
has_error = ret[0].length > 0;
|
||||
attributes = ret[1];
|
||||
|
||||
if (has_error){return false;}
|
||||
|
||||
data_sent['custom_attributes'] = attributes;
|
||||
data_sent['file_description'] = g_evidence_desc_editor.getValue();
|
||||
|
||||
post_request_api('evidences/update/' + rfiles_id, JSON.stringify(data_sent), true)
|
||||
.done((data) => {
|
||||
notify_auto_api(data);
|
||||
reload_rfiles();
|
||||
});
|
||||
}
|
||||
|
||||
/* Delete an rfiles */
|
||||
function delete_rfile(rfiles_id) {
|
||||
do_deletion_prompt("You are about to delete evidence #" + rfiles_id)
|
||||
.then((doDelete) => {
|
||||
if (doDelete) {
|
||||
post_request_api('evidences/delete/' + rfiles_id)
|
||||
.done(function(data){
|
||||
reload_rfiles();
|
||||
$('#modal_add_rfiles').modal('hide');
|
||||
notify_auto_api(data);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Page is ready, fetch the rfiles of the case */
|
||||
$(document).ready(function(){
|
||||
|
||||
/* add filtering fields for each table of the page (must be done before datatable initialization) */
|
||||
$.each($.find("table"), function(index, element){
|
||||
addFilterFields($(element).attr("id"));
|
||||
});
|
||||
|
||||
Table = $("#rfiles_table").DataTable({
|
||||
dom: '<"container-fluid"<"row"<"col"l><"col"f>>>rt<"container-fluid"<"row"<"col"i><"col"p>>>',
|
||||
fixedHeader: true,
|
||||
aaData: [],
|
||||
aoColumns: [
|
||||
{
|
||||
"data": "filename",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
if (isWhiteSpace(data)) {
|
||||
data = '#' + row['id'];
|
||||
} else {
|
||||
data = sanitizeHTML(data);
|
||||
}
|
||||
share_link = buildShareLink(row['id']);
|
||||
data = '<a data-toggle="tooltip" data-selector="true" href="' + share_link + '" title="Evidence ID #' + row['id'] + '" onclick="edit_rfiles(\'' + row['id'] + '\');return false;">' + data +'</a>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "date_added" },
|
||||
{ "data": "file_hash",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "file_size",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}},
|
||||
{ "data": "file_description",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}},
|
||||
{ "data": "username",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}}
|
||||
],
|
||||
filter: true,
|
||||
info: true,
|
||||
ordering: true,
|
||||
processing: true,
|
||||
retrieve: true,
|
||||
buttons: [
|
||||
],
|
||||
responsive: {
|
||||
details: {
|
||||
display: $.fn.dataTable.Responsive.display.childRow,
|
||||
renderer: $.fn.dataTable.Responsive.renderer.tableAll()
|
||||
}
|
||||
},
|
||||
orderCellsTop: true,
|
||||
initComplete: function () {
|
||||
tableFiltering(this.api(), 'rfiles_table');
|
||||
},
|
||||
select: true
|
||||
});
|
||||
$("#rfiles_table").css("font-size", 12);
|
||||
var buttons = new $.fn.dataTable.Buttons(Table, {
|
||||
buttons: [
|
||||
{ "extend": 'csvHtml5', "text":'<i class="fas fa-cloud-download-alt"></i>',"className": 'btn btn-link text-white'
|
||||
, "titleAttr": 'Download as CSV', "exportOptions": { "columns": ':visible', 'orthogonal': 'export' } } ,
|
||||
{ "extend": 'copyHtml5', "text":'<i class="fas fa-copy"></i>',"className": 'btn btn-link text-white'
|
||||
, "titleAttr": 'Copy', "exportOptions": { "columns": ':visible', 'orthogonal': 'export' } },
|
||||
{ "extend": 'colvis', "text":'<i class="fas fa-eye-slash"></i>',"className": 'btn btn-link text-white'
|
||||
, "titleAttr": 'Toggle columns' }
|
||||
]
|
||||
}).container().appendTo($('#tables_button'));
|
||||
|
||||
Table.on( 'responsive-resize', function ( e, datatable, columns ) {
|
||||
hide_table_search_input( columns );
|
||||
});
|
||||
|
||||
get_case_rfiles();
|
||||
setInterval(function() { check_update('evidences/state'); }, 3000);
|
||||
|
||||
/* Modal to add rfiles is closed, clear its contents */
|
||||
$('.modal').on('hidden.bs.modal', function () {
|
||||
$(this).find('form').trigger('reset');
|
||||
$('#btn_rfile_proc').text('Process');
|
||||
})
|
||||
|
||||
shared_id = getSharedLink();
|
||||
if (shared_id) {
|
||||
edit_rfiles(shared_id);
|
||||
}
|
||||
|
||||
});
|
||||
514
iris-web/source/app/static/assets/js/iris/case.summary.js
Normal file
514
iris-web/source/app/static/assets/js/iris/case.summary.js
Normal file
@@ -0,0 +1,514 @@
|
||||
var session_id = null ;
|
||||
var collaborator = null ;
|
||||
var buffer_dumped = false ;
|
||||
var last_applied_change = null ;
|
||||
var just_cleared_buffer = null ;
|
||||
var from_sync = null;
|
||||
|
||||
var editor = ace.edit("editor_summary",
|
||||
{
|
||||
autoScrollEditorIntoView: true,
|
||||
minLines: 4
|
||||
});
|
||||
|
||||
var textarea = $('#case_summary');
|
||||
|
||||
function Collaborator( session_id ) {
|
||||
this.collaboration_socket = io.connect() ;
|
||||
|
||||
this.channel = "case-" + session_id;
|
||||
this.collaboration_socket.emit('join', { 'channel': this.channel });
|
||||
|
||||
this.collaboration_socket.on( "change", function(data) {
|
||||
delta = JSON.parse( data.delta ) ;
|
||||
console.log(delta);
|
||||
last_applied_change = delta ;
|
||||
$("#content_typing").text(data.last_change + " is typing..");
|
||||
editor.getSession().getDocument().applyDeltas( [delta] ) ;
|
||||
}.bind() ) ;
|
||||
|
||||
this.collaboration_socket.on( "clear_buffer", function() {
|
||||
just_cleared_buffer = true ;
|
||||
console.log( "setting editor empty" ) ;
|
||||
editor.setValue( "" ) ;
|
||||
}.bind() ) ;
|
||||
|
||||
this.collaboration_socket.on( "save", function(data) {
|
||||
$("#content_last_saved_by").text("Last saved by " + data.last_saved);
|
||||
sync_editor(true);
|
||||
}.bind() ) ;
|
||||
}
|
||||
|
||||
Collaborator.prototype.change = function( delta ) {
|
||||
this.collaboration_socket.emit( "change", { 'delta': delta, 'channel': this.channel } ) ;
|
||||
}
|
||||
|
||||
Collaborator.prototype.clear_buffer = function() {
|
||||
this.collaboration_socket.emit( "clear_buffer", { 'channel': this.channel } ) ;
|
||||
}
|
||||
|
||||
Collaborator.prototype.save = function() {
|
||||
this.collaboration_socket.emit( "save", { 'channel': this.channel } ) ;
|
||||
}
|
||||
|
||||
function body_loaded() {
|
||||
|
||||
collaborator = new Collaborator( get_caseid() ) ;
|
||||
|
||||
// registering change callback
|
||||
from_sync = true;
|
||||
editor.on( "change", function( e ) {
|
||||
// TODO, we could make things more efficient and not likely to conflict by keeping track of change IDs
|
||||
if( last_applied_change!=e && editor.curOp && editor.curOp.command.name) {
|
||||
collaborator.change( JSON.stringify(e) ) ;
|
||||
}
|
||||
}, false );
|
||||
|
||||
editor.$blockScrolling = Infinity ;
|
||||
|
||||
document.getElementsByTagName('textarea')[0].focus() ;
|
||||
last_applied_change = null ;
|
||||
just_cleared_buffer = false ;
|
||||
}
|
||||
|
||||
function handle_ed_paste(event) {
|
||||
filename = null;
|
||||
const { items } = event.originalEvent.clipboardData;
|
||||
for (let i = 0; i < items.length; i += 1) {
|
||||
const item = items[i];
|
||||
|
||||
if (item.kind === 'string') {
|
||||
item.getAsString(function (s){
|
||||
filename = $.trim(s.replace(/\t|\n|\r/g, '')).substring(0, 40);
|
||||
});
|
||||
}
|
||||
|
||||
if (item.kind === 'file') {
|
||||
const blob = item.getAsFile();
|
||||
|
||||
if (blob !== null) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
notify_success('The file is uploading in background. Don\'t leave the page');
|
||||
|
||||
if (filename === null) {
|
||||
filename = random_filename(25);
|
||||
}
|
||||
|
||||
upload_interactive_data(e.target.result, filename, function(data){
|
||||
url = data.data.file_url + case_param();
|
||||
event.preventDefault();
|
||||
editor.insertSnippet(`\n\n`);
|
||||
});
|
||||
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
} else {
|
||||
notify_error('Unsupported direct paste of this item. Use datastore to upload.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function report_template_selector() {
|
||||
$('#modal_select_report').modal({ show: true });
|
||||
}
|
||||
|
||||
function gen_report(safe) {
|
||||
url = '/case/report/generate-investigation/' + $("#select_report option:selected").val() + case_param();
|
||||
if (safe === true) {
|
||||
url += '&safe=true';
|
||||
}
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
|
||||
function gen_act_report(safe) {
|
||||
url = '/case/report/generate-activities/' + $("#select_report_act option:selected").val() + case_param();
|
||||
if (safe === true) {
|
||||
url += '&safe=true';
|
||||
}
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
|
||||
function act_report_template_selector() {
|
||||
$('#modal_select_report_act').modal({ show: true });
|
||||
}
|
||||
|
||||
function edit_case_summary() {
|
||||
$('#container_editor_summary').toggle();
|
||||
if ($('#container_editor_summary').is(':visible')) {
|
||||
$('#ctrd_casesum').removeClass('col-md-12').addClass('col-md-6');
|
||||
$('#summary_edition_btn').show(100);
|
||||
$("#sum_refresh_btn").html('Save');
|
||||
$("#sum_edit_btn").html('Close editor');
|
||||
} else {
|
||||
$('#ctrd_casesum').removeClass('col-md-6').addClass('col-md-12');
|
||||
$('#summary_edition_btn').hide();
|
||||
$("#sum_refresh_btn").html('Refresh');
|
||||
$("#sum_edit_btn").html('Edit');
|
||||
}
|
||||
}
|
||||
|
||||
/* sync_editor
|
||||
* Save the editor state.
|
||||
* Check if there are external changes first.
|
||||
* Copy local changes if conflict
|
||||
*/
|
||||
function sync_editor(no_check) {
|
||||
|
||||
$('#last_saved').text('Syncing..').addClass('badge-danger').removeClass('badge-success');
|
||||
|
||||
get_request_api('/case/summary/fetch')
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
if (no_check) {
|
||||
// Set the content from remote server
|
||||
from_sync = true;
|
||||
editor.getSession().setValue(data.data.case_description);
|
||||
|
||||
// Set the CRC in page
|
||||
$('#fetched_crc').val(data.data.crc32.toString());
|
||||
$('#last_saved').text('Changes saved').removeClass('badge-danger').addClass('badge-success');
|
||||
$('#content_last_sync').text("Last synced: " + new Date().toLocaleTimeString());
|
||||
}
|
||||
else {
|
||||
// Check if content is different
|
||||
st = editor.getSession().getValue();
|
||||
if (data.data.crc32 != $('#fetched_crc').val()) {
|
||||
// Content has changed remotely
|
||||
// Check if we have changes locally
|
||||
local_crc = crc32(st).toString();
|
||||
console.log('Content changed. Local CRC is ' + local_crc);
|
||||
console.log('Saved CRC is ' + $('#fetched_crc').val());
|
||||
console.log('Remote CRC is ' + data.data.crc32);
|
||||
if (local_crc == $('#fetched_crc').val()) {
|
||||
// No local change, we can sync and update local CRC
|
||||
editor.getSession().setValue(data.data.case_description);
|
||||
$('#fetched_crc').val(data.data.crc32);
|
||||
$('#last_saved').text('Changes saved').removeClass('badge-danger').addClass('badge-success');
|
||||
$('#content_last_sync').text("Last synced: " + new Date().toLocaleTimeString());
|
||||
} else {
|
||||
// We have a conflict
|
||||
$('#last_saved').text('Conflict !').addClass('badge-danger').removeClass('badge-success');
|
||||
swal ( "Oh no !" ,
|
||||
"We have a conflict with the remote content.\nSomeone may just have changed the description at the same time.\nThe local content will be copied into clipboard and content will be updated with remote." ,
|
||||
"error"
|
||||
).then((value) => {
|
||||
// Old fashion trick
|
||||
editor.selectAll();
|
||||
editor.focus();
|
||||
document.execCommand('copy');
|
||||
editor.getSession().setValue(data.data.desc);
|
||||
$('#fetched_crc').val(data.data.crc32);
|
||||
notify_success('Content updated with remote. Local changes copied to clipboard.');
|
||||
$('#content_last_sync').text("Last synced: " + new Date().toLocaleTimeString());
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Content did not change remotely
|
||||
// Check local change
|
||||
local_crc = crc32(st).toString();
|
||||
if (local_crc != $('#fetched_crc').val()) {
|
||||
console.log('Local change. Old CRC is ' + local_crc);
|
||||
console.log('New CRC is ' + $('#fetched_crc').val());
|
||||
var data = Object();
|
||||
data['case_description'] = st;
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
// Local change detected. Update to remote
|
||||
$.ajax({
|
||||
url: '/case/summary/update' + case_param(),
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json;charset=UTF-8",
|
||||
data: JSON.stringify(data),
|
||||
success: function (data) {
|
||||
if (data.status == 'success') {
|
||||
collaborator.save();
|
||||
$('#content_last_sync').text("Last synced: " + new Date().toLocaleTimeString());
|
||||
$('#fetched_crc').val(data.data);
|
||||
$('#last_saved').text('Changes saved').removeClass('badge-danger').addClass('badge-success');
|
||||
} else {
|
||||
notify_error("Unable to save content to remote server");
|
||||
$('#last_saved').text('Error saving !').addClass('badge-danger').removeClass('badge-success');
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
notify_error(error.responseJSON.message);
|
||||
('#last_saved').text('Error saving !').addClass('badge-danger').removeClass('badge-success');
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#content_last_sync').text("Last synced: " + new Date().toLocaleTimeString());
|
||||
$('#last_saved').text('Changes saved').removeClass('badge-danger').addClass('badge-success');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
is_typing = "";
|
||||
function auto_remove_typing() {
|
||||
if ($("#content_typing").text() == is_typing) {
|
||||
$("#content_typing").text("");
|
||||
} else {
|
||||
is_typing = $("#content_typing").text();
|
||||
}
|
||||
}
|
||||
|
||||
function case_pipeline_popup() {
|
||||
url = '/case/pipelines-modal' + case_param();
|
||||
$('#info_case_modal_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
$('#modal_case_detail').modal({ show: true });
|
||||
$("#update_pipeline_selector").selectpicker({
|
||||
liveSearch: true,
|
||||
style: "btn-outline-white"
|
||||
})
|
||||
$('#update_pipeline_selector').selectpicker("refresh");
|
||||
$(".control-update-pipeline-args ").hide();
|
||||
$('.control-update-pipeline-'+ $('#update_pipeline_selector').val() ).show();
|
||||
$('#update_pipeline_selector').on('change', function(e){
|
||||
$(".control-update-pipeline-args ").hide();
|
||||
$('.control-update-pipeline-'+this.value).show();
|
||||
});
|
||||
$('[data-toggle="popover"]').popover();
|
||||
});
|
||||
}
|
||||
|
||||
async function do_case_review(action, reviewer_id) {
|
||||
let data = Object();
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
data['action'] = action;
|
||||
if (reviewer_id) {
|
||||
data['reviewer_id'] = reviewer_id;
|
||||
}
|
||||
|
||||
return post_request_api('/case/review/update', JSON.stringify(data));
|
||||
}
|
||||
|
||||
function case_detail(case_id, edit_mode=false) {
|
||||
url = '/case/details/' + case_id + case_param();
|
||||
$('#info_case_modal_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
$('#modal_case_detail').modal({ show: true });
|
||||
if (edit_mode) {
|
||||
edit_case_info();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function manage_case(case_id) {
|
||||
window.location = '/manage/cases?cid='+ case_id +'#view';
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
if ($("#editor_summary").attr("data-theme") !== "dark") {
|
||||
editor.setTheme("ace/theme/tomorrow");
|
||||
} else {
|
||||
editor.setTheme("ace/theme/iris_night");
|
||||
}
|
||||
editor.session.setMode("ace/mode/markdown");
|
||||
editor.renderer.setShowGutter(true);
|
||||
editor.setOption("showLineNumbers", true);
|
||||
editor.setOption("showPrintMargin", false);
|
||||
editor.setOption("displayIndentGuides", true);
|
||||
editor.setOption("indentedSoftWrap", false);
|
||||
editor.session.setUseWrapMode(true);
|
||||
editor.setOption("maxLines", "Infinity")
|
||||
editor.renderer.setScrollMargin(8, 5)
|
||||
editor.setOption("enableBasicAutocompletion", true);
|
||||
editor.commands.addCommand({
|
||||
name: 'save',
|
||||
bindKey: {win: "Ctrl-S", "mac": "Cmd-S"},
|
||||
exec: function(editor) {
|
||||
sync_editor(false);
|
||||
}
|
||||
})
|
||||
editor.commands.addCommand({
|
||||
name: 'bold',
|
||||
bindKey: {win: "Ctrl-B", "mac": "Cmd-B"},
|
||||
exec: function(editor) {
|
||||
editor.insertSnippet('**${1:$SELECTION}**');
|
||||
}
|
||||
});
|
||||
editor.commands.addCommand({
|
||||
name: 'italic',
|
||||
bindKey: {win: "Ctrl-I", "mac": "Cmd-I"},
|
||||
exec: function(editor) {
|
||||
editor.insertSnippet('*${1:$SELECTION}*');
|
||||
}
|
||||
});
|
||||
editor.commands.addCommand({
|
||||
name: 'head_1',
|
||||
bindKey: {win: "Ctrl-Shift-1", "mac": "Cmd-Shift-1"},
|
||||
exec: function(editor) {
|
||||
editor.insertSnippet('# ${1:$SELECTION}');
|
||||
}
|
||||
});
|
||||
editor.commands.addCommand({
|
||||
name: 'head_2',
|
||||
bindKey: {win: "Ctrl-Shift-2", "mac": "Cmd-Shift-2"},
|
||||
exec: function(editor) {
|
||||
editor.insertSnippet('## ${1:$SELECTION}');
|
||||
}
|
||||
});
|
||||
editor.commands.addCommand({
|
||||
name: 'head_3',
|
||||
bindKey: {win: "Ctrl-Shift-3", "mac": "Cmd-Shift-3"},
|
||||
exec: function(editor) {
|
||||
editor.insertSnippet('### ${1:$SELECTION}');
|
||||
}
|
||||
});
|
||||
editor.commands.addCommand({
|
||||
name: 'head_4',
|
||||
bindKey: {win: "Ctrl-Shift-4", "mac": "Cmd-Shift-4"},
|
||||
exec: function(editor) {
|
||||
editor.insertSnippet('#### ${1:$SELECTION}');
|
||||
}
|
||||
});
|
||||
$('#editor_summary').on('paste', (event) => {
|
||||
event.preventDefault();
|
||||
handle_ed_paste(event);
|
||||
});
|
||||
|
||||
var timer;
|
||||
var timeout = 10000;
|
||||
$('#editor_summary').keyup(function(){
|
||||
if(timer) {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
timer = setTimeout(sync_editor, timeout);
|
||||
});
|
||||
|
||||
|
||||
//var textarea = $('#case_summary');
|
||||
editor.getSession().on("change", function () {
|
||||
//textarea.val(do_md_filter_xss(editor.getSession().getValue()));
|
||||
$('#last_saved').text('Changes not saved').addClass('badge-danger').removeClass('badge-success');
|
||||
let target = document.getElementById('targetDiv');
|
||||
let converter = get_showdown_convert();
|
||||
let html = converter.makeHtml(do_md_filter_xss(editor.getSession().getValue()));
|
||||
|
||||
target.innerHTML = do_md_filter_xss(html);
|
||||
|
||||
});
|
||||
|
||||
edit_case_summary();
|
||||
body_loaded();
|
||||
sync_editor(true);
|
||||
setInterval(auto_remove_typing, 2000);
|
||||
|
||||
let review_state = $('#caseReviewState');
|
||||
if (review_state.length > 0) {
|
||||
let current_review_state = review_state.data('review-state');
|
||||
|
||||
if (current_review_state === 'Review in progress') {
|
||||
$(".btn-start-review").hide();
|
||||
$(".btn-confirm-review").show();
|
||||
$(".btn-cancel-review").show();
|
||||
$('#reviewSubtitle').text('You started this review. Press "Confirm review" when you are done.');
|
||||
} else if (current_review_state === 'Review completed') {
|
||||
$(".btn-start-review").hide();
|
||||
$(".btn-confirm-review").hide();
|
||||
$(".btn-cancel-review").hide();
|
||||
} else if (current_review_state === 'Pending review') {
|
||||
$(".btn-start-review").show();
|
||||
$(".btn-confirm-review").hide();
|
||||
$(".btn-cancel-review").hide();
|
||||
}
|
||||
$('.review-card').show();
|
||||
}
|
||||
|
||||
$('.btn-start-review').on('click', function(e){
|
||||
do_case_review('start').then(function(data) {
|
||||
if (notify_auto_api(data)) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.btn-confirm-review').on('click', function(e){
|
||||
do_case_review('done').then(function(data) {
|
||||
if (notify_auto_api(data)) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.btn-cancel-review').on('click', function(e){
|
||||
do_case_review('cancel').then(function(data) {
|
||||
if (notify_auto_api(data)) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#request_review').on('click', function(e){
|
||||
let reviewer_id = $('#caseReviewState').data('reviewer-id');
|
||||
let reviewer_name = $('#caseReviewState').data('reviewer-name');
|
||||
|
||||
|
||||
|
||||
if (reviewer_id !== "None") {
|
||||
swal({
|
||||
title: "Request review",
|
||||
text: "Request a case review from " + reviewer_name + "?",
|
||||
icon: "info",
|
||||
buttons: true,
|
||||
dangerMode: false,
|
||||
}).then((willRequest) => {
|
||||
if (willRequest) {
|
||||
do_case_review('request', reviewer_id).then(function (data) {
|
||||
if (notify_auto_api(data)) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('#reviewer_id').selectpicker({
|
||||
liveSearch: true,
|
||||
size: 10,
|
||||
width: '100%'
|
||||
});
|
||||
get_request_api('/case/users/list')
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data)) {
|
||||
let users = data.data;
|
||||
let options = '';
|
||||
for (let i = 0; i < users.length; i++) {
|
||||
if (users[i].user_access_level === 4) {
|
||||
options += '<option value="' + users[i].user_id + '">' + filterXSS(users[i].user_name) + '</option>';
|
||||
}
|
||||
}
|
||||
$('#reviewer_id').html(options);
|
||||
$('#reviewer_id').selectpicker('refresh');
|
||||
$('#modal_choose_reviewer').modal('show');
|
||||
|
||||
$('#submit_set_reviewer').off('click').on('click', function(e){
|
||||
let reviewer_id = $('#reviewer_id').val();
|
||||
do_case_review('request', reviewer_id).then(function (data) {
|
||||
if (notify_auto_api(data)) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
466
iris-web/source/app/static/assets/js/iris/case.tasks.js
Normal file
466
iris-web/source/app/static/assets/js/iris/case.tasks.js
Normal file
@@ -0,0 +1,466 @@
|
||||
var current_users_list = [];
|
||||
var g_task_id = null;
|
||||
var g_task_desc_editor = null;
|
||||
|
||||
function edit_in_task_desc() {
|
||||
if($('#container_task_desc_content').is(':visible')) {
|
||||
$('#container_task_description').show(100);
|
||||
$('#container_task_desc_content').hide(100);
|
||||
$('#task_edition_btn').hide(100);
|
||||
$('#task_preview_button').hide(100);
|
||||
} else {
|
||||
$('#task_preview_button').show(100);
|
||||
$('#task_edition_btn').show(100);
|
||||
$('#container_task_desc_content').show(100);
|
||||
$('#container_task_description').hide(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Fetch a modal that allows to add an event */
|
||||
function add_task() {
|
||||
url = 'tasks/add/modal' + case_param();
|
||||
$('#modal_add_task_content').load(url, function (response, status, xhr) {
|
||||
hide_minimized_modal_box();
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
g_task_desc_editor = get_new_ace_editor('task_description', 'task_desc_content', 'target_task_desc',
|
||||
function() {
|
||||
$('#last_saved').addClass('btn-danger').removeClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-exclamation");
|
||||
}, null);
|
||||
g_task_desc_editor.setOption("minLines", "10");
|
||||
edit_in_task_desc();
|
||||
|
||||
headers = get_editor_headers('g_task_desc_editor', null, 'task_edition_btn');
|
||||
$('#task_edition_btn').append(headers);
|
||||
|
||||
$('#submit_new_task').on("click", function () {
|
||||
|
||||
clear_api_error();
|
||||
if(!$('form#form_new_task').valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var data_sent = $('#form_new_task').serializeObject();
|
||||
data_sent['task_tags'] = $('#task_tags').val();
|
||||
data_sent['task_assignees_id'] = $('#task_assignees_id').val();
|
||||
data_sent['task_status_id'] = $('#task_status_id').val();
|
||||
data_sent['task_description'] = g_task_desc_editor.getValue();
|
||||
ret = get_custom_attributes_fields();
|
||||
has_error = ret[0].length > 0;
|
||||
attributes = ret[1];
|
||||
|
||||
if (has_error){return false;}
|
||||
|
||||
data_sent['custom_attributes'] = attributes;
|
||||
|
||||
post_request_api('tasks/add', JSON.stringify(data_sent), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
get_tasks();
|
||||
$('#modal_add_task').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
$('#modal_add_task').modal({ show: true });
|
||||
$('#task_title').focus();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function save_task() {
|
||||
$('#submit_new_task').click();
|
||||
}
|
||||
|
||||
function update_task(task_id) {
|
||||
update_task_ext(task_id, true);
|
||||
}
|
||||
|
||||
function update_task_ext(task_id, do_close) {
|
||||
|
||||
clear_api_error();
|
||||
if(!$('form#form_new_task').valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (task_id === undefined || task_id === null) {
|
||||
task_id = g_task_id;
|
||||
}
|
||||
|
||||
var data_sent = $('#form_new_task').serializeObject();
|
||||
data_sent['task_tags'] = $('#task_tags').val();
|
||||
|
||||
data_sent['task_assignees_id'] = $('#task_assignees_id').val();
|
||||
data_sent['task_status_id'] = $('#task_status_id').val();
|
||||
ret = get_custom_attributes_fields();
|
||||
has_error = ret[0].length > 0;
|
||||
attributes = ret[1];
|
||||
|
||||
if (has_error){return false;}
|
||||
|
||||
data_sent['custom_attributes'] = attributes;
|
||||
data_sent['task_description'] = g_task_desc_editor.getValue();
|
||||
|
||||
$('#update_task_btn').text('Updating..');
|
||||
|
||||
post_request_api('tasks/update/' + task_id, JSON.stringify(data_sent), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
get_tasks();
|
||||
$('#submit_new_task').text("Saved").addClass('btn-outline-success').removeClass('btn-outline-danger').removeClass('btn-outline-warning');
|
||||
$('#last_saved').removeClass('btn-danger').addClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-check");
|
||||
|
||||
if (do_close !== undefined && do_close === true) {
|
||||
$('#modal_add_task').modal('hide');
|
||||
}
|
||||
}
|
||||
})
|
||||
.always(() => {
|
||||
$('#update_task_btn').text('Update');
|
||||
});
|
||||
}
|
||||
|
||||
/* Delete an event from the timeline thank to its id */
|
||||
function delete_task(id) {
|
||||
do_deletion_prompt("You are about to delete task #" + id)
|
||||
.then((doDelete) => {
|
||||
if (doDelete) {
|
||||
post_request_api("tasks/delete/" + id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
get_tasks();
|
||||
$('#modal_add_task').modal('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Edit and event from the timeline thanks to its ID */
|
||||
function edit_task(id) {
|
||||
url = '/case/tasks/'+ id + '/modal' + case_param();
|
||||
$('#modal_add_task_content').load(url, function (response, status, xhr) {
|
||||
hide_minimized_modal_box();
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
g_task_id = id;
|
||||
|
||||
g_task_desc_editor = get_new_ace_editor('task_description', 'task_desc_content', 'target_task_desc',
|
||||
function() {
|
||||
$('#last_saved').addClass('btn-danger').removeClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-exclamation");
|
||||
}, null);
|
||||
|
||||
g_task_desc_editor.setOption("minLines", "6");
|
||||
preview_task_description(true);
|
||||
|
||||
headers = get_editor_headers('g_task_desc_editor', null, 'task_edition_btn');
|
||||
$('#task_edition_btn').append(headers);
|
||||
|
||||
load_menu_mod_options_modal(id, 'task', $("#task_modal_quick_actions"));
|
||||
$('#modal_add_task').modal({show:true});
|
||||
edit_in_task_desc();
|
||||
});
|
||||
}
|
||||
|
||||
function preview_task_description(no_btn_update) {
|
||||
if(!$('#container_task_description').is(':visible')) {
|
||||
task_desc = g_task_desc_editor.getValue();
|
||||
converter = get_showdown_convert();
|
||||
html = converter.makeHtml(do_md_filter_xss(task_desc));
|
||||
task_desc_html = do_md_filter_xss(html);
|
||||
$('#target_task_desc').html(task_desc_html);
|
||||
$('#container_task_description').show();
|
||||
if (!no_btn_update) {
|
||||
$('#task_preview_button').html('<i class="fa-solid fa-eye-slash"></i>');
|
||||
}
|
||||
$('#container_task_desc_content').hide();
|
||||
}
|
||||
else {
|
||||
$('#container_task_description').hide();
|
||||
if (!no_btn_update) {
|
||||
$('#task_preview_button').html('<i class="fa-solid fa-eye"></i>');
|
||||
}
|
||||
|
||||
$('#task_preview_button').html('<i class="fa-solid fa-eye"></i>');
|
||||
$('#container_task_desc_content').show();
|
||||
}
|
||||
}
|
||||
|
||||
/* Fetch and draw the tasks */
|
||||
function get_tasks() {
|
||||
$('#tasks_list').empty();
|
||||
show_loader();
|
||||
|
||||
get_request_api("tasks/list")
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
Table.MakeCellsEditable("destroy");
|
||||
tasks_list = data.data.tasks;
|
||||
|
||||
options_l = data.data.tasks_status;
|
||||
options = [];
|
||||
for (index in options_l) {
|
||||
option = options_l[index];
|
||||
options.push({ "value": option.id, "display": option.status_name })
|
||||
}
|
||||
Table.clear();
|
||||
Table.rows.add(tasks_list);
|
||||
Table.MakeCellsEditable({
|
||||
"onUpdate": callBackEditTaskStatus,
|
||||
"inputCss": 'form-control col-12',
|
||||
"columns": [2],
|
||||
"allowNulls": {
|
||||
"columns": [2],
|
||||
"errorClass": 'error'
|
||||
},
|
||||
"confirmationButton": {
|
||||
"confirmCss": 'my-confirm-class',
|
||||
"cancelCss": 'my-cancel-class'
|
||||
},
|
||||
"inputTypes": [
|
||||
{
|
||||
"column": 2,
|
||||
"type": "list",
|
||||
"options": options
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
Table.columns.adjust().draw();
|
||||
load_menu_mod_options('task', Table, delete_task);
|
||||
$('[data-toggle="popover"]').popover();
|
||||
Table.responsive.recalc();
|
||||
|
||||
set_last_state(data.data.state);
|
||||
hide_loader();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function refresh_users(on_finish, cur_assignees_id_list) {
|
||||
|
||||
get_request_api('/case/users/list')
|
||||
.done((data) => {
|
||||
|
||||
if(notify_auto_api(data, true)) {
|
||||
current_users_list = data.data;
|
||||
|
||||
if (on_finish !== undefined) {
|
||||
on_finish(current_users_list, cur_assignees_id_list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function do_list_users(list_users, cur_assignees_id_list) {
|
||||
|
||||
$('#task_assignees_id').selectpicker({
|
||||
liveSearch: true,
|
||||
title: "Select assignee(s)"
|
||||
});
|
||||
|
||||
for (let user in list_users) {
|
||||
if (list_users[user].user_access_level === 4) {
|
||||
$('#task_assignees_id').append(new Option(`${filterXSS(list_users[user].user_login)} (${filterXSS(list_users[user].user_name)})`,
|
||||
list_users[user].user_id));
|
||||
}
|
||||
}
|
||||
|
||||
if (cur_assignees_id_list !== undefined) {
|
||||
$('#task_assignees_id').selectpicker('val', cur_assignees_id_list);
|
||||
}
|
||||
|
||||
$('#task_assignees_id').selectpicker('refresh');
|
||||
}
|
||||
|
||||
function callBackEditTaskStatus(updatedCell, updatedRow, oldValue) {
|
||||
data_send = updatedRow.data();
|
||||
data_send['csrf_token'] = $('#csrf_token').val();
|
||||
tid = data_send['task_id'];
|
||||
|
||||
post_request_api("tasks/status/update/" + tid, JSON.stringify(data_send))
|
||||
.done(function (data){
|
||||
if(notify_auto_api(data)) {
|
||||
get_tasks();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Page is ready, fetch the assets of the case */
|
||||
$(document).ready(function(){
|
||||
|
||||
/* add filtering fields for each table of the page (must be done before datatable initialization) */
|
||||
$.each($.find("table"), function(index, element){
|
||||
addFilterFields($(element).attr("id"));
|
||||
});
|
||||
|
||||
Table = $("#tasks_table").DataTable({
|
||||
dom: '<"container-fluid"<"row"<"col"l><"col"f>>>rt<"container-fluid"<"row"<"col"i><"col"p>>>',
|
||||
aaData: [],
|
||||
fixedHeader: true,
|
||||
aoColumns: [
|
||||
{
|
||||
"data": "task_title",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
|
||||
if (isWhiteSpace(data)) {
|
||||
data = '#' + row['task_id'];
|
||||
} else {
|
||||
data = sanitizeHTML(data);
|
||||
}
|
||||
share_link = buildShareLink(row['task_id']);
|
||||
data = '<a href="'+ share_link + '" data-selector="true" title="Task ID #'+ row['task_id'] +'" onclick="edit_task(\'' + row['task_id'] + '\');return false;">' + data +'</a>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "task_description",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
datas = '<span data-toggle="popover" style="cursor: pointer;" title="Info" data-trigger="hover" href="#" data-content="' + data + '">' + data.slice(0, 70);
|
||||
|
||||
if (data.length > 70) {
|
||||
datas += ' (..)</span>';
|
||||
} else {
|
||||
datas += '</span>';
|
||||
}
|
||||
return datas;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "task_status_id",
|
||||
"render": function(data, type, row) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
data = '<span class="badge ml-2 badge-'+ row['status_bscolor'] +'">' + row['status_name'] + '</span>';
|
||||
}
|
||||
else if (type === 'filter' || type === 'sort'){
|
||||
data = row['status_name']
|
||||
} else if (type === 'export') {
|
||||
data = row['status_name']
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "task_assignees",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (data != null) {
|
||||
names = "";
|
||||
|
||||
if (data.length > 0) {
|
||||
lst = [];
|
||||
data.forEach(function (item, index) { lst.push(item['name']); });
|
||||
if (type === 'display') {
|
||||
names = list_to_badges(lst, 'primary', 10, 'users');
|
||||
}
|
||||
else {
|
||||
lst.forEach(function (item, index) {
|
||||
names += `${sanitizeHTML(item)}`;
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (type === 'display') {
|
||||
names = '<span class="badge badge-light ml-2">' + "Unassigned" + '</span>';
|
||||
}
|
||||
else {
|
||||
names = "Unassigned";
|
||||
}
|
||||
}
|
||||
|
||||
return names;
|
||||
|
||||
}
|
||||
return data;
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "task_open_date",
|
||||
"render": function (data, type, row, meta) { return sanitizeHTML(data);}
|
||||
},
|
||||
{ "data": "task_tags",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
tags = "";
|
||||
de = data.split(',');
|
||||
for (tag in de) {
|
||||
tags += '<span class="badge badge-primary ml-2">' + sanitizeHTML(de[tag]) + '</span>';
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
],
|
||||
rowCallback: function (nRow, data) {
|
||||
nRow = '<span class="badge ml-2 badge-'+ sanitizeHTML(data['status_bscolor']) +'">' + sanitizeHTML(data['status_name']) + '</span>';
|
||||
},
|
||||
filter: true,
|
||||
info: true,
|
||||
ordering: true,
|
||||
processing: true,
|
||||
retrieve: true,
|
||||
pageLength: 50,
|
||||
order: [[ 2, "asc" ]],
|
||||
buttons: [
|
||||
],
|
||||
responsive: {
|
||||
details: {
|
||||
display: $.fn.dataTable.Responsive.display.childRow,
|
||||
renderer: $.fn.dataTable.Responsive.renderer.tableAll()
|
||||
}
|
||||
},
|
||||
orderCellsTop: true,
|
||||
initComplete: function () {
|
||||
tableFiltering(this.api(), 'tasks_table');
|
||||
},
|
||||
select: true
|
||||
});
|
||||
$("#tasks_table").css("font-size", 12);
|
||||
|
||||
Table.on( 'responsive-resize', function ( e, datatable, columns ) {
|
||||
hide_table_search_input( columns );
|
||||
});
|
||||
|
||||
var buttons = new $.fn.dataTable.Buttons(Table, {
|
||||
buttons: [
|
||||
{ "extend": 'csvHtml5', "text":'<i class="fas fa-cloud-download-alt"></i>',"className": 'btn btn-link text-white'
|
||||
, "titleAttr": 'Download as CSV', "exportOptions": { "columns": ':visible', 'orthogonal': 'export' } } ,
|
||||
{ "extend": 'copyHtml5', "text":'<i class="fas fa-copy"></i>',"className": 'btn btn-link text-white'
|
||||
, "titleAttr": 'Copy', "exportOptions": { "columns": ':visible', 'orthogonal': 'export' } },
|
||||
{ "extend": 'colvis', "text":'<i class="fas fa-eye-slash"></i>',"className": 'btn btn-link text-white'
|
||||
, "titleAttr": 'Toggle columns' }
|
||||
]
|
||||
}).container().appendTo($('#tables_button'));
|
||||
|
||||
get_tasks();
|
||||
|
||||
setInterval(function() { check_update('tasks/state'); }, 3000);
|
||||
|
||||
shared_id = getSharedLink();
|
||||
if (shared_id) {
|
||||
edit_task(shared_id);
|
||||
}
|
||||
});
|
||||
1088
iris-web/source/app/static/assets/js/iris/case.timeline.js
Normal file
1088
iris-web/source/app/static/assets/js/iris/case.timeline.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,73 @@
|
||||
function visualizeTimeline(group) {
|
||||
ggr = ['asset', 'category']
|
||||
if (group == 'asset') {
|
||||
src = '/case/timeline/visualize/data/by-asset';
|
||||
} else {
|
||||
src = '/case/timeline/visualize/data/by-category';
|
||||
}
|
||||
|
||||
get_request_api(src)
|
||||
.done((data) => {
|
||||
if (data.status == 'success') {
|
||||
var items = new vis.DataSet();
|
||||
|
||||
groups = new vis.DataSet();
|
||||
groups_l = []
|
||||
if (data.data.events.length == 0) {
|
||||
$('#card_main_load').show();
|
||||
$('#visualization').text('No events in summary');
|
||||
hide_loader();
|
||||
return true;
|
||||
}
|
||||
for (index in data.data.events) {
|
||||
event = data.data.events[index];
|
||||
if (!groups_l.includes(event.group)){
|
||||
groups.add({
|
||||
id: groups_l.length,
|
||||
content: event.group
|
||||
})
|
||||
groups_l.push(event.group);
|
||||
}
|
||||
items.add({
|
||||
id: index,
|
||||
group: groups_l.indexOf(event.group),
|
||||
start: event.date,
|
||||
content: event.content,
|
||||
style: event.style,
|
||||
title: event.title
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// specify options
|
||||
var options = {
|
||||
stack: true,
|
||||
minHeight: '400px',
|
||||
maxHeight: $(window).height() - 250,
|
||||
start: data.data.events[0].date,
|
||||
end: data.data.events[data.data.events.length - 1].date,
|
||||
};
|
||||
|
||||
// create a Timeline
|
||||
|
||||
var container = document.getElementById('visualization');
|
||||
container.innerHTML = '';
|
||||
$('#card_main_load').show();
|
||||
timeline = new vis.Timeline(container, null, options);
|
||||
if (ggr.includes(group)) {
|
||||
timeline.setGroups(groups);
|
||||
}
|
||||
timeline.setItems(items);
|
||||
hide_loader();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function refresh_timeline_graph(){
|
||||
show_loader();
|
||||
queryString = window.location.search;
|
||||
urlParams = new URLSearchParams(queryString);
|
||||
group = urlParams.get('group-by');
|
||||
visualizeTimeline(group);
|
||||
}
|
||||
261
iris-web/source/app/static/assets/js/iris/comments.js
Normal file
261
iris-web/source/app/static/assets/js/iris/comments.js
Normal file
@@ -0,0 +1,261 @@
|
||||
var g_comment_desc_editor = null;
|
||||
function comment_element(element_id, element_type, is_alert=false) {
|
||||
|
||||
const prefix = is_alert ? '/alerts' : `/case/${element_type}`;
|
||||
const url = `${prefix}/${element_id}/comments/modal`;
|
||||
$('#modal_comment_content').load(url + case_param(),
|
||||
function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#modal_comment_content').resizable({
|
||||
minHeight: 300,
|
||||
minWidth: 300,
|
||||
handles: "n, e, s, w, ne, se, sw, nw"
|
||||
});
|
||||
$('.modal-comment').draggable({
|
||||
cursor: 'move'
|
||||
});
|
||||
|
||||
$('#modal_comment').modal('show');
|
||||
|
||||
g_comment_desc_editor = get_new_ace_editor('comment_message', 'comment_content', 'target_comment_content',
|
||||
function() {
|
||||
$('#last_saved').addClass('btn-danger').removeClass('btn-success');
|
||||
$('#last_saved > i').attr('class', "fa-solid fa-file-circle-exclamation");
|
||||
}, null, false, false);
|
||||
|
||||
headers = get_editor_headers('g_comment_desc_editor', null, 'comment_edition_btn');
|
||||
$('#comment_edition_btn').append(headers);
|
||||
|
||||
load_comments(element_id, element_type, undefined, undefined, is_alert);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function preview_comment() {
|
||||
if(!$('#container_comment_preview').is(':visible')) {
|
||||
let comment_text = g_comment_desc_editor.getValue();
|
||||
let converter = get_showdown_convert();
|
||||
let html = converter.makeHtml(comment_text);
|
||||
let comment_html = do_md_filter_xss(html);
|
||||
$('#target_comment_content').html(comment_html);
|
||||
$('#container_comment_preview').show();
|
||||
$('#comment_preview_button').html('<i class="fa-solid fa-eye-slash"></i> Edit');
|
||||
$('#container_comment_content').hide();
|
||||
}
|
||||
else {
|
||||
$('#container_comment_preview').hide();
|
||||
$('#comment_preview_button').html('<i class="fa-solid fa-eye"></i> Preview');
|
||||
$('#container_comment_content').show();
|
||||
}
|
||||
}
|
||||
|
||||
function save_comment(element_id, element_type) {
|
||||
save_comment_ext(element_id, element_type, false);
|
||||
}
|
||||
|
||||
function save_comment_ext(element_id, element_type, do_close){
|
||||
data = Object();
|
||||
data['comment_text'] = g_comment_desc_editor.getValue();
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
const is_alert = element_type === 'alerts';
|
||||
const prefix = is_alert ? '/alerts' : `/case/${element_type}`;
|
||||
|
||||
post_request_api(`${prefix}/${element_id}/comments/add`, JSON.stringify(data), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
load_comments(element_id, element_type, undefined, undefined, is_alert);
|
||||
g_comment_desc_editor.setValue('');
|
||||
increase_modal_comments_count(element_type, element_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function decrease_modal_comments_count(element_type, element_id) {
|
||||
|
||||
let tid = '#object_comments_number';
|
||||
if (element_type === 'timeline/events' || element_type === 'alerts') {
|
||||
tid = '#object_comments_number_' + element_id;
|
||||
}
|
||||
|
||||
let curr_count = $(tid).text();
|
||||
|
||||
if (curr_count > 0) {
|
||||
$(tid).text(curr_count - 1);
|
||||
if (element_type === 'timeline/events' || element_type === 'alerts') {
|
||||
$('#object_comments_number').text(parseInt(curr_count) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function increase_modal_comments_count(element_type, element_id) {
|
||||
let tid = '#object_comments_number';
|
||||
if (element_type === 'timeline/events' || element_type === 'alerts') {
|
||||
tid = '#object_comments_number_' + element_id;
|
||||
}
|
||||
|
||||
let curr_count = $(tid).text();
|
||||
if (curr_count === '') {
|
||||
curr_count = 0;
|
||||
}
|
||||
|
||||
$(tid).text(parseInt(curr_count) + 1);
|
||||
if (element_type === 'timeline/events' || element_type === 'alerts') {
|
||||
$('#object_comments_number').text(parseInt(curr_count) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
function delete_comment(comment_id, element_id, element_type) {
|
||||
do_deletion_prompt("You are about to delete comment #" + comment_id)
|
||||
.then((doDelete) => {
|
||||
if (doDelete) {
|
||||
data = Object();
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
const is_alert = element_type === 'alerts';
|
||||
const prefix = is_alert ? '/alerts' : `/case/${element_type}`;
|
||||
post_request_api(`${prefix}/${element_id}/comments/${comment_id}/delete`, JSON.stringify(data))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
load_comments(element_id, element_type, undefined, undefined, is_alert);
|
||||
decrease_modal_comments_count(element_type, element_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function edit_comment(comment_id, element_id, element_type) {
|
||||
const is_alert = element_type === 'alerts';
|
||||
const prefix = is_alert ? '/alerts' : `/case/${element_type}`;
|
||||
get_request_api(`${prefix}/${element_id}/comments/${comment_id}`)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data, true)) {
|
||||
|
||||
$('#comment_'+comment_id).addClass('comment_editing');
|
||||
$('#comment_'+comment_id).data('comment_id', comment_id);
|
||||
g_comment_desc_editor.setValue(data.data.comment_text);
|
||||
$('#comment_edition').show();
|
||||
$('#comment_submit').hide();
|
||||
$('#cancel_edition').show();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function save_edit_comment(element_id, element_type) {
|
||||
data = Object();
|
||||
data['comment_text'] = g_comment_desc_editor.getValue();
|
||||
comment_id = $('.comment_editing').data('comment_id');
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
const is_alert = element_type === 'alerts';
|
||||
const prefix = is_alert ? '/alerts' : `/case/${element_type}`;
|
||||
post_request_api(`${prefix}/${element_id}/comments/${comment_id}/edit`, JSON.stringify(data), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
cancel_edition(comment_id);
|
||||
load_comments(element_id, element_type, comment_id, undefined, is_alert);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function cancel_edition(comment_id) {
|
||||
$('.comment_editing').css('background-color', '');
|
||||
$('.comment_editing').css('border-radius', '');
|
||||
$('.comment_editing').removeClass('comment_editing');
|
||||
$('.comment_editing').data('comment_id', '');
|
||||
$('#comment_edition').hide();
|
||||
$('#cancel_edition').hide();
|
||||
$('#comment_submit').show();
|
||||
g_comment_desc_editor.setValue('');
|
||||
}
|
||||
|
||||
function load_comments(element_id, element_type, comment_id, do_notification, is_alert=false) {
|
||||
|
||||
if (do_notification !== undefined) {
|
||||
silent_success = !do_notification;
|
||||
} else {
|
||||
silent_success = true;
|
||||
}
|
||||
|
||||
const prefix = is_alert || element_type === 'alerts' ? '/alerts' : `/case/${element_type}`;
|
||||
|
||||
get_request_api(`${prefix}/${element_id}/comments/list`)
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data, silent_success)) {
|
||||
$('#comments_list').empty();
|
||||
var names = Object;
|
||||
for (var i = 0; i < data['data'].length; i++) {
|
||||
|
||||
comment_text = data['data'][i].comment_text;
|
||||
converter = get_showdown_convert();
|
||||
html = converter.makeHtml(do_md_filter_xss(comment_text));
|
||||
comment_html = do_md_filter_xss(html);
|
||||
const username = data['data'][i].user.user_name;
|
||||
if (names.hasOwnProperty(username)) {
|
||||
avatar = names[username];
|
||||
} else {
|
||||
avatar = get_avatar_initials(username);
|
||||
names[username] = avatar;
|
||||
}
|
||||
|
||||
can_edit = "";
|
||||
current_user = $('#current_username').text();
|
||||
|
||||
if (current_user === data['data'][i].user.user_login) {
|
||||
can_edit = '<a href="#" class="btn btn-sm comment-edition-hidden" title="Edit comment" onclick="edit_comment(\'' + data['data'][i].comment_id + '\', \'' + element_id + '\',\''+ element_type +'\'); return false;"><i class="fa-solid fa-edit text-dark"></i></a>';
|
||||
can_edit += '<a href="#" class="btn btn-sm comment-edition-hidden" title="Delete comment" onclick="delete_comment(\'' + data['data'][i].comment_id + '\', \'' + element_id + '\',\''+ element_type +'\'); return false;"><i class="fa-solid fa-trash text-dark"></i></a>';
|
||||
}
|
||||
|
||||
comment = `
|
||||
<div class="row mb-2 mr-1" >
|
||||
<div class="col-12" id="comment_${data['data'][i].comment_id}">
|
||||
<div class="row mt-2">
|
||||
<div class="col">
|
||||
<div class="row mr-2">
|
||||
<div class="col">
|
||||
<div class="ml-2 row">
|
||||
${avatar}
|
||||
<h6 class="text-uppercase fw-bold mb-1 ml-1 mt-2">${filterXSS(data['data'][i].name)}</h6>
|
||||
<div class="ml-auto">
|
||||
${can_edit} <small class="text-muted text-wrap">${data['data'][i].comment_date}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="border-left: 3px solid #eaeaea;margin-left:30px;">
|
||||
<span class="text-muted ml-2">${comment_html}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
$('#comments_list').append(comment);
|
||||
}
|
||||
$('#comments_list').append('<div id="last-comment"><div>');
|
||||
|
||||
if (data['data'].length === 0) {
|
||||
$('#comments_list').html('<div class="text-center">No comments yet</div>');
|
||||
} else if (comment_id === undefined || comment_id === null) {
|
||||
offset = document.getElementById("last-comment").offsetTop;
|
||||
if (offset > 20) {
|
||||
$('.comments-listing').animate({ scrollTop: offset});
|
||||
}
|
||||
} else {
|
||||
if (document.getElementById('#comment_'+comment_id) !== null) {
|
||||
offset = document.getElementById('#comment_'+comment_id).offsetTop;
|
||||
if (offset > 20) {
|
||||
$('.comments-listing').animate({ scrollTop: offset});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
1597
iris-web/source/app/static/assets/js/iris/common.js
Normal file
1597
iris-web/source/app/static/assets/js/iris/common.js
Normal file
File diff suppressed because it is too large
Load Diff
23
iris-web/source/app/static/assets/js/iris/crc32.js
Normal file
23
iris-web/source/app/static/assets/js/iris/crc32.js
Normal file
@@ -0,0 +1,23 @@
|
||||
var makeCRCTable = function(){
|
||||
var c;
|
||||
var crcTable = [];
|
||||
for(var n =0; n < 256; n++){
|
||||
c = n;
|
||||
for(var k =0; k < 8; k++){
|
||||
c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
|
||||
}
|
||||
crcTable[n] = c;
|
||||
}
|
||||
return crcTable;
|
||||
}
|
||||
|
||||
var crc32 = function(str) {
|
||||
var crcTable = window.crcTable || (window.crcTable = makeCRCTable());
|
||||
var crc = 0 ^ (-1);
|
||||
|
||||
for (var i = 0; i < str.length; i++ ) {
|
||||
crc = (crc >>> 8) ^ crcTable[(crc ^ str.charCodeAt(i)) & 0xFF];
|
||||
}
|
||||
|
||||
return (crc ^ (-1)) >>> 0;
|
||||
};
|
||||
535
iris-web/source/app/static/assets/js/iris/dashboard.js
Normal file
535
iris-web/source/app/static/assets/js/iris/dashboard.js
Normal file
@@ -0,0 +1,535 @@
|
||||
let UserReviewsTable;
|
||||
let UserCasesTable;
|
||||
let UserTaskTable;
|
||||
function check_page_update(){
|
||||
update_gtasks_list();
|
||||
update_utasks_list();
|
||||
}
|
||||
|
||||
function task_status(id) {
|
||||
url = 'tasks/status/human/'+id + case_param();
|
||||
$('#info_task_modal_body').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
$('#modal_task_detail').modal({show:true});
|
||||
});
|
||||
}
|
||||
|
||||
async function update_ucases_list(show_all=false) {
|
||||
$('#ucases_list').empty();
|
||||
get_raw_request_api("/user/cases/list" + case_param() + "&show_closed=" + show_all)
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data, true)) {
|
||||
UserCasesTable.clear();
|
||||
UserCasesTable.rows.add(data.data);
|
||||
UserCasesTable.columns.adjust().draw();
|
||||
UserCasesTable.buttons().container().appendTo($('#ucases_table_info'));
|
||||
$('[data-toggle="popover"]').popover();
|
||||
$('#ucases_last_updated').text("Last updated: " + new Date().toLocaleTimeString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function update_ureviews_list() {
|
||||
get_raw_request_api("/user/reviews/list" + case_param())
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data, true)) {
|
||||
if (data.data.length == 0) {
|
||||
$('#rowPendingCasesReview').hide();
|
||||
return;
|
||||
}
|
||||
UserReviewsTable.clear();
|
||||
UserReviewsTable.rows.add(data.data);
|
||||
UserReviewsTable.columns.adjust().draw();
|
||||
$('[data-toggle="popover"]').popover();
|
||||
$('#ureviews_last_updated').text("Last updated: " + new Date().toLocaleTimeString());
|
||||
$('#rowPendingCasesReview').show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function update_utasks_list() {
|
||||
$('#utasks_list').empty();
|
||||
return get_request_api("/user/tasks/list")
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data, true)) {
|
||||
UserTaskTable.MakeCellsEditable("destroy");
|
||||
tasks_list = data.data.tasks;
|
||||
|
||||
$('#user_attr_count').text(tasks_list.length);
|
||||
if (tasks_list.length != 0){
|
||||
$('#icon_user_task').removeClass().addClass('flaticon-alarm text-danger');
|
||||
} else {
|
||||
$('#icon_user_task').removeClass().addClass('flaticon-success text-success');
|
||||
}
|
||||
options_l = data.data.tasks_status;
|
||||
options = [];
|
||||
for (index in options_l) {
|
||||
option = options_l[index];
|
||||
options.push({ "value": option.id, "display": option.status_name })
|
||||
}
|
||||
|
||||
UserTaskTable.clear();
|
||||
UserTaskTable.rows.add(tasks_list);
|
||||
UserTaskTable.MakeCellsEditable({
|
||||
"onUpdate": callBackEditUserTaskStatus,
|
||||
"inputCss": 'form-control col-12',
|
||||
"columns": [2],
|
||||
"allowNulls": {
|
||||
"columns": [2],
|
||||
"errorClass": 'error'
|
||||
},
|
||||
"confirmationButton": {
|
||||
"confirmCss": 'my-confirm-class',
|
||||
"cancelCss": 'my-cancel-class'
|
||||
},
|
||||
"inputTypes": [
|
||||
{
|
||||
"column": 2,
|
||||
"type": "list",
|
||||
"options": options
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
UserTaskTable.columns.adjust().draw();
|
||||
UserTaskTable.buttons().container().appendTo($('#utasks_table_info'));
|
||||
$('[data-toggle="popover"]').popover();
|
||||
|
||||
$('#utasks_last_updated').text("Last updated: " + new Date().toLocaleTimeString());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function callBackEditUserTaskStatus(updatedCell, updatedRow, oldValue) {
|
||||
data_send = updatedRow.data()
|
||||
data_send['csrf_token'] = $('#csrf_token').val();
|
||||
post_request_api("user/tasks/status/update", JSON.stringify(data_send))
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data)) {
|
||||
update_utasks_list();
|
||||
UserTaskTable.columns.adjust().draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**** GTASKS ****/
|
||||
|
||||
/* Fetch a modal that allows to add an event */
|
||||
function add_gtask() {
|
||||
url = '/global/tasks/add/modal' + case_param();
|
||||
$('#modal_add_gtask_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#submit_new_gtask').on("click", function () {
|
||||
var data_sent = $('#form_new_gtask').serializeObject();
|
||||
data_sent['task_tags'] = $('#task_tags').val();
|
||||
data_sent['task_assignees_id'] = $('#task_assignees_id').val();
|
||||
data_sent['task_status_id'] = $('#task_status_id').val();
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
post_request_api('/global/tasks/add', JSON.stringify(data_sent), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
update_gtasks_list();
|
||||
$('#modal_add_gtask').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
$('#modal_add_gtask').modal({ show: true });
|
||||
}
|
||||
|
||||
function update_gtask(id) {
|
||||
var data_sent = $('#form_new_gtask').serializeObject();
|
||||
data_sent['task_tags'] = $('#task_tags').val();
|
||||
data_sent['task_assignee_id'] = $('#task_assignee_id').val();
|
||||
data_sent['task_status_id'] = $('#task_status_id').val();
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
post_request_api('/global/tasks/update/' + id, JSON.stringify(data_sent), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
update_gtasks_list();
|
||||
$('#modal_add_gtask').modal('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Delete an event from the timeline thank to its id */
|
||||
function delete_gtask(id) {
|
||||
post_request_api("/global/tasks/delete/" + id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
update_gtasks_list();
|
||||
$('#modal_add_gtask').modal('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Edit and event from the timeline thanks to its ID */
|
||||
function edit_gtask(id) {
|
||||
url = '/global/tasks/update/'+ id + "/modal" + case_param();
|
||||
$('#modal_add_gtask_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
$('#modal_add_gtask').modal({show:true});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/* Fetch and draw the tasks */
|
||||
async function update_gtasks_list() {
|
||||
$('#gtasks_list').empty();
|
||||
|
||||
return get_request_api("/global/tasks/list")
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data, true)) {
|
||||
Table.MakeCellsEditable("destroy");
|
||||
tasks_list = data.data.tasks;
|
||||
|
||||
options_l = data.data.tasks_status;
|
||||
options = [];
|
||||
for (index in options_l) {
|
||||
option = options_l[index];
|
||||
options.push({ "value": option.id, "display": option.status_name })
|
||||
}
|
||||
|
||||
Table.clear();
|
||||
Table.rows.add(tasks_list);
|
||||
|
||||
Table.columns.adjust().draw();
|
||||
Table.buttons().container().appendTo($('#gtasks_table_info'));
|
||||
$('[data-toggle="popover"]').popover();
|
||||
|
||||
load_menu_mod_options('global_task', Table, delete_gtask);
|
||||
$('#tasks_last_updated').text("Last updated: " + new Date().toLocaleTimeString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
UserReviewsTable = $("#ureview_table").DataTable({
|
||||
dom: 'frtip',
|
||||
aaData: [],
|
||||
aoColumns: [
|
||||
{
|
||||
"data": "name",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = `<a href="/case?cid=${row['case_id']}">${sanitizeHTML(data)}</a>`;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "status_name",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = `<span class="badge badge-light">${sanitizeHTML(data)}</span>`;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
],
|
||||
ordering: false,
|
||||
processing: true,
|
||||
retrieve: true,
|
||||
lengthChange: false,
|
||||
pageLength: 10,
|
||||
order: [[ 1, "asc" ]],
|
||||
select: true
|
||||
});
|
||||
|
||||
UserCasesTable = $("#ucases_table").DataTable({
|
||||
dom: 'Blfrtip',
|
||||
aaData: [],
|
||||
aoColumns: [
|
||||
{
|
||||
"data": "name",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = `<a rel="noopener" target="_blank" href="/case?cid=${row['case_id']}">${sanitizeHTML(data)}</a>`;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "description",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
datas = '<span data-toggle="popover" style="cursor: pointer;" title="Info" data-trigger="hover" href="#" data-content="' + data + '">' + data.slice(0, 70);
|
||||
|
||||
if (data.length > 70) {
|
||||
datas += ' (..)</span>';
|
||||
} else {
|
||||
datas += '</span>';
|
||||
}
|
||||
return datas;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "client",
|
||||
"render": function(data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
//data = sanitizeHTML(data);
|
||||
data = sanitizeHTML(row['client']['customer_name']);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "open_date",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "tags",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
datas = '';
|
||||
for (index in data) {
|
||||
datas += '<span class="badge badge-primary">' + sanitizeHTML(data[index]['tag_title']) + '</span> ';
|
||||
}
|
||||
return datas;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
],
|
||||
filter: true,
|
||||
info: true,
|
||||
ordering: true,
|
||||
processing: true,
|
||||
retrieve: true,
|
||||
lengthChange: false,
|
||||
pageLength: 10,
|
||||
order: [[ 2, "asc" ]],
|
||||
buttons: [
|
||||
{ "extend": 'csvHtml5', "text":'Export',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
{ "extend": 'copyHtml5', "text":'Copy',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
],
|
||||
select: true
|
||||
});
|
||||
|
||||
$("#ucases_table").css("font-size", 12);
|
||||
|
||||
UserTaskTable = $("#utasks_table").DataTable({
|
||||
dom: 'Blfrtip',
|
||||
aaData: [],
|
||||
aoColumns: [
|
||||
{
|
||||
"data": "task_title",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
if (isWhiteSpace(data)) {
|
||||
data = '#' + row['task_id'];
|
||||
} else {
|
||||
data = sanitizeHTML(data);
|
||||
}
|
||||
data = '<a target="_blank" rel="noopener" href="case/tasks?cid='+ row['case_id'] + '&shared=' + row['task_id'] + '">' + data +'</a>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "task_description",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
datas = '<span data-toggle="popover" style="cursor: pointer;" title="Info" data-trigger="hover" href="#" data-content="' + data + '">' + data.slice(0, 70);
|
||||
|
||||
if (data.length > 70) {
|
||||
datas += ' (..)</span>';
|
||||
} else {
|
||||
datas += '</span>';
|
||||
}
|
||||
return datas;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "task_status_id",
|
||||
"render": function(data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
data = '<span class="badge ml-2 badge-'+ row['status_bscolor'] +'">' + row['status_name'] + '</span>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "task_case",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
data = '<a href="/case?cid='+ row['case_id'] +'">' + data +'</a>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "task_last_update",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
data = sanitizeHTML(data);
|
||||
data = data.replace(/GMT/g, "");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "task_tags",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
tags = "";
|
||||
de = data.split(',');
|
||||
for (tag in de) {
|
||||
tags += '<span class="badge badge-primary ml-2">' + sanitizeHTML(de[tag]) + '</span>';
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
],
|
||||
rowCallback: function (nRow, data) {
|
||||
data = sanitizeHTML(data);
|
||||
nRow = '<span class="badge ml-2 badge-'+ sanitizeHTML(data['status_bscolor']) +'">' + sanitizeHTML(data['status_name']) + '</span>';
|
||||
},
|
||||
filter: true,
|
||||
info: true,
|
||||
ordering: true,
|
||||
processing: true,
|
||||
retrieve: true,
|
||||
lengthChange: false,
|
||||
pageLength: 10,
|
||||
order: [[ 2, "asc" ]],
|
||||
buttons: [
|
||||
{ "extend": 'csvHtml5', "text":'Export',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
{ "extend": 'copyHtml5', "text":'Copy',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
],
|
||||
select: true
|
||||
});
|
||||
$("#utasks_table").css("font-size", 12);
|
||||
|
||||
Table = $("#gtasks_table").DataTable({
|
||||
dom: 'Blfrtip',
|
||||
aaData: [],
|
||||
aoColumns: [
|
||||
{
|
||||
"data": "task_title",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
if (isWhiteSpace(data)) {
|
||||
data = '#' + row['task_id'];
|
||||
} else {
|
||||
data = sanitizeHTML(data);
|
||||
}
|
||||
data = '<a href="#" onclick="edit_gtask(\'' + row['task_id'] + '\');">' + data +'</a>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "task_description",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
datas = '<span data-toggle="popover" style="cursor: pointer;" title="Info" data-trigger="hover" href="#" data-content="' + data + '">' + data.slice(0, 70);
|
||||
|
||||
if (data.length > 70) {
|
||||
datas += ' (..)</span>';
|
||||
} else {
|
||||
datas += '</span>';
|
||||
}
|
||||
return datas;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "task_status_id",
|
||||
"render": function(data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
data = sanitizeHTML(data);
|
||||
data = '<span class="badge ml-2 badge-'+ row['status_bscolor'] +'">' + row['status_name'] + '</span>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "user_name",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "task_last_update",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
data = sanitizeHTML(data);
|
||||
data = data.replace(/GMT/g, "");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "task_tags",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
tags = "";
|
||||
de = data.split(',');
|
||||
for (tag in de) {
|
||||
tags += '<span class="badge badge-primary ml-2">' + sanitizeHTML(de[tag]) + '</span>';
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
],
|
||||
rowCallback: function (nRow, data) {
|
||||
nRow = '<span class="badge ml-2 badge-'+ sanitizeHTML(data['status_bscolor']) +'">' + sanitizeHTML(data['status_name']) + '</span>';
|
||||
},
|
||||
filter: true,
|
||||
info: true,
|
||||
ordering: true,
|
||||
processing: true,
|
||||
retrieve: true,
|
||||
lengthChange: false,
|
||||
pageLength: 10,
|
||||
order: [[ 2, "asc" ]],
|
||||
buttons: [
|
||||
{ "extend": 'csvHtml5', "text":'Export',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
{ "extend": 'copyHtml5', "text":'Copy',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
],
|
||||
select: true
|
||||
});
|
||||
$("#gtasks_table").css("font-size", 12);
|
||||
|
||||
update_utasks_list();
|
||||
update_ucases_list();
|
||||
update_ureviews_list();
|
||||
setInterval(check_page_update,30000);
|
||||
});
|
||||
639
iris-web/source/app/static/assets/js/iris/datastore.js
Normal file
639
iris-web/source/app/static/assets/js/iris/datastore.js
Normal file
@@ -0,0 +1,639 @@
|
||||
var ds_filter;
|
||||
|
||||
function load_datastore() {
|
||||
|
||||
ds_filter = ace.edit("ds_file_search",
|
||||
{
|
||||
autoScrollEditorIntoView: true,
|
||||
minLines: 1,
|
||||
maxLines: 5
|
||||
});
|
||||
ds_filter.setTheme("ace/theme/tomorrow");
|
||||
ds_filter.session.setMode("ace/mode/json");
|
||||
ds_filter.renderer.setShowGutter(false);
|
||||
ds_filter.setShowPrintMargin(false);
|
||||
ds_filter.renderer.setScrollMargin(10, 10);
|
||||
ds_filter.setOption("displayIndentGuides", true);
|
||||
ds_filter.setOption("indentedSoftWrap", true);
|
||||
ds_filter.setOption("showLineNumbers", false);
|
||||
ds_filter.setOption("placeholder", "Search files");
|
||||
ds_filter.setOption("highlightActiveLine", false);
|
||||
ds_filter.commands.addCommand({
|
||||
name: "Do filter",
|
||||
bindKey: { win: "Enter", mac: "Enter" },
|
||||
exec: function (editor) {
|
||||
filter_ds_files();
|
||||
}
|
||||
});
|
||||
|
||||
get_request_api('/datastore/list/tree')
|
||||
.done(function (data){
|
||||
if(notify_auto_api(data, true)){
|
||||
$('#ds-tree-root').empty();
|
||||
build_ds_tree(data.data, 'ds-tree-root');
|
||||
reparse_activate_tree();
|
||||
show_datastore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function build_ds_tree(data, tree_node) {
|
||||
|
||||
var standard_files_filters = [
|
||||
{value: 'name: ', score: 10, meta: 'Match filename'},
|
||||
{value: 'storage_name: ', score: 10, meta: 'Match local storage filename'},
|
||||
{value: 'tag: ', score: 10, meta: 'Match tag of file'},
|
||||
{value: 'description: ', score: 10, meta: 'Match description of file'},
|
||||
{value: 'is_ioc: ', score: 10, meta: "Match file is IOC"},
|
||||
{value: 'is_evidence: ', score: 10, meta: "Match file is evidence"},
|
||||
{value: 'has_password: ', score: 10, meta: "Match file is password protected"},
|
||||
{value: 'id: ', score: 10, meta: "Match ID of the file"},
|
||||
{value: 'uuid: ', score: 10, meta: "Match UUID of the file"},
|
||||
{value: 'sha256: ', score: 10, meta: "Match sha256 of the file"},
|
||||
{value: 'AND ', score: 10, meta: 'AND operator'}
|
||||
]
|
||||
|
||||
for (node in data) {
|
||||
|
||||
if (data[node] === null) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (data[node].type == 'directory') {
|
||||
data[node].name = sanitizeHTML(data[node].name);
|
||||
can_delete = '';
|
||||
if (!data[node].is_root) {
|
||||
can_delete = `<div class="dropdown-divider"></div><a href="#" class="dropdown-item text-danger" onclick="delete_ds_folder('${node}');"><small class="fa fa-trash mr-2"></small>Delete</a>`;
|
||||
}
|
||||
jnode = `<li>
|
||||
<span id='${node}' title='Folder ID ${node}' data-node-id="${node}"><i class="fa-regular fa-folder"></i> ${sanitizeHTML(data[node].name)}</span> <i class="fas fa-plus ds-folder-menu" role="menu" style="cursor:pointer;" data-toggle="dropdown" aria-expanded="false"></i>
|
||||
<div class="dropdown-menu" role="menu">
|
||||
<a href="#" class="dropdown-item" onclick="add_ds_folder('${node}');return false;"><small class="fa-solid fa-folder mr-2"></small>Add subfolder</a>
|
||||
<a href="#" class="dropdown-item" onclick="add_ds_file('${node}');return false;"><small class="fa-solid fa-file mr-2"></small>Add file</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a href="#" class="dropdown-item" onclick="move_ds_folder('${node}');return false;"><small class="fa fa-arrow-right-arrow-left mr-2"></small>Move</a>
|
||||
<a href="#" class="dropdown-item" onclick="rename_ds_folder('${node}', '${sanitizeHTML(data[node].name)}');return false;"><small class="fa-solid fa-pencil mr-2"></small>Rename</a>
|
||||
${can_delete}
|
||||
</div>
|
||||
<ul id='tree-${node}'></ul>
|
||||
</li>`;
|
||||
$('#'+ tree_node).append(jnode);
|
||||
build_ds_tree(data[node].children, 'tree-' + node);
|
||||
} else {
|
||||
data[node].file_original_name = sanitizeHTML(data[node].file_original_name);
|
||||
data[node].file_password = sanitizeHTML(data[node].file_password);
|
||||
data[node].file_description = sanitizeHTML(data[node].file_description);
|
||||
standard_files_filters.push({
|
||||
value: data[node].file_original_name,
|
||||
score: 1,
|
||||
meta: data[node].file_description
|
||||
});
|
||||
icon = '';
|
||||
if (data[node].file_is_ioc) {
|
||||
icon += '<i class="fa-solid fa-virus-covid text-danger mr-1" title="File is an IOC"></i>';
|
||||
}
|
||||
if (data[node].file_is_evidence) {
|
||||
icon += '<i class="fa-solid fa-file-shield text-success mr-1" title="File is an evidence"></i>';
|
||||
}
|
||||
if (icon.length === 0) {
|
||||
icon = '<i class="fa-regular fa-file mr-1" title="Regular file"></i>';
|
||||
}
|
||||
icon_lock = '';
|
||||
has_password = data[node].file_password !== null && data[node].file_password.length > 0;
|
||||
if (has_password) {
|
||||
icon_lock = '<i title="Password protected" class="fa-solid fa-lock text-success mr-1"></i>'
|
||||
}
|
||||
icn_content = btoa(icon + icon_lock);
|
||||
jnode = `<li>
|
||||
<span id='${node}' data-file-id="${node}" title="ID : ${data[node].file_id}\nUUID : ${data[node].file_uuid}" class='tree-leaf'>
|
||||
<span role="menu" style="cursor:pointer;" data-toggle="dropdown" aria-expanded="false">${icon}${icon_lock} ${sanitizeHTML(data[node].file_original_name)}</span>
|
||||
<i class="fa-regular fa-circle ds-file-selector" style="cursor:pointer;display:none;" onclick="ds_file_select('${node}');"></i>
|
||||
<div class="dropdown-menu" role="menu">
|
||||
<a href="#" class="dropdown-item" onclick="get_link_ds_file('${node}');return false;"><small class="fa fa-link mr-2"></small>Link</a>
|
||||
<a href="#" class="dropdown-item" onclick="get_mk_link_ds_file('${node}', '${toBinary64(data[node].file_original_name)}', '${icn_content}', '${has_password}');return false;"><small class="fa-brands fa-markdown mr-2"></small>Markdown link</a>
|
||||
<a href="#" class="dropdown-item" onclick="download_ds_file('${node}');return false;"><small class="fa-solid fa-download mr-2"></small>Download</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a href="#" class="dropdown-item" onclick="info_ds_file('${node}');return false;"><small class="fa fa-eye mr-2"></small>Info</a>
|
||||
<a href="#" class="dropdown-item" onclick="edit_ds_file('${node}');return false;"><small class="fa fa-pencil mr-2"></small>Edit</a>
|
||||
<a href="#" class="dropdown-item" onclick="move_ds_file('${node}');return false;"><small class="fa fa-arrow-right-arrow-left mr-2"></small>Move</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a href="#" class="dropdown-item text-danger" onclick="delete_ds_file('${node}');"><small class="fa fa-trash mr-2"></small>Delete</a>
|
||||
</div>
|
||||
</span>
|
||||
</li>`;
|
||||
$('#'+ tree_node).append(jnode);
|
||||
}
|
||||
}
|
||||
ds_filter.setOptions({
|
||||
enableBasicAutocompletion: [{
|
||||
getCompletions: (editor, session, pos, prefix, callback) => {
|
||||
callback(null, standard_files_filters);
|
||||
},
|
||||
}],
|
||||
enableLiveAutocompletion: true,
|
||||
});
|
||||
}
|
||||
|
||||
function show_datastore() {
|
||||
$('html').addClass('ds_sidebar_open');
|
||||
$('.ds-sidebar-toggler').addClass('toggled');
|
||||
}
|
||||
|
||||
function hide_datastore() {
|
||||
$('html').removeClass('ds_sidebar_open');
|
||||
$('.ds-sidebar-toggler').removeClass('toggled');
|
||||
}
|
||||
|
||||
function reparse_activate_tree() {
|
||||
$('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch');
|
||||
$('.tree li.parent_li > span').on('click', function (e) {
|
||||
var children = $(this).parent('li.parent_li').find(' > ul > li');
|
||||
if (children.is(":visible")) {
|
||||
children.hide('fast');
|
||||
$(this).attr('title', 'Expand this branch').find(' > i').addClass('icon-plus-sign').removeClass('icon-minus-sign');
|
||||
} else {
|
||||
children.show('fast');
|
||||
$(this).attr('title', 'Collapse this branch').find(' > i').addClass('icon-minus-sign').removeClass('icon-plus-sign');
|
||||
}
|
||||
e.stopPropagation();
|
||||
});
|
||||
}
|
||||
|
||||
function add_ds_folder(parent_node) {
|
||||
$('#ds_mod_folder_name').data('parent-node', parent_node);
|
||||
$('#ds_mod_folder_name').data('node-update', false);
|
||||
$('#ds_mod_folder_name').val('');
|
||||
$('#modal_ds_folder').modal("show");
|
||||
}
|
||||
|
||||
function rename_ds_folder(parent_node, name) {
|
||||
$('#ds_mod_folder_name').data('parent-node', parent_node);
|
||||
$('#ds_mod_folder_name').data('node-update', true);
|
||||
$('#ds_mod_folder_name').val(name);
|
||||
$('#modal_ds_folder').modal("show");
|
||||
}
|
||||
|
||||
function delete_ds_folder(node) {
|
||||
node = node.replace('d-', '');
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "This will delete all files included and sub-folders",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
var data_sent = {
|
||||
"csrf_token": $('#csrf_token').val()
|
||||
}
|
||||
post_request_api('/datastore/folder/delete/' + node, JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data)) {
|
||||
reset_ds_file_view();
|
||||
load_datastore();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function save_ds_mod_folder() {
|
||||
var data = Object();
|
||||
|
||||
data['parent_node'] = $('#ds_mod_folder_name').data('parent-node').replace('d-', '');
|
||||
data['folder_name'] = $('#ds_mod_folder_name').val();
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
if ($('#ds_mod_folder_name').data('node-update')) {
|
||||
uri = '/datastore/folder/rename/' + data['parent_node'];
|
||||
} else {
|
||||
uri = '/datastore/folder/add';
|
||||
}
|
||||
|
||||
post_request_api(uri, JSON.stringify(data))
|
||||
.done(function (data){
|
||||
if(notify_auto_api(data)){
|
||||
$('#modal_ds_folder').modal("hide");
|
||||
load_datastore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function add_ds_file(node) {
|
||||
node = node.replace('d-', '');
|
||||
url = '/datastore/file/add/'+ node +'/modal' + case_param();
|
||||
$('#modal_ds_file_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#modal_ds_file').modal("show");
|
||||
});
|
||||
}
|
||||
|
||||
function edit_ds_file(node) {
|
||||
node = node.replace('f-', '');
|
||||
url = '/datastore/file/update/'+ node +'/modal' + case_param();
|
||||
$('#modal_ds_file_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#modal_ds_file').modal("show");
|
||||
});
|
||||
}
|
||||
|
||||
function info_ds_file(node) {
|
||||
node = node.replace('f-', '');
|
||||
url = '/datastore/file/info/'+ node +'/modal' + case_param();
|
||||
$('#modal_ds_file_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#modal_ds_file').modal("show");
|
||||
});
|
||||
}
|
||||
|
||||
function save_ds_file(node, file_id) {
|
||||
var formData = new FormData($('#form_new_ds_file')[0]);
|
||||
formData.append('file_content', $('#input_upload_ds_file').prop('files')[0]);
|
||||
|
||||
if (file_id === undefined) {
|
||||
uri = '/datastore/file/add/' + node;
|
||||
} else {
|
||||
uri = '/datastore/file/update/' + file_id;
|
||||
}
|
||||
|
||||
post_request_data_api(uri, formData, true, function() {
|
||||
window.swal({
|
||||
title: "File is uploading",
|
||||
text: "Please wait. This window will close automatically when the file is uploaded.",
|
||||
icon: "/static/assets/img/loader.gif",
|
||||
button: false,
|
||||
allowOutsideClick: false
|
||||
});
|
||||
})
|
||||
.done(function (data){
|
||||
if(notify_auto_api(data)){
|
||||
$('#modal_ds_file').modal("hide");
|
||||
reset_ds_file_view();
|
||||
load_datastore();
|
||||
}
|
||||
})
|
||||
.always((data) => {
|
||||
window.swal.close();
|
||||
});
|
||||
}
|
||||
|
||||
function refresh_ds(){
|
||||
reset_ds_file_view();
|
||||
load_datastore();
|
||||
notify_success('Datastore refreshed');
|
||||
}
|
||||
|
||||
function upload_interactive_data(data_blob, filename, completion_callback) {
|
||||
|
||||
var data_sent = Object()
|
||||
data_sent["csrf_token"] = $('#csrf_token').val();
|
||||
data_sent["file_content"] = data_blob.split(';base64,')[1];
|
||||
data_sent["file_original_name"] = filename;
|
||||
|
||||
post_request_api('/datastore/file/add-interactive', JSON.stringify(data_sent), true)
|
||||
.done(function (data){
|
||||
if(notify_auto_api(data)) {
|
||||
if (completion_callback !== undefined) {
|
||||
completion_callback(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function toggle_select_file() {
|
||||
if ($('.btn-ds-bulk-selector').hasClass('active')) {
|
||||
reset_ds_file_view();
|
||||
load_datastore();
|
||||
} else {
|
||||
$('.ds-file-selector').show(250);
|
||||
$('.btn-ds-bulk').show(250);
|
||||
$('.btn-ds-bulk-selector').addClass('active');
|
||||
}
|
||||
}
|
||||
|
||||
function move_ds_file(file_id) {
|
||||
|
||||
reparse_activate_tree_selection();
|
||||
$('.ds-file-selector').show();
|
||||
$('#msg_mv_dst_folder').text('unselected destination');
|
||||
$('#msg_select_destination_folder').show();
|
||||
|
||||
ds_file_select(file_id);
|
||||
}
|
||||
|
||||
function reset_ds_file_view() {
|
||||
$(".node-selected").removeClass("node-selected");
|
||||
$(".file-selected").removeClass("file-selected");
|
||||
$('.ds-file-selector').hide();
|
||||
$('#msg_select_destination_folder').attr("data-file-id", '');
|
||||
$('#msg_select_destination_folder').hide();
|
||||
$('#msg_select_destination_folder_folder').hide();
|
||||
$('.ds-file-selector').hide();
|
||||
$('.btn-ds-bulk').hide();
|
||||
$('.btn-ds-bulk-selector').removeClass('active');
|
||||
}
|
||||
|
||||
function ds_file_select(file_id) {
|
||||
file_id = '#'+ file_id;
|
||||
if ($(file_id).hasClass('file-selected')) {
|
||||
$(file_id + '> i').removeClass('fa-circle-check');
|
||||
$(file_id + '> i').addClass('fa-circle');
|
||||
$(file_id).removeClass('file-selected');
|
||||
} else {
|
||||
$(file_id+ '> i').removeClass('fa-circle');
|
||||
$(file_id+ '> i').addClass('fa-circle-check');
|
||||
$(file_id).addClass('file-selected');
|
||||
}
|
||||
$('#msg_mv_files').text($('.file-selected').length);
|
||||
}
|
||||
|
||||
function validate_ds_file_move() {
|
||||
var data_sent = Object();
|
||||
if ($(".node-selected").length === 0) {
|
||||
notify_error('No destination folder selected');
|
||||
return false;
|
||||
}
|
||||
if ($(".file-selected").length === 0) {
|
||||
notify_error('No file to move selected');
|
||||
return false;
|
||||
}
|
||||
|
||||
data_sent['destination-node'] = $(".node-selected").data('node-id').replace('d-', '');
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
index = 0;
|
||||
selected_files = $(".file-selected");
|
||||
selected_files.each((index) => {
|
||||
file_id = $(selected_files[index]).data('file-id').replace('f-', '');
|
||||
post_request_api('/datastore/file/move/' + file_id, JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data)) {
|
||||
if (index == $(".file-selected").length - 1) {
|
||||
reset_ds_file_view();
|
||||
load_datastore();
|
||||
}
|
||||
index +=1;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function move_ds_folder(node_id) {
|
||||
reset_ds_file_view();
|
||||
|
||||
$('#msg_mv_folder').text($('#' + node_id).text());
|
||||
$('#msg_mv_dst_folder_folder').text('unselected destination');
|
||||
$('#msg_select_destination_folder_folder').show();
|
||||
|
||||
reparse_activate_tree_selection();
|
||||
$('#' + node_id).addClass('node-source-selected');
|
||||
}
|
||||
|
||||
function validate_ds_folder_move() {
|
||||
var data_sent = Object();
|
||||
if ($(".node-selected").length === 0) {
|
||||
notify_error('No destination folder selected');
|
||||
return false;
|
||||
}
|
||||
if ($(".node-source-selected").length === 0) {
|
||||
notify_error('No initial folder to move');
|
||||
return false;
|
||||
}
|
||||
|
||||
data_sent['destination-node'] = $(".node-selected").data('node-id').replace('d-', '');
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
node_id = $(".node-source-selected").data('node-id').replace('d-', '');
|
||||
post_request_api('/datastore/folder/move/' + node_id, JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data)) {
|
||||
reset_ds_file_view();
|
||||
load_datastore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function delete_ds_file(file_id) {
|
||||
file_id = file_id.replace('f-', '');
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "This will delete the file on the server and any manual reference will become invalid",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
var data_sent = {
|
||||
"csrf_token": $('#csrf_token').val()
|
||||
}
|
||||
post_request_api('/datastore/file/delete/' + file_id, JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data)) {
|
||||
reset_ds_file_view();
|
||||
load_datastore();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function delete_bulk_ds_file() {
|
||||
|
||||
selected_files = $(".file-selected");
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: `Yu are about to delete ${selected_files.length} files\nThis will delete the files on the server and any manual reference will become invalid`,
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
selected_files.each((index) => {
|
||||
file_id = $(selected_files[index]).data('file-id').replace('f-', '');
|
||||
var data_sent = {
|
||||
"csrf_token": $('#csrf_token').val()
|
||||
}
|
||||
post_request_api('/datastore/file/delete/' + file_id, JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data)) {
|
||||
if (index == $(".file-selected").length - 1) {
|
||||
reset_ds_file_view();
|
||||
load_datastore();
|
||||
}
|
||||
index +=1;
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function get_link_ds_file(file_id) {
|
||||
|
||||
file_id = file_id.replace('f-', '');
|
||||
|
||||
link = location.protocol + '//' + location.host + '/datastore/file/view/' + file_id;
|
||||
link = link + case_param();
|
||||
|
||||
navigator.clipboard.writeText(link).then(function() {
|
||||
notify_success('File link copied')
|
||||
}, function(err) {
|
||||
notify_error('Unable to copy link. Error ' + err);
|
||||
console.error('File link link', err);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function build_dsfile_view_link(file_id) {
|
||||
file_id = file_id.replace('f-', '');
|
||||
|
||||
link = '/datastore/file/view/' + file_id;
|
||||
link = link + case_param();
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
function get_mk_link_ds_file(file_id, filename, file_icon, has_password) {
|
||||
|
||||
let link = build_dsfile_view_link(file_id);
|
||||
|
||||
filename = sanitizeHTML(fromBinary64(filename));
|
||||
|
||||
|
||||
if (has_password == 'false' && ['png', 'svg', 'jpeg', 'jpg', 'webp', 'bmp', 'gif'].includes(filename.split('.').pop())) {
|
||||
mk_link = ``;
|
||||
} else {
|
||||
file_icon = atob(file_icon);
|
||||
mk_link = `[${file_icon} [DS] ${filename}](${link})`;
|
||||
}
|
||||
|
||||
navigator.clipboard.writeText(mk_link).then(function() {
|
||||
notify_success('Markdown file link copied')
|
||||
}, function(err) {
|
||||
notify_error('Unable to copy link. Error ' + err);
|
||||
console.error(`Markdown file link ${md_link}`, err);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function download_ds_file(file_id) {
|
||||
let link = build_dsfile_view_link(file_id);
|
||||
downloadURI(link, name);
|
||||
}
|
||||
|
||||
function reparse_activate_tree_selection() {
|
||||
$('.tree li.parent_li > span').on('click', function (e) {
|
||||
if ($(this).hasClass('node-selected')) {
|
||||
$(this).removeClass('node-selected');
|
||||
$('#msg_mv_dst_folder').text('unselected destination');
|
||||
$('#msg_mv_dst_folder_folder').text('unselected destination');
|
||||
} else {
|
||||
$(".node-selected").removeClass("node-selected");
|
||||
$(this).addClass('node-selected');
|
||||
$('#msg_mv_dst_folder').text($(".node-selected").text());
|
||||
$('#msg_mv_dst_folder_folder').text($(".node-selected").text());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var parsed_filter_ds = {};
|
||||
var ds_keywords = ['storage_name', 'name', 'tag', 'description', 'is_ioc', 'is_evidence', 'has_password', 'uuid', 'id', 'sha256'];
|
||||
|
||||
function parse_filter(str_filter, keywords) {
|
||||
for (var k = 0; k < keywords.length; k++) {
|
||||
keyword = keywords[k];
|
||||
items = str_filter.split(keyword + ':');
|
||||
|
||||
ita = items[1];
|
||||
|
||||
if (ita === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
item = split_bool(ita);
|
||||
|
||||
if (item != null) {
|
||||
if (!(keyword in parsed_filter_ds)) {
|
||||
parsed_filter_ds[keyword] = [];
|
||||
}
|
||||
if (!parsed_filter_ds[keyword].includes(item)) {
|
||||
parsed_filter_ds[keyword].push(item.trim());
|
||||
}
|
||||
|
||||
if (items[1] != undefined) {
|
||||
str_filter = str_filter.replace(keyword + ':' + item, '');
|
||||
if (parse_filter(str_filter, keywords)) {
|
||||
keywords.shift();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function filter_ds_files() {
|
||||
|
||||
ds_keywords = ['storage_name', 'name', 'tag', 'description', 'is_ioc', 'is_evidence', 'has_password', 'uuid', 'id', 'sha256'];
|
||||
parsed_filter_ds = {};
|
||||
parse_filter(ds_filter.getValue(), ds_keywords);
|
||||
filter_query = encodeURIComponent(JSON.stringify(parsed_filter_ds));
|
||||
|
||||
$('#btn_filter_ds_files').text('Searching..');
|
||||
get_request_data_api("/datastore/list/filter",{ 'q': filter_query })
|
||||
.done(function (data){
|
||||
if(notify_auto_api(data, true)){
|
||||
$('#ds-tree-root').empty();
|
||||
build_ds_tree(data.data, 'ds-tree-root');
|
||||
reparse_activate_tree();
|
||||
show_datastore();
|
||||
}
|
||||
})
|
||||
.always(() => {
|
||||
$('#btn_filter_ds_files').text('Search');
|
||||
});
|
||||
}
|
||||
|
||||
function reset_ds_files_filter() {
|
||||
ds_filter.setValue("");
|
||||
load_datastore();
|
||||
}
|
||||
|
||||
function show_ds_filter_help() {
|
||||
$('#modal_help').load('/datastore/filter-help/modal' + case_param(), function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, '/datastore/filter-help/modal');
|
||||
return false;
|
||||
}
|
||||
$('#modal_help').modal('show');
|
||||
});
|
||||
}
|
||||
|
||||
66
iris-web/source/app/static/assets/js/iris/datatablesUtils.js
Normal file
66
iris-web/source/app/static/assets/js/iris/datatablesUtils.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/* remove user provided filter */
|
||||
function removeFilter(clickedObject) {
|
||||
console.log("removeFilter")
|
||||
let inputObject = $(clickedObject)
|
||||
.parents("table")
|
||||
.find("input")[$(clickedObject).parents("th").index()]
|
||||
inputObject.value=""; // Clear input
|
||||
$(inputObject).trigger("change"); // trigger change event
|
||||
}
|
||||
|
||||
/* add a text input to each column of a given datatable to allow filtering */
|
||||
function addFilterFields(tableId){
|
||||
$('#' + tableId + ' thead tr')
|
||||
.clone(true)
|
||||
.addClass('filters')
|
||||
.appendTo('#' + tableId + ' thead');
|
||||
}
|
||||
|
||||
/* callback function to activate filtering on a datatable */
|
||||
function tableFiltering(api, table_anchor, exclude_columns=[]) {
|
||||
// For each column
|
||||
api
|
||||
.columns()
|
||||
.eq(0)
|
||||
.each(function (colIdx) {
|
||||
// Set the header cell to contain the input element
|
||||
var cell = $('#'+table_anchor+' .filters th').eq(
|
||||
$(api.column(colIdx).header()).index()
|
||||
);
|
||||
|
||||
if (exclude_columns.includes(colIdx)) {
|
||||
$(cell).html('<div class="form-group has-feedback" style="display: none;"><input type="text" class="form-control" placeholder="Filter"><i class="fas fa-times-circle form-control-feedback" onclick="removeFilter(this);"></i></div>');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$(cell).html('<div class="form-group has-feedback"><input type="text" class="form-control" placeholder="Filter"><i class="fas fa-times-circle form-control-feedback" onclick="removeFilter(this);"></i></div>');
|
||||
// On every keypress in this input
|
||||
$(
|
||||
'input',
|
||||
$('#'+table_anchor+' .filters th').eq($(api.column(colIdx).header()).index())
|
||||
)
|
||||
.off('keyup change')
|
||||
.on('keyup change', function (e) {
|
||||
e.stopPropagation();
|
||||
// Get the search value
|
||||
$(this).attr('title', $(this).val());
|
||||
var regexr = '({search})';
|
||||
var cursorPosition = this.selectionStart;
|
||||
// Search the column for that value
|
||||
api
|
||||
.column(colIdx)
|
||||
.search(
|
||||
this.value != ''
|
||||
? regexr.replace('{search}', '(((' + this.value + ')))')
|
||||
: '',
|
||||
this.value != '',
|
||||
this.value == ''
|
||||
)
|
||||
.draw();
|
||||
$(this)
|
||||
.focus()[0]
|
||||
.setSelectionRange(cursorPosition, cursorPosition);
|
||||
});
|
||||
});
|
||||
}
|
||||
86
iris-web/source/app/static/assets/js/iris/dim_tasks.js
Normal file
86
iris-web/source/app/static/assets/js/iris/dim_tasks.js
Normal file
@@ -0,0 +1,86 @@
|
||||
function get_activities () {
|
||||
|
||||
get_request_api('/dim/tasks/list/1000')
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data, true)) {
|
||||
content = data.data;
|
||||
Table.clear();
|
||||
Table.rows.add(content);
|
||||
Table.columns.adjust().draw();
|
||||
$('#feed_last_updated').text("Last updated: " + new Date().toLocaleTimeString());
|
||||
hide_loader();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$.each($.find("table"), function(index, element){
|
||||
addFilterFields($(element).attr("id"));
|
||||
});
|
||||
|
||||
|
||||
Table = $("#activities_table").DataTable({
|
||||
dom: 'Blfrtip',
|
||||
aaData: [],
|
||||
bSort: false,
|
||||
aoColumns: [
|
||||
|
||||
{ "data": "task_id",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
data = "<a href='#' onclick=\"dim_task_status('"+ data +"');return false;\">"+ data +"</a>"
|
||||
}
|
||||
return data;
|
||||
} },
|
||||
{ "data": "state",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
if (data == 'success'){
|
||||
data = "<i class='fas fa-check text-success' title='success'></i>";
|
||||
} else {
|
||||
data = "<i class='fas fa-times text-danger' title='failure'></i>";
|
||||
}
|
||||
}
|
||||
return data;
|
||||
} },
|
||||
{ "data": "date_done",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
} },
|
||||
{ "data": "case",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
} },
|
||||
{ "data": "module",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
} },
|
||||
{ "data": "user",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
} }
|
||||
],
|
||||
filter: true,
|
||||
info: true,
|
||||
processing: true,
|
||||
retrieve: true,
|
||||
initComplete: function () {
|
||||
tableFiltering(this.api(), 'activities_table');
|
||||
},
|
||||
buttons: [
|
||||
{ "extend": 'csvHtml5', "text":'Export',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
{ "extend": 'copyHtml5', "text":'Copy',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
]
|
||||
});
|
||||
$("#activities_table").css("font-size", 12);
|
||||
|
||||
|
||||
get_activities();
|
||||
});
|
||||
188
iris-web/source/app/static/assets/js/iris/manage.attributes.js
Normal file
188
iris-web/source/app/static/assets/js/iris/manage.attributes.js
Normal file
@@ -0,0 +1,188 @@
|
||||
function add_object_attribute() {
|
||||
url = '/manage/attributes/add/modal' + case_param();
|
||||
$('#modal_add_attribute_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#submit_new_attribute').on("click", function () {
|
||||
var form = $('#form_new_attribute').serializeObject();
|
||||
|
||||
post_request_api('/manage/attributes/add', JSON.stringify(form), true)
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data, true)) {
|
||||
refresh_attribute_table();
|
||||
$('#modal_add_attribute').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
});
|
||||
$('#modal_add_type').modal({ show: true });
|
||||
}
|
||||
|
||||
$('#attributes_table').dataTable( {
|
||||
"ajax": {
|
||||
"url": "/manage/attributes/list" + case_param(),
|
||||
"contentType": "application/json",
|
||||
"type": "GET",
|
||||
"data": function ( d ) {
|
||||
if (d.status == 'success') {
|
||||
return JSON.stringify( d.data );
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
"order": [[ 0, "desc" ]],
|
||||
"autoWidth": false,
|
||||
"columns": [
|
||||
{
|
||||
"data": "attribute_id",
|
||||
"render": function ( data, type, row ) {
|
||||
return '<a href="#" onclick="attribute_detail(\'' + row['attribute_id'] + '\');">' + sanitizeHTML(data) +'</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "attribute_display_name",
|
||||
"render": function ( data, type, row ) {
|
||||
return '<a href="#" onclick="attribute_detail(\'' + row['attribute_id'] + '\');">' + sanitizeHTML(data) +'</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "attribute_description"
|
||||
}
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
function refresh_attribute_table() {
|
||||
$('#attributes_table').DataTable().ajax.reload();
|
||||
notify_success("Refreshed");
|
||||
}
|
||||
|
||||
function attribute_detail(attr_id) {
|
||||
url = '/manage/attributes/' + attr_id + '/modal' + case_param();
|
||||
$('#modal_add_attribute_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
var editor = ace.edit("editor_detail",
|
||||
{
|
||||
autoScrollEditorIntoView: true,
|
||||
minLines: 30,
|
||||
});
|
||||
editor.setTheme("ace/theme/tomorrow");
|
||||
editor.session.setMode("ace/mode/json");
|
||||
editor.renderer.setShowGutter(true);
|
||||
editor.setOption("showLineNumbers", true);
|
||||
editor.setOption("showPrintMargin", false);
|
||||
editor.setOption("displayIndentGuides", true);
|
||||
editor.setOption("maxLines", "Infinity");
|
||||
editor.session.setUseWrapMode(true);
|
||||
editor.setOption("indentedSoftWrap", true);
|
||||
editor.renderer.setScrollMargin(8, 5)
|
||||
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: [{
|
||||
getCompletions: (editor, session, pos, prefix, callback) => {
|
||||
callback(null, [
|
||||
{value: 'mandatory', score: 1, meta: 'mandatory tag'},
|
||||
{value: 'type', score: 1, meta: 'type tag'},
|
||||
{value: 'input_string', score: 1, meta: 'An input string field type'},
|
||||
{value: 'input_checkbox', score: 1, meta: 'An input checkbox field type'},
|
||||
{value: 'input_textfield', score: 1, meta: 'An input textfield field type'},
|
||||
{value: 'input_date', score: 1, meta: 'An input date field type'},
|
||||
{value: 'input_datetime', score: 1, meta: 'An input datetime field type'},
|
||||
{value: 'input_select', score: 1, meta: 'An input select field type'},
|
||||
{value: 'raw', score: 1, meta: 'A raw field type'},
|
||||
{value: 'html', score: 1, meta: 'An html field type'},
|
||||
{value: 'value', score: 1, meta: 'default value'},
|
||||
]);
|
||||
},
|
||||
}],
|
||||
enableLiveAutocompletion: true,
|
||||
enableSnippets: true
|
||||
});
|
||||
|
||||
$('#preview_attribute').on("click", function () {
|
||||
var data_sent = Object();
|
||||
data_sent['attribute_content'] = editor.getSession().getValue();
|
||||
data_sent['csrf_token'] = $("#csrf_token").val();
|
||||
|
||||
post_request_api('/manage/attributes/preview', JSON.stringify(data_sent), true)
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data, true)) {
|
||||
$('#modal_preview_attribute_content').html(data.data);
|
||||
|
||||
$('#modal_preview_attribute').modal({ show: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#submit_new_attribute').on("click", function () {
|
||||
update_attribute(attr_id, editor, false, false);
|
||||
})
|
||||
$('#submit_partial_overwrite').on("click", function () {
|
||||
update_attribute(attr_id, editor, true, false);
|
||||
})
|
||||
$('#submit_complete_overwrite').on("click", function () {
|
||||
update_attribute(attr_id, editor, false, true);
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
$('#modal_add_attribute').modal({ show: true });
|
||||
}
|
||||
|
||||
function update_attribute(attr_id, editor, partial, complete){
|
||||
event.preventDefault();
|
||||
|
||||
var data_sent = Object();
|
||||
data_sent['attribute_content'] = editor.getSession().getValue();
|
||||
data_sent['csrf_token'] = $("#csrf_token").val();
|
||||
data_sent['partial_overwrite'] = partial;
|
||||
data_sent['complete_overwrite'] = complete;
|
||||
|
||||
$('#alert_attributes_edit').empty();
|
||||
$('#alert_attributes_details').hide();
|
||||
$('#attributes_err_details_list').empty();
|
||||
|
||||
post_request_api('/manage/attributes/update/' + attr_id, JSON.stringify(data_sent), false, function() {
|
||||
window.swal({
|
||||
title: "Updating and migrating...",
|
||||
text: "Please wait",
|
||||
icon: "/static/assets/img/loader.gif",
|
||||
button: false,
|
||||
allowOutsideClick: false
|
||||
});
|
||||
})
|
||||
.done((data) => {
|
||||
notify_auto_api(data);
|
||||
})
|
||||
.fail((error) => {
|
||||
data = error.responseJSON;
|
||||
$('#submit_new_attribute').text('Save');
|
||||
$('#alert_attributes_edit').text(data.message);
|
||||
if (data.data && data.data.length > 0) {
|
||||
for(var i in data.data)
|
||||
{
|
||||
var output='<li>'+ sanitizeHTML(data.data[i]) +'</li>';
|
||||
$('#attributes_err_details_list').append(output);
|
||||
}
|
||||
|
||||
$('#alert_attributes_details').show();
|
||||
}
|
||||
$('#alert_attributes_edit').show();
|
||||
$('#submit_new_module').text("Retry");
|
||||
})
|
||||
.always((data) => {
|
||||
window.swal.close();
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
|
||||
|
||||
|
||||
function get_case_audit_page() {
|
||||
us_val = $('#cases_audit_select').val();
|
||||
if (!us_val) {
|
||||
notify_error('I really wanna help you but I still can\'t read your mind');
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#get_case_audit_btn').text('Auditing case..');
|
||||
url = '/manage/access-control/audit/cases/'+ us_val +'/modal' + case_param();
|
||||
$('#case_audit_content').load(url, function (response, status, xhr) {
|
||||
$('#get_case_audit_btn').text('Audit');
|
||||
if (status !== "success") {
|
||||
$('#get_case_audit_btn').text('Audit');
|
||||
ajax_notify_error(xhr, url);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$.each($.find("table"), function(index, element){
|
||||
addFilterFields($(element).attr("id"));
|
||||
});
|
||||
|
||||
$('#case_audit_access_table').dataTable({
|
||||
order: [[ 1, "asc" ]],
|
||||
info: true,
|
||||
filter: true,
|
||||
processing: true,
|
||||
orderCellsTop: true,
|
||||
initComplete: function () {
|
||||
tableFiltering(this.api(), 'case_audit_access_table');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function refresh_cases_list_audit() {
|
||||
get_request_api('/manage/cases/list')
|
||||
.done((data) => {
|
||||
|
||||
if(notify_auto_api(data, true)) {
|
||||
|
||||
$('#cases_audit_select').selectpicker({
|
||||
liveSearch: true,
|
||||
title: "Select case to audit",
|
||||
style: "btn-outline-white",
|
||||
size: 10
|
||||
});
|
||||
data_select = [];
|
||||
for (caseid in data.data) {
|
||||
label = `${sanitizeHTML(data.data[caseid].case_name)}`;
|
||||
$("#cases_audit_select").append('<option value="'+data.data[caseid].case_id+'">'+label+'</option>');
|
||||
}
|
||||
$("#cases_audit_select").selectpicker("refresh");
|
||||
$("#cases_audit_select").show();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
refresh_cases_list_audit();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
|
||||
|
||||
|
||||
function get_user_audit_page() {
|
||||
|
||||
us_val = $('#users_audit_select').val();
|
||||
if (!us_val) {
|
||||
notify_error('I really wanna help you but I still can\'t read your mind');
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#get_user_audit_btn').text('Auditing user..');
|
||||
url = '/manage/access-control/audit/users/'+ us_val +'/modal' + case_param();
|
||||
$('#user_audit_content').load(url, function (response, status, xhr) {
|
||||
$('#get_user_audit_btn').text('Audit');
|
||||
if (status !== "success") {
|
||||
$('#get_user_audit_btn').text('Audit');
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$.each($.find("table"), function(index, element){
|
||||
addFilterFields($(element).attr("id"));
|
||||
});
|
||||
|
||||
$('#user_audit_access_table').dataTable({
|
||||
order: [[ 1, "asc" ]],
|
||||
info: true,
|
||||
filter: true,
|
||||
processing: true,
|
||||
orderCellsTop: true,
|
||||
initComplete: function () {
|
||||
tableFiltering(this.api(), 'user_audit_access_table');
|
||||
}
|
||||
});
|
||||
|
||||
$('#user_audit_permissions_table').dataTable({
|
||||
order: [[ 1, "asc" ]],
|
||||
info: true,
|
||||
filter: true,
|
||||
processing: true,
|
||||
orderCellsTop: true,
|
||||
initComplete: function () {
|
||||
tableFiltering(this.api(), 'user_audit_permissions_table');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function refresh_users_list_audit() {
|
||||
get_request_api('/manage/users/list')
|
||||
.done((data) => {
|
||||
|
||||
if(notify_auto_api(data, true)) {
|
||||
|
||||
$('#users_audit_select').selectpicker({
|
||||
liveSearch: true,
|
||||
title: "Select user to audit",
|
||||
style: "btn-outline-white",
|
||||
size: 10
|
||||
});
|
||||
data_select = [];
|
||||
for (user in data.data) {
|
||||
label = `${sanitizeHTML(data.data[user].user_login)} (${sanitizeHTML(data.data[user].user_name)} - ${sanitizeHTML(data.data[user].user_email)})`;
|
||||
$("#users_audit_select").append('<option value="'+data.data[user].user_id+'">'+label+'</option>');
|
||||
}
|
||||
$("#users_audit_select").selectpicker("refresh");
|
||||
$("#users_audit_select").show();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
refresh_users_list_audit();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,336 @@
|
||||
function add_case_template() {
|
||||
let url = '/manage/case-templates/add/modal' + case_param();
|
||||
$('#modal_case_template_json').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
let editor = ace.edit("editor_detail",
|
||||
{
|
||||
autoScrollEditorIntoView: true,
|
||||
minLines: 30,
|
||||
});
|
||||
editor.setTheme("ace/theme/tomorrow");
|
||||
editor.session.setMode("ace/mode/json");
|
||||
editor.renderer.setShowGutter(true);
|
||||
editor.setOption("showLineNumbers", true);
|
||||
editor.setOption("showPrintMargin", false);
|
||||
editor.setOption("displayIndentGuides", true);
|
||||
editor.setOption("maxLines", "Infinity");
|
||||
editor.session.setUseWrapMode(true);
|
||||
editor.setOption("indentedSoftWrap", true);
|
||||
editor.renderer.setScrollMargin(8, 5)
|
||||
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: [{
|
||||
getCompletions: (editor, session, pos, prefix, callback) => {
|
||||
callback(null, [
|
||||
{value: 'name', score: 1, meta: 'name of the template'},
|
||||
{value: 'display', score: 1, meta: 'display name of the template'},
|
||||
{value: 'description', score: 1, meta: 'description of the template'},
|
||||
{value: 'author', score: 1, meta: 'author of the template'},
|
||||
{value: 'title_prefix', score: 1, meta: 'prefix of instantiated cases'},
|
||||
{value: 'summary', score: 1, meta: 'summary of the case'},
|
||||
{value: 'tags', score: 1, meta: 'tags of the case or the tasks'},
|
||||
{value: 'tasks', score: 1, meta: 'tasks of the case'},
|
||||
{value: 'note_groups', score: 1, meta: 'groups of notes'},
|
||||
{value: 'title', score: 1, meta: 'title of the task or the note group or the note'},
|
||||
{value: 'content', score: 1, meta: 'content of the note'},
|
||||
]);
|
||||
},
|
||||
}],
|
||||
enableLiveAutocompletion: true,
|
||||
enableSnippets: true
|
||||
});
|
||||
|
||||
$('#submit_new_case_template').on("click", function () {
|
||||
let data_sent = Object();
|
||||
data_sent['case_template_json'] = editor.getSession().getValue();
|
||||
data_sent['csrf_token'] = $("#csrf_token").val();
|
||||
|
||||
post_request_api('/manage/case-templates/add', JSON.stringify(data_sent), false, function() {
|
||||
window.swal({
|
||||
title: "Adding...",
|
||||
text: "Please wait",
|
||||
icon: "/static/assets/img/loader.gif",
|
||||
button: false,
|
||||
allowOutsideClick: false
|
||||
});
|
||||
})
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data)) {
|
||||
refresh_case_template_table();
|
||||
$('#modal_case_template').modal('hide');
|
||||
}
|
||||
})
|
||||
.fail((error) => {
|
||||
let data = error.responseJSON;
|
||||
$('#submit_new_case_template').text('Save');
|
||||
$('#alert_case_template_edit').text(data.message);
|
||||
if (data.data && data.data.length > 0) {
|
||||
|
||||
let output='<li>'+ sanitizeHTML(data.data) +'</li>';
|
||||
$('#case_template_err_details_list').append(output);
|
||||
|
||||
$('#alert_case_template_details').show();
|
||||
}
|
||||
$('#alert_case_template_edit').show();
|
||||
})
|
||||
.always((data) => {
|
||||
window.swal.close();
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
});
|
||||
$('#modal_case_template').modal({ show: true });
|
||||
}
|
||||
|
||||
$('#case_templates_table').dataTable( {
|
||||
"ajax": {
|
||||
"url": "/manage/case-templates/list" + case_param(),
|
||||
"contentType": "application/json",
|
||||
"type": "GET",
|
||||
"data": function ( d ) {
|
||||
if (d.status == 'success') {
|
||||
return JSON.stringify( d.data );
|
||||
} else {
|
||||
return JSON.stringify([]);
|
||||
}
|
||||
}
|
||||
},
|
||||
"order": [[ 0, "desc" ]],
|
||||
"autoWidth": false,
|
||||
"columns": [
|
||||
{
|
||||
"data": "id",
|
||||
"render": function ( data, type, row ) {
|
||||
return '<a href="#" onclick="case_template_detail(\'' + row['id'] + '\');">' + sanitizeHTML(data) +'</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "display_name",
|
||||
"render": function ( data, type, row ) {
|
||||
return '<a href="#" onclick="case_template_detail(\'' + row['id'] + '\');">' + sanitizeHTML(data) +'</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "description"
|
||||
},
|
||||
{
|
||||
"data": "added_by"
|
||||
},
|
||||
{
|
||||
"data": "created_at"
|
||||
},
|
||||
{
|
||||
"data": "updated_at"
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
function refresh_case_template_table() {
|
||||
$('#case_templates_table').DataTable().ajax.reload();
|
||||
notify_success("Refreshed");
|
||||
}
|
||||
|
||||
function delete_case_template(id) {
|
||||
swal({
|
||||
title: "Are you sure ?",
|
||||
text: "You won't be able to revert this !",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
post_request_api('/manage/case-templates/delete/' + id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
window.location.href = '/manage/case-templates' + case_param();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function case_template_detail(ctempl_id) {
|
||||
let url = '/manage/case-templates/' + ctempl_id + '/modal' + case_param();
|
||||
$('#modal_case_template_json').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
let editor = ace.edit("editor_detail",
|
||||
{
|
||||
autoScrollEditorIntoView: true,
|
||||
minLines: 30,
|
||||
});
|
||||
editor.setTheme("ace/theme/tomorrow");
|
||||
editor.session.setMode("ace/mode/json");
|
||||
editor.renderer.setShowGutter(true);
|
||||
editor.setOption("showLineNumbers", true);
|
||||
editor.setOption("showPrintMargin", false);
|
||||
editor.setOption("displayIndentGuides", true);
|
||||
editor.setOption("maxLines", "Infinity");
|
||||
editor.session.setUseWrapMode(true);
|
||||
editor.setOption("indentedSoftWrap", true);
|
||||
editor.renderer.setScrollMargin(8, 5)
|
||||
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: [{
|
||||
getCompletions: (editor, session, pos, prefix, callback) => {
|
||||
callback(null, [
|
||||
{value: 'name', score: 1, meta: 'name of the template'},
|
||||
{value: 'display_name', score: 1, meta: 'display name of the template'},
|
||||
{value: 'description', score: 1, meta: 'description of the template'},
|
||||
{value: 'author', score: 1, meta: 'author of the template'},
|
||||
{value: 'title_prefix', score: 1, meta: 'prefix of instantiated cases'},
|
||||
{value: 'summary', score: 1, meta: 'summary of the case'},
|
||||
{value: 'tags', score: 1, meta: 'tags of the case or the tasks'},
|
||||
{value: 'tasks', score: 1, meta: 'tasks of the case'},
|
||||
{value: 'note_groups', score: 1, meta: 'groups of notes'},
|
||||
{value: 'title', score: 1, meta: 'title of the task or the note group or the note'},
|
||||
{value: 'content', score: 1, meta: 'content of the note'},
|
||||
]);
|
||||
},
|
||||
}],
|
||||
enableLiveAutocompletion: true,
|
||||
enableSnippets: true
|
||||
});
|
||||
|
||||
$('#submit_new_case_template').on("click", function () {
|
||||
update_case_template(ctempl_id, editor, false, false);
|
||||
});
|
||||
|
||||
$('#submit_delete_case_template').on("click", function () {
|
||||
delete_case_template(ctempl_id);
|
||||
});
|
||||
});
|
||||
$('#modal_case_template').modal({ show: true });
|
||||
}
|
||||
|
||||
function update_case_template(ctempl_id, editor, partial, complete){
|
||||
event.preventDefault();
|
||||
|
||||
let data_sent = Object();
|
||||
data_sent['case_template_json'] = editor.getSession().getValue();
|
||||
data_sent['csrf_token'] = $("#csrf_token").val();
|
||||
|
||||
$('#alert_case_template_edit').empty();
|
||||
$('#alert_case_template_details').hide();
|
||||
$('#case_template_err_details_list').empty();
|
||||
|
||||
post_request_api('/manage/case-templates/update/' + ctempl_id, JSON.stringify(data_sent), false, function() {
|
||||
window.swal({
|
||||
title: "Updating...",
|
||||
text: "Please wait",
|
||||
icon: "/static/assets/img/loader.gif",
|
||||
button: false,
|
||||
allowOutsideClick: false
|
||||
});
|
||||
})
|
||||
.done((data) => {
|
||||
notify_auto_api(data);
|
||||
})
|
||||
.fail((error) => {
|
||||
let data = error.responseJSON;
|
||||
$('#submit_new_case_template').text('Update');
|
||||
$('#alert_case_template_edit').text(data.message);
|
||||
if (data.data && data.data.length > 0) {
|
||||
let output='<li>'+ sanitizeHTML(data.data) +'</li>';
|
||||
$('#case_template_err_details_list').append(output);
|
||||
|
||||
$('#alert_case_template_details').show();
|
||||
}
|
||||
$('#alert_case_template_edit').show();
|
||||
})
|
||||
.always((data) => {
|
||||
window.swal.close();
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function fire_upload_case_template() {
|
||||
let url = '/manage/case-templates/upload/modal' + case_param();
|
||||
$('#modal_upload_case_template_json').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
$('#modal_upload_case_template').modal({ show: true });
|
||||
}
|
||||
|
||||
function upload_case_template() {
|
||||
|
||||
if ($("#input_upload_case_template").val() !== "")
|
||||
{
|
||||
var file = $("#input_upload_case_template").get(0).files[0];
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
fileData = e.target.result
|
||||
var data = new Object();
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
data['case_template_json'] = fileData;
|
||||
|
||||
post_request_api('/manage/case-templates/add', JSON.stringify(data), false, function() {
|
||||
window.swal({
|
||||
title: "Adding...",
|
||||
text: "Please wait",
|
||||
icon: "/static/assets/img/loader.gif",
|
||||
button: false,
|
||||
allowOutsideClick: false
|
||||
});
|
||||
})
|
||||
.done((data) => {
|
||||
notify_auto_api(data);
|
||||
jsdata = data;
|
||||
if (jsdata.status == "success") {
|
||||
refresh_case_template_table();
|
||||
$('#modal_upload_case_template').modal('hide');
|
||||
}
|
||||
})
|
||||
.fail((error) => {
|
||||
let data = error.responseJSON;
|
||||
$('#alert_upload_case_template').text(data.message);
|
||||
if (data.data && data.data.length > 0) {
|
||||
|
||||
let output='<li>'+ sanitizeHTML(data.data) +'</li>';
|
||||
$('#upload_case_template_err_details_list').append(output);
|
||||
|
||||
$('#alert_upload_case_template_details').show();
|
||||
}
|
||||
$('#alert_upload_case_template').show();
|
||||
})
|
||||
.always((data) => {
|
||||
$("#input_upload_case_template").val("");
|
||||
window.swal.close();
|
||||
});
|
||||
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function downloadCaseTemplateDefinition() {
|
||||
event.preventDefault();
|
||||
let editor = ace.edit("editor_detail");
|
||||
let data = editor.getSession().getValue();
|
||||
|
||||
let filename = "case_template.json";
|
||||
download_file(filename, 'text/json' , data);
|
||||
}
|
||||
404
iris-web/source/app/static/assets/js/iris/manage.cases.common.js
Normal file
404
iris-web/source/app/static/assets/js/iris/manage.cases.common.js
Normal file
@@ -0,0 +1,404 @@
|
||||
|
||||
function add_protagonist() {
|
||||
prota_html = $('#protagonist_list_edit_template').html();
|
||||
$('#protagonist_list_edit').append(prota_html);
|
||||
}
|
||||
|
||||
function refresh_case_table() {
|
||||
if ($('#cases_table').length === 0) {
|
||||
return false;
|
||||
}
|
||||
$('#cases_table').DataTable().ajax.reload();
|
||||
$('#cases_table').DataTable().columns.adjust().draw();
|
||||
notify_success('Cases list refreshed');
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Create detail modal function */
|
||||
function case_detail(id) {
|
||||
url = 'cases/details/' + id + case_param();
|
||||
$('#info_case_modal_content').load(url, function (response, status, xhr) {
|
||||
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#modal_case_detail').modal({ show: true });
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/* Remove case function */
|
||||
function remove_case(id) {
|
||||
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "You are about to delete this case forever. This cannot be reverted.\nAll associated data will be deleted",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
post_request_api('/manage/cases/delete/' + id)
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data)) {
|
||||
if (!refresh_case_table()) {
|
||||
swal({
|
||||
title: "Done!",
|
||||
text: "You will be redirected in 5 seconds",
|
||||
icon: "success",
|
||||
buttons: false,
|
||||
dangerMode: false
|
||||
})
|
||||
setTimeout(function () {
|
||||
window.location.href = '/dashboard?cid=1';
|
||||
}, 4500);
|
||||
} else {
|
||||
refresh_case_table();
|
||||
$('#modal_case_detail').modal('hide');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Reopen case function */
|
||||
function reopen_case(id) {
|
||||
post_request_api('/manage/cases/reopen/' + id)
|
||||
.done((data) => {
|
||||
if (!refresh_case_table()) {
|
||||
window.location.reload();
|
||||
}
|
||||
$('#modal_case_detail').modal('hide');
|
||||
});
|
||||
}
|
||||
|
||||
/* Close case function */
|
||||
function close_case(id) {
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "Case ID " + id + " will be closed and will not appear in contexts anymore",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, close it!'
|
||||
})
|
||||
.then((willClose) => {
|
||||
if (willClose) {
|
||||
post_request_api('/manage/cases/close/' + id)
|
||||
.done((data) => {
|
||||
if (!refresh_case_table()) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function edit_case_info() {
|
||||
$('#case_gen_info_content').hide();
|
||||
$('#case_gen_info_edit').show();
|
||||
$('#cancel_case_info').show();
|
||||
$('#save_case_info').show();
|
||||
$('#case_info').hide();
|
||||
}
|
||||
|
||||
function cancel_case_edit() {
|
||||
$('#case_gen_info_content').show();
|
||||
$('#case_gen_info_edit').hide();
|
||||
$('#cancel_case_info').hide();
|
||||
$('#case_info').show();
|
||||
$('#save_case_info').hide();
|
||||
}
|
||||
|
||||
function save_case_edit(case_id) {
|
||||
|
||||
var data_sent = $('form#form_update_case').serializeObject();
|
||||
var map_protagonists = Object();
|
||||
|
||||
for (e in data_sent) {
|
||||
if (e.startsWith('protagonist_role_')) {
|
||||
map_protagonists[e.replace('protagonist_role_', '')] = {
|
||||
'role': data_sent[e]
|
||||
};
|
||||
delete data_sent[e];
|
||||
}
|
||||
if (e.startsWith('protagonist_name_')) {
|
||||
map_protagonists[e.replace('protagonist_name_', '')]['name'] = data_sent[e];
|
||||
delete data_sent[e];
|
||||
}
|
||||
if (e.startsWith('protagonist_contact_')) {
|
||||
map_protagonists[e.replace('protagonist_contact_', '')]['contact'] = data_sent[e];
|
||||
delete data_sent[e];
|
||||
}
|
||||
if (e.startsWith('protagonist_id_')) {
|
||||
map_protagonists[e.replace('protagonist_id_', '')]['id'] = data_sent[e];
|
||||
delete data_sent[e];
|
||||
}
|
||||
}
|
||||
data_sent['protagonists'] = [];
|
||||
for (e in map_protagonists) {
|
||||
data_sent['protagonists'].push(map_protagonists[e]);
|
||||
}
|
||||
|
||||
data_sent['case_tags'] = $('#case_tags').val();
|
||||
|
||||
ret = get_custom_attributes_fields();
|
||||
has_error = ret[0].length > 0;
|
||||
attributes = ret[1];
|
||||
|
||||
if (has_error){return false;}
|
||||
|
||||
data_sent['custom_attributes'] = attributes;
|
||||
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
post_request_api('/manage/cases/update/' + case_id, JSON.stringify(data_sent), true, undefined, case_id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
case_detail(case_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function remove_case_access_from_user(user_id, case_id, on_finish) {
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "This user might not be able access this case anymore",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, remove it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
url = '/manage/users/' + user_id + '/case-access/delete';
|
||||
|
||||
var data_sent = Object();
|
||||
data_sent['case'] = case_id;
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
|
||||
post_request_api(url, JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
|
||||
if (on_finish !== undefined) {
|
||||
on_finish();
|
||||
}
|
||||
|
||||
}
|
||||
}).always(() => {
|
||||
window.swal.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var access_levels = [
|
||||
{ "id": 1, "name": "Deny all" },
|
||||
{ "id": 2, "name": "Read only" },
|
||||
{ "id": 4, "name": "Full access" }
|
||||
]
|
||||
|
||||
function get_access_level_options(data) {
|
||||
var options = "";
|
||||
|
||||
for (var i = 0; i < access_levels.length; i++) {
|
||||
options += `<option value="${access_levels[i].id}" ${data == access_levels[i].id ? 'selected' : ''}>${access_levels[i].name}</option>`;
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
function update_user_case_access_level(user_id, case_id, access_level) {
|
||||
var data = {
|
||||
"case_id": parseInt(case_id),
|
||||
"user_id": parseInt(user_id),
|
||||
"access_level": parseInt(access_level),
|
||||
"csrf_token": $('#csrf_token').val()
|
||||
};
|
||||
|
||||
post_request_api('/case/access/set-user', JSON.stringify(data), false, null, case_id)
|
||||
.done((data) => {
|
||||
notify_auto_api(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function view_case_access_via_group(case_id) {
|
||||
url = '/case/groups/access/modal' + case_param();
|
||||
$('#modal_ac_additional').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
$('#modal_ac_additional').modal({ show: true });
|
||||
});
|
||||
}
|
||||
|
||||
function set_case_access_via_group(case_id) {
|
||||
var data = {
|
||||
"case_id": parseInt(case_id),
|
||||
"access_level": parseInt($('#group_case_ac_select').val()),
|
||||
"group_id": parseInt($('#group_case_access_select').val()),
|
||||
"csrf_token": $('#csrf_token').val()
|
||||
};
|
||||
|
||||
post_request_api('/case/access/set-group', JSON.stringify(data))
|
||||
.done((data) => {
|
||||
notify_auto_api(data);
|
||||
access_case_info_reload(case_id);
|
||||
$('#modal_ac_additional').modal('hide');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function access_case_info_reload(case_id, owner_id, reviewer_id) {
|
||||
var req_users = [];
|
||||
|
||||
get_request_api('/case/users/list')
|
||||
.done((data) => {
|
||||
has_table = $.fn.dataTable.isDataTable( '#case_access_users_list_table' );
|
||||
if (!notify_auto_api(data, !has_table)) {
|
||||
return;
|
||||
}
|
||||
|
||||
req_users = data.data;
|
||||
if ( has_table ) {
|
||||
table = $('#case_access_users_list_table').DataTable();
|
||||
table.clear();
|
||||
table.rows.add(req_users);
|
||||
table.draw();
|
||||
} else {
|
||||
addFilterFields($('#case_access_users_list_table').attr("id"));
|
||||
$("#case_access_users_list_table").DataTable({
|
||||
dom: '<"container-fluid"<"row"<"col"l><"col"f>>>rt<"container-fluid"<"row"<"col"i><"col"p>>>',
|
||||
aaData: req_users,
|
||||
aoColumns: [
|
||||
{
|
||||
"data": "user_id",
|
||||
"className": "dt-center"
|
||||
},
|
||||
{
|
||||
"data": "user_name",
|
||||
"className": "dt-center",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "user_login",
|
||||
"className": "dt-center",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "user_access_level",
|
||||
"className": "dt-center",
|
||||
"render": function ( data, type, row ) {
|
||||
return `<select class="form-control" onchange="update_user_case_access_level('${row.user_id}',${case_id},this.value)">${get_access_level_options(data)}</select>`;
|
||||
}
|
||||
}
|
||||
],
|
||||
filter: true,
|
||||
info: true,
|
||||
ordering: true,
|
||||
processing: true,
|
||||
initComplete: function () {
|
||||
tableFiltering(this.api(), 'case_access_users_list_table');
|
||||
}
|
||||
});
|
||||
}
|
||||
let quick_owner = $('#case_quick_owner');
|
||||
let quick_reviewer = $('#case_quick_reviewer');
|
||||
quick_reviewer.append($('<option>'));
|
||||
|
||||
|
||||
for (let i = 0; i < req_users.length; i++) {
|
||||
$('#username-list').append($('<option>', {
|
||||
value: req_users[i].user_name
|
||||
}));
|
||||
$('#emails-list').append($('<option>', {
|
||||
value: req_users[i].user_email
|
||||
}));
|
||||
|
||||
quick_owner.append($('<option>', {
|
||||
value: req_users[i].user_id,
|
||||
text: req_users[i].user_name
|
||||
}));
|
||||
if (req_users[i].user_id == owner_id) {
|
||||
quick_owner.val(req_users[i].user_id);
|
||||
}
|
||||
quick_owner.selectpicker('refresh');
|
||||
quick_reviewer.append($('<option>', {
|
||||
value: req_users[i].user_id,
|
||||
text: req_users[i].user_name
|
||||
}));
|
||||
if (req_users[i].user_id == reviewer_id) {
|
||||
quick_reviewer.val(req_users[i].user_id);
|
||||
}
|
||||
quick_reviewer.selectpicker('refresh');
|
||||
}
|
||||
});
|
||||
|
||||
$('#case_tags').amsifySuggestags({
|
||||
printValues: false,
|
||||
suggestions: []
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function remove_cases_access_user(user_id, cases, on_finish) {
|
||||
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "This user might not be able access these cases anymore",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, remove it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
url = '/manage/users/' + user_id + '/cases-access/delete';
|
||||
|
||||
var data_sent = Object();
|
||||
data_sent['cases'] = cases;
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
|
||||
post_request_api(url, JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_user_cac(user_id);
|
||||
|
||||
if (on_finish !== undefined) {
|
||||
on_finish();
|
||||
}
|
||||
|
||||
}
|
||||
}).always(() => {
|
||||
window.swal.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
239
iris-web/source/app/static/assets/js/iris/manage.cases.js
Normal file
239
iris-web/source/app/static/assets/js/iris/manage.cases.js
Normal file
@@ -0,0 +1,239 @@
|
||||
/*************************
|
||||
* Case creation section
|
||||
*************************/
|
||||
|
||||
/* create the select picker for customer */
|
||||
$('#case_customer').selectpicker({
|
||||
liveSearch: true,
|
||||
title: "Select customer *",
|
||||
style: "btn-outline-white",
|
||||
size: 8
|
||||
});
|
||||
$('#case_template_id').selectpicker({
|
||||
liveSearch: true,
|
||||
title: "Select case template",
|
||||
style: "btn-outline-white",
|
||||
size: 8
|
||||
});
|
||||
$('#case_template_id').prepend(new Option('', ''));
|
||||
$('#classification_id').selectpicker({
|
||||
liveSearch: true,
|
||||
title: "Select classification",
|
||||
style: "btn-outline-white",
|
||||
size: 8
|
||||
});
|
||||
$('#classification_id').prepend(new Option('', ''));
|
||||
|
||||
|
||||
/* Submit event handler for new case */
|
||||
function submit_new_case() {
|
||||
|
||||
if(!$('form#form_new_case').valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var data_sent = $('form#form_new_case').serializeObject();
|
||||
ret = get_custom_attributes_fields();
|
||||
has_error = ret[0].length > 0;
|
||||
attributes = ret[1];
|
||||
|
||||
if (has_error){return false;}
|
||||
|
||||
data_sent['custom_attributes'] = attributes;
|
||||
|
||||
send_add_case(data_sent);
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
function send_add_case(data_sent) {
|
||||
|
||||
post_request_api('/manage/cases/add', JSON.stringify(data_sent), true, function () {
|
||||
$('#submit_new_case_btn').text('Checking data..')
|
||||
.attr("disabled", true)
|
||||
.removeClass('bt-outline-success')
|
||||
.addClass('btn-success', 'text-dark');
|
||||
})
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data, true)) {
|
||||
case_id = data.data.case_id;
|
||||
swal("That's done !",
|
||||
"Case has been successfully created",
|
||||
"success",
|
||||
{
|
||||
buttons: {
|
||||
again: {
|
||||
text: "Create a case again",
|
||||
value: "again",
|
||||
dangerMode: true,
|
||||
color: '#d33'
|
||||
},
|
||||
dash: {
|
||||
text: "Go to dashboard",
|
||||
value: "dash",
|
||||
color: '#d33'
|
||||
},
|
||||
go_case: {
|
||||
text: "Switch to newly created case",
|
||||
value: "go_case"
|
||||
}
|
||||
}
|
||||
}
|
||||
).then((value) => {
|
||||
switch (value) {
|
||||
|
||||
case "dash":
|
||||
window.location.replace("/dashboard" + case_param());
|
||||
break;
|
||||
|
||||
case "again":
|
||||
window.location.replace("/manage/cases" + case_param());
|
||||
break;
|
||||
|
||||
case 'go_case':
|
||||
window.location.replace("/case?cid=" + case_id);
|
||||
|
||||
default:
|
||||
window.location.replace("/case?cid=" + case_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.always(() => {
|
||||
$('#submit_new_case_btn')
|
||||
.attr("disabled", false)
|
||||
.addClass('bt-outline-success')
|
||||
.removeClass('btn-success', 'text-dark');
|
||||
})
|
||||
.fail(() => {
|
||||
$('#submit_new_case_btn').text('Save');
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/*************************
|
||||
* Case list section
|
||||
*************************/
|
||||
/* case table creation */
|
||||
$.each($.find("table"), function(index, element){
|
||||
addFilterFields($(element).attr("id"));
|
||||
});
|
||||
$('#cases_table').dataTable({
|
||||
"ajax": {
|
||||
"url": "cases/list" + case_param(),
|
||||
"contentType": "application/json",
|
||||
"type": "GET",
|
||||
"data": function (d) {
|
||||
if (d.status == 'success') {
|
||||
return JSON.stringify(d.data);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
"columns": [
|
||||
{
|
||||
"render": function (data, type, row) {
|
||||
data = sanitizeHTML(data);
|
||||
return '<a href="#" onclick="case_detail(\'' + row['case_id'] + '\');">' + data + '</a>';
|
||||
},
|
||||
"data": "case_name"
|
||||
},
|
||||
{
|
||||
"data": "case_description",
|
||||
"render": function (data, type, row) {
|
||||
if (type === 'display' && data != null) {
|
||||
if (row["case_description"].length > 50){
|
||||
return sanitizeHTML(row["case_description"].slice(0,50)) + " ... " ;
|
||||
}
|
||||
else {
|
||||
return sanitizeHTML(row["case_description"]);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
},
|
||||
{
|
||||
"data": "client_name",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "state_name",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "case_open_date",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
},
|
||||
"type": "date"
|
||||
},
|
||||
{
|
||||
"data": "case_close_date",
|
||||
"type": "date",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "case_soc_id",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "opened_by",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
],
|
||||
dom: '<"container-fluid"<"row"<"col"l><"col"f>>>rt<"container-fluid"<"row"<"col"i><"col"p>>>',
|
||||
filter: true,
|
||||
info: true,
|
||||
ordering: true,
|
||||
processing: true,
|
||||
retrieve: true,
|
||||
lengthChange: true,
|
||||
pageLength: 25,
|
||||
select: true,
|
||||
sort: true,
|
||||
responsive: {
|
||||
details: {
|
||||
display: $.fn.dataTable.Responsive.display.childRow,
|
||||
renderer: $.fn.dataTable.Responsive.renderer.tableAll()
|
||||
}
|
||||
},
|
||||
initComplete: function () {
|
||||
tableFiltering(this.api(), 'cases_table');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
if ($('.nav-tabs').length > 0) { // if .nav-tabs exists
|
||||
var hashtag = window.location.hash;
|
||||
if (hashtag!='') {
|
||||
$('.nav-item > a').removeClass('active').removeClass('show');
|
||||
$('.nav-item > a[href="'+hashtag+'"]').addClass('active');
|
||||
$('.nav-item > a[href="'+hashtag+'"]').addClass('show');
|
||||
$('.tab-content > div').removeClass('active');
|
||||
$(hashtag).addClass('active'); $(hashtag).addClass('show');
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
148
iris-web/source/app/static/assets/js/iris/manage.customers.js
Normal file
148
iris-web/source/app/static/assets/js/iris/manage.customers.js
Normal file
@@ -0,0 +1,148 @@
|
||||
const preventFormDefaultBehaviourOnSubmit = (event) => {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
};
|
||||
|
||||
function add_customer() {
|
||||
const url = 'customers/add/modal' + case_param();
|
||||
$('#modal_add_customer_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
$('#form_new_customer').on("submit", preventFormDefaultBehaviourOnSubmit);
|
||||
$('#submit_new_customer').on("click", function () {
|
||||
const form = $('#form_new_customer').serializeObject();
|
||||
|
||||
ret = get_custom_attributes_fields();
|
||||
has_error = ret[0].length > 0;
|
||||
attributes = ret[1];
|
||||
|
||||
if (has_error){return false;}
|
||||
|
||||
form['custom_attributes'] = attributes;
|
||||
|
||||
post_request_api('customers/add', JSON.stringify(form), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_customer_table();
|
||||
$('#modal_add_customer').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
});
|
||||
$('#modal_add_customer').modal({show: true});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
cid = case_param();
|
||||
$('#customers_table').dataTable({
|
||||
"ajax": {
|
||||
"url": "customers/list" + cid,
|
||||
"contentType": "application/json",
|
||||
"type": "GET",
|
||||
"data": function (d) {
|
||||
if (d.status == 'success') {
|
||||
return JSON.stringify(d.data);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
"order": [[0, "desc"]],
|
||||
"autoWidth": false,
|
||||
"columns": [
|
||||
{
|
||||
"data": "customer_name",
|
||||
"render": function (data, type, row) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
return '<a href="/manage/customers/' + row['customer_id'] + '/view'+ cid +'">' + data + '</a>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "customer_description",
|
||||
"render": function (data, type, row) {
|
||||
if (type === 'display') {
|
||||
return sanitizeHTML(data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function refresh_customer_table(do_notify) {
|
||||
$('#customers_table').DataTable().ajax.reload();
|
||||
if (do_notify !== undefined) {
|
||||
notify_success("Refreshed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Fetch the details of an asset and allow modification */
|
||||
function customer_detail(customer_id) {
|
||||
url = '/manage/customers/update/' + customer_id + '/modal' + case_param();
|
||||
$('#modal_add_customer_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#form_new_customer').on("submit", preventFormDefaultBehaviourOnSubmit);
|
||||
$('#submit_new_customer').on("click", function () {
|
||||
|
||||
const form = $('#form_new_customer').serializeObject();
|
||||
ret = get_custom_attributes_fields();
|
||||
has_error = ret[0].length > 0;
|
||||
attributes = ret[1];
|
||||
|
||||
if (has_error){return false;}
|
||||
|
||||
form['custom_attributes'] = attributes;
|
||||
|
||||
post_request_api('/manage/customers/update/' + customer_id, JSON.stringify(form), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
$('#modal_add_customer').modal({show: true});
|
||||
}
|
||||
|
||||
function delete_customer(id) {
|
||||
swal({
|
||||
title: "Are you sure ?",
|
||||
text: "You won't be able to revert this !",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
post_request_api('/manage/customers/delete/' + id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
window.location.href = '/manage/customers' + case_param();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
349
iris-web/source/app/static/assets/js/iris/manage.groups.js
Normal file
349
iris-web/source/app/static/assets/js/iris/manage.groups.js
Normal file
@@ -0,0 +1,349 @@
|
||||
var modal_group_table;
|
||||
var current_groups_list;
|
||||
manage_groups_table = $('#groups_table').dataTable( {
|
||||
"order": [[ 1, "asc" ]],
|
||||
"autoWidth": true,
|
||||
"columns": [
|
||||
{
|
||||
"data": "group_id",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data)
|
||||
return '<a href="#" onclick="group_detail(\'' + row["group_id"] + '\');">' + data +'</a>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "group_name",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data)
|
||||
return '<a href="#" onclick="group_detail(\'' + row["group_id"] + '\');">' + data +'</a>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "group_description",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "group_permissions_list",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
tags = "";
|
||||
for (perm in data) {
|
||||
permstr = sanitizeHTML(data[perm].name);
|
||||
tags += '<span class="badge badge-pill badge-light" title="Value 0x'+ data[perm].value.toString(16) +'">'+ permstr + '</span> ';
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "group_members",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') {
|
||||
return data.length;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
function refresh_groups(do_notify) {
|
||||
|
||||
get_request_api('groups/list')
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data, true)) {
|
||||
current_groups_list = data.data;
|
||||
manage_groups_table.api().clear().rows.add(data.data).draw();
|
||||
|
||||
if (do_notify !== undefined) {
|
||||
notify_success("Refreshed");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Fetch the details of an user and allow modification */
|
||||
function group_detail(group_id) {
|
||||
url = 'groups/' + group_id + '/modal' + case_param();
|
||||
$('#modal_access_control').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#submit_new_group').on("click", function () {
|
||||
clear_api_error();
|
||||
|
||||
var data_sent = $('#form_new_group').serializeObject();
|
||||
post_request_api('/manage/groups/update/' + group_id, JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_groups();
|
||||
$('#modal_access_control').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
$('#modal_access_control').modal({ show: true });
|
||||
}
|
||||
|
||||
function add_group() {
|
||||
url = '/manage/groups/add/modal' + case_param();
|
||||
$('#modal_access_control').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#submit_new_group').on("click", function () {
|
||||
clear_api_error();
|
||||
var data_sent = $('#form_new_group').serializeObject();
|
||||
post_request_api('/manage/groups/add', JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_groups();
|
||||
$('#modal_access_control').modal('hide');
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#modal_access_control').modal({ show: true });
|
||||
});
|
||||
}
|
||||
|
||||
function delete_group(id) {
|
||||
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "You won't be able to revert this!\nPlease make sure a group remains with enough rights to avoid a lockdown!",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
var data_sent = {
|
||||
"csrf_token": $('#csrf_token').val()
|
||||
}
|
||||
post_request_api('/manage/groups/delete/' + id, JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_groups();
|
||||
$('#modal_access_control').modal('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function remove_members_from_group(group_id, user_id, on_finish) {
|
||||
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "This will remove the user from the group",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, remove it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
url = '/manage/groups/' + group_id + '/members/delete/' + user_id;
|
||||
var data_sent = {
|
||||
"csrf_token": $('#csrf_token').val()
|
||||
}
|
||||
post_request_api(url, JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_groups();
|
||||
refresh_group_members(group_id);
|
||||
|
||||
if (on_finish !== undefined) {
|
||||
on_finish();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function add_members_to_group(group_id) {
|
||||
url = 'groups/' + group_id + '/members/modal' + case_param();
|
||||
$('#modal_ac_additional').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#save_group_members').on("click", function () {
|
||||
clear_api_error();
|
||||
|
||||
var data_sent = Object();
|
||||
data_sent['group_members'] = $('#group_members').val();
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
post_request_api('groups/' + group_id + '/members/update', JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_groups();
|
||||
refresh_group_members(group_id);
|
||||
$('#modal_ac_additional').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
$('#modal_ac_additional').modal({ show: true });
|
||||
});
|
||||
}
|
||||
|
||||
function refresh_group_members(group_id) {
|
||||
if (modal_group_table !== undefined) {
|
||||
get_request_api('/manage/groups/' + group_id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
modal_group_table.clear();
|
||||
modal_group_table.rows.add(data.data.group_members).draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function refresh_group_cac(group_id) {
|
||||
if (modal_group_cac_table !== undefined) {
|
||||
get_request_api('/manage/groups/' + group_id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
current_group_cases_access_list = data.data.group_cases_access;
|
||||
modal_group_cac_table.clear();
|
||||
modal_group_cac_table.rows.add(current_group_cases_access_list).draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function manage_group_cac(group_id) {
|
||||
url = 'groups/' + group_id + '/cases-access/modal' + case_param();
|
||||
|
||||
$('#manage_group_cac_button').text('Loading manager...');
|
||||
|
||||
$('#modal_ac_additional').load(url, function (response, status, xhr) {
|
||||
$('#manage_group_cac_button').text('Set case access');
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#grant_case_access_to_group').on("click", function () {
|
||||
clear_api_error();
|
||||
|
||||
var data_sent = Object();
|
||||
data_sent['access_level'] = parseInt($('#group_case_ac_select').val());
|
||||
data_sent['cases_list'] = $('#group_case_access_select').val();
|
||||
data_sent['auto_follow_cases'] = $('#enable_auto_follow_cases').is(':checked');
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
window.swal({
|
||||
title: "Updating access",
|
||||
text: "Please wait. We are updating users access.",
|
||||
icon: "/static/assets/img/loader_cubes.gif",
|
||||
button: false,
|
||||
allowOutsideClick: false
|
||||
});
|
||||
|
||||
post_request_api('groups/' + group_id + '/cases-access/update', JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_group_cac(group_id);
|
||||
$('#modal_ac_additional').modal('hide');
|
||||
}
|
||||
})
|
||||
.always(() => {
|
||||
window.swal.close();
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
$('#modal_ac_additional').modal({ show: true });
|
||||
});
|
||||
}
|
||||
|
||||
function remove_case_access_from_group(group_id, case_id, on_finish) {
|
||||
remove_cases_access_group(group_id, [case_id], on_finish);
|
||||
}
|
||||
|
||||
function remove_group_cases_from_group_table(group_id, rows) {
|
||||
cases = [];
|
||||
for (cid in rows) {
|
||||
cases.push(rows[cid].case_id);
|
||||
}
|
||||
remove_cases_access_group(group_id, cases);
|
||||
}
|
||||
|
||||
function remove_cases_access_group(group_id, cases, on_finish) {
|
||||
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "Members of this group won't be able to access these cases anymore",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, remove them!'
|
||||
}).then((willDelete) => {
|
||||
if (willDelete) {
|
||||
url = '/manage/groups/' + group_id + '/cases-access/delete';
|
||||
|
||||
window.swal({
|
||||
title: "Updating access",
|
||||
text: "Please wait. We are updating users access.",
|
||||
icon: "/static/assets/img/loader_cubes.gif",
|
||||
button: false,
|
||||
allowOutsideClick: false
|
||||
});
|
||||
var data_sent = Object();
|
||||
data_sent['cases'] = cases;
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
post_request_api(url, JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_group_cac(group_id);
|
||||
if (on_finish !== undefined) {
|
||||
on_finish();
|
||||
}
|
||||
}
|
||||
})
|
||||
.always(() => {
|
||||
window.swal.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
refresh_groups();
|
||||
});
|
||||
371
iris-web/source/app/static/assets/js/iris/manage.modules.js
Normal file
371
iris-web/source/app/static/assets/js/iris/manage.modules.js
Normal file
@@ -0,0 +1,371 @@
|
||||
$('#form_new_module').submit(function () {
|
||||
|
||||
post_request_api('/manage/modules/add', $('form#form_new_module').serializeArray(), function() {
|
||||
$('#submit_new_module').text('Saving..')
|
||||
.attr("disabled", true)
|
||||
.removeClass('bt-outline-success')
|
||||
.addClass('btn-success', 'text-dark');
|
||||
})
|
||||
.done((data) => {
|
||||
notify_auto_api(data);
|
||||
})
|
||||
.always(() => {
|
||||
$('#submit_new_module')
|
||||
.attr("disabled", false)
|
||||
.addClass('bt-outline-success')
|
||||
.removeClass('btn-success', 'text-dark');
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
function add_module() {
|
||||
url = 'modules/add/modal' + case_param();
|
||||
$('#modal_add_module_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#submit_new_module').on("click", function () {
|
||||
|
||||
post_request_api('modules/add', JSON.stringify($('#form_new_module').serializeObject()), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_modules(true);
|
||||
refresh_modules_hooks(true);
|
||||
$('#modal_add_module').modal('hide');
|
||||
} else {
|
||||
$('#alert_mod_add').text(data.message);
|
||||
if (data.data) {
|
||||
$('#details_list').empty();
|
||||
for(var i in data.data)
|
||||
{
|
||||
var output='<li>'+data.data[i]+'</li>';
|
||||
$('#details_list').append(output);
|
||||
}
|
||||
|
||||
$('#alert_mod_details').show();
|
||||
}
|
||||
$('#alert_mod_add').show();
|
||||
$('#submit_new_module').text("Retry");
|
||||
}
|
||||
})
|
||||
.fail((error) => {
|
||||
data = error.responseJSON;
|
||||
$('#submit_new_module').text('Save');
|
||||
$('#alert_mod_add').text(data.message);
|
||||
if (data.data && data.data.length > 0) {
|
||||
$('#details_list').empty();
|
||||
for(var i in data.data)
|
||||
{
|
||||
var output='<li>'+data.data[i]+'</li>';
|
||||
$('#details_list').append(output);
|
||||
}
|
||||
|
||||
$('#alert_mod_details').show();
|
||||
}
|
||||
$('#alert_mod_add').show();
|
||||
$('#submit_new_module').text("Retry");
|
||||
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
});
|
||||
$('#modal_add_module').modal({ show: true });
|
||||
}
|
||||
|
||||
$('#modules_table').dataTable( {
|
||||
"ajax": {
|
||||
"url": "modules/list" + case_param(),
|
||||
"contentType": "application/json",
|
||||
"type": "GET",
|
||||
"data": function ( d ) {
|
||||
if (d.status == 'success') {
|
||||
return JSON.stringify( d.data );
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
"order": [[ 1, "asc" ]],
|
||||
"autoWidth": false,
|
||||
"columns": [
|
||||
{ 'data': 'id'},
|
||||
{ 'data': 'module_human_name'},
|
||||
{ 'data': 'has_pipeline',
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
} },
|
||||
{ 'data': 'module_version',
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
} },
|
||||
{ 'data': 'interface_version',
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
} },
|
||||
{ 'data': 'date_added',
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
} },
|
||||
{ 'data': 'name',
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
} },
|
||||
{ 'data': 'is_active'},
|
||||
|
||||
],
|
||||
"columnDefs": [
|
||||
{
|
||||
"render": function ( data, type, row ) {
|
||||
data = sanitizeHTML(data);
|
||||
return '<a href="#" onclick="module_detail(\'' + row['id'] + '\');">' + data +'</a>';
|
||||
},
|
||||
"targets": [0, 1]
|
||||
},
|
||||
{
|
||||
"render": function ( data, type, row ) {
|
||||
if (data == true) {
|
||||
data = '<i class="fas fa-check text-success"></i>';
|
||||
} else {
|
||||
data = '<i class="fas fa-times text-warning"></i>';
|
||||
}
|
||||
if (row['configured'] == false) {
|
||||
return data + ' <i class="fas fa-exclamation-triangle text-warning" data-toggle="tooltip" data-placement="top" title="Module was disabled because mandatory settings are not set. Please configure to activate."></i>'
|
||||
} else { return data; }
|
||||
},
|
||||
"targets": [7]
|
||||
}
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
function refresh_modules(silent) {
|
||||
$('#modules_table').DataTable().ajax.reload();
|
||||
$(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
})
|
||||
if (silent === undefined || silent !== true) {
|
||||
notify_success("Modules refreshed");
|
||||
}
|
||||
}
|
||||
|
||||
$('#hooks_table').dataTable( {
|
||||
"ajax": {
|
||||
"url": "modules/hooks/list" + case_param(),
|
||||
"contentType": "application/json",
|
||||
"type": "GET",
|
||||
"data": function ( d ) {
|
||||
if (d.status == 'success') {
|
||||
return JSON.stringify( d.data );
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
"order": [[ 1, "asc" ]],
|
||||
"autoWidth": false,
|
||||
"columns": [
|
||||
{ 'data': 'id'},
|
||||
{ 'data': 'module_name',
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
} },
|
||||
{ 'data': 'hook_name',
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
} },
|
||||
{ 'data': 'hook_description',
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
} },
|
||||
{ 'data': 'is_manual_hook',
|
||||
"render": function (data, type, row, meta) {
|
||||
if (data == false) {
|
||||
data = "<i class='fas fa-check text-success'></i>";
|
||||
} else {
|
||||
data = "<i class='fas fa-times text-muted'></i>";
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ 'data': 'is_active',
|
||||
"render": function (data, type, row, meta) {
|
||||
if (data == true) {
|
||||
data = "<i class='fas fa-check text-success'></i>";
|
||||
} else {
|
||||
data = "<i class='fas fa-times text-muted'></i>";
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
function refresh_modules_hooks(silent) {
|
||||
$('#hooks_table').DataTable().ajax.reload();
|
||||
if (silent === undefined || silent !== true) {
|
||||
notify_success("Hooks refreshed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function export_mod_config(module_id) {
|
||||
get_request_api('/manage/modules/export-config/' + module_id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data, true)) {
|
||||
download_file(data.data.module_name + "_configuration_export.json", "text/json",
|
||||
JSON.stringify(data.data.module_configuration, null, 4));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function import_mod_config(module_id){
|
||||
|
||||
var file = $("#input_configuration_file").get(0).files[0];
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
fileData = e.target.result
|
||||
var data = new Object();
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
data['module_configuration'] = fileData;
|
||||
|
||||
post_request_api('/manage/modules/import-config/'+ module_id, JSON.stringify(data), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data, true)) {
|
||||
module_detail(module_id);
|
||||
$('#modal_input_config').modal('hide');
|
||||
swal("Got news for you", data.message, "success");
|
||||
} else {
|
||||
swal("Got bad news for you", data.data, "error");
|
||||
}
|
||||
});
|
||||
};
|
||||
reader.readAsText(file)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Update the param of a module */
|
||||
function update_param(module_id, param_name) {
|
||||
url = 'modules/get-parameter/' + decodeURIComponent(escape(window.btoa(param_name))) + case_param();
|
||||
$('#modal_update_param_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
$('#submit_save_parameter').on("click", function () {
|
||||
var data = Object();
|
||||
if ($('#editor_detail').length != 0) {
|
||||
editor = ace.edit("editor_detail");
|
||||
data['parameter_value'] = editor.getSession().getValue();
|
||||
data['csrf_token'] = $('#csrf_token').val();
|
||||
} else {
|
||||
data = $('#form_update_param').serializeObject();
|
||||
if ($('#parameter_value').attr('type') == "checkbox") {
|
||||
data['parameter_value'] = $('#parameter_value').prop('checked');
|
||||
}
|
||||
}
|
||||
|
||||
post_request_api('modules/set-parameter/' + decodeURIComponent(escape(window.btoa(param_name))), JSON.stringify(data))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
module_detail(module_id);
|
||||
refresh_modules(true);
|
||||
$('#modal_update_param').modal('hide');
|
||||
}
|
||||
})
|
||||
|
||||
return false;
|
||||
})
|
||||
});
|
||||
$('#modal_update_param').modal({ show: true });
|
||||
}
|
||||
|
||||
/* Fetch the details of an module and allow modification */
|
||||
function module_detail(module_id) {
|
||||
url = 'modules/update/' + module_id + '/modal' + case_param();
|
||||
$('#modal_add_module_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#submit_new_module').on("click", function () {
|
||||
post_request_api('modules/update/' + module_id, $('#form_new_module').serializeArray())
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
module_detail(module_id);
|
||||
$('#modal_update_param').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
|
||||
});
|
||||
$('#modal_add_module').modal({ show: true });
|
||||
}
|
||||
|
||||
function remove_module(id) {
|
||||
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "Please note this will only remove the reference of the module in Iris. The module will stay installed on the server.",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, remove it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
post_request_api('/manage/modules/remove/' + id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_modules(true);
|
||||
refresh_modules_hooks(true);
|
||||
$('#modal_add_module').modal('hide');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function enable_module(module_id) {
|
||||
post_request_api('modules/enable/' + module_id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_modules(true);
|
||||
refresh_modules_hooks(true);
|
||||
module_detail(module_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function disable_module(module_id) {
|
||||
post_request_api('modules/disable/' + module_id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_modules(true);
|
||||
refresh_modules_hooks(true);
|
||||
module_detail(module_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
538
iris-web/source/app/static/assets/js/iris/manage.objects.js
Normal file
538
iris-web/source/app/static/assets/js/iris/manage.objects.js
Normal file
@@ -0,0 +1,538 @@
|
||||
function add_asset_type() {
|
||||
url = '/manage/asset-type/add/modal' + case_param();
|
||||
$('#modal_add_type_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
$('#form_new_asset_type').submit("click", function (event) {
|
||||
|
||||
|
||||
event.preventDefault();
|
||||
var formData = new FormData(this);
|
||||
|
||||
url = '/manage/asset-type/add' + case_param();
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "POST",
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
if(notify_auto_api(data, true)) {
|
||||
refresh_asset_table();
|
||||
$('#modal_add_type').modal('hide');
|
||||
}
|
||||
},
|
||||
error: function (error) {
|
||||
$('#modal_add_type').text('Save');
|
||||
propagate_form_api_errors(error.responseJSON.data);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
$('#modal_add_type').modal({ show: true });
|
||||
})};
|
||||
|
||||
$('#assets_table').dataTable( {
|
||||
"ajax": {
|
||||
"url": "/manage/asset-type/list" + case_param(),
|
||||
"contentType": "application/json",
|
||||
"type": "GET",
|
||||
"data": function ( d ) {
|
||||
if (d.status == 'success') {
|
||||
return JSON.stringify( d.data );
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
"order": [[ 0, "desc" ]],
|
||||
"autoWidth": false,
|
||||
"columns": [
|
||||
{
|
||||
"data": "asset_name",
|
||||
"render": function ( data, type, row ) {
|
||||
return '<a href="#" onclick="assettype_detail(\'' + row['asset_id'] + '\');">' + sanitizeHTML(data) +'</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "asset_description",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "asset_icon_not_compromised_path",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return '<img style="width:2em;height:2em" src=\'' + data + '\'>';
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "asset_icon_compromised_path",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return '<img style="width:2em;height:2em" src=\'' + data + '\'>';
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
function refresh_asset_table() {
|
||||
$('#assets_table').DataTable().ajax.reload();
|
||||
notify_success("Refreshed");
|
||||
}
|
||||
|
||||
|
||||
/* Fetch the details of an asset and allow modification */
|
||||
function assettype_detail(asset_id) {
|
||||
url = '/manage/asset-type/update/' + asset_id + '/modal' + case_param();
|
||||
$('#modal_add_type_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#form_new_asset_type').submit("click", function (event) {
|
||||
event.preventDefault();
|
||||
var formData = new FormData(this);
|
||||
|
||||
url = '/manage/asset-type/update/' + asset_id + case_param();
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "POST",
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
if(notify_auto_api(data, true)) {
|
||||
refresh_asset_table();
|
||||
$('#modal_add_type').modal('hide');
|
||||
}
|
||||
},
|
||||
error: function (jqXHR) {
|
||||
if(jqXHR.responseJSON && jqXHR.status == 400) {
|
||||
propagate_form_api_errors(jqXHR.responseJSON.data);
|
||||
} else {
|
||||
ajax_notify_error(jqXHR, this.url);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
$('#modal_add_type').modal({ show: true });
|
||||
});
|
||||
}
|
||||
|
||||
function delete_asset_type(id) {
|
||||
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "You won't be able to revert this !",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
post_request_api('/manage/asset-type/delete/' + id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_asset_table();
|
||||
$('#modal_add_type').modal('hide');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*** IOC Type ***/
|
||||
|
||||
function add_ioc_type() {
|
||||
let url = '/manage/ioc-types/add/modal' + case_param();
|
||||
$('#modal_add_type_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#submit_new_ioc_type').on("click", function () {
|
||||
var form = $('form#form_new_ioc_type').serializeObject();
|
||||
|
||||
post_request_api('/manage/ioc-types/add', JSON.stringify(form), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_ioc_table();
|
||||
$('#modal_add_type').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
$('#modal_add_type').modal({ show: true });
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$('#ioc_table').dataTable({
|
||||
"ajax": {
|
||||
"url": "/manage/ioc-types/list" + case_param(),
|
||||
"contentType": "application/json",
|
||||
"type": "GET",
|
||||
"data": function ( d ) {
|
||||
if (d.status == 'success') {
|
||||
return JSON.stringify( d.data );
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
"order": [[ 0, "asc" ]],
|
||||
"autoWidth": false,
|
||||
"columns": [
|
||||
{
|
||||
"data": "type_name",
|
||||
"render": function ( data, type, row ) {
|
||||
return '<a href="#" onclick="ioc_type_detail(\'' + row['type_id'] + '\');">' + sanitizeHTML(data) +'</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "type_description",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "type_taxonomy",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "type_validation_regex",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
function refresh_ioc_table() {
|
||||
$('#ioc_table').DataTable().ajax.reload();
|
||||
notify_success("Refreshed");
|
||||
}
|
||||
|
||||
|
||||
/* Fetch the details of an asset and allow modification */
|
||||
function ioc_type_detail(ioc_id) {
|
||||
url = '/manage/ioc-types/update/' + ioc_id + '/modal' + case_param();
|
||||
$('#modal_add_type_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#submit_new_ioc_type').on("click", function () {
|
||||
var form = $('form#form_new_ioc_type').serializeObject();
|
||||
|
||||
post_request_api('/manage/ioc-types/update/' + ioc_id, JSON.stringify(form), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_ioc_table();
|
||||
$('#modal_add_type').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
$('#modal_add_type').modal({ show: true });
|
||||
}
|
||||
function delete_ioc_type(id) {
|
||||
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "You won't be able to revert this !",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
post_request_api('/manage/ioc-types/delete/' + id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_ioc_table();
|
||||
$('#modal_add_type').modal('hide');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*** Classification ***/
|
||||
|
||||
function add_classification() {
|
||||
url = '/manage/case-classifications/add/modal' + case_param();
|
||||
$('#modal_add_type_content').load(url, function () {
|
||||
|
||||
$('#submit_new_case_classification').on("click", function () {
|
||||
var form = $('form#form_new_case_classification').serializeObject();
|
||||
|
||||
post_request_api('/manage/case-classifications/add', JSON.stringify(form), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_classification_table();
|
||||
$('#modal_add_type').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
});
|
||||
$('#modal_add_type').modal({ show: true });
|
||||
}
|
||||
|
||||
$('#classification_table').dataTable({
|
||||
"ajax": {
|
||||
"url": "/manage/case-classifications/list" + case_param(),
|
||||
"contentType": "application/json",
|
||||
"type": "GET",
|
||||
"data": function ( d ) {
|
||||
if (d.status == 'success') {
|
||||
return JSON.stringify( d.data );
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
"order": [[ 0, "asc" ]],
|
||||
"autoWidth": false,
|
||||
"columns": [
|
||||
{
|
||||
"data": "name",
|
||||
"render": function ( data, type, row ) {
|
||||
return '<a href="#" onclick="classification_detail(\'' + row['id'] + '\');">' + sanitizeHTML(data) +'</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "name_expanded",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "description",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
function refresh_classification_table() {
|
||||
$('#classification_table').DataTable().ajax.reload();
|
||||
notify_success("Refreshed");
|
||||
}
|
||||
|
||||
/* Fetch the details of an classification and allow modification */
|
||||
function classification_detail(ioc_id) {
|
||||
url = '/manage/case-classifications/update/' + ioc_id + '/modal' + case_param();
|
||||
$('#modal_add_type_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#submit_new_case_classification').on("click", function () {
|
||||
var form = $('form#form_new_case_classification').serializeObject();
|
||||
|
||||
post_request_api('/manage/case-classifications/update/' + ioc_id, JSON.stringify(form), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_classification_table();
|
||||
$('#modal_add_type').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
$('#modal_add_type').modal({ show: true });
|
||||
}
|
||||
function delete_case_classification(id) {
|
||||
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "You won't be able to revert this !",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
post_request_api('/manage/case-classifications/delete/' + id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_classification_table();
|
||||
$('#modal_add_type').modal('hide');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*** State ***/
|
||||
|
||||
function add_state() {
|
||||
url = '/manage/case-states/add/modal' + case_param();
|
||||
$('#modal_add_type_content').load(url, function () {
|
||||
|
||||
$('#submit_new_case_state').on("click", function () {
|
||||
var form = $('form#form_new_case_state').serializeObject();
|
||||
|
||||
post_request_api('/manage/case-states/add', JSON.stringify(form), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_state_table();
|
||||
$('#modal_add_type').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
});
|
||||
$('#modal_add_type').modal({ show: true });
|
||||
}
|
||||
|
||||
$('#state_table').dataTable({
|
||||
"ajax": {
|
||||
"url": "/manage/case-states/list" + case_param(),
|
||||
"contentType": "application/json",
|
||||
"type": "GET",
|
||||
"data": function ( d ) {
|
||||
if (d.status == 'success') {
|
||||
return JSON.stringify( d.data );
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
"order": [[ 0, "asc" ]],
|
||||
"autoWidth": false,
|
||||
"columns": [
|
||||
{
|
||||
"data": "state_name",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') {
|
||||
if (row['protected'] === true) {
|
||||
return '<span href="#" "><i class="fa fa-lock mr-2" title="Protected state"></i>' + sanitizeHTML(data) + '</span>';
|
||||
}
|
||||
return '<a href="#" onclick="state_detail(\'' + row['state_id'] + '\');">' + sanitizeHTML(data) + '</a>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "state_description",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
function refresh_state_table() {
|
||||
$('#state_table').DataTable().ajax.reload();
|
||||
notify_success("Refreshed");
|
||||
}
|
||||
|
||||
/* Fetch the details of an state and allow modification */
|
||||
function state_detail(ioc_id) {
|
||||
url = '/manage/case-states/update/' + ioc_id + '/modal' + case_param();
|
||||
$('#modal_add_type_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#submit_new_case_state').on("click", function () {
|
||||
var form = $('form#form_new_case_state').serializeObject();
|
||||
|
||||
post_request_api('/manage/case-states/update/' + ioc_id, JSON.stringify(form))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_state_table();
|
||||
$('#modal_add_type').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
$('#modal_add_type').modal({ show: true });
|
||||
}
|
||||
function delete_case_state(id) {
|
||||
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "You won't be able to revert this !",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
post_request_api('/manage/case-states/delete/' + id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_state_table();
|
||||
$('#modal_add_type').modal('hide');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
function update_settings() {
|
||||
var data_sent = $('form#form_srv_settings').serializeObject();
|
||||
data_sent['prevent_post_mod_repush'] = $('#prevent_post_mod_repush').is(":checked");
|
||||
data_sent['prevent_post_objects_repush'] = $('#prevent_post_objects_repush').is(":checked");
|
||||
data_sent['password_policy_upper_case'] = $('#password_policy_upper_case').is(":checked");
|
||||
data_sent['password_policy_lower_case'] = $('#password_policy_lower_case').is(":checked");
|
||||
data_sent['password_policy_digit'] = $('#password_policy_digit').is(":checked");
|
||||
|
||||
post_request_api('/manage/settings/update', JSON.stringify(data_sent), true)
|
||||
.done((data) => {
|
||||
notify_auto_api(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function init_db_backup() {
|
||||
|
||||
get_request_api('/manage/server/backups/make-db')
|
||||
.done((data) => {
|
||||
msg = ""
|
||||
for (idx in data.data) {
|
||||
msg += data.data[idx] + '\n';
|
||||
}
|
||||
swal("Done",
|
||||
msg,
|
||||
{
|
||||
icon: "success"
|
||||
});
|
||||
})
|
||||
.fail((error) => {
|
||||
for (idx in error.responseJSON.data) {
|
||||
msg += data.data[idx] + '\n';
|
||||
}
|
||||
|
||||
swal("Error",
|
||||
msg,
|
||||
{
|
||||
icon: "error"
|
||||
});
|
||||
});
|
||||
}
|
||||
179
iris-web/source/app/static/assets/js/iris/manage.templates.js
Normal file
179
iris-web/source/app/static/assets/js/iris/manage.templates.js
Normal file
@@ -0,0 +1,179 @@
|
||||
function add_report_template() {
|
||||
url = 'templates/add/modal' + case_param();
|
||||
$('#modal_report_template_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* create the select picker for language */
|
||||
$('#report_language').selectpicker({
|
||||
liveSearch: true,
|
||||
title: "Language",
|
||||
style: "Bootstrap 4: 'btn-outline-primary'"
|
||||
});
|
||||
$('#report_type').selectpicker({
|
||||
liveSearch: true,
|
||||
title: "Report type",
|
||||
style: "Bootstrap 4: 'btn-outline-primary'"
|
||||
});
|
||||
$('#form_new_report_template').submit("click", function (event) {
|
||||
|
||||
event.preventDefault();
|
||||
var formData = new FormData(this);
|
||||
|
||||
$.ajax({
|
||||
url: 'templates/add' + case_param(),
|
||||
type: "POST",
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
if (notify_auto_api(data)) {
|
||||
refresh_template_table();
|
||||
$('#modal_add_report_template').modal('hide');
|
||||
}
|
||||
},
|
||||
error: function (error) {
|
||||
if(error.responseJSON) {
|
||||
notify_error(error.responseJSON.message);
|
||||
} else {
|
||||
ajax_notify_error(error, this.url);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
});
|
||||
$('#modal_add_report_template').modal({ show: true });
|
||||
}
|
||||
|
||||
$('#reports_table').dataTable( {
|
||||
"ajax": {
|
||||
"url": "templates/list" + case_param(),
|
||||
"contentType": "application/json",
|
||||
"type": "GET",
|
||||
"data": function ( d ) {
|
||||
if (d.status == 'success') {
|
||||
return JSON.stringify( d.data );
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoWidth": false,
|
||||
"columns": [
|
||||
{
|
||||
"data": "name",
|
||||
"render": function ( data, type, row ) {
|
||||
data = sanitizeHTML(data);
|
||||
return '<a href="#" onclick="delete_report(\'' + row['id'] + '\');">' + data +'</a>';
|
||||
}
|
||||
},
|
||||
{
|
||||
"render": function ( data, type, row ) {return sanitizeHTML(data);},
|
||||
"data": "description",
|
||||
},
|
||||
{
|
||||
"render": function ( data, type, row ) {return sanitizeHTML(data);},
|
||||
"data": "naming_format",
|
||||
},
|
||||
{
|
||||
"render": function ( data, type, row ) {return sanitizeHTML(data);},
|
||||
"data": "date_created",
|
||||
},
|
||||
{
|
||||
"render": function ( data, type, row ) {return sanitizeHTML(data);},
|
||||
"data": "created_by",
|
||||
},
|
||||
{
|
||||
"render": function ( data, type, row ) {return sanitizeHTML(data);},
|
||||
"data": "code",
|
||||
},
|
||||
{
|
||||
"render": function ( data, type, row ) {return sanitizeHTML(data);},
|
||||
"data": "type_name",
|
||||
},
|
||||
{
|
||||
"render": function ( data, type, row ) {
|
||||
data = sanitizeHTML(data);
|
||||
return '<a href="templates/download/' + row["id"] + case_param() + '"><i class="fas fa-download"></i></a>';
|
||||
},
|
||||
"data": "id",
|
||||
}
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
function refresh_template_table() {
|
||||
$('#reports_table').DataTable().ajax.reload();
|
||||
notify_success("Refreshed");
|
||||
}
|
||||
|
||||
|
||||
/* Fetch the details of an asset and allow modification */
|
||||
function report_detail(report_id) {
|
||||
url = 'templates/update/' + report_id + case_param();
|
||||
$('#modal_report_template_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#submit_new_report_template').on("click", function () {
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "POST",
|
||||
data: $('#form_new_report_template').serializeArray(),
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (notify_auto_api(data)) {
|
||||
refresh_template_table();
|
||||
$('#modal_add_report_template').modal('hide');
|
||||
}
|
||||
},
|
||||
error: function (error) {
|
||||
if(error.responseJSON) {
|
||||
notify_error(error.responseJSON.message);
|
||||
} else {
|
||||
ajax_notify_error(error, this.url);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
$('#modal_report_template').modal({ show: true });
|
||||
}
|
||||
|
||||
function delete_report(id) {
|
||||
|
||||
swal({
|
||||
title: "This will delete the report template\nAre you sure?",
|
||||
text: "You won't be able to revert this !",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
post_request_api('/manage/templates/delete/' + id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_template_table();
|
||||
$('#modal_add_report_template').modal('hide');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
337
iris-web/source/app/static/assets/js/iris/manage.users.js
Normal file
337
iris-web/source/app/static/assets/js/iris/manage.users.js
Normal file
@@ -0,0 +1,337 @@
|
||||
var current_users_list = [];
|
||||
function add_user() {
|
||||
url = 'users/add/modal' + case_param();
|
||||
$('#modal_access_control').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#submit_new_user').on("click", function () {
|
||||
|
||||
var data_sent = $('#form_new_user').serializeObject()
|
||||
clear_api_error();
|
||||
|
||||
post_request_api('users/add', JSON.stringify(data_sent), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_users();
|
||||
$('#modal_access_control').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
});
|
||||
$('#modal_access_control').modal({ show: true });
|
||||
}
|
||||
|
||||
manage_users_table = $('#users_table').dataTable( {
|
||||
"order": [[ 1, "asc" ]],
|
||||
"autoWidth": false,
|
||||
"language": {
|
||||
"emptyTable": "Loading users..."
|
||||
},
|
||||
"columns": [
|
||||
{
|
||||
"data": "user_id",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data)
|
||||
return '<a href="#" onclick="user_detail(\'' + row["user_id"] + '\');">' + data +'</a>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "user_name",
|
||||
"render": function ( data, type, row ) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data)
|
||||
return '<a href="#" onclick="user_detail(\'' + row["user_id"] + '\');">' + data +'</a>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "user_login",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "user_email",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "user_active",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
if (data == true) {
|
||||
data = '<span class="badge ml-2 badge-success">Active</span>';
|
||||
} else {
|
||||
data = '<span class="badge ml-2 badge-warning">Disabled</span>';
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "user_is_service_account",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
if (data == true) {
|
||||
data = '<i class="fa fa-check text-success"></i>';
|
||||
} else {
|
||||
data = '<i class="fa fa-xmark text-danger"></i>';
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
function refresh_users(do_notify) {
|
||||
|
||||
get_request_api('users/list')
|
||||
.done((data) => {
|
||||
|
||||
if(notify_auto_api(data, true)) {
|
||||
current_users_list = data.data;
|
||||
manage_users_table.api().clear().rows.add(data.data).draw();
|
||||
|
||||
if (do_notify !== undefined) {
|
||||
notify_success("Refreshed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Fetch the details of an user and allow modification */
|
||||
function user_detail(user_id, goto_tab) {
|
||||
url = 'users/' + user_id + '/modal' + case_param();
|
||||
$('#modal_access_control').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#submit_new_user').on("click", function () {
|
||||
clear_api_error();
|
||||
|
||||
var data_sent = $('#form_new_user').serializeObject();
|
||||
post_request_api('/manage/users/update/' + user_id, JSON.stringify(data_sent), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_users();
|
||||
$('#modal_access_control').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
if (goto_tab !== undefined) {
|
||||
$('.nav-pills a[href="#'+ goto_tab +'"]').tab('show');
|
||||
}
|
||||
$('#modal_access_control').modal({ show: true });
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function refresh_user_ac(user_id) {
|
||||
var ori_txt = $('#users_refresh_ac_btn').text();
|
||||
$('#users_refresh_ac_btn').text('Refreshing..');
|
||||
get_request_api('/manage/access-control/recompute-effective-user-ac/' + user_id)
|
||||
.done((data) => {
|
||||
notify_auto_api(data);
|
||||
}).always(() => {
|
||||
$('#users_refresh_ac_btn').text(ori_txt);
|
||||
});
|
||||
}
|
||||
|
||||
function delete_user(id) {
|
||||
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "You won't be able to revert this !",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
var data_sent = {
|
||||
'csrf_token': $('#csrf_token').val()
|
||||
}
|
||||
post_request_api('/manage/users/delete/' + id, JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_users();
|
||||
$('#modal_access_control').modal('hide');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function activate_user(user_id) {
|
||||
get_request_api('/manage/users/activate/' + user_id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
user_detail(user_id);
|
||||
refresh_users();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deactivate_user(user_id) {
|
||||
get_request_api('/manage/users/deactivate/' + user_id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
user_detail(user_id);
|
||||
refresh_users();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function remove_member_from_org_wrap(org_id, user_id) {
|
||||
remove_members_from_org(org_id, user_id, function() {
|
||||
user_detail(user_id, 'user_orgs_tab');
|
||||
});
|
||||
}
|
||||
|
||||
function remove_member_from_group_wrap(group_id, user_id) {
|
||||
remove_members_from_group(group_id, user_id, function() {
|
||||
user_detail(user_id, 'user_groups_tab');
|
||||
});
|
||||
}
|
||||
|
||||
function manage_user_groups(user_id) {
|
||||
url = 'users/' + user_id + '/groups/modal' + case_param();
|
||||
$('#modal_ac_additional').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
$('#modal_ac_additional').modal({ show: true });
|
||||
|
||||
$('#save_user_groups_membership').on("click", function () {
|
||||
clear_api_error();
|
||||
|
||||
var data_sent = Object();
|
||||
data_sent['groups_membership'] = $('#user_groups_membership').val();
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
post_request_api('/manage/users/' + user_id + '/groups/update', JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_groups();
|
||||
user_detail(user_id, 'user_groups_tab');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function manage_user_organisations(user_id) {
|
||||
url = 'users/' + user_id + '/organisations/modal' + case_param();
|
||||
$('#modal_ac_additional').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
$('#modal_ac_additional').modal({ show: true });
|
||||
|
||||
$('#save_user_orgs_membership').on("click", function () {
|
||||
clear_api_error();
|
||||
|
||||
var data_sent = Object();
|
||||
data_sent['orgs_membership'] = $('#user_orgs_membership').val();
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
post_request_api('/manage/users/' + user_id + '/organisations/update', JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
user_detail(user_id, 'user_orgs_tab');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function refresh_user_cac(user_id) {
|
||||
if (modal_user_cac_table !== undefined) {
|
||||
get_request_api('/manage/users/' + user_id)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
current_user_cases_access_list = data.data.user_cases_access;
|
||||
modal_user_cac_table.clear();
|
||||
modal_user_cac_table.rows.add(current_user_cases_access_list).draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function manage_user_cac(user_id) {
|
||||
url = 'users/' + user_id + '/cases-access/modal' + case_param();
|
||||
|
||||
$('#manage_user_cac_button').text('Loading manager...');
|
||||
|
||||
$('#modal_ac_additional').load(url, function (response, status, xhr) {
|
||||
$('#manage_user_cac_button').text('Set case access');
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#grant_case_access_to_user').on("click", function () {
|
||||
clear_api_error();
|
||||
|
||||
var data_sent = Object();
|
||||
|
||||
data_sent['cases_list'] = $('#user_case_access_select').val();
|
||||
data_sent['access_level'] = parseInt($('#user_case_ac_select').val());
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
|
||||
post_request_api('users/' + user_id + '/cases-access/update', JSON.stringify(data_sent))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
refresh_user_cac(user_id);
|
||||
$('#modal_ac_additional').modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
$('#modal_ac_additional').modal({ show: true });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function remove_cases_access_from_user_table(org_id, rows) {
|
||||
cases = [];
|
||||
for (cid in rows) {
|
||||
cases.push(rows[cid].case_id);
|
||||
}
|
||||
remove_cases_access_user(org_id, cases);
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
refresh_users();
|
||||
});
|
||||
363
iris-web/source/app/static/assets/js/iris/overview.js
Normal file
363
iris-web/source/app/static/assets/js/iris/overview.js
Normal file
@@ -0,0 +1,363 @@
|
||||
$.each($.find("table"), function(index, element){
|
||||
addFilterFields($(element).attr("id"));
|
||||
});
|
||||
var OverviewTable = $("#overview_table").DataTable({
|
||||
dom: '<"container-fluid"<"row"<"col"l><"col"f>>>rt<"container-fluid"<"row"<"col"i><"col"p>>>',
|
||||
aaData: [],
|
||||
aoColumns: [
|
||||
{
|
||||
data: "case_id",
|
||||
render: function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = `<span title="Quick look" class="bg-transparent btn-quick-view" style="cursor: pointer;" data-index="${meta.row}" ><i class="fa-solid fa-eye"></i></span>`;
|
||||
} else if (type === 'sort' || type === 'filter') {
|
||||
data = parseInt(row['case_id']);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "name",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
if (isWhiteSpace(data)) {
|
||||
data = '#' + row['case_id'];
|
||||
} else {
|
||||
data = sanitizeHTML(data);
|
||||
}
|
||||
data = '<a rel="noopener" title="Open case in new tab" target="_blank" href="case?cid='+ row['case_id'] + '">' + data +'</a>';
|
||||
} else if (type === 'sort' || type === 'filter') {
|
||||
data = sanitizeHTML(data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "client",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data.customer_name);
|
||||
} else if (type === 'sort' || type === 'filter') {
|
||||
data = sanitizeHTML(data.customer_name);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "classification",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
data = sanitizeHTML(data.name);
|
||||
} else if (data != null && (type === 'sort' || type === 'filter')) {
|
||||
data = data.name;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "state",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
let datar = sanitizeHTML(data.state_name);
|
||||
let review_status = row['review_status'] ? row['review_status'].status_name : 'Not reviewed';
|
||||
datar = `${datar} ${review_status === "Not reviewed"? '' : ' - ' + review_status}`;
|
||||
if (data.state_name === 'Closed') {
|
||||
datar = `<span class="badge badge-light"> Closed - ${review_status}</span>`;
|
||||
}
|
||||
return datar;
|
||||
} else if (data != null && (type === 'sort' || type === 'filter')) {
|
||||
let datar = sanitizeHTML(data.state_name);
|
||||
let review_status = row['review_status'] ? row['review_status'].status_name : 'Not reviewed';
|
||||
datar = `${datar} ${review_status === "Not reviewed"? '' : ' - ' + review_status}`;
|
||||
if (data.state_name === 'Closed') {
|
||||
datar = `Closed - ${review_status}`;
|
||||
}
|
||||
return datar;
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "tags",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
let output = '';
|
||||
for (let index in data) {
|
||||
let tag = sanitizeHTML(data[index].tag_title);
|
||||
output += `<span class="badge badge-pill badge-light">${tag}</span> `;
|
||||
}
|
||||
return output;
|
||||
} else if (type === 'sort' || type === 'filter') {
|
||||
let output = [];
|
||||
for (let index in data) {
|
||||
let tag = sanitizeHTML(data[index].tag_title);
|
||||
output.push(tag);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
"data": "case_open_since_days",
|
||||
"render": function(data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
title = "You\'re not forgetting me, are you?";
|
||||
if (data <= 1) {
|
||||
data = `<i title="Sounds good" class="text-success fw-bold fa-solid fa-stopwatch mr-1"></i>${data} day`;
|
||||
}
|
||||
else if (data <= 7) {
|
||||
data = `<i title="Sounds good" class="text-success fw-bold fa-solid fa-stopwatch mr-1"></i>${data} days`;
|
||||
} else if (7 < data && data < 14) {
|
||||
data = `<i title="${title}" class="text-warning fw-bold fa-solid fa-stopwatch mr-1"></i>${data} days</div>`;
|
||||
} else {
|
||||
data = `<i title="${title}" class="text-danger fw-bold fa-solid fa-stopwatch mr-1"></i>${data} days</div>`;
|
||||
}
|
||||
} else if (type === 'sort' || type === 'filter') {
|
||||
data = parseInt(data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "open_date",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
data = sanitizeHTML(data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "tasks_status",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
now = (data.closed_tasks / (data.closed_tasks + data.open_tasks))*100;
|
||||
if (data.closed_tasks + data.open_tasks > 1) {
|
||||
tasks_text = `tasks`;
|
||||
} else {
|
||||
tasks_text = `task`;
|
||||
}
|
||||
data = `<div class="progress progress-sm">
|
||||
<div class="progress-bar bg-success" style="width:${now}%" role="progressbar" aria-valuenow="${now}" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div><small class="float-right">${data.closed_tasks} / ${data.closed_tasks + data.open_tasks} ${tasks_text} done</small>`;
|
||||
} else if (data != null && (type === 'sort' || type === 'filter')) {
|
||||
data = data.closed_tasks / (data.closed_tasks + data.open_tasks);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "owner",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display' && data != null) {
|
||||
sdata = sanitizeHTML(data.user_name);
|
||||
data = `<div class="row">${get_avatar_initials(sdata, false, null, true)} <span class="ml-1">${sdata}</span></div>`;
|
||||
} else if (type === 'filter' || type === 'sort') {
|
||||
data = data.user_name;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
],
|
||||
filter: true,
|
||||
info: true,
|
||||
ordering: true,
|
||||
processing: true,
|
||||
retrieve: true,
|
||||
lengthChange: true,
|
||||
pageLength: 25,
|
||||
searchBuilder: {
|
||||
},
|
||||
language: {
|
||||
searchBuilder: {
|
||||
add: "Add filter",
|
||||
title: {
|
||||
_: 'Filters (%d)',
|
||||
0: '',
|
||||
}
|
||||
}
|
||||
},
|
||||
order: [[ 1, "asc" ]],
|
||||
buttons: [
|
||||
{ "extend": 'csvHtml5', "text":'Export',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
{ "extend": 'copyHtml5', "text":'Copy',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
],
|
||||
responsive: {
|
||||
details: {
|
||||
display: $.fn.dataTable.Responsive.display.childRow,
|
||||
renderer: $.fn.dataTable.Responsive.renderer.tableAll()
|
||||
}
|
||||
},
|
||||
select: true,
|
||||
initComplete: function () {
|
||||
tableFiltering(this.api(), 'overview_table', [0]);
|
||||
},
|
||||
drawCallback: function () {
|
||||
$('.btn-quick-view').off('click').on('click', function() {
|
||||
show_case_view($(this).data('index'));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
OverviewTable.searchBuilder.container().appendTo($('#table_buttons'));
|
||||
|
||||
function get_cases_overview(silent, show_full=false) {
|
||||
show_full = show_full || $('#overviewLoadClosedCase').prop('checked');
|
||||
|
||||
$('#overviewTableTitle').text(show_full ? 'All cases' : 'Open cases');
|
||||
|
||||
get_raw_request_api('/overview/filter?cid=' + get_caseid() + (show_full ? '&show_closed=true' : ''))
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data, silent)) {
|
||||
overview_list = data.data;
|
||||
OverviewTable.clear();
|
||||
OverviewTable.rows.add(overview_list);
|
||||
OverviewTable.columns.adjust().draw();
|
||||
$(".truncate").on("click", function() {
|
||||
var index = $(this).index() + 1;
|
||||
$('table tr td:nth-child(' + index + ')').toggleClass("truncate");
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function show_case_view(row_index) {
|
||||
let case_data = OverviewTable.row(row_index).data();
|
||||
$('#caseViewModal').find('.modal-title').text(case_data.name);
|
||||
$('#caseViewModal').find('.modal-subtitle').text(case_data.case_uuid);
|
||||
|
||||
let body = $('#caseViewModal').find('.modal-body .container');
|
||||
body.empty();
|
||||
|
||||
// Owner Card
|
||||
let owner_card = $('<div/>').addClass('card mb-3');
|
||||
let owner_body = $('<div/>').addClass('card-body');
|
||||
owner_body.append($('<h2/>').addClass('card-title mb-2').text('Metadata'));
|
||||
|
||||
let owner_row = $('<div/>').addClass('row');
|
||||
let owner_col1 = $('<div/>').addClass('col-md-6');
|
||||
let owner_col2 = $('<div/>').addClass('col-md-6');
|
||||
let timeSinceLastUpdateStr = '';
|
||||
let modifications = case_data.modification_history;
|
||||
if (modifications != null) {
|
||||
let timestamps = Object.keys(modifications).map(parseFloat);
|
||||
let lastUpdatedTimestamp = Math.max(...timestamps);
|
||||
|
||||
let currentTime = Date.now() / 1000; // convert to seconds
|
||||
let timeSinceLastUpdate = currentTime - lastUpdatedTimestamp;
|
||||
let timeSinceLastUpdateInSeconds = currentTime - lastUpdatedTimestamp;
|
||||
|
||||
let timeSinceLastUpdateInMinutes = timeSinceLastUpdate / 60;
|
||||
let timeSinceLastUpdateInHours = timeSinceLastUpdateInMinutes / 60;
|
||||
let timeSinceLastUpdateInDays = timeSinceLastUpdateInHours / 24;
|
||||
|
||||
|
||||
if (timeSinceLastUpdateInSeconds < 60) {
|
||||
timeSinceLastUpdateStr = `${Math.round(timeSinceLastUpdateInSeconds)} second(s) ago`;
|
||||
} else if (timeSinceLastUpdateInMinutes < 60) {
|
||||
timeSinceLastUpdateStr = `${Math.round(timeSinceLastUpdateInMinutes)} minute(s) ago`;
|
||||
} else if (timeSinceLastUpdateInHours < 24) {
|
||||
timeSinceLastUpdateStr = `${Math.round(timeSinceLastUpdateInHours)} hour(s) ago`;
|
||||
} else {
|
||||
timeSinceLastUpdateStr = `${Math.round(timeSinceLastUpdateInDays)} day(s) ago`;
|
||||
}
|
||||
} else {
|
||||
timeSinceLastUpdateStr = 'Never';
|
||||
}
|
||||
|
||||
let tagsStr = '';
|
||||
for (let index in case_data.tags) {
|
||||
let tag = sanitizeHTML(case_data.tags[index].tag_title);
|
||||
tagsStr += `<span class="badge badge-pill badge-light">${tag}</span> `;
|
||||
}
|
||||
|
||||
let owner_dl1 = $('<dl class="row"/>');
|
||||
owner_dl1.append($('<dt class="col-sm-3"/>').text('Owner:'));
|
||||
owner_dl1.append($('<dd class="col-sm-8"/>').text(case_data.owner.user_name));
|
||||
owner_dl1.append($('<dt class="col-sm-3"/>').text('Opening User:'));
|
||||
owner_dl1.append($('<dd class="col-sm-8"/>').text(case_data.user.user_name));
|
||||
owner_dl1.append($('<dt class="col-sm-3"/>').text('Open Date:'));
|
||||
owner_dl1.append($('<dd class="col-sm-8"/>').text(case_data.open_date));
|
||||
|
||||
if (case_data.close_date != null) {
|
||||
owner_dl1.append($('<dt class="col-sm-3"/>').text('Close Date:'));
|
||||
owner_dl1.append($('<dd class="col-sm-8"/>').text(case_data.close_date))
|
||||
}
|
||||
owner_dl1.append($('<dt class="col-sm-3"/>').text('Tags:'));
|
||||
owner_dl1.append($('<dd class="col-sm-8"/>').html(tagsStr !== ''? tagsStr : 'No tags'));
|
||||
owner_dl1.append($('<dt class="col-sm-3"/>').text('State:'));
|
||||
owner_dl1.append($('<dd class="col-sm-8"/>').text(case_data.state ? case_data.state.state_description: 'None'));
|
||||
owner_dl1.append($('<dt class="col-sm-3"/>').text('Last update:'));
|
||||
owner_dl1.append($('<dd class="col-sm-8"/>').text(timeSinceLastUpdateStr));
|
||||
|
||||
|
||||
owner_col1.append(owner_dl1);
|
||||
|
||||
|
||||
|
||||
let owner_dl2 = $('<dl class="row"/>');
|
||||
owner_dl2.append($('<dt class="col-sm-3"/>').text('Customer Name:'));
|
||||
owner_dl2.append($('<dd class="col-sm-8"/>').text(case_data.client.customer_name));
|
||||
|
||||
owner_dl2.append($('<dt class="col-sm-3"/>').text('Classification:'));
|
||||
owner_dl2.append($('<dd class="col-sm-8"/>').text(case_data.classification ? case_data.classification.name: 'None'));
|
||||
owner_dl2.append($('<dt class="col-sm-3"/>').text('SOC ID:'));
|
||||
owner_dl2.append($('<dd class="col-sm-8"/>').text(case_data.soc_id !== '' ? case_data.soc_id : 'None'));
|
||||
owner_dl2.append($('<dt class="col-sm-3"/>').text('Related alerts:'));
|
||||
owner_dl2.append($('<dd class="col-sm-8"/>').html(`<a target="_blank" rel="noopener" href='/alerts?case_id=${case_data.case_id}'>${case_data.alerts.length} related alert(s) <i class="fa-solid fa-up-right-from-square ml-2"></i></a>`));
|
||||
owner_dl2.append($('<dt class="col-sm-3"/>').text('Tasks:'));
|
||||
if (case_data.tasks_status != null) {
|
||||
owner_dl2.append($('<dd class="col-sm-8"/>').html(`<a target="_blank" rel="noopener" href='/case/tasks?cid=${case_data.case_id}'>${case_data.tasks_status.closed_tasks}/${case_data.tasks_status.open_tasks + case_data.tasks_status.closed_tasks} task(s) <i class="fa-solid fa-up-right-from-square ml-2"></i></a>`));
|
||||
} else {
|
||||
owner_dl2.append($('<dd class="col-sm-8"/>').text('No tasks'));
|
||||
}
|
||||
owner_dl2.append($('<dt class="col-sm-3"/>').text('Review:'));
|
||||
if (case_data.review_status != null) {
|
||||
owner_dl2.append($('<dd class="col-sm-8"/>').text(case_data.review_status.status_name));
|
||||
} else {
|
||||
owner_dl2.append($('<dd class="col-sm-8"/>').text('No review'));
|
||||
}
|
||||
owner_dl2.append($('<dt class="col-sm-3"/>').text('Reviewer:'));
|
||||
if (case_data.reviewer != null) {
|
||||
owner_dl2.append($('<dd class="col-sm-8"/>').text(case_data.reviewer.user_name));
|
||||
} else {
|
||||
owner_dl2.append($('<dd class="col-sm-8"/>').text('No reviewer'));
|
||||
}
|
||||
owner_col2.append(owner_dl2);
|
||||
|
||||
owner_row.append(owner_col1);
|
||||
owner_row.append(owner_col2);
|
||||
owner_body.append(owner_row);
|
||||
owner_body.append(`<a type="button" class="btn btn-sm btn-dark float-right" target="_blank" rel="noopener" href='/case?cid=${case_data.case_id}'><i class="fa-solid fa-up-right-from-square mr-2"></i> View case</a>`);
|
||||
|
||||
owner_card.append(owner_body);
|
||||
body.append(owner_card);
|
||||
|
||||
// Description Card
|
||||
let desc_card = $('<div/>').addClass('card mb-3');
|
||||
let desc_body = $('<div/>').addClass('card-body');
|
||||
desc_body.append($('<h2/>').addClass('card-title mb-3').text('Summary'));
|
||||
let converter = get_showdown_convert();
|
||||
let html = converter.makeHtml(case_data.description);
|
||||
desc_body.append($('<div/>').addClass('card-text').html(html));
|
||||
|
||||
desc_card.append(desc_body);
|
||||
body.append(desc_card);
|
||||
|
||||
|
||||
$('#caseViewModal').modal('show');
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
get_cases_overview(true);
|
||||
|
||||
|
||||
$('#overviewLoadClosedCase').change(function() {
|
||||
get_cases_overview(true, this.checked);
|
||||
});
|
||||
|
||||
});
|
||||
209
iris-web/source/app/static/assets/js/iris/search.js
Normal file
209
iris-web/source/app/static/assets/js/iris/search.js
Normal file
@@ -0,0 +1,209 @@
|
||||
$('#search_value').keypress(function(event){
|
||||
var keycode = (event.keyCode ? event.keyCode : event.which);
|
||||
if(keycode == '13'){
|
||||
jQuery(this).blur();
|
||||
jQuery('#submit_search').focus().click();
|
||||
event.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Table_1 = $("#file_search_table_1").DataTable({
|
||||
dom: 'Bfrtip',
|
||||
aaData: [],
|
||||
aoColumns: [
|
||||
{ "data": "ioc_name",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
if (row['ioc_misp'] != null) {
|
||||
jse = JSON.parse(row['ioc_misp']);
|
||||
data += `<i class="fas fa-exclamation-triangle ml-2 text-warning" style="cursor: pointer;" data-html="true"
|
||||
data-toggle="popover" data-trigger="hover" title="Seen on MISP" data-content="Has been seen on <a href='` + row['misp_link'] + `/events/view/` + jse.misp_id +`'>this event</a><br/><br/><b>Description: </b>`+ jse.misp_desc +`"></i>`;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "ioc_description",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
datas = '<span data-toggle="popover" style="cursor: pointer;" data-trigger="hover" title="Description" data-content="' + data + '">' + data.slice(0, 70);
|
||||
|
||||
if (data.length > 70) {
|
||||
datas += ' (..)</span>';
|
||||
} else {
|
||||
datas += '</span>';
|
||||
}
|
||||
return datas;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "type_name",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}},
|
||||
{ "data": "case_name",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
data = '<a target="_blank" href="case?cid='+ row["case_id"] +'">' + data + '</a>';
|
||||
}
|
||||
return data;
|
||||
}},
|
||||
{ "data": "customer_name",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
} },
|
||||
{ "data": "tlp_name",
|
||||
"render": function(data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
data = '<span class="badge badge-'+ row['tlp_bscolor'] +' ml-2">tlp:' + data + '</span>';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
],
|
||||
filter: true,
|
||||
info: true,
|
||||
ordering: true,
|
||||
processing: true,
|
||||
retrieve: true,
|
||||
buttons: [
|
||||
{ "extend": 'csvHtml5', "text":'Export',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
{ "extend": 'copyHtml5', "text":'Copy',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
]
|
||||
});
|
||||
$("#file_search_table_1").css("font-size", 12);
|
||||
|
||||
Table_comments = $("#comments_search_table").DataTable({
|
||||
dom: 'Bfrtip',
|
||||
aaData: [],
|
||||
aoColumns: [
|
||||
{ "data": "comment_id",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
if (row['ioc_misp'] != null) {
|
||||
jse = JSON.parse(row['ioc_misp']);
|
||||
data += `<i class="fas fa-exclamation-triangle ml-2 text-warning" style="cursor: pointer;" data-html="true"
|
||||
data-toggle="popover" data-trigger="hover" title="Seen on MISP" data-content="Has been seen on <a href='` + row['misp_link'] + `/events/view/` + jse.misp_id +`'>this event</a><br/><br/><b>Description: </b>`+ jse.misp_desc +`"></i>`;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "comment_text",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
datas = '<span data-toggle="popover" style="cursor: pointer;" data-trigger="hover" title="Description" data-content="' + data + '">' + data.slice(0, 70);
|
||||
|
||||
if (data.length > 70) {
|
||||
datas += ' (..)</span>';
|
||||
} else {
|
||||
datas += '</span>';
|
||||
}
|
||||
return datas;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
},
|
||||
{ "data": "case_name",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') {
|
||||
data = sanitizeHTML(data);
|
||||
data = '<a target="_blank" href="case?cid='+ row["case_id"] +'">' + data + '</a>';
|
||||
}
|
||||
return data;
|
||||
}},
|
||||
{ "data": "customer_name",
|
||||
"render": function (data, type, row, meta) {
|
||||
if (type === 'display') { data = sanitizeHTML(data);}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
],
|
||||
filter: true,
|
||||
info: true,
|
||||
ordering: true,
|
||||
processing: true,
|
||||
retrieve: true,
|
||||
buttons: [
|
||||
{ "extend": 'csvHtml5', "text":'Export',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
{ "extend": 'copyHtml5', "text":'Copy',"className": 'btn btn-primary btn-border btn-round btn-sm float-left mr-4 mt-2' },
|
||||
]
|
||||
});
|
||||
$("#comments_search_table").css("font-size", 12);
|
||||
|
||||
$('#submit_search').click(function () {
|
||||
search();
|
||||
});
|
||||
|
||||
|
||||
function search() {
|
||||
var data_sent = $('form#form_search').serializeObject();
|
||||
data_sent['csrf_token'] = $('#csrf_token').val();
|
||||
post_request_api('/search', JSON.stringify(data_sent), true, function (data) {
|
||||
$('#submit_search').text("Searching...");
|
||||
})
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data, true)) {
|
||||
$('#notes_msearch_list').empty();
|
||||
Table_1.clear();
|
||||
Table_comments.clear();
|
||||
$('#search_table_wrapper_1').hide();
|
||||
$('#search_table_wrapper_2').hide();
|
||||
$('#search_table_wrapper_3').hide();
|
||||
val = $("input[type='radio']:checked").val();
|
||||
if (val == "ioc") {
|
||||
Table_1.rows.add(data.data);
|
||||
Table_1.columns.adjust().draw();
|
||||
$('#search_table_wrapper_1').show();
|
||||
|
||||
$('#search_table_wrapper_1').on('click', function(e){
|
||||
if($('.popover').length>1)
|
||||
$('.popover').popover('hide');
|
||||
$(e.target).popover('toggle');
|
||||
});
|
||||
}
|
||||
else if (val == "notes") {
|
||||
for (e in data.data) {
|
||||
li = `<li class="list-group-item">
|
||||
<span class="name" style="cursor:pointer" title="Click to open note" onclick="note_in_details(${data.data[e]['note_id']}, ${data.data[e]['case_id']});">`+ sanitizeHTML(data.data[e]['note_title']) + ` - ` + sanitizeHTML(data.data[e]['case_name']) + ` - ` + sanitizeHTML(data.data[e]['client_name']) +`</span>
|
||||
</li>`
|
||||
$('#notes_msearch_list').append(li);
|
||||
}
|
||||
$('#search_table_wrapper_2').show();
|
||||
} else if (val == "comments") {
|
||||
Table_comments.rows.add(data.data);
|
||||
Table_comments.columns.adjust().draw();
|
||||
$('#search_table_wrapper_3').show();
|
||||
|
||||
$('#search_table_wrapper_3').on('click', function(e){
|
||||
if($('.popover').length>1)
|
||||
$('.popover').popover('hide');
|
||||
$(e.target).popover('toggle');
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.always(() => {
|
||||
$('#submit_search').text("Search");
|
||||
});
|
||||
}
|
||||
|
||||
function note_in_details(note_id, case_id) {
|
||||
window.open("/case/notes?cid=" + case_id + "&shared=" + note_id);
|
||||
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#search_value').focus();
|
||||
});
|
||||
174
iris-web/source/app/static/assets/js/iris/updates.handler.js
Normal file
174
iris-web/source/app/static/assets/js/iris/updates.handler.js
Normal file
@@ -0,0 +1,174 @@
|
||||
channel = 'iris_update_status';
|
||||
|
||||
function log_error(message) {
|
||||
add_update_log(message, true);
|
||||
}
|
||||
|
||||
function log_msg(message) {
|
||||
add_update_log(message, false)
|
||||
}
|
||||
|
||||
function add_update_log(message, is_error) {
|
||||
html_wrap = `<h4><i class="mt-2 fas fa-check text-success"></i> `
|
||||
if (is_error) {
|
||||
html_wrap = `<h4><i class="mt-2 fas fa-times text-danger"></i> `
|
||||
}
|
||||
$("#updates_log").append(html_wrap + message + '</h4><br/>')
|
||||
$('html, body').animate({
|
||||
scrollTop: $("#updates_log_end").offset().top
|
||||
}, 50);
|
||||
}
|
||||
|
||||
function get_caseid() {
|
||||
queryString = window.location.search;
|
||||
urlParams = new URLSearchParams(queryString);
|
||||
|
||||
return urlParams.get('cid')
|
||||
}
|
||||
|
||||
function case_param() {
|
||||
var params = {
|
||||
cid: get_caseid
|
||||
}
|
||||
return '?'+ $.param(params);
|
||||
}
|
||||
|
||||
function initiate_update() {
|
||||
$.ajax({
|
||||
url: '/manage/server/start-update' + case_param(),
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
beforeSend : function () {
|
||||
log_msg('Update order sent. Expecting feedback anytime soon');
|
||||
},
|
||||
success: function (data) {},
|
||||
error: function (data) {
|
||||
log_error('Unexpected error starting update');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var intervalId = null;
|
||||
var ios = io('/server-updates');
|
||||
var update_socket = null;
|
||||
var current_version = null;
|
||||
var updated_version = null;
|
||||
var steps = 0;
|
||||
var no_resp_time = 0;
|
||||
|
||||
function check_server_version() {
|
||||
$.ajax({
|
||||
url: '/api/versions' + case_param(),
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
timeout: 1000,
|
||||
success: function (data) {
|
||||
server_version = data.data.iris_current;
|
||||
if (server_version == current_version) {
|
||||
add_update_log('Something was wrong - server is still in the same version', true);
|
||||
add_update_log('Please check server logs', true);
|
||||
clearInterval(intervalId);
|
||||
$('#tag_bottom').hide();
|
||||
$('#update_return_button').show();
|
||||
} else {
|
||||
add_update_log('Successfully updated from ' + current_version + ' to ' + server_version, false);
|
||||
add_update_log('You can now leave this page', false);
|
||||
clearInterval(intervalId);
|
||||
$('#tag_bottom').hide();
|
||||
$('#update_return_button').show();
|
||||
}
|
||||
},
|
||||
error: function (error) {
|
||||
log_error('Something\'s wrong, server is not answering');
|
||||
log_error('Please check server logs')
|
||||
clearInterval(intervalId);
|
||||
$('#tag_bottom').hide();
|
||||
$('#update_return_button').show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function ping_check_server_online() {
|
||||
|
||||
$.ajax({
|
||||
url: '/api/ping' + case_param(),
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
timeout: 1000,
|
||||
success: function (data) {
|
||||
$("#offline_time").hide();
|
||||
log_msg('Server is back online');
|
||||
clearInterval(intervalId);
|
||||
check_server_version();
|
||||
},
|
||||
error: function (error) {
|
||||
no_resp_time += 1;
|
||||
if (no_resp_time > 29) {
|
||||
log_error('Something\'s wrong, server is not answering');
|
||||
log_error('Please check server logs')
|
||||
clearInterval(intervalId);
|
||||
$('#tag_bottom').hide();
|
||||
$('#update_return_button').show();
|
||||
}
|
||||
$("#offline_time").html('<h4 id="offline_time"><i class="fas fa-clock"></i> Attempt '+ no_resp_time +' / 30</h4><br/>');
|
||||
$("#offline_time").show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function start_updates(){
|
||||
$('#update_start_btn').hide();
|
||||
$('.update_start_txt').hide();
|
||||
$('#container-updates').show();
|
||||
update_socket.emit('update_get_current_version', { 'channel': channel });
|
||||
update_socket.emit('update_ping', { 'channel': channel });
|
||||
// index = 0;
|
||||
// while(index < 20) {
|
||||
// add_update_log('ping');
|
||||
// index += 1;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
update_socket = ios.connect();
|
||||
|
||||
update_socket.on( "update_status", function(data) {
|
||||
add_update_log(data.message, data.is_error)
|
||||
}.bind() );
|
||||
|
||||
update_socket.on( "update_ping", function(data) {
|
||||
log_msg('Server connection verified');
|
||||
log_msg('Starting update');
|
||||
initiate_update();
|
||||
}.bind() );
|
||||
|
||||
update_socket.on( "server_has_updated", function(data) {
|
||||
log_msg('Server reported updates applied. Checking . . .');
|
||||
check_server_version();
|
||||
}.bind() );
|
||||
|
||||
update_socket.on('disconnect', function () {
|
||||
add_update_log('Server is offline, waiting for connection', false);
|
||||
intervalId = window.setInterval(function(){
|
||||
ping_check_server_online();
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
update_socket.on('update_current_version', function (data) {
|
||||
add_update_log('Server reported version ' + data.version , false);
|
||||
if (current_version == null) {
|
||||
current_version = data.version;
|
||||
}
|
||||
});
|
||||
|
||||
update_socket.on('update_has_fail', function () {
|
||||
$('#tag_bottom').hide();
|
||||
$('#update_return_button').show();
|
||||
});
|
||||
|
||||
update_socket.emit('join-update', { 'channel': channel });
|
||||
|
||||
|
||||
});
|
||||
104
iris-web/source/app/static/assets/js/iris/user.js
Normal file
104
iris-web/source/app/static/assets/js/iris/user.js
Normal file
@@ -0,0 +1,104 @@
|
||||
function renew_api() {
|
||||
swal({
|
||||
title: "Are you sure?",
|
||||
text: "The current key will be revoked and cannot be used anymore",
|
||||
icon: "warning",
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Go for it'
|
||||
})
|
||||
.then((willDelete) => {
|
||||
if (willDelete) {
|
||||
get_request_api('/user/token/renew')
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
location.reload(true);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
swal("Pfew, that was close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function save_user_password() {
|
||||
clear_api_error();
|
||||
|
||||
if ( $('#user_password').val() != $('#user_password_v').val()) {
|
||||
$('#user_password').addClass('is-invalid');
|
||||
$('#user_password').after("<div class='invalid-feedback' id='user_password-invalid-msg'>Password and verification are not the same</div>");
|
||||
$('#user_password').show();
|
||||
return False;
|
||||
}
|
||||
|
||||
var data_sent = $('#form_update_pwd').serializeObject();
|
||||
data_sent['user_password'] = $('#user_password').val();
|
||||
|
||||
post_request_api('update', JSON.stringify(data_sent), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
$('#modal_pwd_user').modal('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Fetch the details of an user and allow modification */
|
||||
function update_password(user_id) {
|
||||
url = 'update/modal' + case_param();
|
||||
$('#modal_pwd_user_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
$('#modal_pwd_user').modal({ show: true });
|
||||
}
|
||||
|
||||
function refresh_user_permissions() {
|
||||
var ori_txt = $('#user_refresh_perms_btn').text();
|
||||
$('#user_refresh_perms_btn').text('Refreshing..');
|
||||
get_request_api('refresh-permissions')
|
||||
.done((data) => {
|
||||
notify_auto_api(data);
|
||||
}).always(() => {
|
||||
$('#user_refresh_perms_btn').text(ori_txt);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
$('input[type=radio][name=iris-theme]').change(function() {
|
||||
if (this.value == 'false') {
|
||||
theme = 'light'
|
||||
}
|
||||
else if (this.value == 'true') {
|
||||
theme = 'dark';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
get_request_api('theme/set/'+ theme)
|
||||
.done((data) => {
|
||||
if (notify_auto_api(data, true)) {
|
||||
location.reload(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('input[type=radio][name=user-has-deletion-prompt]').change(function() {
|
||||
if (this.value == 'false') {
|
||||
do_prompt = false;
|
||||
}
|
||||
else if (this.value == 'true') {
|
||||
do_prompt = true;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
get_request_api('deletion-prompt/set/'+ do_prompt)
|
||||
.then((data) => {
|
||||
if (notify_auto_api(data)) {
|
||||
userWhoamiRequest(true);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
117
iris-web/source/app/static/assets/js/iris/view.customers.js
Normal file
117
iris-web/source/app/static/assets/js/iris/view.customers.js
Normal file
@@ -0,0 +1,117 @@
|
||||
|
||||
function delete_contact(contact_id, customer_id) {
|
||||
post_request_api('/manage/customers/' + customer_id + '/contacts/' + contact_id + '/delete', null, true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function edit_contact(contact_id, customer_id) {
|
||||
url = '/manage/customers/' + customer_id + '/contacts/' + contact_id + '/modal' + case_param();
|
||||
$('#modal_add_contact_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#form_new_contact').on("submit", preventFormDefaultBehaviourOnSubmit);
|
||||
$('#submit_new_contact').on("click", function () {
|
||||
|
||||
const form = $('#form_new_contact').serializeObject();
|
||||
|
||||
post_request_api('/manage/customers/' + customer_id + '/contacts/' + contact_id + '/update', JSON.stringify(form), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$('#submit_delete_contact').on("click", function () {
|
||||
post_request_api('/manage/customers/' + customer_id + '/contacts/' + contact_id + '/delete')
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
$('#modal_add_contact').modal({show: true});
|
||||
}
|
||||
|
||||
function add_new_contact(customer_id) {
|
||||
url = '/manage/customers/' + customer_id + '/contacts/add/modal' + case_param();
|
||||
$('#modal_add_contact_content').load(url, function (response, status, xhr) {
|
||||
if (status !== "success") {
|
||||
ajax_notify_error(xhr, url);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#form_new_contact').on("submit", preventFormDefaultBehaviourOnSubmit);
|
||||
$('#submit_new_contact').on("click", function () {
|
||||
|
||||
const form = $('#form_new_contact').serializeObject();
|
||||
|
||||
post_request_api('/manage/customers/' + customer_id + '/contacts/add', JSON.stringify(form), true)
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data)) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
$('#modal_add_contact').modal({show: true});
|
||||
}
|
||||
|
||||
function load_customer_stats(customer_id) {
|
||||
get_request_api('/manage/customers/' + customer_id + '/cases')
|
||||
.done((data) => {
|
||||
if(notify_auto_api(data, true)) {
|
||||
$('#last_month_cases').text(data.data.stats.cases_last_month);
|
||||
$('#last_year_cases').text(data.data.stats.cases_last_year);
|
||||
$('#cases_last_month').text(data.data.stats.cases_last_month);
|
||||
$('#cases_current_month').text(data.data.stats.cases_current_month);
|
||||
$('#cases_current_year').text(data.data.stats.cases_current_year);
|
||||
$('#current_open_cases').text(data.data.stats.open_cases);
|
||||
$('#cases_total').text(data.data.stats.cases_total);
|
||||
$('#ratio_year').text(data.data.stats.ratio_year);
|
||||
$('#average_case_duration').text(data.data.stats.average_case_duration);
|
||||
|
||||
if (data.data.stats.ratio_year > 0) {
|
||||
$('#ratio_year').addClass('text-warning');
|
||||
$('#ratio_year').html(`+${data.data.stats.ratio_year}% <i class="ml-1 fa fa-chevron-up"></i>`);
|
||||
} else if (data.data.stats.ratio_year < 0) {
|
||||
$('#ratio_year').addClass('text-success');
|
||||
$('#ratio_year').html(`${data.data.stats.ratio_year}% <i class="ml-1 fa fa-chevron-down"></i>`);
|
||||
}
|
||||
|
||||
if (data.data.stats.ratio_month > 0) {
|
||||
$('#ratio_month').addClass('text-warning');
|
||||
$('#ratio_month').html(`+${data.data.stats.ratio_month}% <i class="ml-1 fa fa-chevron-up"></i>`);
|
||||
} else if (data.data.stats.ratio_month < 0) {
|
||||
$('#ratio_month').addClass('text-success');
|
||||
$('#ratio_month').html(`${data.data.stats.ratio_month}% <i class="ml-1 fa fa-chevron-down"></i>`);
|
||||
}
|
||||
|
||||
$('#last_year').text(data.data.stats.last_year);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
customer_id = $('#customer_id').val();
|
||||
load_customer_stats(customer_id);
|
||||
|
||||
});
|
||||
21973
iris-web/source/app/static/assets/js/plugin/ace/src-noconflict/ace.js
Normal file
21973
iris-web/source/app/static/assets/js/plugin/ace/src-noconflict/ace.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,327 @@
|
||||
ace.define("ace/ext/beautify",["require","exports","module","ace/token_iterator"], function(require, exports, module) {
|
||||
"use strict";
|
||||
var TokenIterator = require("../token_iterator").TokenIterator;
|
||||
|
||||
function is(token, type) {
|
||||
return token.type.lastIndexOf(type + ".xml") > -1;
|
||||
}
|
||||
exports.singletonTags = ["area", "base", "br", "col", "command", "embed", "hr", "html", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
||||
exports.blockTags = ["article", "aside", "blockquote", "body", "div", "dl", "fieldset", "footer", "form", "head", "header", "html", "nav", "ol", "p", "script", "section", "style", "table", "tbody", "tfoot", "thead", "ul"];
|
||||
|
||||
exports.beautify = function(session) {
|
||||
var iterator = new TokenIterator(session, 0, 0);
|
||||
var token = iterator.getCurrentToken();
|
||||
var tabString = session.getTabString();
|
||||
var singletonTags = exports.singletonTags;
|
||||
var blockTags = exports.blockTags;
|
||||
var nextToken;
|
||||
var breakBefore = false;
|
||||
var spaceBefore = false;
|
||||
var spaceAfter = false;
|
||||
var code = "";
|
||||
var value = "";
|
||||
var tagName = "";
|
||||
var depth = 0;
|
||||
var lastDepth = 0;
|
||||
var lastIndent = 0;
|
||||
var indent = 0;
|
||||
var unindent = 0;
|
||||
var roundDepth = 0;
|
||||
var curlyDepth = 0;
|
||||
var row;
|
||||
var curRow = 0;
|
||||
var rowsToAdd = 0;
|
||||
var rowTokens = [];
|
||||
var abort = false;
|
||||
var i;
|
||||
var indentNextLine = false;
|
||||
var inTag = false;
|
||||
var inCSS = false;
|
||||
var inBlock = false;
|
||||
var levels = {0: 0};
|
||||
var parents = [];
|
||||
|
||||
var trimNext = function() {
|
||||
if (nextToken && nextToken.value && nextToken.type !== 'string.regexp')
|
||||
nextToken.value = nextToken.value.replace(/^\s*/, "");
|
||||
};
|
||||
|
||||
var trimLine = function() {
|
||||
code = code.replace(/ +$/, "");
|
||||
};
|
||||
|
||||
var trimCode = function() {
|
||||
code = code.trimRight();
|
||||
breakBefore = false;
|
||||
};
|
||||
|
||||
while (token !== null) {
|
||||
curRow = iterator.getCurrentTokenRow();
|
||||
rowTokens = iterator.$rowTokens;
|
||||
nextToken = iterator.stepForward();
|
||||
|
||||
if (typeof token !== "undefined") {
|
||||
value = token.value;
|
||||
unindent = 0;
|
||||
inCSS = (tagName === "style" || session.$modeId === "ace/mode/css");
|
||||
if (is(token, "tag-open")) {
|
||||
inTag = true;
|
||||
if (nextToken)
|
||||
inBlock = (blockTags.indexOf(nextToken.value) !== -1);
|
||||
if (value === "</") {
|
||||
if (inBlock && !breakBefore && rowsToAdd < 1)
|
||||
rowsToAdd++;
|
||||
|
||||
if (inCSS)
|
||||
rowsToAdd = 1;
|
||||
|
||||
unindent = 1;
|
||||
inBlock = false;
|
||||
}
|
||||
} else if (is(token, "tag-close")) {
|
||||
inTag = false;
|
||||
} else if (is(token, "comment.start")) {
|
||||
inBlock = true;
|
||||
} else if (is(token, "comment.end")) {
|
||||
inBlock = false;
|
||||
}
|
||||
if (!inTag && !rowsToAdd && token.type === "paren.rparen" && token.value.substr(0, 1) === "}") {
|
||||
rowsToAdd++;
|
||||
}
|
||||
if (curRow !== row) {
|
||||
rowsToAdd = curRow;
|
||||
|
||||
if (row)
|
||||
rowsToAdd -= row;
|
||||
}
|
||||
|
||||
if (rowsToAdd) {
|
||||
trimCode();
|
||||
for (; rowsToAdd > 0; rowsToAdd--)
|
||||
code += "\n";
|
||||
|
||||
breakBefore = true;
|
||||
if (!is(token, "comment") && !token.type.match(/^(comment|string)$/))
|
||||
value = value.trimLeft();
|
||||
}
|
||||
|
||||
if (value) {
|
||||
if (token.type === "keyword" && value.match(/^(if|else|elseif|for|foreach|while|switch)$/)) {
|
||||
parents[depth] = value;
|
||||
|
||||
trimNext();
|
||||
spaceAfter = true;
|
||||
if (value.match(/^(else|elseif)$/)) {
|
||||
if (code.match(/\}[\s]*$/)) {
|
||||
trimCode();
|
||||
spaceBefore = true;
|
||||
}
|
||||
}
|
||||
} else if (token.type === "paren.lparen") {
|
||||
trimNext();
|
||||
if (value.substr(-1) === "{") {
|
||||
spaceAfter = true;
|
||||
indentNextLine = false;
|
||||
|
||||
if(!inTag)
|
||||
rowsToAdd = 1;
|
||||
}
|
||||
if (value.substr(0, 1) === "{") {
|
||||
spaceBefore = true;
|
||||
if (code.substr(-1) !== '[' && code.trimRight().substr(-1) === '[') {
|
||||
trimCode();
|
||||
spaceBefore = false;
|
||||
} else if (code.trimRight().substr(-1) === ')') {
|
||||
trimCode();
|
||||
} else {
|
||||
trimLine();
|
||||
}
|
||||
}
|
||||
} else if (token.type === "paren.rparen") {
|
||||
unindent = 1;
|
||||
if (value.substr(0, 1) === "}") {
|
||||
if (parents[depth-1] === 'case')
|
||||
unindent++;
|
||||
|
||||
if (code.trimRight().substr(-1) === '{') {
|
||||
trimCode();
|
||||
} else {
|
||||
spaceBefore = true;
|
||||
|
||||
if (inCSS)
|
||||
rowsToAdd+=2;
|
||||
}
|
||||
}
|
||||
if (value.substr(0, 1) === "]") {
|
||||
if (code.substr(-1) !== '}' && code.trimRight().substr(-1) === '}') {
|
||||
spaceBefore = false;
|
||||
indent++;
|
||||
trimCode();
|
||||
}
|
||||
}
|
||||
if (value.substr(0, 1) === ")") {
|
||||
if (code.substr(-1) !== '(' && code.trimRight().substr(-1) === '(') {
|
||||
spaceBefore = false;
|
||||
indent++;
|
||||
trimCode();
|
||||
}
|
||||
}
|
||||
|
||||
trimLine();
|
||||
} else if ((token.type === "keyword.operator" || token.type === "keyword") && value.match(/^(=|==|===|!=|!==|&&|\|\||and|or|xor|\+=|.=|>|>=|<|<=|=>)$/)) {
|
||||
trimCode();
|
||||
trimNext();
|
||||
spaceBefore = true;
|
||||
spaceAfter = true;
|
||||
} else if (token.type === "punctuation.operator" && value === ';') {
|
||||
trimCode();
|
||||
trimNext();
|
||||
spaceAfter = true;
|
||||
|
||||
if (inCSS)
|
||||
rowsToAdd++;
|
||||
} else if (token.type === "punctuation.operator" && value.match(/^(:|,)$/)) {
|
||||
trimCode();
|
||||
trimNext();
|
||||
if (value.match(/^(,)$/) && curlyDepth>0 && roundDepth===0) {
|
||||
rowsToAdd++;
|
||||
} else {
|
||||
spaceAfter = true;
|
||||
breakBefore = false;
|
||||
}
|
||||
} else if (token.type === "support.php_tag" && value === "?>" && !breakBefore) {
|
||||
trimCode();
|
||||
spaceBefore = true;
|
||||
} else if (is(token, "attribute-name") && code.substr(-1).match(/^\s$/)) {
|
||||
spaceBefore = true;
|
||||
} else if (is(token, "attribute-equals")) {
|
||||
trimLine();
|
||||
trimNext();
|
||||
} else if (is(token, "tag-close")) {
|
||||
trimLine();
|
||||
if(value === "/>")
|
||||
spaceBefore = true;
|
||||
}
|
||||
if (breakBefore && !(token.type.match(/^(comment)$/) && !value.substr(0, 1).match(/^[/#]$/)) && !(token.type.match(/^(string)$/) && !value.substr(0, 1).match(/^['"]$/))) {
|
||||
|
||||
indent = lastIndent;
|
||||
|
||||
if(depth > lastDepth) {
|
||||
indent++;
|
||||
|
||||
for (i=depth; i > lastDepth; i--)
|
||||
levels[i] = indent;
|
||||
} else if(depth < lastDepth)
|
||||
indent = levels[depth];
|
||||
|
||||
lastDepth = depth;
|
||||
lastIndent = indent;
|
||||
|
||||
if(unindent)
|
||||
indent -= unindent;
|
||||
|
||||
if (indentNextLine && !roundDepth) {
|
||||
indent++;
|
||||
indentNextLine = false;
|
||||
}
|
||||
|
||||
for (i = 0; i < indent; i++)
|
||||
code += tabString;
|
||||
}
|
||||
|
||||
|
||||
if (token.type === "keyword" && value.match(/^(case|default)$/)) {
|
||||
parents[depth] = value;
|
||||
depth++;
|
||||
}
|
||||
|
||||
|
||||
if (token.type === "keyword" && value.match(/^(break)$/)) {
|
||||
if(parents[depth-1] && parents[depth-1].match(/^(case|default)$/)) {
|
||||
depth--;
|
||||
}
|
||||
}
|
||||
if (token.type === "paren.lparen") {
|
||||
roundDepth += (value.match(/\(/g) || []).length;
|
||||
curlyDepth += (value.match(/\{/g) || []).length;
|
||||
depth += value.length;
|
||||
}
|
||||
|
||||
if (token.type === "keyword" && value.match(/^(if|else|elseif|for|while)$/)) {
|
||||
indentNextLine = true;
|
||||
roundDepth = 0;
|
||||
} else if (!roundDepth && value.trim() && token.type !== "comment")
|
||||
indentNextLine = false;
|
||||
|
||||
if (token.type === "paren.rparen") {
|
||||
roundDepth -= (value.match(/\)/g) || []).length;
|
||||
curlyDepth -= (value.match(/\}/g) || []).length;
|
||||
|
||||
for (i = 0; i < value.length; i++) {
|
||||
depth--;
|
||||
if(value.substr(i, 1)==='}' && parents[depth]==='case') {
|
||||
depth--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (token.type == "text")
|
||||
value = value.replace(/\s+$/, " ");
|
||||
if (spaceBefore && !breakBefore) {
|
||||
trimLine();
|
||||
if (code.substr(-1) !== "\n")
|
||||
code += " ";
|
||||
}
|
||||
|
||||
code += value;
|
||||
|
||||
if (spaceAfter)
|
||||
code += " ";
|
||||
|
||||
breakBefore = false;
|
||||
spaceBefore = false;
|
||||
spaceAfter = false;
|
||||
if ((is(token, "tag-close") && (inBlock || blockTags.indexOf(tagName) !== -1)) || (is(token, "doctype") && value === ">")) {
|
||||
if (inBlock && nextToken && nextToken.value === "</")
|
||||
rowsToAdd = -1;
|
||||
else
|
||||
rowsToAdd = 1;
|
||||
}
|
||||
if (is(token, "tag-open") && value === "</") {
|
||||
depth--;
|
||||
} else if (is(token, "tag-open") && value === "<" && singletonTags.indexOf(nextToken.value) === -1) {
|
||||
depth++;
|
||||
} else if (is(token, "tag-name")) {
|
||||
tagName = value;
|
||||
} else if (is(token, "tag-close") && value === "/>" && singletonTags.indexOf(tagName) === -1){
|
||||
depth--;
|
||||
}
|
||||
|
||||
row = curRow;
|
||||
}
|
||||
}
|
||||
|
||||
token = nextToken;
|
||||
}
|
||||
|
||||
code = code.trim();
|
||||
session.doc.setValue(code);
|
||||
};
|
||||
|
||||
exports.commands = [{
|
||||
name: "beautify",
|
||||
description: "Format selection (Beautify)",
|
||||
exec: function(editor) {
|
||||
exports.beautify(editor.session);
|
||||
},
|
||||
bindKey: "Ctrl-Shift-B"
|
||||
}];
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/beautify"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
ace.define("ace/ext/code_lens",["require","exports","module","ace/line_widgets","ace/lib/lang","ace/lib/dom","ace/editor","ace/config"], function(require, exports, module) {
|
||||
"use strict";
|
||||
var LineWidgets = require("../line_widgets").LineWidgets;
|
||||
var lang = require("../lib/lang");
|
||||
var dom = require("../lib/dom");
|
||||
|
||||
function clearLensElements(renderer) {
|
||||
var textLayer = renderer.$textLayer;
|
||||
var lensElements = textLayer.$lenses;
|
||||
if (lensElements)
|
||||
lensElements.forEach(function(el) {el.remove(); });
|
||||
textLayer.$lenses = null;
|
||||
}
|
||||
|
||||
function renderWidgets(changes, renderer) {
|
||||
var changed = changes & renderer.CHANGE_LINES
|
||||
|| changes & renderer.CHANGE_FULL
|
||||
|| changes & renderer.CHANGE_SCROLL
|
||||
|| changes & renderer.CHANGE_TEXT;
|
||||
if (!changed)
|
||||
return;
|
||||
|
||||
var session = renderer.session;
|
||||
var lineWidgets = renderer.session.lineWidgets;
|
||||
var textLayer = renderer.$textLayer;
|
||||
var lensElements = textLayer.$lenses;
|
||||
if (!lineWidgets) {
|
||||
if (lensElements)
|
||||
clearLensElements(renderer);
|
||||
return;
|
||||
}
|
||||
|
||||
var textCells = renderer.$textLayer.$lines.cells;
|
||||
var config = renderer.layerConfig;
|
||||
var padding = renderer.$padding;
|
||||
|
||||
if (!lensElements)
|
||||
lensElements = textLayer.$lenses = [];
|
||||
|
||||
|
||||
var index = 0;
|
||||
for (var i = 0; i < textCells.length; i++) {
|
||||
var row = textCells[i].row;
|
||||
var widget = lineWidgets[row];
|
||||
var lenses = widget && widget.lenses;
|
||||
|
||||
if (!lenses || !lenses.length) continue;
|
||||
|
||||
var lensContainer = lensElements[index];
|
||||
if (!lensContainer) {
|
||||
lensContainer = lensElements[index]
|
||||
= dom.buildDom(["div", {class: "ace_codeLens"}], renderer.container);
|
||||
}
|
||||
lensContainer.style.height = config.lineHeight + "px";
|
||||
index++;
|
||||
|
||||
for (var j = 0; j < lenses.length; j++) {
|
||||
var el = lensContainer.childNodes[2 * j];
|
||||
if (!el) {
|
||||
if (j != 0) lensContainer.appendChild(dom.createTextNode("\xa0|\xa0"));
|
||||
el = dom.buildDom(["a"], lensContainer);
|
||||
}
|
||||
el.textContent = lenses[j].title;
|
||||
el.lensCommand = lenses[j];
|
||||
}
|
||||
while (lensContainer.childNodes.length > 2 * j - 1)
|
||||
lensContainer.lastChild.remove();
|
||||
|
||||
var top = renderer.$cursorLayer.getPixelPosition({
|
||||
row: row,
|
||||
column: 0
|
||||
}, true).top - config.lineHeight * widget.rowsAbove - config.offset;
|
||||
lensContainer.style.top = top + "px";
|
||||
|
||||
var left = renderer.gutterWidth;
|
||||
var indent = session.getLine(row).search(/\S|$/);
|
||||
if (indent == -1)
|
||||
indent = 0;
|
||||
left += indent * config.characterWidth;
|
||||
left -= renderer.scrollLeft;
|
||||
lensContainer.style.paddingLeft = padding + left + "px";
|
||||
}
|
||||
while (index < lensElements.length)
|
||||
lensElements.pop().remove();
|
||||
}
|
||||
|
||||
function clearCodeLensWidgets(session) {
|
||||
if (!session.lineWidgets) return;
|
||||
var widgetManager = session.widgetManager;
|
||||
session.lineWidgets.forEach(function(widget) {
|
||||
if (widget && widget.lenses)
|
||||
widgetManager.removeLineWidget(widget);
|
||||
});
|
||||
}
|
||||
|
||||
exports.setLenses = function(session, lenses) {
|
||||
var firstRow = Number.MAX_VALUE;
|
||||
|
||||
clearCodeLensWidgets(session);
|
||||
lenses && lenses.forEach(function(lens) {
|
||||
var row = lens.start.row;
|
||||
var column = lens.start.column;
|
||||
var widget = session.lineWidgets && session.lineWidgets[row];
|
||||
if (!widget || !widget.lenses) {
|
||||
widget = session.widgetManager.$registerLineWidget({
|
||||
rowCount: 1,
|
||||
rowsAbove: 1,
|
||||
row: row,
|
||||
column: column,
|
||||
lenses: []
|
||||
});
|
||||
}
|
||||
widget.lenses.push(lens.command);
|
||||
if (row < firstRow)
|
||||
firstRow = row;
|
||||
});
|
||||
session._emit("changeFold", {data: {start: {row: firstRow}}});
|
||||
};
|
||||
|
||||
function attachToEditor(editor) {
|
||||
editor.codeLensProviders = [];
|
||||
editor.renderer.on("afterRender", renderWidgets);
|
||||
editor.$codeLensClickHandler = function(e) {
|
||||
var command = e.target.lensCommand;
|
||||
if (command)
|
||||
editor.execCommand(command.id, command.arguments);
|
||||
};
|
||||
editor.container.addEventListener("click", editor.$codeLensClickHandler);
|
||||
editor.$updateLenses = function() {
|
||||
var session = editor.session;
|
||||
if (!session) return;
|
||||
|
||||
if (!session.widgetManager) {
|
||||
session.widgetManager = new LineWidgets(session);
|
||||
session.widgetManager.attach(editor);
|
||||
}
|
||||
|
||||
var providersToWaitNum = editor.codeLensProviders.length;
|
||||
var lenses = [];
|
||||
editor.codeLensProviders.forEach(function(provider) {
|
||||
provider.provideCodeLenses(session, function(currentLenses) {
|
||||
currentLenses.forEach(function(lens) {
|
||||
lenses.push(lens);
|
||||
});
|
||||
providersToWaitNum--;
|
||||
if (providersToWaitNum == 0) {
|
||||
applyLenses();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function applyLenses() {
|
||||
var cursor = session.selection.cursor;
|
||||
var oldRow = session.documentToScreenRow(cursor);
|
||||
exports.setLenses(session, lenses);
|
||||
|
||||
var lastDelta = session.$undoManager && session.$undoManager.$lastDelta;
|
||||
if (lastDelta && lastDelta.action == "remove" && lastDelta.lines.length > 1)
|
||||
return;
|
||||
var row = session.documentToScreenRow(cursor);
|
||||
var lineHeight = editor.renderer.layerConfig.lineHeight;
|
||||
var top = session.getScrollTop() + (row - oldRow) * lineHeight;
|
||||
session.setScrollTop(top);
|
||||
}
|
||||
};
|
||||
var updateLenses = lang.delayedCall(editor.$updateLenses);
|
||||
editor.$updateLensesOnInput = function() {
|
||||
updateLenses.delay(250);
|
||||
};
|
||||
editor.on("input", editor.$updateLensesOnInput);
|
||||
}
|
||||
|
||||
function detachFromEditor(editor) {
|
||||
editor.off("input", editor.$updateLensesOnInput);
|
||||
editor.renderer.off("afterRender", renderWidgets);
|
||||
if (editor.$codeLensClickHandler)
|
||||
editor.container.removeEventListener("click", editor.$codeLensClickHandler);
|
||||
}
|
||||
|
||||
exports.registerCodeLensProvider = function(editor, codeLensProvider) {
|
||||
editor.setOption("enableCodeLens", true);
|
||||
editor.codeLensProviders.push(codeLensProvider);
|
||||
editor.$updateLensesOnInput();
|
||||
};
|
||||
|
||||
exports.clear = function(session) {
|
||||
exports.setLenses(session, null);
|
||||
};
|
||||
|
||||
var Editor = require("../editor").Editor;
|
||||
require("../config").defineOptions(Editor.prototype, "editor", {
|
||||
enableCodeLens: {
|
||||
set: function(val) {
|
||||
if (val) {
|
||||
attachToEditor(this);
|
||||
} else {
|
||||
detachFromEditor(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dom.importCssString("\
|
||||
.ace_codeLens {\
|
||||
position: absolute;\
|
||||
color: #aaa;\
|
||||
font-size: 88%;\
|
||||
background: inherit;\
|
||||
width: 100%;\
|
||||
display: flex;\
|
||||
align-items: flex-end;\
|
||||
pointer-events: none;\
|
||||
}\
|
||||
.ace_codeLens > a {\
|
||||
cursor: pointer;\
|
||||
pointer-events: auto;\
|
||||
}\
|
||||
.ace_codeLens > a:hover {\
|
||||
color: #0000ff;\
|
||||
text-decoration: underline;\
|
||||
}\
|
||||
.ace_dark > .ace_codeLens > a:hover {\
|
||||
color: #4e94ce;\
|
||||
}\
|
||||
", "");
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/code_lens"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,277 @@
|
||||
ace.define("ace/ext/elastic_tabstops_lite",["require","exports","module","ace/editor","ace/config"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var ElasticTabstopsLite = function(editor) {
|
||||
this.$editor = editor;
|
||||
var self = this;
|
||||
var changedRows = [];
|
||||
var recordChanges = false;
|
||||
this.onAfterExec = function() {
|
||||
recordChanges = false;
|
||||
self.processRows(changedRows);
|
||||
changedRows = [];
|
||||
};
|
||||
this.onExec = function() {
|
||||
recordChanges = true;
|
||||
};
|
||||
this.onChange = function(delta) {
|
||||
if (recordChanges) {
|
||||
if (changedRows.indexOf(delta.start.row) == -1)
|
||||
changedRows.push(delta.start.row);
|
||||
if (delta.end.row != delta.start.row)
|
||||
changedRows.push(delta.end.row);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
(function() {
|
||||
this.processRows = function(rows) {
|
||||
this.$inChange = true;
|
||||
var checkedRows = [];
|
||||
|
||||
for (var r = 0, rowCount = rows.length; r < rowCount; r++) {
|
||||
var row = rows[r];
|
||||
|
||||
if (checkedRows.indexOf(row) > -1)
|
||||
continue;
|
||||
|
||||
var cellWidthObj = this.$findCellWidthsForBlock(row);
|
||||
var cellWidths = this.$setBlockCellWidthsToMax(cellWidthObj.cellWidths);
|
||||
var rowIndex = cellWidthObj.firstRow;
|
||||
|
||||
for (var w = 0, l = cellWidths.length; w < l; w++) {
|
||||
var widths = cellWidths[w];
|
||||
checkedRows.push(rowIndex);
|
||||
this.$adjustRow(rowIndex, widths);
|
||||
rowIndex++;
|
||||
}
|
||||
}
|
||||
this.$inChange = false;
|
||||
};
|
||||
|
||||
this.$findCellWidthsForBlock = function(row) {
|
||||
var cellWidths = [], widths;
|
||||
var rowIter = row;
|
||||
while (rowIter >= 0) {
|
||||
widths = this.$cellWidthsForRow(rowIter);
|
||||
if (widths.length == 0)
|
||||
break;
|
||||
|
||||
cellWidths.unshift(widths);
|
||||
rowIter--;
|
||||
}
|
||||
var firstRow = rowIter + 1;
|
||||
rowIter = row;
|
||||
var numRows = this.$editor.session.getLength();
|
||||
|
||||
while (rowIter < numRows - 1) {
|
||||
rowIter++;
|
||||
|
||||
widths = this.$cellWidthsForRow(rowIter);
|
||||
if (widths.length == 0)
|
||||
break;
|
||||
|
||||
cellWidths.push(widths);
|
||||
}
|
||||
|
||||
return { cellWidths: cellWidths, firstRow: firstRow };
|
||||
};
|
||||
|
||||
this.$cellWidthsForRow = function(row) {
|
||||
var selectionColumns = this.$selectionColumnsForRow(row);
|
||||
|
||||
var tabs = [-1].concat(this.$tabsForRow(row));
|
||||
var widths = tabs.map(function(el) { return 0; } ).slice(1);
|
||||
var line = this.$editor.session.getLine(row);
|
||||
|
||||
for (var i = 0, len = tabs.length - 1; i < len; i++) {
|
||||
var leftEdge = tabs[i]+1;
|
||||
var rightEdge = tabs[i+1];
|
||||
|
||||
var rightmostSelection = this.$rightmostSelectionInCell(selectionColumns, rightEdge);
|
||||
var cell = line.substring(leftEdge, rightEdge);
|
||||
widths[i] = Math.max(cell.replace(/\s+$/g,'').length, rightmostSelection - leftEdge);
|
||||
}
|
||||
|
||||
return widths;
|
||||
};
|
||||
|
||||
this.$selectionColumnsForRow = function(row) {
|
||||
var selections = [], cursor = this.$editor.getCursorPosition();
|
||||
if (this.$editor.session.getSelection().isEmpty()) {
|
||||
if (row == cursor.row)
|
||||
selections.push(cursor.column);
|
||||
}
|
||||
|
||||
return selections;
|
||||
};
|
||||
|
||||
this.$setBlockCellWidthsToMax = function(cellWidths) {
|
||||
var startingNewBlock = true, blockStartRow, blockEndRow, maxWidth;
|
||||
var columnInfo = this.$izip_longest(cellWidths);
|
||||
|
||||
for (var c = 0, l = columnInfo.length; c < l; c++) {
|
||||
var column = columnInfo[c];
|
||||
if (!column.push) {
|
||||
console.error(column);
|
||||
continue;
|
||||
}
|
||||
column.push(NaN);
|
||||
|
||||
for (var r = 0, s = column.length; r < s; r++) {
|
||||
var width = column[r];
|
||||
if (startingNewBlock) {
|
||||
blockStartRow = r;
|
||||
maxWidth = 0;
|
||||
startingNewBlock = false;
|
||||
}
|
||||
if (isNaN(width)) {
|
||||
blockEndRow = r;
|
||||
|
||||
for (var j = blockStartRow; j < blockEndRow; j++) {
|
||||
cellWidths[j][c] = maxWidth;
|
||||
}
|
||||
startingNewBlock = true;
|
||||
}
|
||||
|
||||
maxWidth = Math.max(maxWidth, width);
|
||||
}
|
||||
}
|
||||
|
||||
return cellWidths;
|
||||
};
|
||||
|
||||
this.$rightmostSelectionInCell = function(selectionColumns, cellRightEdge) {
|
||||
var rightmost = 0;
|
||||
|
||||
if (selectionColumns.length) {
|
||||
var lengths = [];
|
||||
for (var s = 0, length = selectionColumns.length; s < length; s++) {
|
||||
if (selectionColumns[s] <= cellRightEdge)
|
||||
lengths.push(s);
|
||||
else
|
||||
lengths.push(0);
|
||||
}
|
||||
rightmost = Math.max.apply(Math, lengths);
|
||||
}
|
||||
|
||||
return rightmost;
|
||||
};
|
||||
|
||||
this.$tabsForRow = function(row) {
|
||||
var rowTabs = [], line = this.$editor.session.getLine(row),
|
||||
re = /\t/g, match;
|
||||
|
||||
while ((match = re.exec(line)) != null) {
|
||||
rowTabs.push(match.index);
|
||||
}
|
||||
|
||||
return rowTabs;
|
||||
};
|
||||
|
||||
this.$adjustRow = function(row, widths) {
|
||||
var rowTabs = this.$tabsForRow(row);
|
||||
|
||||
if (rowTabs.length == 0)
|
||||
return;
|
||||
|
||||
var bias = 0, location = -1;
|
||||
var expandedSet = this.$izip(widths, rowTabs);
|
||||
|
||||
for (var i = 0, l = expandedSet.length; i < l; i++) {
|
||||
var w = expandedSet[i][0], it = expandedSet[i][1];
|
||||
location += 1 + w;
|
||||
it += bias;
|
||||
var difference = location - it;
|
||||
|
||||
if (difference == 0)
|
||||
continue;
|
||||
|
||||
var partialLine = this.$editor.session.getLine(row).substr(0, it );
|
||||
var strippedPartialLine = partialLine.replace(/\s*$/g, "");
|
||||
var ispaces = partialLine.length - strippedPartialLine.length;
|
||||
|
||||
if (difference > 0) {
|
||||
this.$editor.session.getDocument().insertInLine({row: row, column: it + 1}, Array(difference + 1).join(" ") + "\t");
|
||||
this.$editor.session.getDocument().removeInLine(row, it, it + 1);
|
||||
|
||||
bias += difference;
|
||||
}
|
||||
|
||||
if (difference < 0 && ispaces >= -difference) {
|
||||
this.$editor.session.getDocument().removeInLine(row, it + difference, it);
|
||||
bias += difference;
|
||||
}
|
||||
}
|
||||
};
|
||||
this.$izip_longest = function(iterables) {
|
||||
if (!iterables[0])
|
||||
return [];
|
||||
var longest = iterables[0].length;
|
||||
var iterablesLength = iterables.length;
|
||||
|
||||
for (var i = 1; i < iterablesLength; i++) {
|
||||
var iLength = iterables[i].length;
|
||||
if (iLength > longest)
|
||||
longest = iLength;
|
||||
}
|
||||
|
||||
var expandedSet = [];
|
||||
|
||||
for (var l = 0; l < longest; l++) {
|
||||
var set = [];
|
||||
for (var i = 0; i < iterablesLength; i++) {
|
||||
if (iterables[i][l] === "")
|
||||
set.push(NaN);
|
||||
else
|
||||
set.push(iterables[i][l]);
|
||||
}
|
||||
|
||||
expandedSet.push(set);
|
||||
}
|
||||
|
||||
|
||||
return expandedSet;
|
||||
};
|
||||
this.$izip = function(widths, tabs) {
|
||||
var size = widths.length >= tabs.length ? tabs.length : widths.length;
|
||||
|
||||
var expandedSet = [];
|
||||
for (var i = 0; i < size; i++) {
|
||||
var set = [ widths[i], tabs[i] ];
|
||||
expandedSet.push(set);
|
||||
}
|
||||
return expandedSet;
|
||||
};
|
||||
|
||||
}).call(ElasticTabstopsLite.prototype);
|
||||
|
||||
exports.ElasticTabstopsLite = ElasticTabstopsLite;
|
||||
|
||||
var Editor = require("../editor").Editor;
|
||||
require("../config").defineOptions(Editor.prototype, "editor", {
|
||||
useElasticTabstops: {
|
||||
set: function(val) {
|
||||
if (val) {
|
||||
if (!this.elasticTabstops)
|
||||
this.elasticTabstops = new ElasticTabstopsLite(this);
|
||||
this.commands.on("afterExec", this.elasticTabstops.onAfterExec);
|
||||
this.commands.on("exec", this.elasticTabstops.onExec);
|
||||
this.on("change", this.elasticTabstops.onChange);
|
||||
} else if (this.elasticTabstops) {
|
||||
this.commands.removeListener("afterExec", this.elasticTabstops.onAfterExec);
|
||||
this.commands.removeListener("exec", this.elasticTabstops.onExec);
|
||||
this.removeListener("change", this.elasticTabstops.onChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/elastic_tabstops_lite"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
||||
|
||||
; (function() {
|
||||
ace.require(["ace/ext/error_marker"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
ace.define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
|
||||
'use strict';
|
||||
var dom = require("../../lib/dom");
|
||||
var cssText = "#ace_settingsmenu, #kbshortcutmenu {\
|
||||
background-color: #F7F7F7;\
|
||||
color: black;\
|
||||
box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\
|
||||
padding: 1em 0.5em 2em 1em;\
|
||||
overflow: auto;\
|
||||
position: absolute;\
|
||||
margin: 0;\
|
||||
bottom: 0;\
|
||||
right: 0;\
|
||||
top: 0;\
|
||||
z-index: 9991;\
|
||||
cursor: default;\
|
||||
}\
|
||||
.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\
|
||||
box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\
|
||||
background-color: rgba(255, 255, 255, 0.6);\
|
||||
color: black;\
|
||||
}\
|
||||
.ace_optionsMenuEntry:hover {\
|
||||
background-color: rgba(100, 100, 100, 0.1);\
|
||||
transition: all 0.3s\
|
||||
}\
|
||||
.ace_closeButton {\
|
||||
background: rgba(245, 146, 146, 0.5);\
|
||||
border: 1px solid #F48A8A;\
|
||||
border-radius: 50%;\
|
||||
padding: 7px;\
|
||||
position: absolute;\
|
||||
right: -8px;\
|
||||
top: -8px;\
|
||||
z-index: 100000;\
|
||||
}\
|
||||
.ace_closeButton{\
|
||||
background: rgba(245, 146, 146, 0.9);\
|
||||
}\
|
||||
.ace_optionsMenuKey {\
|
||||
color: darkslateblue;\
|
||||
font-weight: bold;\
|
||||
}\
|
||||
.ace_optionsMenuCommand {\
|
||||
color: darkcyan;\
|
||||
font-weight: normal;\
|
||||
}\
|
||||
.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\
|
||||
vertical-align: middle;\
|
||||
}\
|
||||
.ace_optionsMenuEntry button[ace_selected_button=true] {\
|
||||
background: #e7e7e7;\
|
||||
box-shadow: 1px 0px 2px 0px #adadad inset;\
|
||||
border-color: #adadad;\
|
||||
}\
|
||||
.ace_optionsMenuEntry button {\
|
||||
background: white;\
|
||||
border: 1px solid lightgray;\
|
||||
margin: 0px;\
|
||||
}\
|
||||
.ace_optionsMenuEntry button:hover{\
|
||||
background: #f0f0f0;\
|
||||
}";
|
||||
dom.importCssString(cssText);
|
||||
|
||||
module.exports.overlayPage = function overlayPage(editor, contentElement, callback) {
|
||||
var closer = document.createElement('div');
|
||||
var ignoreFocusOut = false;
|
||||
|
||||
function documentEscListener(e) {
|
||||
if (e.keyCode === 27) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
if (!closer) return;
|
||||
document.removeEventListener('keydown', documentEscListener);
|
||||
closer.parentNode.removeChild(closer);
|
||||
if (editor) {
|
||||
editor.focus();
|
||||
}
|
||||
closer = null;
|
||||
callback && callback();
|
||||
}
|
||||
function setIgnoreFocusOut(ignore) {
|
||||
ignoreFocusOut = ignore;
|
||||
if (ignore) {
|
||||
closer.style.pointerEvents = "none";
|
||||
contentElement.style.pointerEvents = "auto";
|
||||
}
|
||||
}
|
||||
|
||||
closer.style.cssText = 'margin: 0; padding: 0; ' +
|
||||
'position: fixed; top:0; bottom:0; left:0; right:0;' +
|
||||
'z-index: 9990; ' +
|
||||
(editor ? 'background-color: rgba(0, 0, 0, 0.3);' : '');
|
||||
closer.addEventListener('click', function(e) {
|
||||
if (!ignoreFocusOut) {
|
||||
close();
|
||||
}
|
||||
});
|
||||
document.addEventListener('keydown', documentEscListener);
|
||||
|
||||
contentElement.addEventListener('click', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
closer.appendChild(contentElement);
|
||||
document.body.appendChild(closer);
|
||||
if (editor) {
|
||||
editor.blur();
|
||||
}
|
||||
return {
|
||||
close: close,
|
||||
setIgnoreFocusOut: setIgnoreFocusOut
|
||||
};
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/ext/menu_tools/get_editor_keyboard_shortcuts",["require","exports","module","ace/lib/keys"], function(require, exports, module) {
|
||||
"use strict";
|
||||
var keys = require("../../lib/keys");
|
||||
module.exports.getEditorKeybordShortcuts = function(editor) {
|
||||
var KEY_MODS = keys.KEY_MODS;
|
||||
var keybindings = [];
|
||||
var commandMap = {};
|
||||
editor.keyBinding.$handlers.forEach(function(handler) {
|
||||
var ckb = handler.commandKeyBinding;
|
||||
for (var i in ckb) {
|
||||
var key = i.replace(/(^|-)\w/g, function(x) { return x.toUpperCase(); });
|
||||
var commands = ckb[i];
|
||||
if (!Array.isArray(commands))
|
||||
commands = [commands];
|
||||
commands.forEach(function(command) {
|
||||
if (typeof command != "string")
|
||||
command = command.name;
|
||||
if (commandMap[command]) {
|
||||
commandMap[command].key += "|" + key;
|
||||
} else {
|
||||
commandMap[command] = {key: key, command: command};
|
||||
keybindings.push(commandMap[command]);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return keybindings;
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/ext/keybinding_menu",["require","exports","module","ace/editor","ace/ext/menu_tools/overlay_page","ace/ext/menu_tools/get_editor_keyboard_shortcuts"], function(require, exports, module) {
|
||||
"use strict";
|
||||
var Editor = require("../editor").Editor;
|
||||
function showKeyboardShortcuts (editor) {
|
||||
if(!document.getElementById('kbshortcutmenu')) {
|
||||
var overlayPage = require('./menu_tools/overlay_page').overlayPage;
|
||||
var getEditorKeybordShortcuts = require('./menu_tools/get_editor_keyboard_shortcuts').getEditorKeybordShortcuts;
|
||||
var kb = getEditorKeybordShortcuts(editor);
|
||||
var el = document.createElement('div');
|
||||
var commands = kb.reduce(function(previous, current) {
|
||||
return previous + '<div class="ace_optionsMenuEntry"><span class="ace_optionsMenuCommand">'
|
||||
+ current.command + '</span> : '
|
||||
+ '<span class="ace_optionsMenuKey">' + current.key + '</span></div>';
|
||||
}, '');
|
||||
|
||||
el.id = 'kbshortcutmenu';
|
||||
el.innerHTML = '<h1>Keyboard Shortcuts</h1>' + commands + '</div>';
|
||||
overlayPage(editor, el);
|
||||
}
|
||||
}
|
||||
module.exports.init = function(editor) {
|
||||
Editor.prototype.showKeyboardShortcuts = function() {
|
||||
showKeyboardShortcuts(this);
|
||||
};
|
||||
editor.commands.addCommands([{
|
||||
name: "showKeyboardShortcuts",
|
||||
bindKey: {win: "Ctrl-Alt-h", mac: "Command-Alt-h"},
|
||||
exec: function(editor, line) {
|
||||
editor.showKeyboardShortcuts();
|
||||
}
|
||||
}]);
|
||||
};
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/keybinding_menu"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,64 @@
|
||||
ace.define("ace/ext/linking",["require","exports","module","ace/editor","ace/config"], function(require, exports, module) {
|
||||
|
||||
var Editor = require("../editor").Editor;
|
||||
|
||||
require("../config").defineOptions(Editor.prototype, "editor", {
|
||||
enableLinking: {
|
||||
set: function(val) {
|
||||
if (val) {
|
||||
this.on("click", onClick);
|
||||
this.on("mousemove", onMouseMove);
|
||||
} else {
|
||||
this.off("click", onClick);
|
||||
this.off("mousemove", onMouseMove);
|
||||
}
|
||||
},
|
||||
value: false
|
||||
}
|
||||
});
|
||||
|
||||
exports.previousLinkingHover = false;
|
||||
|
||||
function onMouseMove(e) {
|
||||
var editor = e.editor;
|
||||
var ctrl = e.getAccelKey();
|
||||
|
||||
if (ctrl) {
|
||||
var editor = e.editor;
|
||||
var docPos = e.getDocumentPosition();
|
||||
var session = editor.session;
|
||||
var token = session.getTokenAt(docPos.row, docPos.column);
|
||||
|
||||
if (exports.previousLinkingHover && exports.previousLinkingHover != token) {
|
||||
editor._emit("linkHoverOut");
|
||||
}
|
||||
editor._emit("linkHover", {position: docPos, token: token});
|
||||
exports.previousLinkingHover = token;
|
||||
} else if (exports.previousLinkingHover) {
|
||||
editor._emit("linkHoverOut");
|
||||
exports.previousLinkingHover = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onClick(e) {
|
||||
var ctrl = e.getAccelKey();
|
||||
var button = e.getButton();
|
||||
|
||||
if (button == 0 && ctrl) {
|
||||
var editor = e.editor;
|
||||
var docPos = e.getDocumentPosition();
|
||||
var session = editor.session;
|
||||
var token = session.getTokenAt(docPos.row, docPos.column);
|
||||
|
||||
editor._emit("linkClick", {position: docPos, token: token});
|
||||
}
|
||||
}
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/linking"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
ace.define("ace/ext/modelist",["require","exports","module"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var modes = [];
|
||||
function getModeForPath(path) {
|
||||
var mode = modesByName.text;
|
||||
var fileName = path.split(/[\/\\]/).pop();
|
||||
for (var i = 0; i < modes.length; i++) {
|
||||
if (modes[i].supportsFile(fileName)) {
|
||||
mode = modes[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
var Mode = function(name, caption, extensions) {
|
||||
this.name = name;
|
||||
this.caption = caption;
|
||||
this.mode = "ace/mode/" + name;
|
||||
this.extensions = extensions;
|
||||
var re;
|
||||
if (/\^/.test(extensions)) {
|
||||
re = extensions.replace(/\|(\^)?/g, function(a, b){
|
||||
return "$|" + (b ? "^" : "^.*\\.");
|
||||
}) + "$";
|
||||
} else {
|
||||
re = "^.*\\.(" + extensions + ")$";
|
||||
}
|
||||
|
||||
this.extRe = new RegExp(re, "gi");
|
||||
};
|
||||
|
||||
Mode.prototype.supportsFile = function(filename) {
|
||||
return filename.match(this.extRe);
|
||||
};
|
||||
var supportedModes = {
|
||||
ABAP: ["abap"],
|
||||
ABC: ["abc"],
|
||||
ActionScript:["as"],
|
||||
ADA: ["ada|adb"],
|
||||
Alda: ["alda"],
|
||||
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
|
||||
Apex: ["apex|cls|trigger|tgr"],
|
||||
AQL: ["aql"],
|
||||
AsciiDoc: ["asciidoc|adoc"],
|
||||
ASL: ["dsl|asl"],
|
||||
Assembly_x86:["asm|a"],
|
||||
AutoHotKey: ["ahk"],
|
||||
BatchFile: ["bat|cmd"],
|
||||
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"],
|
||||
C9Search: ["c9search_results"],
|
||||
Cirru: ["cirru|cr"],
|
||||
Clojure: ["clj|cljs"],
|
||||
Cobol: ["CBL|COB"],
|
||||
coffee: ["coffee|cf|cson|^Cakefile"],
|
||||
ColdFusion: ["cfm"],
|
||||
Crystal: ["cr"],
|
||||
CSharp: ["cs"],
|
||||
Csound_Document: ["csd"],
|
||||
Csound_Orchestra: ["orc"],
|
||||
Csound_Score: ["sco"],
|
||||
CSS: ["css"],
|
||||
Curly: ["curly"],
|
||||
D: ["d|di"],
|
||||
Dart: ["dart"],
|
||||
Diff: ["diff|patch"],
|
||||
Dockerfile: ["^Dockerfile"],
|
||||
Dot: ["dot"],
|
||||
Drools: ["drl"],
|
||||
Edifact: ["edi"],
|
||||
Eiffel: ["e|ge"],
|
||||
EJS: ["ejs"],
|
||||
Elixir: ["ex|exs"],
|
||||
Elm: ["elm"],
|
||||
Erlang: ["erl|hrl"],
|
||||
Forth: ["frt|fs|ldr|fth|4th"],
|
||||
Fortran: ["f|f90"],
|
||||
FSharp: ["fsi|fs|ml|mli|fsx|fsscript"],
|
||||
FSL: ["fsl"],
|
||||
FTL: ["ftl"],
|
||||
Gcode: ["gcode"],
|
||||
Gherkin: ["feature"],
|
||||
Gitignore: ["^.gitignore"],
|
||||
Glsl: ["glsl|frag|vert"],
|
||||
Gobstones: ["gbs"],
|
||||
golang: ["go"],
|
||||
GraphQLSchema: ["gql"],
|
||||
Groovy: ["groovy"],
|
||||
HAML: ["haml"],
|
||||
Handlebars: ["hbs|handlebars|tpl|mustache"],
|
||||
Haskell: ["hs"],
|
||||
Haskell_Cabal: ["cabal"],
|
||||
haXe: ["hx"],
|
||||
Hjson: ["hjson"],
|
||||
HTML: ["html|htm|xhtml|vue|we|wpy"],
|
||||
HTML_Elixir: ["eex|html.eex"],
|
||||
HTML_Ruby: ["erb|rhtml|html.erb"],
|
||||
INI: ["ini|conf|cfg|prefs"],
|
||||
Io: ["io"],
|
||||
Jack: ["jack"],
|
||||
Jade: ["jade|pug"],
|
||||
Java: ["java"],
|
||||
JavaScript: ["js|jsm|jsx"],
|
||||
JSON: ["json"],
|
||||
JSON5: ["json5"],
|
||||
JSONiq: ["jq"],
|
||||
JSP: ["jsp"],
|
||||
JSSM: ["jssm|jssm_state"],
|
||||
JSX: ["jsx"],
|
||||
Julia: ["jl"],
|
||||
Kotlin: ["kt|kts"],
|
||||
LaTeX: ["tex|latex|ltx|bib"],
|
||||
LESS: ["less"],
|
||||
Liquid: ["liquid"],
|
||||
Lisp: ["lisp"],
|
||||
LiveScript: ["ls"],
|
||||
LogiQL: ["logic|lql"],
|
||||
LSL: ["lsl"],
|
||||
Lua: ["lua"],
|
||||
LuaPage: ["lp"],
|
||||
Lucene: ["lucene"],
|
||||
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
|
||||
Markdown: ["md|markdown"],
|
||||
Mask: ["mask"],
|
||||
MATLAB: ["matlab"],
|
||||
Maze: ["mz"],
|
||||
MediaWiki: ["wiki|mediawiki"],
|
||||
MEL: ["mel"],
|
||||
MIXAL: ["mixal"],
|
||||
MUSHCode: ["mc|mush"],
|
||||
MySQL: ["mysql"],
|
||||
Nginx: ["nginx|conf"],
|
||||
Nim: ["nim"],
|
||||
Nix: ["nix"],
|
||||
NSIS: ["nsi|nsh"],
|
||||
Nunjucks: ["nunjucks|nunjs|nj|njk"],
|
||||
ObjectiveC: ["m|mm"],
|
||||
OCaml: ["ml|mli"],
|
||||
Pascal: ["pas|p"],
|
||||
Perl: ["pl|pm"],
|
||||
Perl6: ["p6|pl6|pm6"],
|
||||
pgSQL: ["pgsql"],
|
||||
PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
|
||||
PHP_Laravel_blade: ["blade.php"],
|
||||
Pig: ["pig"],
|
||||
Powershell: ["ps1"],
|
||||
Praat: ["praat|praatscript|psc|proc"],
|
||||
Prisma: ["prisma"],
|
||||
Prolog: ["plg|prolog"],
|
||||
Properties: ["properties"],
|
||||
Protobuf: ["proto"],
|
||||
Puppet: ["epp|pp"],
|
||||
Python: ["py"],
|
||||
QML: ["qml"],
|
||||
R: ["r"],
|
||||
Razor: ["cshtml|asp"],
|
||||
RDoc: ["Rd"],
|
||||
Red: ["red|reds"],
|
||||
RHTML: ["Rhtml"],
|
||||
RST: ["rst"],
|
||||
Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
|
||||
Rust: ["rs"],
|
||||
SASS: ["sass"],
|
||||
SCAD: ["scad"],
|
||||
Scala: ["scala|sbt"],
|
||||
Scheme: ["scm|sm|rkt|oak|scheme"],
|
||||
SCSS: ["scss"],
|
||||
SH: ["sh|bash|^.bashrc"],
|
||||
SJS: ["sjs"],
|
||||
Slim: ["slim|skim"],
|
||||
Smarty: ["smarty|tpl"],
|
||||
snippets: ["snippets"],
|
||||
Soy_Template:["soy"],
|
||||
Space: ["space"],
|
||||
SQL: ["sql"],
|
||||
SQLServer: ["sqlserver"],
|
||||
Stylus: ["styl|stylus"],
|
||||
SVG: ["svg"],
|
||||
Swift: ["swift"],
|
||||
Tcl: ["tcl"],
|
||||
Terraform: ["tf", "tfvars", "terragrunt"],
|
||||
Tex: ["tex"],
|
||||
Text: ["txt"],
|
||||
Textile: ["textile"],
|
||||
Toml: ["toml"],
|
||||
TSX: ["tsx"],
|
||||
Twig: ["latte|twig|swig"],
|
||||
Typescript: ["ts|typescript|str"],
|
||||
Vala: ["vala"],
|
||||
VBScript: ["vbs|vb"],
|
||||
Velocity: ["vm"],
|
||||
Verilog: ["v|vh|sv|svh"],
|
||||
VHDL: ["vhd|vhdl"],
|
||||
Visualforce: ["vfp|component|page"],
|
||||
Wollok: ["wlk|wpgm|wtest"],
|
||||
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
|
||||
XQuery: ["xq"],
|
||||
YAML: ["yaml|yml"],
|
||||
Zeek: ["zeek|bro"],
|
||||
Django: ["html"]
|
||||
};
|
||||
|
||||
var nameOverrides = {
|
||||
ObjectiveC: "Objective-C",
|
||||
CSharp: "C#",
|
||||
golang: "Go",
|
||||
C_Cpp: "C and C++",
|
||||
Csound_Document: "Csound Document",
|
||||
Csound_Orchestra: "Csound",
|
||||
Csound_Score: "Csound Score",
|
||||
coffee: "CoffeeScript",
|
||||
HTML_Ruby: "HTML (Ruby)",
|
||||
HTML_Elixir: "HTML (Elixir)",
|
||||
FTL: "FreeMarker",
|
||||
PHP_Laravel_blade: "PHP (Blade Template)",
|
||||
Perl6: "Perl 6",
|
||||
AutoHotKey: "AutoHotkey / AutoIt"
|
||||
};
|
||||
var modesByName = {};
|
||||
for (var name in supportedModes) {
|
||||
var data = supportedModes[name];
|
||||
var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
|
||||
var filename = name.toLowerCase();
|
||||
var mode = new Mode(filename, displayName, data[0]);
|
||||
modesByName[filename] = mode;
|
||||
modes.push(mode);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getModeForPath: getModeForPath,
|
||||
modes: modes,
|
||||
modesByName: modesByName
|
||||
};
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/modelist"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,793 @@
|
||||
ace.define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
|
||||
'use strict';
|
||||
var dom = require("../../lib/dom");
|
||||
var cssText = "#ace_settingsmenu, #kbshortcutmenu {\
|
||||
background-color: #F7F7F7;\
|
||||
color: black;\
|
||||
box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\
|
||||
padding: 1em 0.5em 2em 1em;\
|
||||
overflow: auto;\
|
||||
position: absolute;\
|
||||
margin: 0;\
|
||||
bottom: 0;\
|
||||
right: 0;\
|
||||
top: 0;\
|
||||
z-index: 9991;\
|
||||
cursor: default;\
|
||||
}\
|
||||
.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\
|
||||
box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\
|
||||
background-color: rgba(255, 255, 255, 0.6);\
|
||||
color: black;\
|
||||
}\
|
||||
.ace_optionsMenuEntry:hover {\
|
||||
background-color: rgba(100, 100, 100, 0.1);\
|
||||
transition: all 0.3s\
|
||||
}\
|
||||
.ace_closeButton {\
|
||||
background: rgba(245, 146, 146, 0.5);\
|
||||
border: 1px solid #F48A8A;\
|
||||
border-radius: 50%;\
|
||||
padding: 7px;\
|
||||
position: absolute;\
|
||||
right: -8px;\
|
||||
top: -8px;\
|
||||
z-index: 100000;\
|
||||
}\
|
||||
.ace_closeButton{\
|
||||
background: rgba(245, 146, 146, 0.9);\
|
||||
}\
|
||||
.ace_optionsMenuKey {\
|
||||
color: darkslateblue;\
|
||||
font-weight: bold;\
|
||||
}\
|
||||
.ace_optionsMenuCommand {\
|
||||
color: darkcyan;\
|
||||
font-weight: normal;\
|
||||
}\
|
||||
.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\
|
||||
vertical-align: middle;\
|
||||
}\
|
||||
.ace_optionsMenuEntry button[ace_selected_button=true] {\
|
||||
background: #e7e7e7;\
|
||||
box-shadow: 1px 0px 2px 0px #adadad inset;\
|
||||
border-color: #adadad;\
|
||||
}\
|
||||
.ace_optionsMenuEntry button {\
|
||||
background: white;\
|
||||
border: 1px solid lightgray;\
|
||||
margin: 0px;\
|
||||
}\
|
||||
.ace_optionsMenuEntry button:hover{\
|
||||
background: #f0f0f0;\
|
||||
}";
|
||||
dom.importCssString(cssText);
|
||||
|
||||
module.exports.overlayPage = function overlayPage(editor, contentElement, callback) {
|
||||
var closer = document.createElement('div');
|
||||
var ignoreFocusOut = false;
|
||||
|
||||
function documentEscListener(e) {
|
||||
if (e.keyCode === 27) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
if (!closer) return;
|
||||
document.removeEventListener('keydown', documentEscListener);
|
||||
closer.parentNode.removeChild(closer);
|
||||
if (editor) {
|
||||
editor.focus();
|
||||
}
|
||||
closer = null;
|
||||
callback && callback();
|
||||
}
|
||||
function setIgnoreFocusOut(ignore) {
|
||||
ignoreFocusOut = ignore;
|
||||
if (ignore) {
|
||||
closer.style.pointerEvents = "none";
|
||||
contentElement.style.pointerEvents = "auto";
|
||||
}
|
||||
}
|
||||
|
||||
closer.style.cssText = 'margin: 0; padding: 0; ' +
|
||||
'position: fixed; top:0; bottom:0; left:0; right:0;' +
|
||||
'z-index: 9990; ' +
|
||||
(editor ? 'background-color: rgba(0, 0, 0, 0.3);' : '');
|
||||
closer.addEventListener('click', function(e) {
|
||||
if (!ignoreFocusOut) {
|
||||
close();
|
||||
}
|
||||
});
|
||||
document.addEventListener('keydown', documentEscListener);
|
||||
|
||||
contentElement.addEventListener('click', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
closer.appendChild(contentElement);
|
||||
document.body.appendChild(closer);
|
||||
if (editor) {
|
||||
editor.blur();
|
||||
}
|
||||
return {
|
||||
close: close,
|
||||
setIgnoreFocusOut: setIgnoreFocusOut
|
||||
};
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/ext/modelist",["require","exports","module"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var modes = [];
|
||||
function getModeForPath(path) {
|
||||
var mode = modesByName.text;
|
||||
var fileName = path.split(/[\/\\]/).pop();
|
||||
for (var i = 0; i < modes.length; i++) {
|
||||
if (modes[i].supportsFile(fileName)) {
|
||||
mode = modes[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
var Mode = function(name, caption, extensions) {
|
||||
this.name = name;
|
||||
this.caption = caption;
|
||||
this.mode = "ace/mode/" + name;
|
||||
this.extensions = extensions;
|
||||
var re;
|
||||
if (/\^/.test(extensions)) {
|
||||
re = extensions.replace(/\|(\^)?/g, function(a, b){
|
||||
return "$|" + (b ? "^" : "^.*\\.");
|
||||
}) + "$";
|
||||
} else {
|
||||
re = "^.*\\.(" + extensions + ")$";
|
||||
}
|
||||
|
||||
this.extRe = new RegExp(re, "gi");
|
||||
};
|
||||
|
||||
Mode.prototype.supportsFile = function(filename) {
|
||||
return filename.match(this.extRe);
|
||||
};
|
||||
var supportedModes = {
|
||||
ABAP: ["abap"],
|
||||
ABC: ["abc"],
|
||||
ActionScript:["as"],
|
||||
ADA: ["ada|adb"],
|
||||
Alda: ["alda"],
|
||||
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
|
||||
Apex: ["apex|cls|trigger|tgr"],
|
||||
AQL: ["aql"],
|
||||
AsciiDoc: ["asciidoc|adoc"],
|
||||
ASL: ["dsl|asl"],
|
||||
Assembly_x86:["asm|a"],
|
||||
AutoHotKey: ["ahk"],
|
||||
BatchFile: ["bat|cmd"],
|
||||
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"],
|
||||
C9Search: ["c9search_results"],
|
||||
Cirru: ["cirru|cr"],
|
||||
Clojure: ["clj|cljs"],
|
||||
Cobol: ["CBL|COB"],
|
||||
coffee: ["coffee|cf|cson|^Cakefile"],
|
||||
ColdFusion: ["cfm"],
|
||||
Crystal: ["cr"],
|
||||
CSharp: ["cs"],
|
||||
Csound_Document: ["csd"],
|
||||
Csound_Orchestra: ["orc"],
|
||||
Csound_Score: ["sco"],
|
||||
CSS: ["css"],
|
||||
Curly: ["curly"],
|
||||
D: ["d|di"],
|
||||
Dart: ["dart"],
|
||||
Diff: ["diff|patch"],
|
||||
Dockerfile: ["^Dockerfile"],
|
||||
Dot: ["dot"],
|
||||
Drools: ["drl"],
|
||||
Edifact: ["edi"],
|
||||
Eiffel: ["e|ge"],
|
||||
EJS: ["ejs"],
|
||||
Elixir: ["ex|exs"],
|
||||
Elm: ["elm"],
|
||||
Erlang: ["erl|hrl"],
|
||||
Forth: ["frt|fs|ldr|fth|4th"],
|
||||
Fortran: ["f|f90"],
|
||||
FSharp: ["fsi|fs|ml|mli|fsx|fsscript"],
|
||||
FSL: ["fsl"],
|
||||
FTL: ["ftl"],
|
||||
Gcode: ["gcode"],
|
||||
Gherkin: ["feature"],
|
||||
Gitignore: ["^.gitignore"],
|
||||
Glsl: ["glsl|frag|vert"],
|
||||
Gobstones: ["gbs"],
|
||||
golang: ["go"],
|
||||
GraphQLSchema: ["gql"],
|
||||
Groovy: ["groovy"],
|
||||
HAML: ["haml"],
|
||||
Handlebars: ["hbs|handlebars|tpl|mustache"],
|
||||
Haskell: ["hs"],
|
||||
Haskell_Cabal: ["cabal"],
|
||||
haXe: ["hx"],
|
||||
Hjson: ["hjson"],
|
||||
HTML: ["html|htm|xhtml|vue|we|wpy"],
|
||||
HTML_Elixir: ["eex|html.eex"],
|
||||
HTML_Ruby: ["erb|rhtml|html.erb"],
|
||||
INI: ["ini|conf|cfg|prefs"],
|
||||
Io: ["io"],
|
||||
Jack: ["jack"],
|
||||
Jade: ["jade|pug"],
|
||||
Java: ["java"],
|
||||
JavaScript: ["js|jsm|jsx"],
|
||||
JSON: ["json"],
|
||||
JSON5: ["json5"],
|
||||
JSONiq: ["jq"],
|
||||
JSP: ["jsp"],
|
||||
JSSM: ["jssm|jssm_state"],
|
||||
JSX: ["jsx"],
|
||||
Julia: ["jl"],
|
||||
Kotlin: ["kt|kts"],
|
||||
LaTeX: ["tex|latex|ltx|bib"],
|
||||
LESS: ["less"],
|
||||
Liquid: ["liquid"],
|
||||
Lisp: ["lisp"],
|
||||
LiveScript: ["ls"],
|
||||
LogiQL: ["logic|lql"],
|
||||
LSL: ["lsl"],
|
||||
Lua: ["lua"],
|
||||
LuaPage: ["lp"],
|
||||
Lucene: ["lucene"],
|
||||
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
|
||||
Markdown: ["md|markdown"],
|
||||
Mask: ["mask"],
|
||||
MATLAB: ["matlab"],
|
||||
Maze: ["mz"],
|
||||
MediaWiki: ["wiki|mediawiki"],
|
||||
MEL: ["mel"],
|
||||
MIXAL: ["mixal"],
|
||||
MUSHCode: ["mc|mush"],
|
||||
MySQL: ["mysql"],
|
||||
Nginx: ["nginx|conf"],
|
||||
Nim: ["nim"],
|
||||
Nix: ["nix"],
|
||||
NSIS: ["nsi|nsh"],
|
||||
Nunjucks: ["nunjucks|nunjs|nj|njk"],
|
||||
ObjectiveC: ["m|mm"],
|
||||
OCaml: ["ml|mli"],
|
||||
Pascal: ["pas|p"],
|
||||
Perl: ["pl|pm"],
|
||||
Perl6: ["p6|pl6|pm6"],
|
||||
pgSQL: ["pgsql"],
|
||||
PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
|
||||
PHP_Laravel_blade: ["blade.php"],
|
||||
Pig: ["pig"],
|
||||
Powershell: ["ps1"],
|
||||
Praat: ["praat|praatscript|psc|proc"],
|
||||
Prisma: ["prisma"],
|
||||
Prolog: ["plg|prolog"],
|
||||
Properties: ["properties"],
|
||||
Protobuf: ["proto"],
|
||||
Puppet: ["epp|pp"],
|
||||
Python: ["py"],
|
||||
QML: ["qml"],
|
||||
R: ["r"],
|
||||
Razor: ["cshtml|asp"],
|
||||
RDoc: ["Rd"],
|
||||
Red: ["red|reds"],
|
||||
RHTML: ["Rhtml"],
|
||||
RST: ["rst"],
|
||||
Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
|
||||
Rust: ["rs"],
|
||||
SASS: ["sass"],
|
||||
SCAD: ["scad"],
|
||||
Scala: ["scala|sbt"],
|
||||
Scheme: ["scm|sm|rkt|oak|scheme"],
|
||||
SCSS: ["scss"],
|
||||
SH: ["sh|bash|^.bashrc"],
|
||||
SJS: ["sjs"],
|
||||
Slim: ["slim|skim"],
|
||||
Smarty: ["smarty|tpl"],
|
||||
snippets: ["snippets"],
|
||||
Soy_Template:["soy"],
|
||||
Space: ["space"],
|
||||
SQL: ["sql"],
|
||||
SQLServer: ["sqlserver"],
|
||||
Stylus: ["styl|stylus"],
|
||||
SVG: ["svg"],
|
||||
Swift: ["swift"],
|
||||
Tcl: ["tcl"],
|
||||
Terraform: ["tf", "tfvars", "terragrunt"],
|
||||
Tex: ["tex"],
|
||||
Text: ["txt"],
|
||||
Textile: ["textile"],
|
||||
Toml: ["toml"],
|
||||
TSX: ["tsx"],
|
||||
Twig: ["latte|twig|swig"],
|
||||
Typescript: ["ts|typescript|str"],
|
||||
Vala: ["vala"],
|
||||
VBScript: ["vbs|vb"],
|
||||
Velocity: ["vm"],
|
||||
Verilog: ["v|vh|sv|svh"],
|
||||
VHDL: ["vhd|vhdl"],
|
||||
Visualforce: ["vfp|component|page"],
|
||||
Wollok: ["wlk|wpgm|wtest"],
|
||||
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
|
||||
XQuery: ["xq"],
|
||||
YAML: ["yaml|yml"],
|
||||
Zeek: ["zeek|bro"],
|
||||
Django: ["html"]
|
||||
};
|
||||
|
||||
var nameOverrides = {
|
||||
ObjectiveC: "Objective-C",
|
||||
CSharp: "C#",
|
||||
golang: "Go",
|
||||
C_Cpp: "C and C++",
|
||||
Csound_Document: "Csound Document",
|
||||
Csound_Orchestra: "Csound",
|
||||
Csound_Score: "Csound Score",
|
||||
coffee: "CoffeeScript",
|
||||
HTML_Ruby: "HTML (Ruby)",
|
||||
HTML_Elixir: "HTML (Elixir)",
|
||||
FTL: "FreeMarker",
|
||||
PHP_Laravel_blade: "PHP (Blade Template)",
|
||||
Perl6: "Perl 6",
|
||||
AutoHotKey: "AutoHotkey / AutoIt"
|
||||
};
|
||||
var modesByName = {};
|
||||
for (var name in supportedModes) {
|
||||
var data = supportedModes[name];
|
||||
var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
|
||||
var filename = name.toLowerCase();
|
||||
var mode = new Mode(filename, displayName, data[0]);
|
||||
modesByName[filename] = mode;
|
||||
modes.push(mode);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getModeForPath: getModeForPath,
|
||||
modes: modes,
|
||||
modesByName: modesByName
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/ext/themelist",["require","exports","module"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var themeData = [
|
||||
["Chrome" ],
|
||||
["Clouds" ],
|
||||
["Crimson Editor" ],
|
||||
["Dawn" ],
|
||||
["Dreamweaver" ],
|
||||
["Eclipse" ],
|
||||
["GitHub" ],
|
||||
["IPlastic" ],
|
||||
["Solarized Light"],
|
||||
["TextMate" ],
|
||||
["Tomorrow" ],
|
||||
["Xcode" ],
|
||||
["Kuroir"],
|
||||
["KatzenMilch"],
|
||||
["SQL Server" ,"sqlserver" , "light"],
|
||||
["Ambiance" ,"ambiance" , "dark"],
|
||||
["Chaos" ,"chaos" , "dark"],
|
||||
["Clouds Midnight" ,"clouds_midnight" , "dark"],
|
||||
["Dracula" ,"" , "dark"],
|
||||
["Cobalt" ,"cobalt" , "dark"],
|
||||
["Gruvbox" ,"gruvbox" , "dark"],
|
||||
["Green on Black" ,"gob" , "dark"],
|
||||
["idle Fingers" ,"idle_fingers" , "dark"],
|
||||
["krTheme" ,"kr_theme" , "dark"],
|
||||
["Merbivore" ,"merbivore" , "dark"],
|
||||
["Merbivore Soft" ,"merbivore_soft" , "dark"],
|
||||
["Mono Industrial" ,"mono_industrial" , "dark"],
|
||||
["Monokai" ,"monokai" , "dark"],
|
||||
["Nord Dark" ,"nord_dark" , "dark"],
|
||||
["Pastel on dark" ,"pastel_on_dark" , "dark"],
|
||||
["Solarized Dark" ,"solarized_dark" , "dark"],
|
||||
["Terminal" ,"terminal" , "dark"],
|
||||
["Tomorrow Night" ,"tomorrow_night" , "dark"],
|
||||
["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"],
|
||||
["Tomorrow Night Bright","tomorrow_night_bright" , "dark"],
|
||||
["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"],
|
||||
["Twilight" ,"twilight" , "dark"],
|
||||
["Vibrant Ink" ,"vibrant_ink" , "dark"]
|
||||
];
|
||||
|
||||
|
||||
exports.themesByName = {};
|
||||
exports.themes = themeData.map(function(data) {
|
||||
var name = data[1] || data[0].replace(/ /g, "_").toLowerCase();
|
||||
var theme = {
|
||||
caption: data[0],
|
||||
theme: "ace/theme/" + name,
|
||||
isDark: data[2] == "dark",
|
||||
name: name
|
||||
};
|
||||
exports.themesByName[name] = theme;
|
||||
return theme;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/ext/options",["require","exports","module","ace/ext/menu_tools/overlay_page","ace/lib/dom","ace/lib/oop","ace/config","ace/lib/event_emitter","ace/ext/modelist","ace/ext/themelist"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
require("./menu_tools/overlay_page");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
var oop = require("../lib/oop");
|
||||
var config = require("../config");
|
||||
var EventEmitter = require("../lib/event_emitter").EventEmitter;
|
||||
var buildDom = dom.buildDom;
|
||||
|
||||
var modelist = require("./modelist");
|
||||
var themelist = require("./themelist");
|
||||
|
||||
var themes = { Bright: [], Dark: [] };
|
||||
themelist.themes.forEach(function(x) {
|
||||
themes[x.isDark ? "Dark" : "Bright"].push({ caption: x.caption, value: x.theme });
|
||||
});
|
||||
|
||||
var modes = modelist.modes.map(function(x){
|
||||
return { caption: x.caption, value: x.mode };
|
||||
});
|
||||
|
||||
|
||||
var optionGroups = {
|
||||
Main: {
|
||||
Mode: {
|
||||
path: "mode",
|
||||
type: "select",
|
||||
items: modes
|
||||
},
|
||||
Theme: {
|
||||
path: "theme",
|
||||
type: "select",
|
||||
items: themes
|
||||
},
|
||||
"Keybinding": {
|
||||
type: "buttonBar",
|
||||
path: "keyboardHandler",
|
||||
items: [
|
||||
{ caption : "Ace", value : null },
|
||||
{ caption : "Vim", value : "ace/keyboard/vim" },
|
||||
{ caption : "Emacs", value : "ace/keyboard/emacs" },
|
||||
{ caption : "Sublime", value : "ace/keyboard/sublime" },
|
||||
{ caption : "VSCode", value : "ace/keyboard/vscode" }
|
||||
]
|
||||
},
|
||||
"Font Size": {
|
||||
path: "fontSize",
|
||||
type: "number",
|
||||
defaultValue: 12,
|
||||
defaults: [
|
||||
{caption: "12px", value: 12},
|
||||
{caption: "24px", value: 24}
|
||||
]
|
||||
},
|
||||
"Soft Wrap": {
|
||||
type: "buttonBar",
|
||||
path: "wrap",
|
||||
items: [
|
||||
{ caption : "Off", value : "off" },
|
||||
{ caption : "View", value : "free" },
|
||||
{ caption : "margin", value : "printMargin" },
|
||||
{ caption : "40", value : "40" }
|
||||
]
|
||||
},
|
||||
"Cursor Style": {
|
||||
path: "cursorStyle",
|
||||
items: [
|
||||
{ caption : "Ace", value : "ace" },
|
||||
{ caption : "Slim", value : "slim" },
|
||||
{ caption : "Smooth", value : "smooth" },
|
||||
{ caption : "Smooth And Slim", value : "smooth slim" },
|
||||
{ caption : "Wide", value : "wide" }
|
||||
]
|
||||
},
|
||||
"Folding": {
|
||||
path: "foldStyle",
|
||||
items: [
|
||||
{ caption : "Manual", value : "manual" },
|
||||
{ caption : "Mark begin", value : "markbegin" },
|
||||
{ caption : "Mark begin and end", value : "markbeginend" }
|
||||
]
|
||||
},
|
||||
"Soft Tabs": [{
|
||||
path: "useSoftTabs"
|
||||
}, {
|
||||
ariaLabel: "Tab Size",
|
||||
path: "tabSize",
|
||||
type: "number",
|
||||
values: [2, 3, 4, 8, 16]
|
||||
}],
|
||||
"Overscroll": {
|
||||
type: "buttonBar",
|
||||
path: "scrollPastEnd",
|
||||
items: [
|
||||
{ caption : "None", value : 0 },
|
||||
{ caption : "Half", value : 0.5 },
|
||||
{ caption : "Full", value : 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
More: {
|
||||
"Atomic soft tabs": {
|
||||
path: "navigateWithinSoftTabs"
|
||||
},
|
||||
"Enable Behaviours": {
|
||||
path: "behavioursEnabled"
|
||||
},
|
||||
"Wrap with quotes": {
|
||||
path: "wrapBehavioursEnabled"
|
||||
},
|
||||
"Enable Auto Indent": {
|
||||
path: "enableAutoIndent"
|
||||
},
|
||||
"Full Line Selection": {
|
||||
type: "checkbox",
|
||||
values: "text|line",
|
||||
path: "selectionStyle"
|
||||
},
|
||||
"Highlight Active Line": {
|
||||
path: "highlightActiveLine"
|
||||
},
|
||||
"Show Invisibles": {
|
||||
path: "showInvisibles"
|
||||
},
|
||||
"Show Indent Guides": {
|
||||
path: "displayIndentGuides"
|
||||
},
|
||||
"Persistent HScrollbar": {
|
||||
path: "hScrollBarAlwaysVisible"
|
||||
},
|
||||
"Persistent VScrollbar": {
|
||||
path: "vScrollBarAlwaysVisible"
|
||||
},
|
||||
"Animate scrolling": {
|
||||
path: "animatedScroll"
|
||||
},
|
||||
"Show Gutter": {
|
||||
path: "showGutter"
|
||||
},
|
||||
"Show Line Numbers": {
|
||||
path: "showLineNumbers"
|
||||
},
|
||||
"Relative Line Numbers": {
|
||||
path: "relativeLineNumbers"
|
||||
},
|
||||
"Fixed Gutter Width": {
|
||||
path: "fixedWidthGutter"
|
||||
},
|
||||
"Show Print Margin": [{
|
||||
path: "showPrintMargin"
|
||||
}, {
|
||||
ariaLabel: "Print Margin",
|
||||
type: "number",
|
||||
path: "printMarginColumn"
|
||||
}],
|
||||
"Indented Soft Wrap": {
|
||||
path: "indentedSoftWrap"
|
||||
},
|
||||
"Highlight selected word": {
|
||||
path: "highlightSelectedWord"
|
||||
},
|
||||
"Fade Fold Widgets": {
|
||||
path: "fadeFoldWidgets"
|
||||
},
|
||||
"Use textarea for IME": {
|
||||
path: "useTextareaForIME"
|
||||
},
|
||||
"Merge Undo Deltas": {
|
||||
path: "mergeUndoDeltas",
|
||||
items: [
|
||||
{ caption : "Always", value : "always" },
|
||||
{ caption : "Never", value : "false" },
|
||||
{ caption : "Timed", value : "true" }
|
||||
]
|
||||
},
|
||||
"Elastic Tabstops": {
|
||||
path: "useElasticTabstops"
|
||||
},
|
||||
"Incremental Search": {
|
||||
path: "useIncrementalSearch"
|
||||
},
|
||||
"Read-only": {
|
||||
path: "readOnly"
|
||||
},
|
||||
"Copy without selection": {
|
||||
path: "copyWithEmptySelection"
|
||||
},
|
||||
"Live Autocompletion": {
|
||||
path: "enableLiveAutocompletion"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var OptionPanel = function(editor, element) {
|
||||
this.editor = editor;
|
||||
this.container = element || document.createElement("div");
|
||||
this.groups = [];
|
||||
this.options = {};
|
||||
};
|
||||
|
||||
(function() {
|
||||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.add = function(config) {
|
||||
if (config.Main)
|
||||
oop.mixin(optionGroups.Main, config.Main);
|
||||
if (config.More)
|
||||
oop.mixin(optionGroups.More, config.More);
|
||||
};
|
||||
|
||||
this.render = function() {
|
||||
this.container.innerHTML = "";
|
||||
buildDom(["table", {role: "presentation", id: "controls"},
|
||||
this.renderOptionGroup(optionGroups.Main),
|
||||
["tr", null, ["td", {colspan: 2},
|
||||
["table", {role: "presentation", id: "more-controls"},
|
||||
this.renderOptionGroup(optionGroups.More)
|
||||
]
|
||||
]],
|
||||
["tr", null, ["td", {colspan: 2}, "version " + config.version]]
|
||||
], this.container);
|
||||
};
|
||||
|
||||
this.renderOptionGroup = function(group) {
|
||||
return Object.keys(group).map(function(key, i) {
|
||||
var item = group[key];
|
||||
if (!item.position)
|
||||
item.position = i / 10000;
|
||||
if (!item.label)
|
||||
item.label = key;
|
||||
return item;
|
||||
}).sort(function(a, b) {
|
||||
return a.position - b.position;
|
||||
}).map(function(item) {
|
||||
return this.renderOption(item.label, item);
|
||||
}, this);
|
||||
};
|
||||
|
||||
this.renderOptionControl = function(key, option) {
|
||||
var self = this;
|
||||
if (Array.isArray(option)) {
|
||||
return option.map(function(x) {
|
||||
return self.renderOptionControl(key, x);
|
||||
});
|
||||
}
|
||||
var control;
|
||||
|
||||
var value = self.getOption(option);
|
||||
|
||||
if (option.values && option.type != "checkbox") {
|
||||
if (typeof option.values == "string")
|
||||
option.values = option.values.split("|");
|
||||
option.items = option.values.map(function(v) {
|
||||
return { value: v, name: v };
|
||||
});
|
||||
}
|
||||
|
||||
if (option.type == "buttonBar") {
|
||||
control = ["div", {role: "group", "aria-labelledby": option.path + "-label"}, option.items.map(function(item) {
|
||||
return ["button", {
|
||||
value: item.value,
|
||||
ace_selected_button: value == item.value,
|
||||
'aria-pressed': value == item.value,
|
||||
onclick: function() {
|
||||
self.setOption(option, item.value);
|
||||
var nodes = this.parentNode.querySelectorAll("[ace_selected_button]");
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
nodes[i].removeAttribute("ace_selected_button");
|
||||
nodes[i].setAttribute("aria-pressed", false);
|
||||
}
|
||||
this.setAttribute("ace_selected_button", true);
|
||||
this.setAttribute("aria-pressed", true);
|
||||
}
|
||||
}, item.desc || item.caption || item.name];
|
||||
})];
|
||||
} else if (option.type == "number") {
|
||||
control = ["input", {type: "number", value: value || option.defaultValue, style:"width:3em", oninput: function() {
|
||||
self.setOption(option, parseInt(this.value));
|
||||
}}];
|
||||
if (option.ariaLabel) {
|
||||
control[1]["aria-label"] = option.ariaLabel;
|
||||
} else {
|
||||
control[1].id = key;
|
||||
}
|
||||
if (option.defaults) {
|
||||
control = [control, option.defaults.map(function(item) {
|
||||
return ["button", {onclick: function() {
|
||||
var input = this.parentNode.firstChild;
|
||||
input.value = item.value;
|
||||
input.oninput();
|
||||
}}, item.caption];
|
||||
})];
|
||||
}
|
||||
} else if (option.items) {
|
||||
var buildItems = function(items) {
|
||||
return items.map(function(item) {
|
||||
return ["option", { value: item.value || item.name }, item.desc || item.caption || item.name];
|
||||
});
|
||||
};
|
||||
|
||||
var items = Array.isArray(option.items)
|
||||
? buildItems(option.items)
|
||||
: Object.keys(option.items).map(function(key) {
|
||||
return ["optgroup", {"label": key}, buildItems(option.items[key])];
|
||||
});
|
||||
control = ["select", { id: key, value: value, onchange: function() {
|
||||
self.setOption(option, this.value);
|
||||
} }, items];
|
||||
} else {
|
||||
if (typeof option.values == "string")
|
||||
option.values = option.values.split("|");
|
||||
if (option.values) value = value == option.values[1];
|
||||
control = ["input", { type: "checkbox", id: key, checked: value || null, onchange: function() {
|
||||
var value = this.checked;
|
||||
if (option.values) value = option.values[value ? 1 : 0];
|
||||
self.setOption(option, value);
|
||||
}}];
|
||||
if (option.type == "checkedNumber") {
|
||||
control = [control, []];
|
||||
}
|
||||
}
|
||||
return control;
|
||||
};
|
||||
|
||||
this.renderOption = function(key, option) {
|
||||
if (option.path && !option.onchange && !this.editor.$options[option.path])
|
||||
return;
|
||||
var path = Array.isArray(option) ? option[0].path : option.path;
|
||||
this.options[path] = option;
|
||||
var safeKey = "-" + path;
|
||||
var safeId = path + "-label";
|
||||
var control = this.renderOptionControl(safeKey, option);
|
||||
return ["tr", {class: "ace_optionsMenuEntry"}, ["td",
|
||||
["label", {for: safeKey, id: safeId}, key]
|
||||
], ["td", control]];
|
||||
};
|
||||
|
||||
this.setOption = function(option, value) {
|
||||
if (typeof option == "string")
|
||||
option = this.options[option];
|
||||
if (value == "false") value = false;
|
||||
if (value == "true") value = true;
|
||||
if (value == "null") value = null;
|
||||
if (value == "undefined") value = undefined;
|
||||
if (typeof value == "string" && parseFloat(value).toString() == value)
|
||||
value = parseFloat(value);
|
||||
if (option.onchange)
|
||||
option.onchange(value);
|
||||
else if (option.path)
|
||||
this.editor.setOption(option.path, value);
|
||||
this._signal("setOption", {name: option.path, value: value});
|
||||
};
|
||||
|
||||
this.getOption = function(option) {
|
||||
if (option.getValue)
|
||||
return option.getValue();
|
||||
return this.editor.getOption(option.path);
|
||||
};
|
||||
|
||||
}).call(OptionPanel.prototype);
|
||||
|
||||
exports.OptionPanel = OptionPanel;
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/options"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,122 @@
|
||||
ace.define("ace/ext/rtl",["require","exports","module","ace/editor","ace/config"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var commands = [{
|
||||
name: "leftToRight",
|
||||
bindKey: { win: "Ctrl-Alt-Shift-L", mac: "Command-Alt-Shift-L" },
|
||||
exec: function(editor) {
|
||||
editor.session.$bidiHandler.setRtlDirection(editor, false);
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "rightToLeft",
|
||||
bindKey: { win: "Ctrl-Alt-Shift-R", mac: "Command-Alt-Shift-R" },
|
||||
exec: function(editor) {
|
||||
editor.session.$bidiHandler.setRtlDirection(editor, true);
|
||||
},
|
||||
readOnly: true
|
||||
}];
|
||||
|
||||
var Editor = require("../editor").Editor;
|
||||
require("../config").defineOptions(Editor.prototype, "editor", {
|
||||
rtlText: {
|
||||
set: function(val) {
|
||||
if (val) {
|
||||
this.on("change", onChange);
|
||||
this.on("changeSelection", onChangeSelection);
|
||||
this.renderer.on("afterRender", updateLineDirection);
|
||||
this.commands.on("exec", onCommandEmitted);
|
||||
this.commands.addCommands(commands);
|
||||
} else {
|
||||
this.off("change", onChange);
|
||||
this.off("changeSelection", onChangeSelection);
|
||||
this.renderer.off("afterRender", updateLineDirection);
|
||||
this.commands.off("exec", onCommandEmitted);
|
||||
this.commands.removeCommands(commands);
|
||||
clearTextLayer(this.renderer);
|
||||
}
|
||||
this.renderer.updateFull();
|
||||
}
|
||||
},
|
||||
rtl: {
|
||||
set: function(val) {
|
||||
this.session.$bidiHandler.$isRtl = val;
|
||||
if (val) {
|
||||
this.setOption("rtlText", false);
|
||||
this.renderer.on("afterRender", updateLineDirection);
|
||||
this.session.$bidiHandler.seenBidi = true;
|
||||
} else {
|
||||
this.renderer.off("afterRender", updateLineDirection);
|
||||
clearTextLayer(this.renderer);
|
||||
}
|
||||
this.renderer.updateFull();
|
||||
}
|
||||
}
|
||||
});
|
||||
function onChangeSelection(e, editor) {
|
||||
var lead = editor.getSelection().lead;
|
||||
if (editor.session.$bidiHandler.isRtlLine(lead.row)) {
|
||||
if (lead.column === 0) {
|
||||
if (editor.session.$bidiHandler.isMoveLeftOperation && lead.row > 0) {
|
||||
editor.getSelection().moveCursorTo(lead.row - 1, editor.session.getLine(lead.row - 1).length);
|
||||
} else {
|
||||
if (editor.getSelection().isEmpty())
|
||||
lead.column += 1;
|
||||
else
|
||||
lead.setPosition(lead.row, lead.column + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onCommandEmitted(commadEvent) {
|
||||
commadEvent.editor.session.$bidiHandler.isMoveLeftOperation = /gotoleft|selectleft|backspace|removewordleft/.test(commadEvent.command.name);
|
||||
}
|
||||
function onChange(delta, editor) {
|
||||
var session = editor.session;
|
||||
session.$bidiHandler.currentRow = null;
|
||||
if (session.$bidiHandler.isRtlLine(delta.start.row) && delta.action === 'insert' && delta.lines.length > 1) {
|
||||
for (var row = delta.start.row; row < delta.end.row; row++) {
|
||||
if (session.getLine(row + 1).charAt(0) !== session.$bidiHandler.RLE)
|
||||
session.doc.$lines[row + 1] = session.$bidiHandler.RLE + session.getLine(row + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateLineDirection(e, renderer) {
|
||||
var session = renderer.session;
|
||||
var $bidiHandler = session.$bidiHandler;
|
||||
var cells = renderer.$textLayer.$lines.cells;
|
||||
var width = renderer.layerConfig.width - renderer.layerConfig.padding + "px";
|
||||
cells.forEach(function(cell) {
|
||||
var style = cell.element.style;
|
||||
if ($bidiHandler && $bidiHandler.isRtlLine(cell.row)) {
|
||||
style.direction = "rtl";
|
||||
style.textAlign = "right";
|
||||
style.width = width;
|
||||
} else {
|
||||
style.direction = "";
|
||||
style.textAlign = "";
|
||||
style.width = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function clearTextLayer(renderer) {
|
||||
var lines = renderer.$textLayer.$lines;
|
||||
lines.cells.forEach(clear);
|
||||
lines.cellCache.forEach(clear);
|
||||
function clear(cell) {
|
||||
var style = cell.element.style;
|
||||
style.direction = style.textAlign = style.width = "";
|
||||
}
|
||||
}
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/rtl"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,514 @@
|
||||
ace.define("ace/ext/searchbox",["require","exports","module","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/keyboard/hash_handler","ace/lib/keys"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
var lang = require("../lib/lang");
|
||||
var event = require("../lib/event");
|
||||
var searchboxCss = "\
|
||||
.ace_search {\
|
||||
background-color: #ddd;\
|
||||
color: #666;\
|
||||
border: 1px solid #cbcbcb;\
|
||||
border-top: 0 none;\
|
||||
overflow: hidden;\
|
||||
margin: 0;\
|
||||
padding: 4px 6px 0 4px;\
|
||||
position: absolute;\
|
||||
top: 0;\
|
||||
z-index: 99;\
|
||||
white-space: normal;\
|
||||
}\
|
||||
.ace_search.left {\
|
||||
border-left: 0 none;\
|
||||
border-radius: 0px 0px 5px 0px;\
|
||||
left: 0;\
|
||||
}\
|
||||
.ace_search.right {\
|
||||
border-radius: 0px 0px 0px 5px;\
|
||||
border-right: 0 none;\
|
||||
right: 0;\
|
||||
}\
|
||||
.ace_search_form, .ace_replace_form {\
|
||||
margin: 0 20px 4px 0;\
|
||||
overflow: hidden;\
|
||||
line-height: 1.9;\
|
||||
}\
|
||||
.ace_replace_form {\
|
||||
margin-right: 0;\
|
||||
}\
|
||||
.ace_search_form.ace_nomatch {\
|
||||
outline: 1px solid red;\
|
||||
}\
|
||||
.ace_search_field {\
|
||||
border-radius: 3px 0 0 3px;\
|
||||
background-color: white;\
|
||||
color: black;\
|
||||
border: 1px solid #cbcbcb;\
|
||||
border-right: 0 none;\
|
||||
outline: 0;\
|
||||
padding: 0;\
|
||||
font-size: inherit;\
|
||||
margin: 0;\
|
||||
line-height: inherit;\
|
||||
padding: 0 6px;\
|
||||
min-width: 17em;\
|
||||
vertical-align: top;\
|
||||
min-height: 1.8em;\
|
||||
box-sizing: content-box;\
|
||||
}\
|
||||
.ace_searchbtn {\
|
||||
border: 1px solid #cbcbcb;\
|
||||
line-height: inherit;\
|
||||
display: inline-block;\
|
||||
padding: 0 6px;\
|
||||
background: #fff;\
|
||||
border-right: 0 none;\
|
||||
border-left: 1px solid #dcdcdc;\
|
||||
cursor: pointer;\
|
||||
margin: 0;\
|
||||
position: relative;\
|
||||
color: #666;\
|
||||
}\
|
||||
.ace_searchbtn:last-child {\
|
||||
border-radius: 0 3px 3px 0;\
|
||||
border-right: 1px solid #cbcbcb;\
|
||||
}\
|
||||
.ace_searchbtn:disabled {\
|
||||
background: none;\
|
||||
cursor: default;\
|
||||
}\
|
||||
.ace_searchbtn:hover {\
|
||||
background-color: #eef1f6;\
|
||||
}\
|
||||
.ace_searchbtn.prev, .ace_searchbtn.next {\
|
||||
padding: 0px 0.7em\
|
||||
}\
|
||||
.ace_searchbtn.prev:after, .ace_searchbtn.next:after {\
|
||||
content: \"\";\
|
||||
border: solid 2px #888;\
|
||||
width: 0.5em;\
|
||||
height: 0.5em;\
|
||||
border-width: 2px 0 0 2px;\
|
||||
display:inline-block;\
|
||||
transform: rotate(-45deg);\
|
||||
}\
|
||||
.ace_searchbtn.next:after {\
|
||||
border-width: 0 2px 2px 0 ;\
|
||||
}\
|
||||
.ace_searchbtn_close {\
|
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0;\
|
||||
border-radius: 50%;\
|
||||
border: 0 none;\
|
||||
color: #656565;\
|
||||
cursor: pointer;\
|
||||
font: 16px/16px Arial;\
|
||||
padding: 0;\
|
||||
height: 14px;\
|
||||
width: 14px;\
|
||||
top: 9px;\
|
||||
right: 7px;\
|
||||
position: absolute;\
|
||||
}\
|
||||
.ace_searchbtn_close:hover {\
|
||||
background-color: #656565;\
|
||||
background-position: 50% 100%;\
|
||||
color: white;\
|
||||
}\
|
||||
.ace_button {\
|
||||
margin-left: 2px;\
|
||||
cursor: pointer;\
|
||||
-webkit-user-select: none;\
|
||||
-moz-user-select: none;\
|
||||
-o-user-select: none;\
|
||||
-ms-user-select: none;\
|
||||
user-select: none;\
|
||||
overflow: hidden;\
|
||||
opacity: 0.7;\
|
||||
border: 1px solid rgba(100,100,100,0.23);\
|
||||
padding: 1px;\
|
||||
box-sizing: border-box!important;\
|
||||
color: black;\
|
||||
}\
|
||||
.ace_button:hover {\
|
||||
background-color: #eee;\
|
||||
opacity:1;\
|
||||
}\
|
||||
.ace_button:active {\
|
||||
background-color: #ddd;\
|
||||
}\
|
||||
.ace_button.checked {\
|
||||
border-color: #3399ff;\
|
||||
opacity:1;\
|
||||
}\
|
||||
.ace_search_options{\
|
||||
margin-bottom: 3px;\
|
||||
text-align: right;\
|
||||
-webkit-user-select: none;\
|
||||
-moz-user-select: none;\
|
||||
-o-user-select: none;\
|
||||
-ms-user-select: none;\
|
||||
user-select: none;\
|
||||
clear: both;\
|
||||
}\
|
||||
.ace_search_counter {\
|
||||
float: left;\
|
||||
font-family: arial;\
|
||||
padding: 0 8px;\
|
||||
}";
|
||||
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
||||
var keyUtil = require("../lib/keys");
|
||||
|
||||
var MAX_COUNT = 999;
|
||||
|
||||
dom.importCssString(searchboxCss, "ace_searchbox");
|
||||
|
||||
var SearchBox = function(editor, range, showReplaceForm) {
|
||||
var div = dom.createElement("div");
|
||||
dom.buildDom(["div", {class:"ace_search right"},
|
||||
["span", {action: "hide", class: "ace_searchbtn_close"}],
|
||||
["div", {class: "ace_search_form"},
|
||||
["input", {class: "ace_search_field", placeholder: "Search for", spellcheck: "false"}],
|
||||
["span", {action: "findPrev", class: "ace_searchbtn prev"}, "\u200b"],
|
||||
["span", {action: "findNext", class: "ace_searchbtn next"}, "\u200b"],
|
||||
["span", {action: "findAll", class: "ace_searchbtn", title: "Alt-Enter"}, "All"]
|
||||
],
|
||||
["div", {class: "ace_replace_form"},
|
||||
["input", {class: "ace_search_field", placeholder: "Replace with", spellcheck: "false"}],
|
||||
["span", {action: "replaceAndFindNext", class: "ace_searchbtn"}, "Replace"],
|
||||
["span", {action: "replaceAll", class: "ace_searchbtn"}, "All"]
|
||||
],
|
||||
["div", {class: "ace_search_options"},
|
||||
["span", {action: "toggleReplace", class: "ace_button", title: "Toggle Replace mode",
|
||||
style: "float:left;margin-top:-2px;padding:0 5px;"}, "+"],
|
||||
["span", {class: "ace_search_counter"}],
|
||||
["span", {action: "toggleRegexpMode", class: "ace_button", title: "RegExp Search"}, ".*"],
|
||||
["span", {action: "toggleCaseSensitive", class: "ace_button", title: "CaseSensitive Search"}, "Aa"],
|
||||
["span", {action: "toggleWholeWords", class: "ace_button", title: "Whole Word Search"}, "\\b"],
|
||||
["span", {action: "searchInSelection", class: "ace_button", title: "Search In Selection"}, "S"]
|
||||
]
|
||||
], div);
|
||||
this.element = div.firstChild;
|
||||
|
||||
this.setSession = this.setSession.bind(this);
|
||||
|
||||
this.$init();
|
||||
this.setEditor(editor);
|
||||
dom.importCssString(searchboxCss, "ace_searchbox", editor.container);
|
||||
};
|
||||
|
||||
(function() {
|
||||
this.setEditor = function(editor) {
|
||||
editor.searchBox = this;
|
||||
editor.renderer.scroller.appendChild(this.element);
|
||||
this.editor = editor;
|
||||
};
|
||||
|
||||
this.setSession = function(e) {
|
||||
this.searchRange = null;
|
||||
this.$syncOptions(true);
|
||||
};
|
||||
|
||||
this.$initElements = function(sb) {
|
||||
this.searchBox = sb.querySelector(".ace_search_form");
|
||||
this.replaceBox = sb.querySelector(".ace_replace_form");
|
||||
this.searchOption = sb.querySelector("[action=searchInSelection]");
|
||||
this.replaceOption = sb.querySelector("[action=toggleReplace]");
|
||||
this.regExpOption = sb.querySelector("[action=toggleRegexpMode]");
|
||||
this.caseSensitiveOption = sb.querySelector("[action=toggleCaseSensitive]");
|
||||
this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]");
|
||||
this.searchInput = this.searchBox.querySelector(".ace_search_field");
|
||||
this.replaceInput = this.replaceBox.querySelector(".ace_search_field");
|
||||
this.searchCounter = sb.querySelector(".ace_search_counter");
|
||||
};
|
||||
|
||||
this.$init = function() {
|
||||
var sb = this.element;
|
||||
|
||||
this.$initElements(sb);
|
||||
|
||||
var _this = this;
|
||||
event.addListener(sb, "mousedown", function(e) {
|
||||
setTimeout(function(){
|
||||
_this.activeInput.focus();
|
||||
}, 0);
|
||||
event.stopPropagation(e);
|
||||
});
|
||||
event.addListener(sb, "click", function(e) {
|
||||
var t = e.target || e.srcElement;
|
||||
var action = t.getAttribute("action");
|
||||
if (action && _this[action])
|
||||
_this[action]();
|
||||
else if (_this.$searchBarKb.commands[action])
|
||||
_this.$searchBarKb.commands[action].exec(_this);
|
||||
event.stopPropagation(e);
|
||||
});
|
||||
|
||||
event.addCommandKeyListener(sb, function(e, hashId, keyCode) {
|
||||
var keyString = keyUtil.keyCodeToString(keyCode);
|
||||
var command = _this.$searchBarKb.findKeyCommand(hashId, keyString);
|
||||
if (command && command.exec) {
|
||||
command.exec(_this);
|
||||
event.stopEvent(e);
|
||||
}
|
||||
});
|
||||
|
||||
this.$onChange = lang.delayedCall(function() {
|
||||
_this.find(false, false);
|
||||
});
|
||||
|
||||
event.addListener(this.searchInput, "input", function() {
|
||||
_this.$onChange.schedule(20);
|
||||
});
|
||||
event.addListener(this.searchInput, "focus", function() {
|
||||
_this.activeInput = _this.searchInput;
|
||||
_this.searchInput.value && _this.highlight();
|
||||
});
|
||||
event.addListener(this.replaceInput, "focus", function() {
|
||||
_this.activeInput = _this.replaceInput;
|
||||
_this.searchInput.value && _this.highlight();
|
||||
});
|
||||
};
|
||||
this.$closeSearchBarKb = new HashHandler([{
|
||||
bindKey: "Esc",
|
||||
name: "closeSearchBar",
|
||||
exec: function(editor) {
|
||||
editor.searchBox.hide();
|
||||
}
|
||||
}]);
|
||||
this.$searchBarKb = new HashHandler();
|
||||
this.$searchBarKb.bindKeys({
|
||||
"Ctrl-f|Command-f": function(sb) {
|
||||
var isReplace = sb.isReplace = !sb.isReplace;
|
||||
sb.replaceBox.style.display = isReplace ? "" : "none";
|
||||
sb.replaceOption.checked = false;
|
||||
sb.$syncOptions();
|
||||
sb.searchInput.focus();
|
||||
},
|
||||
"Ctrl-H|Command-Option-F": function(sb) {
|
||||
if (sb.editor.getReadOnly())
|
||||
return;
|
||||
sb.replaceOption.checked = true;
|
||||
sb.$syncOptions();
|
||||
sb.replaceInput.focus();
|
||||
},
|
||||
"Ctrl-G|Command-G": function(sb) {
|
||||
sb.findNext();
|
||||
},
|
||||
"Ctrl-Shift-G|Command-Shift-G": function(sb) {
|
||||
sb.findPrev();
|
||||
},
|
||||
"esc": function(sb) {
|
||||
setTimeout(function() { sb.hide();});
|
||||
},
|
||||
"Return": function(sb) {
|
||||
if (sb.activeInput == sb.replaceInput)
|
||||
sb.replace();
|
||||
sb.findNext();
|
||||
},
|
||||
"Shift-Return": function(sb) {
|
||||
if (sb.activeInput == sb.replaceInput)
|
||||
sb.replace();
|
||||
sb.findPrev();
|
||||
},
|
||||
"Alt-Return": function(sb) {
|
||||
if (sb.activeInput == sb.replaceInput)
|
||||
sb.replaceAll();
|
||||
sb.findAll();
|
||||
},
|
||||
"Tab": function(sb) {
|
||||
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus();
|
||||
}
|
||||
});
|
||||
|
||||
this.$searchBarKb.addCommands([{
|
||||
name: "toggleRegexpMode",
|
||||
bindKey: {win: "Alt-R|Alt-/", mac: "Ctrl-Alt-R|Ctrl-Alt-/"},
|
||||
exec: function(sb) {
|
||||
sb.regExpOption.checked = !sb.regExpOption.checked;
|
||||
sb.$syncOptions();
|
||||
}
|
||||
}, {
|
||||
name: "toggleCaseSensitive",
|
||||
bindKey: {win: "Alt-C|Alt-I", mac: "Ctrl-Alt-R|Ctrl-Alt-I"},
|
||||
exec: function(sb) {
|
||||
sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked;
|
||||
sb.$syncOptions();
|
||||
}
|
||||
}, {
|
||||
name: "toggleWholeWords",
|
||||
bindKey: {win: "Alt-B|Alt-W", mac: "Ctrl-Alt-B|Ctrl-Alt-W"},
|
||||
exec: function(sb) {
|
||||
sb.wholeWordOption.checked = !sb.wholeWordOption.checked;
|
||||
sb.$syncOptions();
|
||||
}
|
||||
}, {
|
||||
name: "toggleReplace",
|
||||
exec: function(sb) {
|
||||
sb.replaceOption.checked = !sb.replaceOption.checked;
|
||||
sb.$syncOptions();
|
||||
}
|
||||
}, {
|
||||
name: "searchInSelection",
|
||||
exec: function(sb) {
|
||||
sb.searchOption.checked = !sb.searchRange;
|
||||
sb.setSearchRange(sb.searchOption.checked && sb.editor.getSelectionRange());
|
||||
sb.$syncOptions();
|
||||
}
|
||||
}]);
|
||||
|
||||
this.setSearchRange = function(range) {
|
||||
this.searchRange = range;
|
||||
if (range) {
|
||||
this.searchRangeMarker = this.editor.session.addMarker(range, "ace_active-line");
|
||||
} else if (this.searchRangeMarker) {
|
||||
this.editor.session.removeMarker(this.searchRangeMarker);
|
||||
this.searchRangeMarker = null;
|
||||
}
|
||||
};
|
||||
|
||||
this.$syncOptions = function(preventScroll) {
|
||||
dom.setCssClass(this.replaceOption, "checked", this.searchRange);
|
||||
dom.setCssClass(this.searchOption, "checked", this.searchOption.checked);
|
||||
this.replaceOption.textContent = this.replaceOption.checked ? "-" : "+";
|
||||
dom.setCssClass(this.regExpOption, "checked", this.regExpOption.checked);
|
||||
dom.setCssClass(this.wholeWordOption, "checked", this.wholeWordOption.checked);
|
||||
dom.setCssClass(this.caseSensitiveOption, "checked", this.caseSensitiveOption.checked);
|
||||
var readOnly = this.editor.getReadOnly();
|
||||
this.replaceOption.style.display = readOnly ? "none" : "";
|
||||
this.replaceBox.style.display = this.replaceOption.checked && !readOnly ? "" : "none";
|
||||
this.find(false, false, preventScroll);
|
||||
};
|
||||
|
||||
this.highlight = function(re) {
|
||||
this.editor.session.highlight(re || this.editor.$search.$options.re);
|
||||
this.editor.renderer.updateBackMarkers();
|
||||
};
|
||||
this.find = function(skipCurrent, backwards, preventScroll) {
|
||||
var range = this.editor.find(this.searchInput.value, {
|
||||
skipCurrent: skipCurrent,
|
||||
backwards: backwards,
|
||||
wrap: true,
|
||||
regExp: this.regExpOption.checked,
|
||||
caseSensitive: this.caseSensitiveOption.checked,
|
||||
wholeWord: this.wholeWordOption.checked,
|
||||
preventScroll: preventScroll,
|
||||
range: this.searchRange
|
||||
});
|
||||
var noMatch = !range && this.searchInput.value;
|
||||
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch);
|
||||
this.editor._emit("findSearchBox", { match: !noMatch });
|
||||
this.highlight();
|
||||
this.updateCounter();
|
||||
};
|
||||
this.updateCounter = function() {
|
||||
var editor = this.editor;
|
||||
var regex = editor.$search.$options.re;
|
||||
var all = 0;
|
||||
var before = 0;
|
||||
if (regex) {
|
||||
var value = this.searchRange
|
||||
? editor.session.getTextRange(this.searchRange)
|
||||
: editor.getValue();
|
||||
|
||||
var offset = editor.session.doc.positionToIndex(editor.selection.anchor);
|
||||
if (this.searchRange)
|
||||
offset -= editor.session.doc.positionToIndex(this.searchRange.start);
|
||||
|
||||
var last = regex.lastIndex = 0;
|
||||
var m;
|
||||
while ((m = regex.exec(value))) {
|
||||
all++;
|
||||
last = m.index;
|
||||
if (last <= offset)
|
||||
before++;
|
||||
if (all > MAX_COUNT)
|
||||
break;
|
||||
if (!m[0]) {
|
||||
regex.lastIndex = last += 1;
|
||||
if (last >= value.length)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.searchCounter.textContent = before + " of " + (all > MAX_COUNT ? MAX_COUNT + "+" : all);
|
||||
};
|
||||
this.findNext = function() {
|
||||
this.find(true, false);
|
||||
};
|
||||
this.findPrev = function() {
|
||||
this.find(true, true);
|
||||
};
|
||||
this.findAll = function(){
|
||||
var range = this.editor.findAll(this.searchInput.value, {
|
||||
regExp: this.regExpOption.checked,
|
||||
caseSensitive: this.caseSensitiveOption.checked,
|
||||
wholeWord: this.wholeWordOption.checked
|
||||
});
|
||||
var noMatch = !range && this.searchInput.value;
|
||||
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch);
|
||||
this.editor._emit("findSearchBox", { match: !noMatch });
|
||||
this.highlight();
|
||||
this.hide();
|
||||
};
|
||||
this.replace = function() {
|
||||
if (!this.editor.getReadOnly())
|
||||
this.editor.replace(this.replaceInput.value);
|
||||
};
|
||||
this.replaceAndFindNext = function() {
|
||||
if (!this.editor.getReadOnly()) {
|
||||
this.editor.replace(this.replaceInput.value);
|
||||
this.findNext();
|
||||
}
|
||||
};
|
||||
this.replaceAll = function() {
|
||||
if (!this.editor.getReadOnly())
|
||||
this.editor.replaceAll(this.replaceInput.value);
|
||||
};
|
||||
|
||||
this.hide = function() {
|
||||
this.active = false;
|
||||
this.setSearchRange(null);
|
||||
this.editor.off("changeSession", this.setSession);
|
||||
|
||||
this.element.style.display = "none";
|
||||
this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb);
|
||||
this.editor.focus();
|
||||
};
|
||||
this.show = function(value, isReplace) {
|
||||
this.active = true;
|
||||
this.editor.on("changeSession", this.setSession);
|
||||
this.element.style.display = "";
|
||||
this.replaceOption.checked = isReplace;
|
||||
|
||||
if (value)
|
||||
this.searchInput.value = value;
|
||||
|
||||
this.searchInput.focus();
|
||||
this.searchInput.select();
|
||||
|
||||
this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb);
|
||||
|
||||
this.$syncOptions(true);
|
||||
};
|
||||
|
||||
this.isFocused = function() {
|
||||
var el = document.activeElement;
|
||||
return el == this.searchInput || el == this.replaceInput;
|
||||
};
|
||||
}).call(SearchBox.prototype);
|
||||
|
||||
exports.SearchBox = SearchBox;
|
||||
|
||||
exports.Search = function(editor, isReplace) {
|
||||
var sb = editor.searchBox || new SearchBox(editor);
|
||||
sb.show(editor.session.getTextRange(), isReplace);
|
||||
};
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/searchbox"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,814 @@
|
||||
ace.define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
|
||||
'use strict';
|
||||
var dom = require("../../lib/dom");
|
||||
var cssText = "#ace_settingsmenu, #kbshortcutmenu {\
|
||||
background-color: #F7F7F7;\
|
||||
color: black;\
|
||||
box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\
|
||||
padding: 1em 0.5em 2em 1em;\
|
||||
overflow: auto;\
|
||||
position: absolute;\
|
||||
margin: 0;\
|
||||
bottom: 0;\
|
||||
right: 0;\
|
||||
top: 0;\
|
||||
z-index: 9991;\
|
||||
cursor: default;\
|
||||
}\
|
||||
.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\
|
||||
box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\
|
||||
background-color: rgba(255, 255, 255, 0.6);\
|
||||
color: black;\
|
||||
}\
|
||||
.ace_optionsMenuEntry:hover {\
|
||||
background-color: rgba(100, 100, 100, 0.1);\
|
||||
transition: all 0.3s\
|
||||
}\
|
||||
.ace_closeButton {\
|
||||
background: rgba(245, 146, 146, 0.5);\
|
||||
border: 1px solid #F48A8A;\
|
||||
border-radius: 50%;\
|
||||
padding: 7px;\
|
||||
position: absolute;\
|
||||
right: -8px;\
|
||||
top: -8px;\
|
||||
z-index: 100000;\
|
||||
}\
|
||||
.ace_closeButton{\
|
||||
background: rgba(245, 146, 146, 0.9);\
|
||||
}\
|
||||
.ace_optionsMenuKey {\
|
||||
color: darkslateblue;\
|
||||
font-weight: bold;\
|
||||
}\
|
||||
.ace_optionsMenuCommand {\
|
||||
color: darkcyan;\
|
||||
font-weight: normal;\
|
||||
}\
|
||||
.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\
|
||||
vertical-align: middle;\
|
||||
}\
|
||||
.ace_optionsMenuEntry button[ace_selected_button=true] {\
|
||||
background: #e7e7e7;\
|
||||
box-shadow: 1px 0px 2px 0px #adadad inset;\
|
||||
border-color: #adadad;\
|
||||
}\
|
||||
.ace_optionsMenuEntry button {\
|
||||
background: white;\
|
||||
border: 1px solid lightgray;\
|
||||
margin: 0px;\
|
||||
}\
|
||||
.ace_optionsMenuEntry button:hover{\
|
||||
background: #f0f0f0;\
|
||||
}";
|
||||
dom.importCssString(cssText);
|
||||
|
||||
module.exports.overlayPage = function overlayPage(editor, contentElement, callback) {
|
||||
var closer = document.createElement('div');
|
||||
var ignoreFocusOut = false;
|
||||
|
||||
function documentEscListener(e) {
|
||||
if (e.keyCode === 27) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
if (!closer) return;
|
||||
document.removeEventListener('keydown', documentEscListener);
|
||||
closer.parentNode.removeChild(closer);
|
||||
if (editor) {
|
||||
editor.focus();
|
||||
}
|
||||
closer = null;
|
||||
callback && callback();
|
||||
}
|
||||
function setIgnoreFocusOut(ignore) {
|
||||
ignoreFocusOut = ignore;
|
||||
if (ignore) {
|
||||
closer.style.pointerEvents = "none";
|
||||
contentElement.style.pointerEvents = "auto";
|
||||
}
|
||||
}
|
||||
|
||||
closer.style.cssText = 'margin: 0; padding: 0; ' +
|
||||
'position: fixed; top:0; bottom:0; left:0; right:0;' +
|
||||
'z-index: 9990; ' +
|
||||
(editor ? 'background-color: rgba(0, 0, 0, 0.3);' : '');
|
||||
closer.addEventListener('click', function(e) {
|
||||
if (!ignoreFocusOut) {
|
||||
close();
|
||||
}
|
||||
});
|
||||
document.addEventListener('keydown', documentEscListener);
|
||||
|
||||
contentElement.addEventListener('click', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
closer.appendChild(contentElement);
|
||||
document.body.appendChild(closer);
|
||||
if (editor) {
|
||||
editor.blur();
|
||||
}
|
||||
return {
|
||||
close: close,
|
||||
setIgnoreFocusOut: setIgnoreFocusOut
|
||||
};
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/ext/modelist",["require","exports","module"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var modes = [];
|
||||
function getModeForPath(path) {
|
||||
var mode = modesByName.text;
|
||||
var fileName = path.split(/[\/\\]/).pop();
|
||||
for (var i = 0; i < modes.length; i++) {
|
||||
if (modes[i].supportsFile(fileName)) {
|
||||
mode = modes[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
var Mode = function(name, caption, extensions) {
|
||||
this.name = name;
|
||||
this.caption = caption;
|
||||
this.mode = "ace/mode/" + name;
|
||||
this.extensions = extensions;
|
||||
var re;
|
||||
if (/\^/.test(extensions)) {
|
||||
re = extensions.replace(/\|(\^)?/g, function(a, b){
|
||||
return "$|" + (b ? "^" : "^.*\\.");
|
||||
}) + "$";
|
||||
} else {
|
||||
re = "^.*\\.(" + extensions + ")$";
|
||||
}
|
||||
|
||||
this.extRe = new RegExp(re, "gi");
|
||||
};
|
||||
|
||||
Mode.prototype.supportsFile = function(filename) {
|
||||
return filename.match(this.extRe);
|
||||
};
|
||||
var supportedModes = {
|
||||
ABAP: ["abap"],
|
||||
ABC: ["abc"],
|
||||
ActionScript:["as"],
|
||||
ADA: ["ada|adb"],
|
||||
Alda: ["alda"],
|
||||
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
|
||||
Apex: ["apex|cls|trigger|tgr"],
|
||||
AQL: ["aql"],
|
||||
AsciiDoc: ["asciidoc|adoc"],
|
||||
ASL: ["dsl|asl"],
|
||||
Assembly_x86:["asm|a"],
|
||||
AutoHotKey: ["ahk"],
|
||||
BatchFile: ["bat|cmd"],
|
||||
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"],
|
||||
C9Search: ["c9search_results"],
|
||||
Cirru: ["cirru|cr"],
|
||||
Clojure: ["clj|cljs"],
|
||||
Cobol: ["CBL|COB"],
|
||||
coffee: ["coffee|cf|cson|^Cakefile"],
|
||||
ColdFusion: ["cfm"],
|
||||
Crystal: ["cr"],
|
||||
CSharp: ["cs"],
|
||||
Csound_Document: ["csd"],
|
||||
Csound_Orchestra: ["orc"],
|
||||
Csound_Score: ["sco"],
|
||||
CSS: ["css"],
|
||||
Curly: ["curly"],
|
||||
D: ["d|di"],
|
||||
Dart: ["dart"],
|
||||
Diff: ["diff|patch"],
|
||||
Dockerfile: ["^Dockerfile"],
|
||||
Dot: ["dot"],
|
||||
Drools: ["drl"],
|
||||
Edifact: ["edi"],
|
||||
Eiffel: ["e|ge"],
|
||||
EJS: ["ejs"],
|
||||
Elixir: ["ex|exs"],
|
||||
Elm: ["elm"],
|
||||
Erlang: ["erl|hrl"],
|
||||
Forth: ["frt|fs|ldr|fth|4th"],
|
||||
Fortran: ["f|f90"],
|
||||
FSharp: ["fsi|fs|ml|mli|fsx|fsscript"],
|
||||
FSL: ["fsl"],
|
||||
FTL: ["ftl"],
|
||||
Gcode: ["gcode"],
|
||||
Gherkin: ["feature"],
|
||||
Gitignore: ["^.gitignore"],
|
||||
Glsl: ["glsl|frag|vert"],
|
||||
Gobstones: ["gbs"],
|
||||
golang: ["go"],
|
||||
GraphQLSchema: ["gql"],
|
||||
Groovy: ["groovy"],
|
||||
HAML: ["haml"],
|
||||
Handlebars: ["hbs|handlebars|tpl|mustache"],
|
||||
Haskell: ["hs"],
|
||||
Haskell_Cabal: ["cabal"],
|
||||
haXe: ["hx"],
|
||||
Hjson: ["hjson"],
|
||||
HTML: ["html|htm|xhtml|vue|we|wpy"],
|
||||
HTML_Elixir: ["eex|html.eex"],
|
||||
HTML_Ruby: ["erb|rhtml|html.erb"],
|
||||
INI: ["ini|conf|cfg|prefs"],
|
||||
Io: ["io"],
|
||||
Jack: ["jack"],
|
||||
Jade: ["jade|pug"],
|
||||
Java: ["java"],
|
||||
JavaScript: ["js|jsm|jsx"],
|
||||
JSON: ["json"],
|
||||
JSON5: ["json5"],
|
||||
JSONiq: ["jq"],
|
||||
JSP: ["jsp"],
|
||||
JSSM: ["jssm|jssm_state"],
|
||||
JSX: ["jsx"],
|
||||
Julia: ["jl"],
|
||||
Kotlin: ["kt|kts"],
|
||||
LaTeX: ["tex|latex|ltx|bib"],
|
||||
LESS: ["less"],
|
||||
Liquid: ["liquid"],
|
||||
Lisp: ["lisp"],
|
||||
LiveScript: ["ls"],
|
||||
LogiQL: ["logic|lql"],
|
||||
LSL: ["lsl"],
|
||||
Lua: ["lua"],
|
||||
LuaPage: ["lp"],
|
||||
Lucene: ["lucene"],
|
||||
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
|
||||
Markdown: ["md|markdown"],
|
||||
Mask: ["mask"],
|
||||
MATLAB: ["matlab"],
|
||||
Maze: ["mz"],
|
||||
MediaWiki: ["wiki|mediawiki"],
|
||||
MEL: ["mel"],
|
||||
MIXAL: ["mixal"],
|
||||
MUSHCode: ["mc|mush"],
|
||||
MySQL: ["mysql"],
|
||||
Nginx: ["nginx|conf"],
|
||||
Nim: ["nim"],
|
||||
Nix: ["nix"],
|
||||
NSIS: ["nsi|nsh"],
|
||||
Nunjucks: ["nunjucks|nunjs|nj|njk"],
|
||||
ObjectiveC: ["m|mm"],
|
||||
OCaml: ["ml|mli"],
|
||||
Pascal: ["pas|p"],
|
||||
Perl: ["pl|pm"],
|
||||
Perl6: ["p6|pl6|pm6"],
|
||||
pgSQL: ["pgsql"],
|
||||
PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
|
||||
PHP_Laravel_blade: ["blade.php"],
|
||||
Pig: ["pig"],
|
||||
Powershell: ["ps1"],
|
||||
Praat: ["praat|praatscript|psc|proc"],
|
||||
Prisma: ["prisma"],
|
||||
Prolog: ["plg|prolog"],
|
||||
Properties: ["properties"],
|
||||
Protobuf: ["proto"],
|
||||
Puppet: ["epp|pp"],
|
||||
Python: ["py"],
|
||||
QML: ["qml"],
|
||||
R: ["r"],
|
||||
Razor: ["cshtml|asp"],
|
||||
RDoc: ["Rd"],
|
||||
Red: ["red|reds"],
|
||||
RHTML: ["Rhtml"],
|
||||
RST: ["rst"],
|
||||
Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
|
||||
Rust: ["rs"],
|
||||
SASS: ["sass"],
|
||||
SCAD: ["scad"],
|
||||
Scala: ["scala|sbt"],
|
||||
Scheme: ["scm|sm|rkt|oak|scheme"],
|
||||
SCSS: ["scss"],
|
||||
SH: ["sh|bash|^.bashrc"],
|
||||
SJS: ["sjs"],
|
||||
Slim: ["slim|skim"],
|
||||
Smarty: ["smarty|tpl"],
|
||||
snippets: ["snippets"],
|
||||
Soy_Template:["soy"],
|
||||
Space: ["space"],
|
||||
SQL: ["sql"],
|
||||
SQLServer: ["sqlserver"],
|
||||
Stylus: ["styl|stylus"],
|
||||
SVG: ["svg"],
|
||||
Swift: ["swift"],
|
||||
Tcl: ["tcl"],
|
||||
Terraform: ["tf", "tfvars", "terragrunt"],
|
||||
Tex: ["tex"],
|
||||
Text: ["txt"],
|
||||
Textile: ["textile"],
|
||||
Toml: ["toml"],
|
||||
TSX: ["tsx"],
|
||||
Twig: ["latte|twig|swig"],
|
||||
Typescript: ["ts|typescript|str"],
|
||||
Vala: ["vala"],
|
||||
VBScript: ["vbs|vb"],
|
||||
Velocity: ["vm"],
|
||||
Verilog: ["v|vh|sv|svh"],
|
||||
VHDL: ["vhd|vhdl"],
|
||||
Visualforce: ["vfp|component|page"],
|
||||
Wollok: ["wlk|wpgm|wtest"],
|
||||
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
|
||||
XQuery: ["xq"],
|
||||
YAML: ["yaml|yml"],
|
||||
Zeek: ["zeek|bro"],
|
||||
Django: ["html"]
|
||||
};
|
||||
|
||||
var nameOverrides = {
|
||||
ObjectiveC: "Objective-C",
|
||||
CSharp: "C#",
|
||||
golang: "Go",
|
||||
C_Cpp: "C and C++",
|
||||
Csound_Document: "Csound Document",
|
||||
Csound_Orchestra: "Csound",
|
||||
Csound_Score: "Csound Score",
|
||||
coffee: "CoffeeScript",
|
||||
HTML_Ruby: "HTML (Ruby)",
|
||||
HTML_Elixir: "HTML (Elixir)",
|
||||
FTL: "FreeMarker",
|
||||
PHP_Laravel_blade: "PHP (Blade Template)",
|
||||
Perl6: "Perl 6",
|
||||
AutoHotKey: "AutoHotkey / AutoIt"
|
||||
};
|
||||
var modesByName = {};
|
||||
for (var name in supportedModes) {
|
||||
var data = supportedModes[name];
|
||||
var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
|
||||
var filename = name.toLowerCase();
|
||||
var mode = new Mode(filename, displayName, data[0]);
|
||||
modesByName[filename] = mode;
|
||||
modes.push(mode);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getModeForPath: getModeForPath,
|
||||
modes: modes,
|
||||
modesByName: modesByName
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/ext/themelist",["require","exports","module"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var themeData = [
|
||||
["Chrome" ],
|
||||
["Clouds" ],
|
||||
["Crimson Editor" ],
|
||||
["Dawn" ],
|
||||
["Dreamweaver" ],
|
||||
["Eclipse" ],
|
||||
["GitHub" ],
|
||||
["IPlastic" ],
|
||||
["Solarized Light"],
|
||||
["TextMate" ],
|
||||
["Tomorrow" ],
|
||||
["Xcode" ],
|
||||
["Kuroir"],
|
||||
["KatzenMilch"],
|
||||
["SQL Server" ,"sqlserver" , "light"],
|
||||
["Ambiance" ,"ambiance" , "dark"],
|
||||
["Chaos" ,"chaos" , "dark"],
|
||||
["Clouds Midnight" ,"clouds_midnight" , "dark"],
|
||||
["Dracula" ,"" , "dark"],
|
||||
["Cobalt" ,"cobalt" , "dark"],
|
||||
["Gruvbox" ,"gruvbox" , "dark"],
|
||||
["Green on Black" ,"gob" , "dark"],
|
||||
["idle Fingers" ,"idle_fingers" , "dark"],
|
||||
["krTheme" ,"kr_theme" , "dark"],
|
||||
["Merbivore" ,"merbivore" , "dark"],
|
||||
["Merbivore Soft" ,"merbivore_soft" , "dark"],
|
||||
["Mono Industrial" ,"mono_industrial" , "dark"],
|
||||
["Monokai" ,"monokai" , "dark"],
|
||||
["Nord Dark" ,"nord_dark" , "dark"],
|
||||
["Pastel on dark" ,"pastel_on_dark" , "dark"],
|
||||
["Solarized Dark" ,"solarized_dark" , "dark"],
|
||||
["Terminal" ,"terminal" , "dark"],
|
||||
["Tomorrow Night" ,"tomorrow_night" , "dark"],
|
||||
["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"],
|
||||
["Tomorrow Night Bright","tomorrow_night_bright" , "dark"],
|
||||
["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"],
|
||||
["Twilight" ,"twilight" , "dark"],
|
||||
["Vibrant Ink" ,"vibrant_ink" , "dark"]
|
||||
];
|
||||
|
||||
|
||||
exports.themesByName = {};
|
||||
exports.themes = themeData.map(function(data) {
|
||||
var name = data[1] || data[0].replace(/ /g, "_").toLowerCase();
|
||||
var theme = {
|
||||
caption: data[0],
|
||||
theme: "ace/theme/" + name,
|
||||
isDark: data[2] == "dark",
|
||||
name: name
|
||||
};
|
||||
exports.themesByName[name] = theme;
|
||||
return theme;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/ext/options",["require","exports","module","ace/ext/menu_tools/overlay_page","ace/lib/dom","ace/lib/oop","ace/config","ace/lib/event_emitter","ace/ext/modelist","ace/ext/themelist"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
require("./menu_tools/overlay_page");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
var oop = require("../lib/oop");
|
||||
var config = require("../config");
|
||||
var EventEmitter = require("../lib/event_emitter").EventEmitter;
|
||||
var buildDom = dom.buildDom;
|
||||
|
||||
var modelist = require("./modelist");
|
||||
var themelist = require("./themelist");
|
||||
|
||||
var themes = { Bright: [], Dark: [] };
|
||||
themelist.themes.forEach(function(x) {
|
||||
themes[x.isDark ? "Dark" : "Bright"].push({ caption: x.caption, value: x.theme });
|
||||
});
|
||||
|
||||
var modes = modelist.modes.map(function(x){
|
||||
return { caption: x.caption, value: x.mode };
|
||||
});
|
||||
|
||||
|
||||
var optionGroups = {
|
||||
Main: {
|
||||
Mode: {
|
||||
path: "mode",
|
||||
type: "select",
|
||||
items: modes
|
||||
},
|
||||
Theme: {
|
||||
path: "theme",
|
||||
type: "select",
|
||||
items: themes
|
||||
},
|
||||
"Keybinding": {
|
||||
type: "buttonBar",
|
||||
path: "keyboardHandler",
|
||||
items: [
|
||||
{ caption : "Ace", value : null },
|
||||
{ caption : "Vim", value : "ace/keyboard/vim" },
|
||||
{ caption : "Emacs", value : "ace/keyboard/emacs" },
|
||||
{ caption : "Sublime", value : "ace/keyboard/sublime" },
|
||||
{ caption : "VSCode", value : "ace/keyboard/vscode" }
|
||||
]
|
||||
},
|
||||
"Font Size": {
|
||||
path: "fontSize",
|
||||
type: "number",
|
||||
defaultValue: 12,
|
||||
defaults: [
|
||||
{caption: "12px", value: 12},
|
||||
{caption: "24px", value: 24}
|
||||
]
|
||||
},
|
||||
"Soft Wrap": {
|
||||
type: "buttonBar",
|
||||
path: "wrap",
|
||||
items: [
|
||||
{ caption : "Off", value : "off" },
|
||||
{ caption : "View", value : "free" },
|
||||
{ caption : "margin", value : "printMargin" },
|
||||
{ caption : "40", value : "40" }
|
||||
]
|
||||
},
|
||||
"Cursor Style": {
|
||||
path: "cursorStyle",
|
||||
items: [
|
||||
{ caption : "Ace", value : "ace" },
|
||||
{ caption : "Slim", value : "slim" },
|
||||
{ caption : "Smooth", value : "smooth" },
|
||||
{ caption : "Smooth And Slim", value : "smooth slim" },
|
||||
{ caption : "Wide", value : "wide" }
|
||||
]
|
||||
},
|
||||
"Folding": {
|
||||
path: "foldStyle",
|
||||
items: [
|
||||
{ caption : "Manual", value : "manual" },
|
||||
{ caption : "Mark begin", value : "markbegin" },
|
||||
{ caption : "Mark begin and end", value : "markbeginend" }
|
||||
]
|
||||
},
|
||||
"Soft Tabs": [{
|
||||
path: "useSoftTabs"
|
||||
}, {
|
||||
ariaLabel: "Tab Size",
|
||||
path: "tabSize",
|
||||
type: "number",
|
||||
values: [2, 3, 4, 8, 16]
|
||||
}],
|
||||
"Overscroll": {
|
||||
type: "buttonBar",
|
||||
path: "scrollPastEnd",
|
||||
items: [
|
||||
{ caption : "None", value : 0 },
|
||||
{ caption : "Half", value : 0.5 },
|
||||
{ caption : "Full", value : 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
More: {
|
||||
"Atomic soft tabs": {
|
||||
path: "navigateWithinSoftTabs"
|
||||
},
|
||||
"Enable Behaviours": {
|
||||
path: "behavioursEnabled"
|
||||
},
|
||||
"Wrap with quotes": {
|
||||
path: "wrapBehavioursEnabled"
|
||||
},
|
||||
"Enable Auto Indent": {
|
||||
path: "enableAutoIndent"
|
||||
},
|
||||
"Full Line Selection": {
|
||||
type: "checkbox",
|
||||
values: "text|line",
|
||||
path: "selectionStyle"
|
||||
},
|
||||
"Highlight Active Line": {
|
||||
path: "highlightActiveLine"
|
||||
},
|
||||
"Show Invisibles": {
|
||||
path: "showInvisibles"
|
||||
},
|
||||
"Show Indent Guides": {
|
||||
path: "displayIndentGuides"
|
||||
},
|
||||
"Persistent HScrollbar": {
|
||||
path: "hScrollBarAlwaysVisible"
|
||||
},
|
||||
"Persistent VScrollbar": {
|
||||
path: "vScrollBarAlwaysVisible"
|
||||
},
|
||||
"Animate scrolling": {
|
||||
path: "animatedScroll"
|
||||
},
|
||||
"Show Gutter": {
|
||||
path: "showGutter"
|
||||
},
|
||||
"Show Line Numbers": {
|
||||
path: "showLineNumbers"
|
||||
},
|
||||
"Relative Line Numbers": {
|
||||
path: "relativeLineNumbers"
|
||||
},
|
||||
"Fixed Gutter Width": {
|
||||
path: "fixedWidthGutter"
|
||||
},
|
||||
"Show Print Margin": [{
|
||||
path: "showPrintMargin"
|
||||
}, {
|
||||
ariaLabel: "Print Margin",
|
||||
type: "number",
|
||||
path: "printMarginColumn"
|
||||
}],
|
||||
"Indented Soft Wrap": {
|
||||
path: "indentedSoftWrap"
|
||||
},
|
||||
"Highlight selected word": {
|
||||
path: "highlightSelectedWord"
|
||||
},
|
||||
"Fade Fold Widgets": {
|
||||
path: "fadeFoldWidgets"
|
||||
},
|
||||
"Use textarea for IME": {
|
||||
path: "useTextareaForIME"
|
||||
},
|
||||
"Merge Undo Deltas": {
|
||||
path: "mergeUndoDeltas",
|
||||
items: [
|
||||
{ caption : "Always", value : "always" },
|
||||
{ caption : "Never", value : "false" },
|
||||
{ caption : "Timed", value : "true" }
|
||||
]
|
||||
},
|
||||
"Elastic Tabstops": {
|
||||
path: "useElasticTabstops"
|
||||
},
|
||||
"Incremental Search": {
|
||||
path: "useIncrementalSearch"
|
||||
},
|
||||
"Read-only": {
|
||||
path: "readOnly"
|
||||
},
|
||||
"Copy without selection": {
|
||||
path: "copyWithEmptySelection"
|
||||
},
|
||||
"Live Autocompletion": {
|
||||
path: "enableLiveAutocompletion"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var OptionPanel = function(editor, element) {
|
||||
this.editor = editor;
|
||||
this.container = element || document.createElement("div");
|
||||
this.groups = [];
|
||||
this.options = {};
|
||||
};
|
||||
|
||||
(function() {
|
||||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.add = function(config) {
|
||||
if (config.Main)
|
||||
oop.mixin(optionGroups.Main, config.Main);
|
||||
if (config.More)
|
||||
oop.mixin(optionGroups.More, config.More);
|
||||
};
|
||||
|
||||
this.render = function() {
|
||||
this.container.innerHTML = "";
|
||||
buildDom(["table", {role: "presentation", id: "controls"},
|
||||
this.renderOptionGroup(optionGroups.Main),
|
||||
["tr", null, ["td", {colspan: 2},
|
||||
["table", {role: "presentation", id: "more-controls"},
|
||||
this.renderOptionGroup(optionGroups.More)
|
||||
]
|
||||
]],
|
||||
["tr", null, ["td", {colspan: 2}, "version " + config.version]]
|
||||
], this.container);
|
||||
};
|
||||
|
||||
this.renderOptionGroup = function(group) {
|
||||
return Object.keys(group).map(function(key, i) {
|
||||
var item = group[key];
|
||||
if (!item.position)
|
||||
item.position = i / 10000;
|
||||
if (!item.label)
|
||||
item.label = key;
|
||||
return item;
|
||||
}).sort(function(a, b) {
|
||||
return a.position - b.position;
|
||||
}).map(function(item) {
|
||||
return this.renderOption(item.label, item);
|
||||
}, this);
|
||||
};
|
||||
|
||||
this.renderOptionControl = function(key, option) {
|
||||
var self = this;
|
||||
if (Array.isArray(option)) {
|
||||
return option.map(function(x) {
|
||||
return self.renderOptionControl(key, x);
|
||||
});
|
||||
}
|
||||
var control;
|
||||
|
||||
var value = self.getOption(option);
|
||||
|
||||
if (option.values && option.type != "checkbox") {
|
||||
if (typeof option.values == "string")
|
||||
option.values = option.values.split("|");
|
||||
option.items = option.values.map(function(v) {
|
||||
return { value: v, name: v };
|
||||
});
|
||||
}
|
||||
|
||||
if (option.type == "buttonBar") {
|
||||
control = ["div", {role: "group", "aria-labelledby": option.path + "-label"}, option.items.map(function(item) {
|
||||
return ["button", {
|
||||
value: item.value,
|
||||
ace_selected_button: value == item.value,
|
||||
'aria-pressed': value == item.value,
|
||||
onclick: function() {
|
||||
self.setOption(option, item.value);
|
||||
var nodes = this.parentNode.querySelectorAll("[ace_selected_button]");
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
nodes[i].removeAttribute("ace_selected_button");
|
||||
nodes[i].setAttribute("aria-pressed", false);
|
||||
}
|
||||
this.setAttribute("ace_selected_button", true);
|
||||
this.setAttribute("aria-pressed", true);
|
||||
}
|
||||
}, item.desc || item.caption || item.name];
|
||||
})];
|
||||
} else if (option.type == "number") {
|
||||
control = ["input", {type: "number", value: value || option.defaultValue, style:"width:3em", oninput: function() {
|
||||
self.setOption(option, parseInt(this.value));
|
||||
}}];
|
||||
if (option.ariaLabel) {
|
||||
control[1]["aria-label"] = option.ariaLabel;
|
||||
} else {
|
||||
control[1].id = key;
|
||||
}
|
||||
if (option.defaults) {
|
||||
control = [control, option.defaults.map(function(item) {
|
||||
return ["button", {onclick: function() {
|
||||
var input = this.parentNode.firstChild;
|
||||
input.value = item.value;
|
||||
input.oninput();
|
||||
}}, item.caption];
|
||||
})];
|
||||
}
|
||||
} else if (option.items) {
|
||||
var buildItems = function(items) {
|
||||
return items.map(function(item) {
|
||||
return ["option", { value: item.value || item.name }, item.desc || item.caption || item.name];
|
||||
});
|
||||
};
|
||||
|
||||
var items = Array.isArray(option.items)
|
||||
? buildItems(option.items)
|
||||
: Object.keys(option.items).map(function(key) {
|
||||
return ["optgroup", {"label": key}, buildItems(option.items[key])];
|
||||
});
|
||||
control = ["select", { id: key, value: value, onchange: function() {
|
||||
self.setOption(option, this.value);
|
||||
} }, items];
|
||||
} else {
|
||||
if (typeof option.values == "string")
|
||||
option.values = option.values.split("|");
|
||||
if (option.values) value = value == option.values[1];
|
||||
control = ["input", { type: "checkbox", id: key, checked: value || null, onchange: function() {
|
||||
var value = this.checked;
|
||||
if (option.values) value = option.values[value ? 1 : 0];
|
||||
self.setOption(option, value);
|
||||
}}];
|
||||
if (option.type == "checkedNumber") {
|
||||
control = [control, []];
|
||||
}
|
||||
}
|
||||
return control;
|
||||
};
|
||||
|
||||
this.renderOption = function(key, option) {
|
||||
if (option.path && !option.onchange && !this.editor.$options[option.path])
|
||||
return;
|
||||
var path = Array.isArray(option) ? option[0].path : option.path;
|
||||
this.options[path] = option;
|
||||
var safeKey = "-" + path;
|
||||
var safeId = path + "-label";
|
||||
var control = this.renderOptionControl(safeKey, option);
|
||||
return ["tr", {class: "ace_optionsMenuEntry"}, ["td",
|
||||
["label", {for: safeKey, id: safeId}, key]
|
||||
], ["td", control]];
|
||||
};
|
||||
|
||||
this.setOption = function(option, value) {
|
||||
if (typeof option == "string")
|
||||
option = this.options[option];
|
||||
if (value == "false") value = false;
|
||||
if (value == "true") value = true;
|
||||
if (value == "null") value = null;
|
||||
if (value == "undefined") value = undefined;
|
||||
if (typeof value == "string" && parseFloat(value).toString() == value)
|
||||
value = parseFloat(value);
|
||||
if (option.onchange)
|
||||
option.onchange(value);
|
||||
else if (option.path)
|
||||
this.editor.setOption(option.path, value);
|
||||
this._signal("setOption", {name: option.path, value: value});
|
||||
};
|
||||
|
||||
this.getOption = function(option) {
|
||||
if (option.getValue)
|
||||
return option.getValue();
|
||||
return this.editor.getOption(option.path);
|
||||
};
|
||||
|
||||
}).call(OptionPanel.prototype);
|
||||
|
||||
exports.OptionPanel = OptionPanel;
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/ext/settings_menu",["require","exports","module","ace/ext/options","ace/ext/menu_tools/overlay_page","ace/editor"], function(require, exports, module) {
|
||||
"use strict";
|
||||
var OptionPanel = require("./options").OptionPanel;
|
||||
var overlayPage = require('./menu_tools/overlay_page').overlayPage;
|
||||
function showSettingsMenu(editor) {
|
||||
if (!document.getElementById('ace_settingsmenu')) {
|
||||
var options = new OptionPanel(editor);
|
||||
options.render();
|
||||
options.container.id = "ace_settingsmenu";
|
||||
overlayPage(editor, options.container);
|
||||
options.container.querySelector("select,input,button,checkbox").focus();
|
||||
}
|
||||
}
|
||||
module.exports.init = function() {
|
||||
var Editor = require("../editor").Editor;
|
||||
Editor.prototype.showSettingsMenu = function() {
|
||||
showSettingsMenu(this);
|
||||
};
|
||||
};
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/settings_menu"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
ace.define("ace/ext/spellcheck",["require","exports","module","ace/lib/event","ace/editor","ace/config"], function(require, exports, module) {
|
||||
"use strict";
|
||||
var event = require("../lib/event");
|
||||
|
||||
exports.contextMenuHandler = function(e){
|
||||
var host = e.target;
|
||||
var text = host.textInput.getElement();
|
||||
if (!host.selection.isEmpty())
|
||||
return;
|
||||
var c = host.getCursorPosition();
|
||||
var r = host.session.getWordRange(c.row, c.column);
|
||||
var w = host.session.getTextRange(r);
|
||||
|
||||
host.session.tokenRe.lastIndex = 0;
|
||||
if (!host.session.tokenRe.test(w))
|
||||
return;
|
||||
var PLACEHOLDER = "\x01\x01";
|
||||
var value = w + " " + PLACEHOLDER;
|
||||
text.value = value;
|
||||
text.setSelectionRange(w.length, w.length + 1);
|
||||
text.setSelectionRange(0, 0);
|
||||
text.setSelectionRange(0, w.length);
|
||||
|
||||
var afterKeydown = false;
|
||||
event.addListener(text, "keydown", function onKeydown() {
|
||||
event.removeListener(text, "keydown", onKeydown);
|
||||
afterKeydown = true;
|
||||
});
|
||||
|
||||
host.textInput.setInputHandler(function(newVal) {
|
||||
if (newVal == value)
|
||||
return '';
|
||||
if (newVal.lastIndexOf(value, 0) === 0)
|
||||
return newVal.slice(value.length);
|
||||
if (newVal.substr(text.selectionEnd) == value)
|
||||
return newVal.slice(0, -value.length);
|
||||
if (newVal.slice(-2) == PLACEHOLDER) {
|
||||
var val = newVal.slice(0, -2);
|
||||
if (val.slice(-1) == " ") {
|
||||
if (afterKeydown)
|
||||
return val.substring(0, text.selectionEnd);
|
||||
val = val.slice(0, -1);
|
||||
host.session.replace(r, val);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
return newVal;
|
||||
});
|
||||
};
|
||||
var Editor = require("../editor").Editor;
|
||||
require("../config").defineOptions(Editor.prototype, "editor", {
|
||||
spellcheck: {
|
||||
set: function(val) {
|
||||
var text = this.textInput.getElement();
|
||||
text.spellcheck = !!val;
|
||||
if (!val)
|
||||
this.removeListener("nativecontextmenu", exports.contextMenuHandler);
|
||||
else
|
||||
this.on("nativecontextmenu", exports.contextMenuHandler);
|
||||
},
|
||||
value: true
|
||||
}
|
||||
});
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/spellcheck"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
ace.define("ace/split",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/editor","ace/virtual_renderer","ace/edit_session"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("./lib/oop");
|
||||
var lang = require("./lib/lang");
|
||||
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||||
|
||||
var Editor = require("./editor").Editor;
|
||||
var Renderer = require("./virtual_renderer").VirtualRenderer;
|
||||
var EditSession = require("./edit_session").EditSession;
|
||||
|
||||
|
||||
var Split = function(container, theme, splits) {
|
||||
this.BELOW = 1;
|
||||
this.BESIDE = 0;
|
||||
|
||||
this.$container = container;
|
||||
this.$theme = theme;
|
||||
this.$splits = 0;
|
||||
this.$editorCSS = "";
|
||||
this.$editors = [];
|
||||
this.$orientation = this.BESIDE;
|
||||
|
||||
this.setSplits(splits || 1);
|
||||
this.$cEditor = this.$editors[0];
|
||||
|
||||
|
||||
this.on("focus", function(editor) {
|
||||
this.$cEditor = editor;
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
(function(){
|
||||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.$createEditor = function() {
|
||||
var el = document.createElement("div");
|
||||
el.className = this.$editorCSS;
|
||||
el.style.cssText = "position: absolute; top:0px; bottom:0px";
|
||||
this.$container.appendChild(el);
|
||||
var editor = new Editor(new Renderer(el, this.$theme));
|
||||
|
||||
editor.on("focus", function() {
|
||||
this._emit("focus", editor);
|
||||
}.bind(this));
|
||||
|
||||
this.$editors.push(editor);
|
||||
editor.setFontSize(this.$fontSize);
|
||||
return editor;
|
||||
};
|
||||
|
||||
this.setSplits = function(splits) {
|
||||
var editor;
|
||||
if (splits < 1) {
|
||||
throw "The number of splits have to be > 0!";
|
||||
}
|
||||
|
||||
if (splits == this.$splits) {
|
||||
return;
|
||||
} else if (splits > this.$splits) {
|
||||
while (this.$splits < this.$editors.length && this.$splits < splits) {
|
||||
editor = this.$editors[this.$splits];
|
||||
this.$container.appendChild(editor.container);
|
||||
editor.setFontSize(this.$fontSize);
|
||||
this.$splits ++;
|
||||
}
|
||||
while (this.$splits < splits) {
|
||||
this.$createEditor();
|
||||
this.$splits ++;
|
||||
}
|
||||
} else {
|
||||
while (this.$splits > splits) {
|
||||
editor = this.$editors[this.$splits - 1];
|
||||
this.$container.removeChild(editor.container);
|
||||
this.$splits --;
|
||||
}
|
||||
}
|
||||
this.resize();
|
||||
};
|
||||
this.getSplits = function() {
|
||||
return this.$splits;
|
||||
};
|
||||
this.getEditor = function(idx) {
|
||||
return this.$editors[idx];
|
||||
};
|
||||
this.getCurrentEditor = function() {
|
||||
return this.$cEditor;
|
||||
};
|
||||
this.focus = function() {
|
||||
this.$cEditor.focus();
|
||||
};
|
||||
this.blur = function() {
|
||||
this.$cEditor.blur();
|
||||
};
|
||||
this.setTheme = function(theme) {
|
||||
this.$editors.forEach(function(editor) {
|
||||
editor.setTheme(theme);
|
||||
});
|
||||
};
|
||||
this.setKeyboardHandler = function(keybinding) {
|
||||
this.$editors.forEach(function(editor) {
|
||||
editor.setKeyboardHandler(keybinding);
|
||||
});
|
||||
};
|
||||
this.forEach = function(callback, scope) {
|
||||
this.$editors.forEach(callback, scope);
|
||||
};
|
||||
|
||||
|
||||
this.$fontSize = "";
|
||||
this.setFontSize = function(size) {
|
||||
this.$fontSize = size;
|
||||
this.forEach(function(editor) {
|
||||
editor.setFontSize(size);
|
||||
});
|
||||
};
|
||||
|
||||
this.$cloneSession = function(session) {
|
||||
var s = new EditSession(session.getDocument(), session.getMode());
|
||||
|
||||
var undoManager = session.getUndoManager();
|
||||
s.setUndoManager(undoManager);
|
||||
s.setTabSize(session.getTabSize());
|
||||
s.setUseSoftTabs(session.getUseSoftTabs());
|
||||
s.setOverwrite(session.getOverwrite());
|
||||
s.setBreakpoints(session.getBreakpoints());
|
||||
s.setUseWrapMode(session.getUseWrapMode());
|
||||
s.setUseWorker(session.getUseWorker());
|
||||
s.setWrapLimitRange(session.$wrapLimitRange.min,
|
||||
session.$wrapLimitRange.max);
|
||||
s.$foldData = session.$cloneFoldData();
|
||||
|
||||
return s;
|
||||
};
|
||||
this.setSession = function(session, idx) {
|
||||
var editor;
|
||||
if (idx == null) {
|
||||
editor = this.$cEditor;
|
||||
} else {
|
||||
editor = this.$editors[idx];
|
||||
}
|
||||
var isUsed = this.$editors.some(function(editor) {
|
||||
return editor.session === session;
|
||||
});
|
||||
|
||||
if (isUsed) {
|
||||
session = this.$cloneSession(session);
|
||||
}
|
||||
editor.setSession(session);
|
||||
return session;
|
||||
};
|
||||
this.getOrientation = function() {
|
||||
return this.$orientation;
|
||||
};
|
||||
this.setOrientation = function(orientation) {
|
||||
if (this.$orientation == orientation) {
|
||||
return;
|
||||
}
|
||||
this.$orientation = orientation;
|
||||
this.resize();
|
||||
};
|
||||
this.resize = function() {
|
||||
var width = this.$container.clientWidth;
|
||||
var height = this.$container.clientHeight;
|
||||
var editor;
|
||||
|
||||
if (this.$orientation == this.BESIDE) {
|
||||
var editorWidth = width / this.$splits;
|
||||
for (var i = 0; i < this.$splits; i++) {
|
||||
editor = this.$editors[i];
|
||||
editor.container.style.width = editorWidth + "px";
|
||||
editor.container.style.top = "0px";
|
||||
editor.container.style.left = i * editorWidth + "px";
|
||||
editor.container.style.height = height + "px";
|
||||
editor.resize();
|
||||
}
|
||||
} else {
|
||||
var editorHeight = height / this.$splits;
|
||||
for (var i = 0; i < this.$splits; i++) {
|
||||
editor = this.$editors[i];
|
||||
editor.container.style.width = width + "px";
|
||||
editor.container.style.top = i * editorHeight + "px";
|
||||
editor.container.style.left = "0px";
|
||||
editor.container.style.height = editorHeight + "px";
|
||||
editor.resize();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}).call(Split.prototype);
|
||||
|
||||
exports.Split = Split;
|
||||
});
|
||||
|
||||
ace.define("ace/ext/split",["require","exports","module","ace/split"], function(require, exports, module) {
|
||||
"use strict";
|
||||
module.exports = require("../split");
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/split"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
ace.define("ace/ext/static_highlight",["require","exports","module","ace/edit_session","ace/layer/text","ace/config","ace/lib/dom","ace/lib/lang"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var EditSession = require("../edit_session").EditSession;
|
||||
var TextLayer = require("../layer/text").Text;
|
||||
var baseStyles = ".ace_static_highlight {\
|
||||
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'Droid Sans Mono', monospace;\
|
||||
font-size: 12px;\
|
||||
white-space: pre-wrap\
|
||||
}\
|
||||
.ace_static_highlight .ace_gutter {\
|
||||
width: 2em;\
|
||||
text-align: right;\
|
||||
padding: 0 3px 0 0;\
|
||||
margin-right: 3px;\
|
||||
contain: none;\
|
||||
}\
|
||||
.ace_static_highlight.ace_show_gutter .ace_line {\
|
||||
padding-left: 2.6em;\
|
||||
}\
|
||||
.ace_static_highlight .ace_line { position: relative; }\
|
||||
.ace_static_highlight .ace_gutter-cell {\
|
||||
-moz-user-select: -moz-none;\
|
||||
-khtml-user-select: none;\
|
||||
-webkit-user-select: none;\
|
||||
user-select: none;\
|
||||
top: 0;\
|
||||
bottom: 0;\
|
||||
left: 0;\
|
||||
position: absolute;\
|
||||
}\
|
||||
.ace_static_highlight .ace_gutter-cell:before {\
|
||||
content: counter(ace_line, decimal);\
|
||||
counter-increment: ace_line;\
|
||||
}\
|
||||
.ace_static_highlight {\
|
||||
counter-reset: ace_line;\
|
||||
}\
|
||||
";
|
||||
var config = require("../config");
|
||||
var dom = require("../lib/dom");
|
||||
var escapeHTML = require("../lib/lang").escapeHTML;
|
||||
|
||||
function Element(type) {
|
||||
this.type = type;
|
||||
this.style = {};
|
||||
this.textContent = "";
|
||||
}
|
||||
Element.prototype.cloneNode = function() {
|
||||
return this;
|
||||
};
|
||||
Element.prototype.appendChild = function(child) {
|
||||
this.textContent += child.toString();
|
||||
};
|
||||
Element.prototype.toString = function() {
|
||||
var stringBuilder = [];
|
||||
if (this.type != "fragment") {
|
||||
stringBuilder.push("<", this.type);
|
||||
if (this.className)
|
||||
stringBuilder.push(" class='", this.className, "'");
|
||||
var styleStr = [];
|
||||
for (var key in this.style) {
|
||||
styleStr.push(key, ":", this.style[key]);
|
||||
}
|
||||
if (styleStr.length)
|
||||
stringBuilder.push(" style='", styleStr.join(""), "'");
|
||||
stringBuilder.push(">");
|
||||
}
|
||||
|
||||
if (this.textContent) {
|
||||
stringBuilder.push(this.textContent);
|
||||
}
|
||||
|
||||
if (this.type != "fragment") {
|
||||
stringBuilder.push("</", this.type, ">");
|
||||
}
|
||||
|
||||
return stringBuilder.join("");
|
||||
};
|
||||
|
||||
|
||||
var simpleDom = {
|
||||
createTextNode: function(textContent, element) {
|
||||
return escapeHTML(textContent);
|
||||
},
|
||||
createElement: function(type) {
|
||||
return new Element(type);
|
||||
},
|
||||
createFragment: function() {
|
||||
return new Element("fragment");
|
||||
}
|
||||
};
|
||||
|
||||
var SimpleTextLayer = function() {
|
||||
this.config = {};
|
||||
this.dom = simpleDom;
|
||||
};
|
||||
SimpleTextLayer.prototype = TextLayer.prototype;
|
||||
|
||||
var highlight = function(el, opts, callback) {
|
||||
var m = el.className.match(/lang-(\w+)/);
|
||||
var mode = opts.mode || m && ("ace/mode/" + m[1]);
|
||||
if (!mode)
|
||||
return false;
|
||||
var theme = opts.theme || "ace/theme/textmate";
|
||||
|
||||
var data = "";
|
||||
var nodes = [];
|
||||
|
||||
if (el.firstElementChild) {
|
||||
var textLen = 0;
|
||||
for (var i = 0; i < el.childNodes.length; i++) {
|
||||
var ch = el.childNodes[i];
|
||||
if (ch.nodeType == 3) {
|
||||
textLen += ch.data.length;
|
||||
data += ch.data;
|
||||
} else {
|
||||
nodes.push(textLen, ch);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
data = el.textContent;
|
||||
if (opts.trim)
|
||||
data = data.trim();
|
||||
}
|
||||
|
||||
highlight.render(data, mode, theme, opts.firstLineNumber, !opts.showGutter, function (highlighted) {
|
||||
dom.importCssString(highlighted.css, "ace_highlight");
|
||||
el.innerHTML = highlighted.html;
|
||||
var container = el.firstChild.firstChild;
|
||||
for (var i = 0; i < nodes.length; i += 2) {
|
||||
var pos = highlighted.session.doc.indexToPosition(nodes[i]);
|
||||
var node = nodes[i + 1];
|
||||
var lineEl = container.children[pos.row];
|
||||
lineEl && lineEl.appendChild(node);
|
||||
}
|
||||
callback && callback();
|
||||
});
|
||||
};
|
||||
highlight.render = function(input, mode, theme, lineStart, disableGutter, callback) {
|
||||
var waiting = 1;
|
||||
var modeCache = EditSession.prototype.$modes;
|
||||
if (typeof theme == "string") {
|
||||
waiting++;
|
||||
config.loadModule(['theme', theme], function(m) {
|
||||
theme = m;
|
||||
--waiting || done();
|
||||
});
|
||||
}
|
||||
var modeOptions;
|
||||
if (mode && typeof mode === "object" && !mode.getTokenizer) {
|
||||
modeOptions = mode;
|
||||
mode = modeOptions.path;
|
||||
}
|
||||
if (typeof mode == "string") {
|
||||
waiting++;
|
||||
config.loadModule(['mode', mode], function(m) {
|
||||
if (!modeCache[mode] || modeOptions)
|
||||
modeCache[mode] = new m.Mode(modeOptions);
|
||||
mode = modeCache[mode];
|
||||
--waiting || done();
|
||||
});
|
||||
}
|
||||
function done() {
|
||||
var result = highlight.renderSync(input, mode, theme, lineStart, disableGutter);
|
||||
return callback ? callback(result) : result;
|
||||
}
|
||||
return --waiting || done();
|
||||
};
|
||||
highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) {
|
||||
lineStart = parseInt(lineStart || 1, 10);
|
||||
|
||||
var session = new EditSession("");
|
||||
session.setUseWorker(false);
|
||||
session.setMode(mode);
|
||||
|
||||
var textLayer = new SimpleTextLayer();
|
||||
textLayer.setSession(session);
|
||||
Object.keys(textLayer.$tabStrings).forEach(function(k) {
|
||||
if (typeof textLayer.$tabStrings[k] == "string") {
|
||||
var el = simpleDom.createFragment();
|
||||
el.textContent = textLayer.$tabStrings[k];
|
||||
textLayer.$tabStrings[k] = el;
|
||||
}
|
||||
});
|
||||
|
||||
session.setValue(input);
|
||||
var length = session.getLength();
|
||||
|
||||
var outerEl = simpleDom.createElement("div");
|
||||
outerEl.className = theme.cssClass;
|
||||
|
||||
var innerEl = simpleDom.createElement("div");
|
||||
innerEl.className = "ace_static_highlight" + (disableGutter ? "" : " ace_show_gutter");
|
||||
innerEl.style["counter-reset"] = "ace_line " + (lineStart - 1);
|
||||
|
||||
for (var ix = 0; ix < length; ix++) {
|
||||
var lineEl = simpleDom.createElement("div");
|
||||
lineEl.className = "ace_line";
|
||||
|
||||
if (!disableGutter) {
|
||||
var gutterEl = simpleDom.createElement("span");
|
||||
gutterEl.className ="ace_gutter ace_gutter-cell";
|
||||
gutterEl.textContent = "";
|
||||
lineEl.appendChild(gutterEl);
|
||||
}
|
||||
textLayer.$renderLine(lineEl, ix, false);
|
||||
lineEl.textContent += "\n";
|
||||
innerEl.appendChild(lineEl);
|
||||
}
|
||||
outerEl.appendChild(innerEl);
|
||||
|
||||
return {
|
||||
css: baseStyles + theme.cssText,
|
||||
html: outerEl.toString(),
|
||||
session: session
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = highlight;
|
||||
module.exports.highlight = highlight;
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/static_highlight"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
ace.define("ace/ext/statusbar",["require","exports","module","ace/lib/dom","ace/lib/lang"], function(require, exports, module) {
|
||||
"use strict";
|
||||
var dom = require("../lib/dom");
|
||||
var lang = require("../lib/lang");
|
||||
|
||||
var StatusBar = function(editor, parentNode) {
|
||||
this.element = dom.createElement("div");
|
||||
this.element.className = "ace_status-indicator";
|
||||
this.element.style.cssText = "display: inline-block;";
|
||||
parentNode.appendChild(this.element);
|
||||
|
||||
var statusUpdate = lang.delayedCall(function(){
|
||||
this.updateStatus(editor);
|
||||
}.bind(this)).schedule.bind(null, 100);
|
||||
|
||||
editor.on("changeStatus", statusUpdate);
|
||||
editor.on("changeSelection", statusUpdate);
|
||||
editor.on("keyboardActivity", statusUpdate);
|
||||
};
|
||||
|
||||
(function(){
|
||||
this.updateStatus = function(editor) {
|
||||
var status = [];
|
||||
function add(str, separator) {
|
||||
str && status.push(str, separator || "|");
|
||||
}
|
||||
|
||||
add(editor.keyBinding.getStatusText(editor));
|
||||
if (editor.commands.recording)
|
||||
add("REC");
|
||||
|
||||
var sel = editor.selection;
|
||||
var c = sel.lead;
|
||||
|
||||
if (!sel.isEmpty()) {
|
||||
var r = editor.getSelectionRange();
|
||||
add("(" + (r.end.row - r.start.row) + ":" +(r.end.column - r.start.column) + ")", " ");
|
||||
}
|
||||
add(c.row + ":" + c.column, " ");
|
||||
if (sel.rangeCount)
|
||||
add("[" + sel.rangeCount + "]", " ");
|
||||
status.pop();
|
||||
this.element.textContent = status.join("");
|
||||
};
|
||||
}).call(StatusBar.prototype);
|
||||
|
||||
exports.StatusBar = StatusBar;
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/statusbar"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,563 @@
|
||||
ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
exports.isDark = false;
|
||||
exports.cssClass = "ace-tm";
|
||||
exports.cssText = ".ace-tm .ace_gutter {\
|
||||
background: #f0f0f0;\
|
||||
color: #333;\
|
||||
}\
|
||||
.ace-tm .ace_print-margin {\
|
||||
width: 1px;\
|
||||
background: #e8e8e8;\
|
||||
}\
|
||||
.ace-tm .ace_fold {\
|
||||
background-color: #6B72E6;\
|
||||
}\
|
||||
.ace-tm {\
|
||||
background-color: #FFFFFF;\
|
||||
color: black;\
|
||||
}\
|
||||
.ace-tm .ace_cursor {\
|
||||
color: black;\
|
||||
}\
|
||||
.ace-tm .ace_invisible {\
|
||||
color: rgb(191, 191, 191);\
|
||||
}\
|
||||
.ace-tm .ace_storage,\
|
||||
.ace-tm .ace_keyword {\
|
||||
color: blue;\
|
||||
}\
|
||||
.ace-tm .ace_constant {\
|
||||
color: rgb(197, 6, 11);\
|
||||
}\
|
||||
.ace-tm .ace_constant.ace_buildin {\
|
||||
color: rgb(88, 72, 246);\
|
||||
}\
|
||||
.ace-tm .ace_constant.ace_language {\
|
||||
color: rgb(88, 92, 246);\
|
||||
}\
|
||||
.ace-tm .ace_constant.ace_library {\
|
||||
color: rgb(6, 150, 14);\
|
||||
}\
|
||||
.ace-tm .ace_invalid {\
|
||||
background-color: rgba(255, 0, 0, 0.1);\
|
||||
color: red;\
|
||||
}\
|
||||
.ace-tm .ace_support.ace_function {\
|
||||
color: rgb(60, 76, 114);\
|
||||
}\
|
||||
.ace-tm .ace_support.ace_constant {\
|
||||
color: rgb(6, 150, 14);\
|
||||
}\
|
||||
.ace-tm .ace_support.ace_type,\
|
||||
.ace-tm .ace_support.ace_class {\
|
||||
color: rgb(109, 121, 222);\
|
||||
}\
|
||||
.ace-tm .ace_keyword.ace_operator {\
|
||||
color: rgb(104, 118, 135);\
|
||||
}\
|
||||
.ace-tm .ace_string {\
|
||||
color: rgb(3, 106, 7);\
|
||||
}\
|
||||
.ace-tm .ace_comment {\
|
||||
color: rgb(76, 136, 107);\
|
||||
}\
|
||||
.ace-tm .ace_comment.ace_doc {\
|
||||
color: rgb(0, 102, 255);\
|
||||
}\
|
||||
.ace-tm .ace_comment.ace_doc.ace_tag {\
|
||||
color: rgb(128, 159, 191);\
|
||||
}\
|
||||
.ace-tm .ace_constant.ace_numeric {\
|
||||
color: rgb(0, 0, 205);\
|
||||
}\
|
||||
.ace-tm .ace_variable {\
|
||||
color: rgb(49, 132, 149);\
|
||||
}\
|
||||
.ace-tm .ace_xml-pe {\
|
||||
color: rgb(104, 104, 91);\
|
||||
}\
|
||||
.ace-tm .ace_entity.ace_name.ace_function {\
|
||||
color: #0000A2;\
|
||||
}\
|
||||
.ace-tm .ace_heading {\
|
||||
color: rgb(12, 7, 255);\
|
||||
}\
|
||||
.ace-tm .ace_list {\
|
||||
color:rgb(185, 6, 144);\
|
||||
}\
|
||||
.ace-tm .ace_meta.ace_tag {\
|
||||
color:rgb(0, 22, 142);\
|
||||
}\
|
||||
.ace-tm .ace_string.ace_regex {\
|
||||
color: rgb(255, 0, 0)\
|
||||
}\
|
||||
.ace-tm .ace_marker-layer .ace_selection {\
|
||||
background: rgb(181, 213, 255);\
|
||||
}\
|
||||
.ace-tm.ace_multiselect .ace_selection.ace_start {\
|
||||
box-shadow: 0 0 3px 0px white;\
|
||||
}\
|
||||
.ace-tm .ace_marker-layer .ace_step {\
|
||||
background: rgb(252, 255, 0);\
|
||||
}\
|
||||
.ace-tm .ace_marker-layer .ace_stack {\
|
||||
background: rgb(164, 229, 101);\
|
||||
}\
|
||||
.ace-tm .ace_marker-layer .ace_bracket {\
|
||||
margin: -1px 0 0 -1px;\
|
||||
border: 1px solid rgb(192, 192, 192);\
|
||||
}\
|
||||
.ace-tm .ace_marker-layer .ace_active-line {\
|
||||
background: rgba(0, 0, 0, 0.07);\
|
||||
}\
|
||||
.ace-tm .ace_gutter-active-line {\
|
||||
background-color : #dcdcdc;\
|
||||
}\
|
||||
.ace-tm .ace_marker-layer .ace_selected-word {\
|
||||
background: rgb(250, 250, 255);\
|
||||
border: 1px solid rgb(200, 200, 250);\
|
||||
}\
|
||||
.ace-tm .ace_indent-guide {\
|
||||
background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
|
||||
}\
|
||||
";
|
||||
exports.$id = "ace/theme/textmate";
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
});
|
||||
|
||||
ace.define("ace/ext/textarea",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/net","ace/ace","ace/theme/textmate"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var event = require("../lib/event");
|
||||
var UA = require("../lib/useragent");
|
||||
var net = require("../lib/net");
|
||||
var ace = require("../ace");
|
||||
|
||||
require("../theme/textmate");
|
||||
|
||||
module.exports = exports = ace;
|
||||
var getCSSProperty = function(element, container, property) {
|
||||
var ret = element.style[property];
|
||||
|
||||
if (!ret) {
|
||||
if (window.getComputedStyle) {
|
||||
ret = window.getComputedStyle(element, '').getPropertyValue(property);
|
||||
} else {
|
||||
ret = element.currentStyle[property];
|
||||
}
|
||||
}
|
||||
|
||||
if (!ret || ret == 'auto' || ret == 'intrinsic') {
|
||||
ret = container.style[property];
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
function applyStyles(elm, styles) {
|
||||
for (var style in styles) {
|
||||
elm.style[style] = styles[style];
|
||||
}
|
||||
}
|
||||
|
||||
function setupContainer(element, getValue) {
|
||||
if (element.type != 'textarea') {
|
||||
throw new Error("Textarea required!");
|
||||
}
|
||||
|
||||
var parentNode = element.parentNode;
|
||||
var container = document.createElement('div');
|
||||
var resizeEvent = function() {
|
||||
var style = 'position:relative;';
|
||||
[
|
||||
'margin-top', 'margin-left', 'margin-right', 'margin-bottom'
|
||||
].forEach(function(item) {
|
||||
style += item + ':' +
|
||||
getCSSProperty(element, container, item) + ';';
|
||||
});
|
||||
var width = getCSSProperty(element, container, 'width') || (element.clientWidth + "px");
|
||||
var height = getCSSProperty(element, container, 'height') || (element.clientHeight + "px");
|
||||
style += 'height:' + height + ';width:' + width + ';';
|
||||
style += 'display:inline-block;';
|
||||
container.setAttribute('style', style);
|
||||
};
|
||||
event.addListener(window, 'resize', resizeEvent);
|
||||
resizeEvent();
|
||||
parentNode.insertBefore(container, element.nextSibling);
|
||||
while (parentNode !== document) {
|
||||
if (parentNode.tagName.toUpperCase() === 'FORM') {
|
||||
var oldSumit = parentNode.onsubmit;
|
||||
parentNode.onsubmit = function(evt) {
|
||||
element.value = getValue();
|
||||
if (oldSumit) {
|
||||
oldSumit.call(this, evt);
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
parentNode = parentNode.parentNode;
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
||||
exports.transformTextarea = function(element, options) {
|
||||
var isFocused = element.autofocus || document.activeElement == element;
|
||||
var session;
|
||||
var container = setupContainer(element, function() {
|
||||
return session.getValue();
|
||||
});
|
||||
element.style.display = 'none';
|
||||
container.style.background = 'white';
|
||||
var editorDiv = document.createElement("div");
|
||||
applyStyles(editorDiv, {
|
||||
top: "0px",
|
||||
left: "0px",
|
||||
right: "0px",
|
||||
bottom: "0px",
|
||||
border: "1px solid gray",
|
||||
position: "absolute"
|
||||
});
|
||||
container.appendChild(editorDiv);
|
||||
|
||||
var settingOpener = document.createElement("div");
|
||||
applyStyles(settingOpener, {
|
||||
position: "absolute",
|
||||
right: "0px",
|
||||
bottom: "0px",
|
||||
cursor: "nw-resize",
|
||||
border: "solid 9px",
|
||||
borderColor: "lightblue gray gray #ceade6",
|
||||
zIndex: 101
|
||||
});
|
||||
|
||||
var settingDiv = document.createElement("div");
|
||||
var settingDivStyles = {
|
||||
top: "0px",
|
||||
left: "20%",
|
||||
right: "0px",
|
||||
bottom: "0px",
|
||||
position: "absolute",
|
||||
padding: "5px",
|
||||
zIndex: 100,
|
||||
color: "white",
|
||||
display: "none",
|
||||
overflow: "auto",
|
||||
fontSize: "14px",
|
||||
boxShadow: "-5px 2px 3px gray"
|
||||
};
|
||||
if (!UA.isOldIE) {
|
||||
settingDivStyles.backgroundColor = "rgba(0, 0, 0, 0.6)";
|
||||
} else {
|
||||
settingDivStyles.backgroundColor = "#333";
|
||||
}
|
||||
|
||||
applyStyles(settingDiv, settingDivStyles);
|
||||
container.appendChild(settingDiv);
|
||||
|
||||
options = options || exports.defaultOptions;
|
||||
var editor = ace.edit(editorDiv);
|
||||
session = editor.getSession();
|
||||
|
||||
session.setValue(element.value || element.innerHTML);
|
||||
if (isFocused)
|
||||
editor.focus();
|
||||
container.appendChild(settingOpener);
|
||||
setupApi(editor, editorDiv, settingDiv, ace, options);
|
||||
setupSettingPanel(settingDiv, settingOpener, editor);
|
||||
|
||||
var state = "";
|
||||
event.addListener(settingOpener, "mousemove", function(e) {
|
||||
var rect = this.getBoundingClientRect();
|
||||
var x = e.clientX - rect.left, y = e.clientY - rect.top;
|
||||
if (x + y < (rect.width + rect.height)/2) {
|
||||
this.style.cursor = "pointer";
|
||||
state = "toggle";
|
||||
} else {
|
||||
state = "resize";
|
||||
this.style.cursor = "nw-resize";
|
||||
}
|
||||
});
|
||||
|
||||
event.addListener(settingOpener, "mousedown", function(e) {
|
||||
e.preventDefault();
|
||||
if (state == "toggle") {
|
||||
editor.setDisplaySettings();
|
||||
return;
|
||||
}
|
||||
container.style.zIndex = 100000;
|
||||
var rect = container.getBoundingClientRect();
|
||||
var startX = rect.width + rect.left - e.clientX;
|
||||
var startY = rect.height + rect.top - e.clientY;
|
||||
event.capture(settingOpener, function(e) {
|
||||
container.style.width = e.clientX - rect.left + startX + "px";
|
||||
container.style.height = e.clientY - rect.top + startY + "px";
|
||||
editor.resize();
|
||||
}, function() {});
|
||||
});
|
||||
|
||||
return editor;
|
||||
};
|
||||
|
||||
function load(url, module, callback) {
|
||||
net.loadScript(url, function() {
|
||||
require([module], callback);
|
||||
});
|
||||
}
|
||||
|
||||
function setupApi(editor, editorDiv, settingDiv, ace, options) {
|
||||
var session = editor.getSession();
|
||||
var renderer = editor.renderer;
|
||||
|
||||
function toBool(value) {
|
||||
return value === "true" || value == true;
|
||||
}
|
||||
|
||||
editor.setDisplaySettings = function(display) {
|
||||
if (display == null)
|
||||
display = settingDiv.style.display == "none";
|
||||
if (display) {
|
||||
settingDiv.style.display = "block";
|
||||
settingDiv.hideButton.focus();
|
||||
editor.on("focus", function onFocus() {
|
||||
editor.removeListener("focus", onFocus);
|
||||
settingDiv.style.display = "none";
|
||||
});
|
||||
} else {
|
||||
editor.focus();
|
||||
}
|
||||
};
|
||||
|
||||
editor.$setOption = editor.setOption;
|
||||
editor.$getOption = editor.getOption;
|
||||
editor.setOption = function(key, value) {
|
||||
switch (key) {
|
||||
case "mode":
|
||||
editor.$setOption("mode", "ace/mode/" + value);
|
||||
break;
|
||||
case "theme":
|
||||
editor.$setOption("theme", "ace/theme/" + value);
|
||||
break;
|
||||
case "keybindings":
|
||||
switch (value) {
|
||||
case "vim":
|
||||
editor.setKeyboardHandler("ace/keyboard/vim");
|
||||
break;
|
||||
case "emacs":
|
||||
editor.setKeyboardHandler("ace/keyboard/emacs");
|
||||
break;
|
||||
default:
|
||||
editor.setKeyboardHandler(null);
|
||||
}
|
||||
break;
|
||||
|
||||
case "wrap":
|
||||
case "fontSize":
|
||||
editor.$setOption(key, value);
|
||||
break;
|
||||
|
||||
default:
|
||||
editor.$setOption(key, toBool(value));
|
||||
}
|
||||
};
|
||||
|
||||
editor.getOption = function(key) {
|
||||
switch (key) {
|
||||
case "mode":
|
||||
return editor.$getOption("mode").substr("ace/mode/".length);
|
||||
break;
|
||||
|
||||
case "theme":
|
||||
return editor.$getOption("theme").substr("ace/theme/".length);
|
||||
break;
|
||||
|
||||
case "keybindings":
|
||||
var value = editor.getKeyboardHandler();
|
||||
switch (value && value.$id) {
|
||||
case "ace/keyboard/vim":
|
||||
return "vim";
|
||||
case "ace/keyboard/emacs":
|
||||
return "emacs";
|
||||
default:
|
||||
return "ace";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return editor.$getOption(key);
|
||||
}
|
||||
};
|
||||
|
||||
editor.setOptions(options);
|
||||
return editor;
|
||||
}
|
||||
|
||||
function setupSettingPanel(settingDiv, settingOpener, editor) {
|
||||
var BOOL = null;
|
||||
|
||||
var desc = {
|
||||
mode: "Mode:",
|
||||
wrap: "Soft Wrap:",
|
||||
theme: "Theme:",
|
||||
fontSize: "Font Size:",
|
||||
showGutter: "Display Gutter:",
|
||||
keybindings: "Keyboard",
|
||||
showPrintMargin: "Show Print Margin:",
|
||||
useSoftTabs: "Use Soft Tabs:",
|
||||
showInvisibles: "Show Invisibles"
|
||||
};
|
||||
|
||||
var optionValues = {
|
||||
mode: {
|
||||
text: "Plain",
|
||||
javascript: "JavaScript",
|
||||
xml: "XML",
|
||||
html: "HTML",
|
||||
css: "CSS",
|
||||
scss: "SCSS",
|
||||
python: "Python",
|
||||
php: "PHP",
|
||||
java: "Java",
|
||||
ruby: "Ruby",
|
||||
c_cpp: "C/C++",
|
||||
coffee: "CoffeeScript",
|
||||
json: "json",
|
||||
perl: "Perl",
|
||||
clojure: "Clojure",
|
||||
ocaml: "OCaml",
|
||||
csharp: "C#",
|
||||
haxe: "haXe",
|
||||
svg: "SVG",
|
||||
textile: "Textile",
|
||||
groovy: "Groovy",
|
||||
liquid: "Liquid",
|
||||
Scala: "Scala"
|
||||
},
|
||||
theme: {
|
||||
clouds: "Clouds",
|
||||
clouds_midnight: "Clouds Midnight",
|
||||
cobalt: "Cobalt",
|
||||
crimson_editor: "Crimson Editor",
|
||||
dawn: "Dawn",
|
||||
gob: "Green on Black",
|
||||
eclipse: "Eclipse",
|
||||
idle_fingers: "Idle Fingers",
|
||||
kr_theme: "Kr Theme",
|
||||
merbivore: "Merbivore",
|
||||
merbivore_soft: "Merbivore Soft",
|
||||
mono_industrial: "Mono Industrial",
|
||||
monokai: "Monokai",
|
||||
pastel_on_dark: "Pastel On Dark",
|
||||
solarized_dark: "Solarized Dark",
|
||||
solarized_light: "Solarized Light",
|
||||
textmate: "Textmate",
|
||||
twilight: "Twilight",
|
||||
vibrant_ink: "Vibrant Ink"
|
||||
},
|
||||
showGutter: BOOL,
|
||||
fontSize: {
|
||||
"10px": "10px",
|
||||
"11px": "11px",
|
||||
"12px": "12px",
|
||||
"14px": "14px",
|
||||
"16px": "16px"
|
||||
},
|
||||
wrap: {
|
||||
off: "Off",
|
||||
40: "40",
|
||||
80: "80",
|
||||
free: "Free"
|
||||
},
|
||||
keybindings: {
|
||||
ace: "ace",
|
||||
vim: "vim",
|
||||
emacs: "emacs"
|
||||
},
|
||||
showPrintMargin: BOOL,
|
||||
useSoftTabs: BOOL,
|
||||
showInvisibles: BOOL
|
||||
};
|
||||
|
||||
var table = [];
|
||||
table.push("<table><tr><th>Setting</th><th>Value</th></tr>");
|
||||
|
||||
function renderOption(builder, option, obj, cValue) {
|
||||
if (!obj) {
|
||||
builder.push(
|
||||
"<input type='checkbox' title='", option, "' ",
|
||||
cValue + "" == "true" ? "checked='true'" : "",
|
||||
"'></input>"
|
||||
);
|
||||
return;
|
||||
}
|
||||
builder.push("<select title='" + option + "'>");
|
||||
for (var value in obj) {
|
||||
builder.push("<option value='" + value + "' ");
|
||||
|
||||
if (cValue == value) {
|
||||
builder.push(" selected ");
|
||||
}
|
||||
|
||||
builder.push(">",
|
||||
obj[value],
|
||||
"</option>");
|
||||
}
|
||||
builder.push("</select>");
|
||||
}
|
||||
|
||||
for (var option in exports.defaultOptions) {
|
||||
table.push("<tr><td>", desc[option], "</td>");
|
||||
table.push("<td>");
|
||||
renderOption(table, option, optionValues[option], editor.getOption(option));
|
||||
table.push("</td></tr>");
|
||||
}
|
||||
table.push("</table>");
|
||||
settingDiv.innerHTML = table.join("");
|
||||
|
||||
var onChange = function(e) {
|
||||
var select = e.currentTarget;
|
||||
editor.setOption(select.title, select.value);
|
||||
};
|
||||
var onClick = function(e) {
|
||||
var cb = e.currentTarget;
|
||||
editor.setOption(cb.title, cb.checked);
|
||||
};
|
||||
var selects = settingDiv.getElementsByTagName("select");
|
||||
for (var i = 0; i < selects.length; i++)
|
||||
selects[i].onchange = onChange;
|
||||
var cbs = settingDiv.getElementsByTagName("input");
|
||||
for (var i = 0; i < cbs.length; i++)
|
||||
cbs[i].onclick = onClick;
|
||||
|
||||
|
||||
var button = document.createElement("input");
|
||||
button.type = "button";
|
||||
button.value = "Hide";
|
||||
event.addListener(button, "click", function() {
|
||||
editor.setDisplaySettings(false);
|
||||
});
|
||||
settingDiv.appendChild(button);
|
||||
settingDiv.hideButton = button;
|
||||
}
|
||||
exports.defaultOptions = {
|
||||
mode: "javascript",
|
||||
theme: "textmate",
|
||||
wrap: "off",
|
||||
fontSize: "12px",
|
||||
showGutter: "false",
|
||||
keybindings: "ace",
|
||||
showPrintMargin: "false",
|
||||
useSoftTabs: "true",
|
||||
showInvisibles: "false"
|
||||
};
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/textarea"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
ace.define("ace/ext/themelist",["require","exports","module"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var themeData = [
|
||||
["Chrome" ],
|
||||
["Clouds" ],
|
||||
["Crimson Editor" ],
|
||||
["Dawn" ],
|
||||
["Dreamweaver" ],
|
||||
["Eclipse" ],
|
||||
["GitHub" ],
|
||||
["IPlastic" ],
|
||||
["Solarized Light"],
|
||||
["TextMate" ],
|
||||
["Tomorrow" ],
|
||||
["Xcode" ],
|
||||
["Kuroir"],
|
||||
["KatzenMilch"],
|
||||
["SQL Server" ,"sqlserver" , "light"],
|
||||
["Ambiance" ,"ambiance" , "dark"],
|
||||
["Chaos" ,"chaos" , "dark"],
|
||||
["Clouds Midnight" ,"clouds_midnight" , "dark"],
|
||||
["Dracula" ,"" , "dark"],
|
||||
["Cobalt" ,"cobalt" , "dark"],
|
||||
["Gruvbox" ,"gruvbox" , "dark"],
|
||||
["Green on Black" ,"gob" , "dark"],
|
||||
["idle Fingers" ,"idle_fingers" , "dark"],
|
||||
["krTheme" ,"kr_theme" , "dark"],
|
||||
["Merbivore" ,"merbivore" , "dark"],
|
||||
["Merbivore Soft" ,"merbivore_soft" , "dark"],
|
||||
["Mono Industrial" ,"mono_industrial" , "dark"],
|
||||
["Monokai" ,"monokai" , "dark"],
|
||||
["Nord Dark" ,"nord_dark" , "dark"],
|
||||
["Pastel on dark" ,"pastel_on_dark" , "dark"],
|
||||
["Solarized Dark" ,"solarized_dark" , "dark"],
|
||||
["Terminal" ,"terminal" , "dark"],
|
||||
["Tomorrow Night" ,"tomorrow_night" , "dark"],
|
||||
["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"],
|
||||
["Tomorrow Night Bright","tomorrow_night_bright" , "dark"],
|
||||
["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"],
|
||||
["Twilight" ,"twilight" , "dark"],
|
||||
["Vibrant Ink" ,"vibrant_ink" , "dark"]
|
||||
];
|
||||
|
||||
|
||||
exports.themesByName = {};
|
||||
exports.themes = themeData.map(function(data) {
|
||||
var name = data[1] || data[0].replace(/ /g, "_").toLowerCase();
|
||||
var theme = {
|
||||
caption: data[0],
|
||||
theme: "ace/theme/" + name,
|
||||
isDark: data[2] == "dark",
|
||||
name: name
|
||||
};
|
||||
exports.themesByName[name] = theme;
|
||||
return theme;
|
||||
});
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/themelist"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
ace.define("ace/ext/whitespace",["require","exports","module","ace/lib/lang"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var lang = require("../lib/lang");
|
||||
exports.$detectIndentation = function(lines, fallback) {
|
||||
var stats = [];
|
||||
var changes = [];
|
||||
var tabIndents = 0;
|
||||
var prevSpaces = 0;
|
||||
var max = Math.min(lines.length, 1000);
|
||||
for (var i = 0; i < max; i++) {
|
||||
var line = lines[i];
|
||||
if (!/^\s*[^*+\-\s]/.test(line))
|
||||
continue;
|
||||
|
||||
if (line[0] == "\t") {
|
||||
tabIndents++;
|
||||
prevSpaces = -Number.MAX_VALUE;
|
||||
} else {
|
||||
var spaces = line.match(/^ */)[0].length;
|
||||
if (spaces && line[spaces] != "\t") {
|
||||
var diff = spaces - prevSpaces;
|
||||
if (diff > 0 && !(prevSpaces%diff) && !(spaces%diff))
|
||||
changes[diff] = (changes[diff] || 0) + 1;
|
||||
|
||||
stats[spaces] = (stats[spaces] || 0) + 1;
|
||||
}
|
||||
prevSpaces = spaces;
|
||||
}
|
||||
while (i < max && line[line.length - 1] == "\\")
|
||||
line = lines[i++];
|
||||
}
|
||||
|
||||
function getScore(indent) {
|
||||
var score = 0;
|
||||
for (var i = indent; i < stats.length; i += indent)
|
||||
score += stats[i] || 0;
|
||||
return score;
|
||||
}
|
||||
|
||||
var changesTotal = changes.reduce(function(a,b){return a+b;}, 0);
|
||||
|
||||
var first = {score: 0, length: 0};
|
||||
var spaceIndents = 0;
|
||||
for (var i = 1; i < 12; i++) {
|
||||
var score = getScore(i);
|
||||
if (i == 1) {
|
||||
spaceIndents = score;
|
||||
score = stats[1] ? 0.9 : 0.8;
|
||||
if (!stats.length)
|
||||
score = 0;
|
||||
} else
|
||||
score /= spaceIndents;
|
||||
|
||||
if (changes[i])
|
||||
score += changes[i] / changesTotal;
|
||||
|
||||
if (score > first.score)
|
||||
first = {score: score, length: i};
|
||||
}
|
||||
|
||||
if (first.score && first.score > 1.4)
|
||||
var tabLength = first.length;
|
||||
|
||||
if (tabIndents > spaceIndents + 1) {
|
||||
if (tabLength == 1 || spaceIndents < tabIndents / 4 || first.score < 1.8)
|
||||
tabLength = undefined;
|
||||
return {ch: "\t", length: tabLength};
|
||||
}
|
||||
if (spaceIndents > tabIndents + 1)
|
||||
return {ch: " ", length: tabLength};
|
||||
};
|
||||
|
||||
exports.detectIndentation = function(session) {
|
||||
var lines = session.getLines(0, 1000);
|
||||
var indent = exports.$detectIndentation(lines) || {};
|
||||
|
||||
if (indent.ch)
|
||||
session.setUseSoftTabs(indent.ch == " ");
|
||||
|
||||
if (indent.length)
|
||||
session.setTabSize(indent.length);
|
||||
return indent;
|
||||
};
|
||||
exports.trimTrailingSpace = function(session, options) {
|
||||
var doc = session.getDocument();
|
||||
var lines = doc.getAllLines();
|
||||
|
||||
var min = options && options.trimEmpty ? -1 : 0;
|
||||
var cursors = [], ci = -1;
|
||||
if (options && options.keepCursorPosition) {
|
||||
if (session.selection.rangeCount) {
|
||||
session.selection.rangeList.ranges.forEach(function(x, i, ranges) {
|
||||
var next = ranges[i + 1];
|
||||
if (next && next.cursor.row == x.cursor.row)
|
||||
return;
|
||||
cursors.push(x.cursor);
|
||||
});
|
||||
} else {
|
||||
cursors.push(session.selection.getCursor());
|
||||
}
|
||||
ci = 0;
|
||||
}
|
||||
var cursorRow = cursors[ci] && cursors[ci].row;
|
||||
|
||||
for (var i = 0, l=lines.length; i < l; i++) {
|
||||
var line = lines[i];
|
||||
var index = line.search(/\s+$/);
|
||||
|
||||
if (i == cursorRow) {
|
||||
if (index < cursors[ci].column && index > min)
|
||||
index = cursors[ci].column;
|
||||
ci++;
|
||||
cursorRow = cursors[ci] ? cursors[ci].row : -1;
|
||||
}
|
||||
|
||||
if (index > min)
|
||||
doc.removeInLine(i, index, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
exports.convertIndentation = function(session, ch, len) {
|
||||
var oldCh = session.getTabString()[0];
|
||||
var oldLen = session.getTabSize();
|
||||
if (!len) len = oldLen;
|
||||
if (!ch) ch = oldCh;
|
||||
|
||||
var tab = ch == "\t" ? ch: lang.stringRepeat(ch, len);
|
||||
|
||||
var doc = session.doc;
|
||||
var lines = doc.getAllLines();
|
||||
|
||||
var cache = {};
|
||||
var spaceCache = {};
|
||||
for (var i = 0, l=lines.length; i < l; i++) {
|
||||
var line = lines[i];
|
||||
var match = line.match(/^\s*/)[0];
|
||||
if (match) {
|
||||
var w = session.$getStringScreenWidth(match)[0];
|
||||
var tabCount = Math.floor(w/oldLen);
|
||||
var reminder = w%oldLen;
|
||||
var toInsert = cache[tabCount] || (cache[tabCount] = lang.stringRepeat(tab, tabCount));
|
||||
toInsert += spaceCache[reminder] || (spaceCache[reminder] = lang.stringRepeat(" ", reminder));
|
||||
|
||||
if (toInsert != match) {
|
||||
doc.removeInLine(i, 0, match.length);
|
||||
doc.insertInLine({row: i, column: 0}, toInsert);
|
||||
}
|
||||
}
|
||||
}
|
||||
session.setTabSize(len);
|
||||
session.setUseSoftTabs(ch == " ");
|
||||
};
|
||||
|
||||
exports.$parseStringArg = function(text) {
|
||||
var indent = {};
|
||||
if (/t/.test(text))
|
||||
indent.ch = "\t";
|
||||
else if (/s/.test(text))
|
||||
indent.ch = " ";
|
||||
var m = text.match(/\d+/);
|
||||
if (m)
|
||||
indent.length = parseInt(m[0], 10);
|
||||
return indent;
|
||||
};
|
||||
|
||||
exports.$parseArg = function(arg) {
|
||||
if (!arg)
|
||||
return {};
|
||||
if (typeof arg == "string")
|
||||
return exports.$parseStringArg(arg);
|
||||
if (typeof arg.text == "string")
|
||||
return exports.$parseStringArg(arg.text);
|
||||
return arg;
|
||||
};
|
||||
|
||||
exports.commands = [{
|
||||
name: "detectIndentation",
|
||||
description: "Detect indentation from content",
|
||||
exec: function(editor) {
|
||||
exports.detectIndentation(editor.session);
|
||||
}
|
||||
}, {
|
||||
name: "trimTrailingSpace",
|
||||
description: "Trim trailing whitespace",
|
||||
exec: function(editor, args) {
|
||||
exports.trimTrailingSpace(editor.session, args);
|
||||
}
|
||||
}, {
|
||||
name: "convertIndentation",
|
||||
description: "Convert indentation to ...",
|
||||
exec: function(editor, arg) {
|
||||
var indent = exports.$parseArg(arg);
|
||||
exports.convertIndentation(editor.session, indent.ch, indent.length);
|
||||
}
|
||||
}, {
|
||||
name: "setIndentation",
|
||||
description: "Set indentation",
|
||||
exec: function(editor, arg) {
|
||||
var indent = exports.$parseArg(arg);
|
||||
indent.length && editor.session.setTabSize(indent.length);
|
||||
indent.ch && editor.session.setUseSoftTabs(indent.ch == " ");
|
||||
}
|
||||
}];
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/ext/whitespace"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,422 @@
|
||||
ace.define("ace/keyboard/sublime",["require","exports","module","ace/keyboard/hash_handler"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
||||
|
||||
function moveBySubWords(editor, direction, extend) {
|
||||
var selection = editor.selection;
|
||||
var row = selection.lead.row;
|
||||
var column = selection.lead.column;
|
||||
|
||||
var line = editor.session.getLine(row);
|
||||
if (!line[column + direction]) {
|
||||
var method = (extend ? "selectWord" : "moveCursorShortWord")
|
||||
+ (direction == 1 ? "Right" : "Left");
|
||||
return editor.selection[method]();
|
||||
}
|
||||
if (direction == -1) column--;
|
||||
while (line[column]) {
|
||||
var type = getType(line[column]) + getType(line[column + direction]);
|
||||
column += direction;
|
||||
if (direction == 1) {
|
||||
if (type == "WW" && getType(line[column + 1]) == "w")
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if (type == "wW") {
|
||||
if (getType(line[column - 1]) == "W") {
|
||||
column -= 1;
|
||||
break;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (type == "Ww")
|
||||
break;
|
||||
}
|
||||
if (/w[s_oW]|_[sWo]|o[s_wW]|s[W]|W[so]/.test(type))
|
||||
break;
|
||||
}
|
||||
if (direction == -1) column++;
|
||||
if (extend)
|
||||
editor.selection.moveCursorTo(row, column);
|
||||
else
|
||||
editor.selection.moveTo(row, column);
|
||||
|
||||
function getType(x) {
|
||||
if (!x) return "-";
|
||||
if (/\s/.test(x)) return "s";
|
||||
if (x == "_") return "_";
|
||||
if (x.toUpperCase() == x && x.toLowerCase() != x) return "W";
|
||||
if (x.toUpperCase() != x && x.toLowerCase() == x) return "w";
|
||||
return "o";
|
||||
}
|
||||
}
|
||||
|
||||
exports.handler = new HashHandler();
|
||||
|
||||
exports.handler.addCommands([{
|
||||
name: "find_all_under",
|
||||
exec: function(editor) {
|
||||
if (editor.selection.isEmpty())
|
||||
editor.selection.selectWord();
|
||||
editor.findAll();
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "find_under",
|
||||
exec: function(editor) {
|
||||
if (editor.selection.isEmpty())
|
||||
editor.selection.selectWord();
|
||||
editor.findNext();
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "find_under_prev",
|
||||
exec: function(editor) {
|
||||
if (editor.selection.isEmpty())
|
||||
editor.selection.selectWord();
|
||||
editor.findPrevious();
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "find_under_expand",
|
||||
exec: function(editor) {
|
||||
editor.selectMore(1, false, true);
|
||||
},
|
||||
scrollIntoView: "animate",
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "find_under_expand_skip",
|
||||
exec: function(editor) {
|
||||
editor.selectMore(1, true, true);
|
||||
},
|
||||
scrollIntoView: "animate",
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "delete_to_hard_bol",
|
||||
exec: function(editor) {
|
||||
var pos = editor.selection.getCursor();
|
||||
editor.session.remove({
|
||||
start: { row: pos.row, column: 0 },
|
||||
end: pos
|
||||
});
|
||||
},
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "cursor"
|
||||
}, {
|
||||
name: "delete_to_hard_eol",
|
||||
exec: function(editor) {
|
||||
var pos = editor.selection.getCursor();
|
||||
editor.session.remove({
|
||||
start: pos,
|
||||
end: { row: pos.row, column: Infinity }
|
||||
});
|
||||
},
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "cursor"
|
||||
}, {
|
||||
name: "moveToWordStartLeft",
|
||||
exec: function(editor) {
|
||||
editor.selection.moveCursorLongWordLeft();
|
||||
editor.clearSelection();
|
||||
},
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "cursor"
|
||||
}, {
|
||||
name: "moveToWordEndRight",
|
||||
exec: function(editor) {
|
||||
editor.selection.moveCursorLongWordRight();
|
||||
editor.clearSelection();
|
||||
},
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "cursor"
|
||||
}, {
|
||||
name: "selectToWordStartLeft",
|
||||
exec: function(editor) {
|
||||
var sel = editor.selection;
|
||||
sel.$moveSelection(sel.moveCursorLongWordLeft);
|
||||
},
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "cursor"
|
||||
}, {
|
||||
name: "selectToWordEndRight",
|
||||
exec: function(editor) {
|
||||
var sel = editor.selection;
|
||||
sel.$moveSelection(sel.moveCursorLongWordRight);
|
||||
},
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "cursor"
|
||||
}, {
|
||||
name: "selectSubWordRight",
|
||||
exec: function(editor) {
|
||||
moveBySubWords(editor, 1, true);
|
||||
},
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "cursor",
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "selectSubWordLeft",
|
||||
exec: function(editor) {
|
||||
moveBySubWords(editor, -1, true);
|
||||
},
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "cursor",
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "moveSubWordRight",
|
||||
exec: function(editor) {
|
||||
moveBySubWords(editor, 1);
|
||||
},
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "cursor",
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "moveSubWordLeft",
|
||||
exec: function(editor) {
|
||||
moveBySubWords(editor, -1);
|
||||
},
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "cursor",
|
||||
readOnly: true
|
||||
}]);
|
||||
|
||||
|
||||
[{
|
||||
bindKey: { mac: "cmd-k cmd-backspace|cmd-backspace", win: "ctrl-shift-backspace|ctrl-k ctrl-backspace" },
|
||||
name: "removetolinestarthard"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-k cmd-k|cmd-delete|ctrl-k", win: "ctrl-shift-delete|ctrl-k ctrl-k" },
|
||||
name: "removetolineendhard"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-shift-d", win: "ctrl-shift-d" },
|
||||
name: "duplicateSelection"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-l", win: "ctrl-l" },
|
||||
name: "expandtoline"
|
||||
},
|
||||
{
|
||||
bindKey: {mac: "cmd-shift-a", win: "ctrl-shift-a"},
|
||||
name: "expandSelection",
|
||||
args: {to: "tag"}
|
||||
}, {
|
||||
bindKey: {mac: "cmd-shift-j", win: "ctrl-shift-j"},
|
||||
name: "expandSelection",
|
||||
args: {to: "indentation"}
|
||||
}, {
|
||||
bindKey: {mac: "ctrl-shift-m", win: "ctrl-shift-m"},
|
||||
name: "expandSelection",
|
||||
args: {to: "brackets"}
|
||||
}, {
|
||||
bindKey: {mac: "cmd-shift-space", win: "ctrl-shift-space"},
|
||||
name: "expandSelection",
|
||||
args: {to: "scope"}
|
||||
},
|
||||
{
|
||||
bindKey: { mac: "ctrl-cmd-g", win: "alt-f3" },
|
||||
name: "find_all_under"
|
||||
}, {
|
||||
bindKey: { mac: "alt-cmd-g", win: "ctrl-f3" },
|
||||
name: "find_under"
|
||||
}, {
|
||||
bindKey: { mac: "shift-alt-cmd-g", win: "ctrl-shift-f3" },
|
||||
name: "find_under_prev"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-g", win: "f3" },
|
||||
name: "findnext"
|
||||
}, {
|
||||
bindKey: { mac: "shift-cmd-g", win: "shift-f3" },
|
||||
name: "findprevious"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-d", win: "ctrl-d" },
|
||||
name: "find_under_expand"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-k cmd-d", win: "ctrl-k ctrl-d" },
|
||||
name: "find_under_expand_skip"
|
||||
},
|
||||
{
|
||||
bindKey: { mac: "cmd-alt-[", win: "ctrl-shift-[" },
|
||||
name: "toggleFoldWidget"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-alt-]", win: "ctrl-shift-]" },
|
||||
name: "unfold"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-k cmd-0|cmd-k cmd-j", win: "ctrl-k ctrl-0|ctrl-k ctrl-j" },
|
||||
name: "unfoldall"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-k cmd-1", win: "ctrl-k ctrl-1" },
|
||||
name: "foldOther",
|
||||
args: { level: 1 }
|
||||
},
|
||||
{
|
||||
bindKey: { win: "ctrl-left", mac: "alt-left" },
|
||||
name: "moveToWordStartLeft"
|
||||
}, {
|
||||
bindKey: { win: "ctrl-right", mac: "alt-right" },
|
||||
name: "moveToWordEndRight"
|
||||
}, {
|
||||
bindKey: { win: "ctrl-shift-left", mac: "alt-shift-left" },
|
||||
name: "selectToWordStartLeft"
|
||||
}, {
|
||||
bindKey: { win: "ctrl-shift-right", mac: "alt-shift-right" },
|
||||
name: "selectToWordEndRight"
|
||||
},
|
||||
{
|
||||
bindKey: {mac: "ctrl-alt-shift-right|ctrl-shift-right", win: "alt-shift-right"},
|
||||
name: "selectSubWordRight"
|
||||
}, {
|
||||
bindKey: {mac: "ctrl-alt-shift-left|ctrl-shift-left", win: "alt-shift-left"},
|
||||
name: "selectSubWordLeft"
|
||||
}, {
|
||||
bindKey: {mac: "ctrl-alt-right|ctrl-right", win: "alt-right"},
|
||||
name: "moveSubWordRight"
|
||||
}, {
|
||||
bindKey: {mac: "ctrl-alt-left|ctrl-left", win: "alt-left"},
|
||||
name: "moveSubWordLeft"
|
||||
},
|
||||
{
|
||||
bindKey: { mac: "ctrl-m", win: "ctrl-m" },
|
||||
name: "jumptomatching",
|
||||
args: { to: "brackets" }
|
||||
},
|
||||
{
|
||||
bindKey: { mac: "ctrl-f6", win: "ctrl-f6" },
|
||||
name: "goToNextError"
|
||||
}, {
|
||||
bindKey: { mac: "ctrl-shift-f6", win: "ctrl-shift-f6" },
|
||||
name: "goToPreviousError"
|
||||
},
|
||||
|
||||
{
|
||||
bindKey: { mac: "ctrl-o" },
|
||||
name: "splitline"
|
||||
},
|
||||
{
|
||||
bindKey: {mac: "ctrl-shift-w", win: "alt-shift-w"},
|
||||
name: "surrowndWithTag"
|
||||
},{
|
||||
bindKey: {mac: "cmd-alt-.", win: "alt-."},
|
||||
name: "close_tag"
|
||||
},
|
||||
{
|
||||
bindKey: { mac: "cmd-j", win: "ctrl-j" },
|
||||
name: "joinlines"
|
||||
},
|
||||
|
||||
{
|
||||
bindKey: {mac: "ctrl--", win: "alt--"},
|
||||
name: "jumpBack"
|
||||
}, {
|
||||
bindKey: {mac: "ctrl-shift--", win: "alt-shift--"},
|
||||
name: "jumpForward"
|
||||
},
|
||||
|
||||
{
|
||||
bindKey: { mac: "cmd-k cmd-l", win: "ctrl-k ctrl-l" },
|
||||
name: "tolowercase"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-k cmd-u", win: "ctrl-k ctrl-u" },
|
||||
name: "touppercase"
|
||||
},
|
||||
|
||||
{
|
||||
bindKey: {mac: "cmd-shift-v", win: "ctrl-shift-v"},
|
||||
name: "paste_and_indent"
|
||||
}, {
|
||||
bindKey: {mac: "cmd-k cmd-v|cmd-alt-v", win: "ctrl-k ctrl-v"},
|
||||
name: "paste_from_history"
|
||||
},
|
||||
|
||||
{
|
||||
bindKey: { mac: "cmd-shift-enter", win: "ctrl-shift-enter" },
|
||||
name: "addLineBefore"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-enter", win: "ctrl-enter" },
|
||||
name: "addLineAfter"
|
||||
}, {
|
||||
bindKey: { mac: "ctrl-shift-k", win: "ctrl-shift-k" },
|
||||
name: "removeline"
|
||||
}, {
|
||||
bindKey: { mac: "ctrl-alt-up", win: "ctrl-up" },
|
||||
name: "scrollup"
|
||||
}, {
|
||||
bindKey: { mac: "ctrl-alt-down", win: "ctrl-down" },
|
||||
name: "scrolldown"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-a", win: "ctrl-a" },
|
||||
name: "selectall"
|
||||
}, {
|
||||
bindKey: { linux: "alt-shift-down", mac: "ctrl-shift-down", win: "ctrl-alt-down" },
|
||||
name: "addCursorBelow"
|
||||
}, {
|
||||
bindKey: { linux: "alt-shift-up", mac: "ctrl-shift-up", win: "ctrl-alt-up" },
|
||||
name: "addCursorAbove"
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
bindKey: { mac: "cmd-k cmd-c|ctrl-l", win: "ctrl-k ctrl-c" },
|
||||
name: "centerselection"
|
||||
},
|
||||
|
||||
{
|
||||
bindKey: { mac: "f5", win: "f9" },
|
||||
name: "sortlines"
|
||||
},
|
||||
{
|
||||
bindKey: {mac: "ctrl-f5", win: "ctrl-f9"},
|
||||
name: "sortlines",
|
||||
args: {caseSensitive: true}
|
||||
},
|
||||
{
|
||||
bindKey: { mac: "cmd-shift-l", win: "ctrl-shift-l" },
|
||||
name: "splitSelectionIntoLines"
|
||||
}, {
|
||||
bindKey: { mac: "ctrl-cmd-down", win: "ctrl-shift-down" },
|
||||
name: "movelinesdown"
|
||||
}, {
|
||||
bindKey: { mac: "ctrl-cmd-up", win: "ctrl-shift-up" },
|
||||
name: "movelinesup"
|
||||
}, {
|
||||
bindKey: { mac: "alt-down", win: "alt-down" },
|
||||
name: "modifyNumberDown"
|
||||
}, {
|
||||
bindKey: { mac: "alt-up", win: "alt-up" },
|
||||
name: "modifyNumberUp"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-/", win: "ctrl-/" },
|
||||
name: "togglecomment"
|
||||
}, {
|
||||
bindKey: { mac: "cmd-alt-/", win: "ctrl-shift-/" },
|
||||
name: "toggleBlockComment"
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
bindKey: { linux: "ctrl-alt-q", mac: "ctrl-q", win: "ctrl-q" },
|
||||
name: "togglerecording"
|
||||
}, {
|
||||
bindKey: { linux: "ctrl-alt-shift-q", mac: "ctrl-shift-q", win: "ctrl-shift-q" },
|
||||
name: "replaymacro"
|
||||
},
|
||||
|
||||
{
|
||||
bindKey: { mac: "ctrl-t", win: "ctrl-t" },
|
||||
name: "transpose"
|
||||
}
|
||||
|
||||
].forEach(function(binding) {
|
||||
var command = exports.handler.commands[binding.name];
|
||||
if (command)
|
||||
command.bindKey = binding.bindKey;
|
||||
exports.handler.bindKey(binding.bindKey, command || binding.name);
|
||||
});
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/keyboard/sublime"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,262 @@
|
||||
ace.define("ace/keyboard/vscode",["require","exports","module","ace/keyboard/hash_handler","ace/config"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
||||
var config = require("../config");
|
||||
|
||||
exports.handler = new HashHandler();
|
||||
exports.handler.$id = "ace/keyboard/vscode";
|
||||
|
||||
exports.handler.addCommands([{
|
||||
name: "toggleWordWrap",
|
||||
exec: function(editor) {
|
||||
var wrapUsed = editor.session.getUseWrapMode();
|
||||
editor.session.setUseWrapMode(!wrapUsed);
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "navigateToLastEditLocation",
|
||||
exec: function(editor) {
|
||||
var lastDelta = editor.session.getUndoManager().$lastDelta;
|
||||
var range = (lastDelta.action == "remove")? lastDelta.start: lastDelta.end;
|
||||
editor.moveCursorTo(range.row, range.column);
|
||||
editor.clearSelection();
|
||||
}
|
||||
}, {
|
||||
name: "replaceAll",
|
||||
exec: function (editor) {
|
||||
if (!editor.searchBox) {
|
||||
config.loadModule("ace/ext/searchbox", function(e) {
|
||||
e.Search(editor, true);
|
||||
});
|
||||
} else {
|
||||
if (editor.searchBox.active === true && editor.searchBox.replaceOption.checked === true) {
|
||||
editor.searchBox.replaceAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: "replaceOne",
|
||||
exec: function (editor) {
|
||||
if (!editor.searchBox) {
|
||||
config.loadModule("ace/ext/searchbox", function(e) {
|
||||
e.Search(editor, true);
|
||||
});
|
||||
} else {
|
||||
if (editor.searchBox.active === true && editor.searchBox.replaceOption.checked === true) {
|
||||
editor.searchBox.replace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: "selectAllMatches",
|
||||
exec: function (editor) {
|
||||
if (!editor.searchBox) {
|
||||
config.loadModule("ace/ext/searchbox", function(e) {
|
||||
e.Search(editor, false);
|
||||
});
|
||||
} else {
|
||||
if (editor.searchBox.active === true) {
|
||||
editor.searchBox.findAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: "toggleFindCaseSensitive",
|
||||
exec: function (editor) {
|
||||
config.loadModule("ace/ext/searchbox", function(e) {
|
||||
e.Search(editor, false);
|
||||
var sb = editor.searchBox;
|
||||
sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked;
|
||||
sb.$syncOptions();
|
||||
});
|
||||
|
||||
}
|
||||
}, {
|
||||
name: "toggleFindInSelection",
|
||||
exec: function (editor) {
|
||||
config.loadModule("ace/ext/searchbox", function(e) {
|
||||
e.Search(editor, false);
|
||||
var sb = editor.searchBox;
|
||||
sb.searchOption.checked = !sb.searchRange;
|
||||
sb.setSearchRange(sb.searchOption.checked && sb.editor.getSelectionRange());
|
||||
sb.$syncOptions();
|
||||
});
|
||||
}
|
||||
}, {
|
||||
name: "toggleFindRegex",
|
||||
exec: function (editor) {
|
||||
config.loadModule("ace/ext/searchbox", function(e) {
|
||||
e.Search(editor, false);
|
||||
var sb = editor.searchBox;
|
||||
sb.regExpOption.checked = !sb.regExpOption.checked;
|
||||
sb.$syncOptions();
|
||||
});
|
||||
}
|
||||
}, {
|
||||
name: "toggleFindWholeWord",
|
||||
exec: function (editor) {
|
||||
config.loadModule("ace/ext/searchbox", function(e) {
|
||||
e.Search(editor, false);
|
||||
var sb = editor.searchBox;
|
||||
sb.wholeWordOption.checked = !sb.wholeWordOption.checked;
|
||||
sb.$syncOptions();
|
||||
});
|
||||
}
|
||||
}, {
|
||||
name: "removeSecondaryCursors",
|
||||
exec: function (editor) {
|
||||
var ranges = editor.selection.ranges;
|
||||
if (ranges && ranges.length > 1)
|
||||
editor.selection.toSingleRange(ranges[ranges.length - 1]);
|
||||
else
|
||||
editor.selection.clearSelection();
|
||||
}
|
||||
}]);
|
||||
|
||||
|
||||
[{
|
||||
bindKey: {mac: "Ctrl-G", win: "Ctrl-G"},
|
||||
name: "gotoline"
|
||||
}, {
|
||||
bindKey: {mac: "Command-Shift-L|Command-F2", win: "Ctrl-Shift-L|Ctrl-F2"},
|
||||
name: "findAll"
|
||||
}, {
|
||||
bindKey: {mac: "Shift-F8|Shift-Option-F8", win: "Shift-F8|Shift-Alt-F8"},
|
||||
name: "goToPreviousError"
|
||||
}, {
|
||||
bindKey: {mac: "F8|Option-F8", win: "F8|Alt-F8"},
|
||||
name: "goToNextError"
|
||||
}, {
|
||||
bindKey: {mac: "Command-Shift-P|F1", win: "Ctrl-Shift-P|F1"},
|
||||
name: "openCommandPallete"
|
||||
}, {
|
||||
bindKey: {mac: "Command-K|Command-S", win: "Ctrl-K|Ctrl-S"},
|
||||
name: "showKeyboardShortcuts"
|
||||
}, {
|
||||
bindKey: {mac: "Shift-Option-Up", win: "Alt-Shift-Up"},
|
||||
name: "copylinesup"
|
||||
}, {
|
||||
bindKey: {mac: "Shift-Option-Down", win: "Alt-Shift-Down"},
|
||||
name: "copylinesdown"
|
||||
}, {
|
||||
bindKey: {mac: "Command-Shift-K", win: "Ctrl-Shift-K"},
|
||||
name: "removeline"
|
||||
}, {
|
||||
bindKey: {mac: "Command-Enter", win: "Ctrl-Enter"},
|
||||
name: "addLineAfter"
|
||||
}, {
|
||||
bindKey: {mac: "Command-Shift-Enter", win: "Ctrl-Shift-Enter"},
|
||||
name: "addLineBefore"
|
||||
}, {
|
||||
bindKey: {mac: "Command-Shift-\\", win: "Ctrl-Shift-\\"},
|
||||
name: "jumptomatching"
|
||||
}, {
|
||||
bindKey: {mac: "Command-]", win: "Ctrl-]"},
|
||||
name: "blockindent"
|
||||
}, {
|
||||
bindKey: {mac: "Command-[", win: "Ctrl-["},
|
||||
name: "blockoutdent"
|
||||
}, {
|
||||
bindKey: {mac: "Ctrl-PageDown", win: "Alt-PageDown"},
|
||||
name: "pagedown"
|
||||
}, {
|
||||
bindKey: {mac: "Ctrl-PageUp", win: "Alt-PageUp"},
|
||||
name: "pageup"
|
||||
}, {
|
||||
bindKey: {mac: "Shift-Option-A", win: "Shift-Alt-A"},
|
||||
name: "toggleBlockComment"
|
||||
}, {
|
||||
bindKey: {mac: "Option-Z", win: "Alt-Z"},
|
||||
name: "toggleWordWrap"
|
||||
}, {
|
||||
bindKey: {mac: "Command-G", win: "F3|Ctrl-K Ctrl-D"},
|
||||
name: "findnext"
|
||||
}, {
|
||||
bindKey: {mac: "Command-Shift-G", win: "Shift-F3"},
|
||||
name: "findprevious"
|
||||
}, {
|
||||
bindKey: {mac: "Option-Enter", win: "Alt-Enter"},
|
||||
name: "selectAllMatches"
|
||||
}, {
|
||||
bindKey: {mac: "Command-D", win: "Ctrl-D"},
|
||||
name: "selectMoreAfter"
|
||||
}, {
|
||||
bindKey: {mac: "Command-K Command-D", win: "Ctrl-K Ctrl-D"},
|
||||
name: "selectOrFindNext"
|
||||
}, {
|
||||
bindKey: {mac: "Shift-Option-I", win: "Shift-Alt-I"},
|
||||
name: "splitSelectionIntoLines"
|
||||
}, {
|
||||
bindKey: {mac: "Command-K M", win: "Ctrl-K M"},
|
||||
name: "modeSelect"
|
||||
}, {
|
||||
bindKey: {mac: "Command-Option-[", win: "Ctrl-Shift-["},
|
||||
name: "toggleFoldWidget"
|
||||
}, {
|
||||
bindKey: {mac: "Command-Option-]", win: "Ctrl-Shift-]"},
|
||||
name: "toggleFoldWidget"
|
||||
}, {
|
||||
bindKey: {mac: "Command-K Command-0", win: "Ctrl-K Ctrl-0"},
|
||||
name: "foldall"
|
||||
}, {
|
||||
bindKey: {mac: "Command-K Command-J", win: "Ctrl-K Ctrl-J"},
|
||||
name: "unfoldall"
|
||||
}, {
|
||||
bindKey: { mac: "Command-K Command-1", win: "Ctrl-K Ctrl-1" },
|
||||
name: "foldOther"
|
||||
}, {
|
||||
bindKey: { mac: "Command-K Command-Q", win: "Ctrl-K Ctrl-Q" },
|
||||
name: "navigateToLastEditLocation"
|
||||
}, {
|
||||
bindKey: { mac: "Command-K Command-R|Command-K Command-S", win: "Ctrl-K Ctrl-R|Ctrl-K Ctrl-S" },
|
||||
name: "showKeyboardShortcuts"
|
||||
}, {
|
||||
bindKey: { mac: "Command-K Command-X", win: "Ctrl-K Ctrl-X" },
|
||||
name: "trimTrailingSpace"
|
||||
}, {
|
||||
bindKey: {mac: "Shift-Down|Command-Shift-Down", win: "Shift-Down|Ctrl-Shift-Down"},
|
||||
name: "selectdown"
|
||||
}, {
|
||||
bindKey: {mac: "Shift-Up|Command-Shift-Up", win: "Shift-Up|Ctrl-Shift-Up"},
|
||||
name: "selectup"
|
||||
}, {
|
||||
bindKey: {mac: "Command-Alt-Enter", win: "Ctrl-Alt-Enter"},
|
||||
name: "replaceAll"
|
||||
}, {
|
||||
bindKey: {mac: "Command-Shift-1", win: "Ctrl-Shift-1"},
|
||||
name: "replaceOne"
|
||||
}, {
|
||||
bindKey: {mac: "Option-C", win: "Alt-C"},
|
||||
name: "toggleFindCaseSensitive"
|
||||
}, {
|
||||
bindKey: {mac: "Option-L", win: "Alt-L"},
|
||||
name: "toggleFindInSelection"
|
||||
}, {
|
||||
bindKey: {mac: "Option-R", win: "Alt-R"},
|
||||
name: "toggleFindRegex"
|
||||
}, {
|
||||
bindKey: {mac: "Option-W", win: "Alt-W"},
|
||||
name: "toggleFindWholeWord"
|
||||
}, {
|
||||
bindKey: {mac: "Command-L", win: "Ctrl-L"},
|
||||
name: "expandtoline"
|
||||
}, {
|
||||
bindKey: {mac: "Shift-Esc", win: "Shift-Esc"},
|
||||
name: "removeSecondaryCursors"
|
||||
}
|
||||
].forEach(function(binding) {
|
||||
var command = exports.handler.commands[binding.name];
|
||||
if (command)
|
||||
command.bindKey = binding.bindKey;
|
||||
exports.handler.bindKey(binding.bindKey, command || binding.name);
|
||||
});
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/keyboard/vscode"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
ace.define("ace/mode/abap_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var AbapHighlightRules = function() {
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"variable.language": "this",
|
||||
"keyword":
|
||||
"ADD ALIAS ALIASES ASCENDING ASSERT ASSIGN ASSIGNING AT BACK" +
|
||||
" CALL CASE CATCH CHECK CLASS CLEAR CLOSE CNT COLLECT COMMIT COMMUNICATION COMPUTE CONCATENATE CONDENSE CONSTANTS CONTINUE CONTROLS CONVERT CREATE CURRENCY" +
|
||||
" DATA DEFINE DEFINITION DEFERRED DELETE DESCENDING DESCRIBE DETAIL DIVIDE DO" +
|
||||
" ELSE ELSEIF ENDAT ENDCASE ENDCLASS ENDDO ENDEXEC ENDFORM ENDFUNCTION ENDIF ENDIFEND ENDINTERFACE ENDLOOP ENDMETHOD ENDMODULE ENDON ENDPROVIDE ENDSELECT ENDTRY ENDWHILE EVENT EVENTS EXEC EXIT EXPORT EXPORTING EXTRACT" +
|
||||
" FETCH FIELDS FORM FORMAT FREE FROM FUNCTION" +
|
||||
" GENERATE GET" +
|
||||
" HIDE" +
|
||||
" IF IMPORT IMPORTING INDEX INFOTYPES INITIALIZATION INTERFACE INTERFACES INPUT INSERT IMPLEMENTATION" +
|
||||
" LEAVE LIKE LINE LOAD LOCAL LOOP" +
|
||||
" MESSAGE METHOD METHODS MODIFY MODULE MOVE MULTIPLY" +
|
||||
" ON OVERLAY OPTIONAL OTHERS" +
|
||||
" PACK PARAMETERS PERFORM POSITION PROGRAM PROVIDE PUT" +
|
||||
" RAISE RANGES READ RECEIVE RECEIVING REDEFINITION REFERENCE REFRESH REJECT REPLACE REPORT RESERVE RESTORE RETURN RETURNING ROLLBACK" +
|
||||
" SCAN SCROLL SEARCH SELECT SET SHIFT SKIP SORT SORTED SPLIT STANDARD STATICS STEP STOP SUBMIT SUBTRACT SUM SUMMARY SUPPRESS" +
|
||||
" TABLES TIMES TRANSFER TRANSLATE TRY TYPE TYPES" +
|
||||
" UNASSIGN ULINE UNPACK UPDATE" +
|
||||
" WHEN WHILE WINDOW WRITE" +
|
||||
" OCCURS STRUCTURE OBJECT PROPERTY" +
|
||||
" CASTING APPEND RAISING VALUE COLOR" +
|
||||
" CHANGING EXCEPTION EXCEPTIONS DEFAULT CHECKBOX COMMENT" +
|
||||
" ID NUMBER FOR TITLE OUTPUT" +
|
||||
" WITH EXIT USING" +
|
||||
" INTO WHERE GROUP BY HAVING ORDER BY SINGLE" +
|
||||
" APPENDING CORRESPONDING FIELDS OF TABLE" +
|
||||
" LEFT RIGHT OUTER INNER JOIN AS CLIENT SPECIFIED BYPASSING BUFFER UP TO ROWS CONNECTING" +
|
||||
" EQ NE LT LE GT GE NOT AND OR XOR IN LIKE BETWEEN",
|
||||
"constant.language":
|
||||
"TRUE FALSE NULL SPACE",
|
||||
"support.type":
|
||||
"c n i p f d t x string xstring decfloat16 decfloat34",
|
||||
"keyword.operator":
|
||||
"abs sign ceil floor trunc frac acos asin atan cos sin tan" +
|
||||
" abapOperator cosh sinh tanh exp log log10 sqrt" +
|
||||
" strlen xstrlen charlen numofchar dbmaxlen lines"
|
||||
}, "text", true, " ");
|
||||
|
||||
var compoundKeywords = "WITH\\W+(?:HEADER\\W+LINE|FRAME|KEY)|NO\\W+STANDARD\\W+PAGE\\W+HEADING|"+
|
||||
"EXIT\\W+FROM\\W+STEP\\W+LOOP|BEGIN\\W+OF\\W+(?:BLOCK|LINE)|BEGIN\\W+OF|"+
|
||||
"END\\W+OF\\W+(?:BLOCK|LINE)|END\\W+OF|NO\\W+INTERVALS|"+
|
||||
"RESPECTING\\W+BLANKS|SEPARATED\\W+BY|USING\\W+(?:EDIT\\W+MASK)|"+
|
||||
"WHERE\\W+(?:LINE)|RADIOBUTTON\\W+GROUP|REF\\W+TO|"+
|
||||
"(?:PUBLIC|PRIVATE|PROTECTED)(?:\\W+SECTION)?|DELETING\\W+(?:TRAILING|LEADING)"+
|
||||
"(?:ALL\\W+OCCURRENCES)|(?:FIRST|LAST)\\W+OCCURRENCE|INHERITING\\W+FROM|"+
|
||||
"LINE-COUNT|ADD-CORRESPONDING|AUTHORITY-CHECK|BREAK-POINT|CLASS-DATA|CLASS-METHODS|"+
|
||||
"CLASS-METHOD|DIVIDE-CORRESPONDING|EDITOR-CALL|END-OF-DEFINITION|END-OF-PAGE|END-OF-SELECTION|"+
|
||||
"FIELD-GROUPS|FIELD-SYMBOLS|FUNCTION-POOL|MOVE-CORRESPONDING|MULTIPLY-CORRESPONDING|NEW-LINE|"+
|
||||
"NEW-PAGE|NEW-SECTION|PRINT-CONTROL|RP-PROVIDE-FROM-LAST|SELECT-OPTIONS|SELECTION-SCREEN|"+
|
||||
"START-OF-SELECTION|SUBTRACT-CORRESPONDING|SYNTAX-CHECK|SYNTAX-TRACE|TOP-OF-PAGE|TYPE-POOL|"+
|
||||
"TYPE-POOLS|LINE-SIZE|LINE-COUNT|MESSAGE-ID|DISPLAY-MODE|READ(?:-ONLY)?|"+
|
||||
"IS\\W+(?:NOT\\W+)?(?:ASSIGNED|BOUND|INITIAL|SUPPLIED)";
|
||||
|
||||
this.$rules = {
|
||||
"start" : [
|
||||
{token : "string", regex : "`", next : "string"},
|
||||
{token : "string", regex : "'", next : "qstring"},
|
||||
{token : "doc.comment", regex : /^\*.+/},
|
||||
{token : "comment", regex : /".+$/},
|
||||
{token : "invalid", regex: "\\.{2,}"},
|
||||
{token : "keyword.operator", regex: /\W[\-+%=<>*]\W|\*\*|[~:,\.&$]|->*?|=>/},
|
||||
{token : "paren.lparen", regex : "[\\[({]"},
|
||||
{token : "paren.rparen", regex : "[\\])}]"},
|
||||
{token : "constant.numeric", regex: "[+-]?\\d+\\b"},
|
||||
{token : "variable.parameter", regex : /sy|pa?\d\d\d\d\|t\d\d\d\.|innnn/},
|
||||
{token : "keyword", regex : compoundKeywords},
|
||||
{token : "variable.parameter", regex : /\w+-\w[\-\w]*/},
|
||||
{token : keywordMapper, regex : "\\b\\w+\\b"},
|
||||
{caseInsensitive: true}
|
||||
],
|
||||
"qstring" : [
|
||||
{token : "constant.language.escape", regex : "''"},
|
||||
{token : "string", regex : "'", next : "start"},
|
||||
{defaultToken : "string"}
|
||||
],
|
||||
"string" : [
|
||||
{token : "constant.language.escape", regex : "``"},
|
||||
{token : "string", regex : "`", next : "start"},
|
||||
{defaultToken : "string"}
|
||||
]
|
||||
};
|
||||
};
|
||||
oop.inherits(AbapHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.AbapHighlightRules = AbapHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
var Range = require("../../range").Range;
|
||||
|
||||
var FoldMode = exports.FoldMode = function() {};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||
var range = this.indentationBlock(session, row);
|
||||
if (range)
|
||||
return range;
|
||||
|
||||
var re = /\S/;
|
||||
var line = session.getLine(row);
|
||||
var startLevel = line.search(re);
|
||||
if (startLevel == -1 || line[startLevel] != "#")
|
||||
return;
|
||||
|
||||
var startColumn = line.length;
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
var endRow = row;
|
||||
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var level = line.search(re);
|
||||
|
||||
if (level == -1)
|
||||
continue;
|
||||
|
||||
if (line[level] != "#")
|
||||
break;
|
||||
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
if (endRow > startRow) {
|
||||
var endColumn = session.getLine(endRow).length;
|
||||
return new Range(startRow, startColumn, endRow, endColumn);
|
||||
}
|
||||
};
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
var next = session.getLine(row + 1);
|
||||
var prev = session.getLine(row - 1);
|
||||
var prevIndent = prev.search(/\S/);
|
||||
var nextIndent = next.search(/\S/);
|
||||
|
||||
if (indent == -1) {
|
||||
session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
|
||||
return "";
|
||||
}
|
||||
if (prevIndent == -1) {
|
||||
if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
|
||||
session.foldWidgets[row - 1] = "";
|
||||
session.foldWidgets[row + 1] = "";
|
||||
return "start";
|
||||
}
|
||||
} else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
|
||||
if (session.getLine(row - 2).search(/\S/) == -1) {
|
||||
session.foldWidgets[row - 1] = "start";
|
||||
session.foldWidgets[row + 1] = "";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
if (prevIndent!= -1 && prevIndent < indent)
|
||||
session.foldWidgets[row - 1] = "start";
|
||||
else
|
||||
session.foldWidgets[row - 1] = "";
|
||||
|
||||
if (indent < nextIndent)
|
||||
return "start";
|
||||
else
|
||||
return "";
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/abap",["require","exports","module","ace/mode/abap_highlight_rules","ace/mode/folding/coffee","ace/range","ace/mode/text","ace/lib/oop"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var Rules = require("./abap_highlight_rules").AbapHighlightRules;
|
||||
var FoldMode = require("./folding/coffee").FoldMode;
|
||||
var Range = require("../range").Range;
|
||||
var TextMode = require("./text").Mode;
|
||||
var oop = require("../lib/oop");
|
||||
|
||||
function Mode() {
|
||||
this.HighlightRules = Rules;
|
||||
this.foldingRules = new FoldMode();
|
||||
}
|
||||
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.lineCommentStart = '"';
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/abap";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/abap"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,269 @@
|
||||
ace.define("ace/mode/abc_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function (require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var ABCHighlightRules = function () {
|
||||
|
||||
this.$rules = {
|
||||
start: [
|
||||
{
|
||||
token: ['zupfnoter.information.comment.line.percentage', 'information.keyword', 'in formation.keyword.embedded'],
|
||||
regex: '(%%%%)(hn\\.[a-z]*)(.*)',
|
||||
comment: 'Instruction Comment'
|
||||
},
|
||||
{
|
||||
token: ['information.comment.line.percentage', 'information.keyword.embedded'],
|
||||
regex: '(%%)(.*)',
|
||||
comment: 'Instruction Comment'
|
||||
},
|
||||
|
||||
{
|
||||
token: 'comment.line.percentage',
|
||||
regex: '%.*',
|
||||
comment: 'Comments'
|
||||
},
|
||||
|
||||
{
|
||||
token: 'barline.keyword.operator',
|
||||
regex: '[\\[:]*[|:][|\\]:]*(?:\\[?[0-9]+)?|\\[[0-9]+',
|
||||
comment: 'Bar lines'
|
||||
},
|
||||
{
|
||||
token: ['information.keyword.embedded', 'information.argument.string.unquoted'],
|
||||
regex: '(\\[[A-Za-z]:)([^\\]]*\\])',
|
||||
comment: 'embedded Header lines'
|
||||
},
|
||||
{
|
||||
token: ['information.keyword', 'information.argument.string.unquoted'],
|
||||
regex: '^([A-Za-z]:)([^%\\\\]*)',
|
||||
comment: 'Header lines'
|
||||
},
|
||||
{
|
||||
token: ['text', 'entity.name.function', 'string.unquoted', 'text'],
|
||||
regex: '(\\[)([A-Z]:)(.*?)(\\])',
|
||||
comment: 'Inline fields'
|
||||
},
|
||||
{
|
||||
token: ['accent.constant.language', 'pitch.constant.numeric', 'duration.constant.numeric'],
|
||||
regex: '([\\^=_]*)([A-Ga-gz][,\']*)([0-9]*/*[><0-9]*)',
|
||||
comment: 'Notes'
|
||||
},
|
||||
{
|
||||
token: 'zupfnoter.jumptarget.string.quoted',
|
||||
regex: '[\\"!]\\^\\:.*?[\\"!]',
|
||||
comment: 'Zupfnoter jumptarget'
|
||||
}, {
|
||||
token: 'zupfnoter.goto.string.quoted',
|
||||
regex: '[\\"!]\\^\\@.*?[\\"!]',
|
||||
comment: 'Zupfnoter goto'
|
||||
},
|
||||
{
|
||||
token: 'zupfnoter.annotation.string.quoted',
|
||||
regex: '[\\"!]\\^\\!.*?[\\"!]',
|
||||
comment: 'Zupfnoter annoation'
|
||||
},
|
||||
{
|
||||
token: 'zupfnoter.annotationref.string.quoted',
|
||||
regex: '[\\"!]\\^\\#.*?[\\"!]',
|
||||
comment: 'Zupfnoter annotation reference'
|
||||
},
|
||||
{
|
||||
token: 'chordname.string.quoted',
|
||||
regex: '[\\"!]\\^.*?[\\"!]',
|
||||
comment: 'abc chord'
|
||||
},
|
||||
{
|
||||
token: 'string.quoted',
|
||||
regex: '[\\"!].*?[\\"!]',
|
||||
comment: 'abc annotation'
|
||||
}
|
||||
|
||||
]
|
||||
};
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
ABCHighlightRules.metaData = {
|
||||
fileTypes: ['abc'],
|
||||
name: 'ABC',
|
||||
scopeName: 'text.abcnotation'
|
||||
};
|
||||
|
||||
|
||||
oop.inherits(ABCHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.ABCHighlightRules = ABCHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
||||
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||
this._getFoldWidgetBase = this.getFoldWidget;
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) {
|
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||
return "";
|
||||
}
|
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||
|
||||
if (!fw && this.startRegionRe.test(line))
|
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.startRegionRe.test(line))
|
||||
return this.getCommentRegionBlock(session, line, row);
|
||||
|
||||
var match = line.match(this.foldingStartMarker);
|
||||
if (match) {
|
||||
var i = match.index;
|
||||
|
||||
if (match[1])
|
||||
return this.openingBracketBlock(session, match[1], row, i);
|
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||
|
||||
if (range && !range.isMultiLine()) {
|
||||
if (forceMultiline) {
|
||||
range = this.getSectionRange(session, row);
|
||||
} else if (foldStyle != "all")
|
||||
range = null;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
if (foldStyle === "markbegin")
|
||||
return;
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match) {
|
||||
var i = match.index + match[0].length;
|
||||
|
||||
if (match[1])
|
||||
return this.closingBracketBlock(session, match[1], row, i);
|
||||
|
||||
return session.getCommentFoldRange(row, i, -1);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSectionRange = function(session, row) {
|
||||
var line = session.getLine(row);
|
||||
var startIndent = line.search(/\S/);
|
||||
var startRow = row;
|
||||
var startColumn = line.length;
|
||||
row = row + 1;
|
||||
var endRow = row;
|
||||
var maxRow = session.getLength();
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
if (indent === -1)
|
||||
continue;
|
||||
if (startIndent > indent)
|
||||
break;
|
||||
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||
|
||||
if (subRange) {
|
||||
if (subRange.start.row <= startRow) {
|
||||
break;
|
||||
} else if (subRange.isMultiLine()) {
|
||||
row = subRange.end.row;
|
||||
} else if (startIndent == indent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||
};
|
||||
this.getCommentRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m) continue;
|
||||
if (m[1]) depth--;
|
||||
else depth++;
|
||||
|
||||
if (!depth) break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/abc",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/abc_highlight_rules","ace/mode/folding/cstyle"], function (require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var ABCHighlightRules = require("./abc_highlight_rules").ABCHighlightRules;
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function () {
|
||||
this.HighlightRules = ABCHighlightRules;
|
||||
this.foldingRules = new FoldMode();
|
||||
this.$behaviour = this.$defaultBehaviour;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function () {
|
||||
this.$id = "ace/mode/abc";
|
||||
this.snippetFileId = "ace/snippets/abc";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/abc"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,137 @@
|
||||
ace.define("ace/mode/ada_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var AdaHighlightRules = function() {
|
||||
var keywords = "abort|else|new|return|abs|elsif|not|reverse|abstract|end|null|accept|entry|select|" +
|
||||
"access|exception|of|separate|aliased|exit|or|some|all|others|subtype|and|for|out|synchronized|" +
|
||||
"array|function|overriding|at|tagged|generic|package|task|begin|goto|pragma|terminate|" +
|
||||
"body|private|then|if|procedure|type|case|in|protected|constant|interface|until|" +
|
||||
"|is|raise|use|declare|range|delay|limited|record|when|delta|loop|rem|while|digits|renames|with|do|mod|requeue|xor";
|
||||
|
||||
var builtinConstants = (
|
||||
"true|false|null"
|
||||
);
|
||||
|
||||
var builtinFunctions = (
|
||||
"count|min|max|avg|sum|rank|now|coalesce|main"
|
||||
);
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"support.function": builtinFunctions,
|
||||
"keyword": keywords,
|
||||
"constant.language": builtinConstants
|
||||
}, "identifier", true);
|
||||
|
||||
this.$rules = {
|
||||
"start" : [ {
|
||||
token : "comment",
|
||||
regex : "--.*$"
|
||||
}, {
|
||||
token : "string", // " string
|
||||
regex : '".*?"'
|
||||
}, {
|
||||
token : "string", // character
|
||||
regex : "'.'"
|
||||
}, {
|
||||
token : "constant.numeric", // float
|
||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : "[\\(]"
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : "[\\)]"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
} ]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(AdaHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.AdaHighlightRules = AdaHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/ada",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/ada_highlight_rules","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var AdaHighlightRules = require("./ada_highlight_rules").AdaHighlightRules;
|
||||
var Range = require("../range").Range;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = AdaHighlightRules;
|
||||
this.$behaviour = this.$defaultBehaviour;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.lineCommentStart = "--";
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
|
||||
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
||||
var tokens = tokenizedLine.tokens;
|
||||
|
||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||
return indent;
|
||||
}
|
||||
if (state == "start") {
|
||||
var match = line.match(/^.*(begin|loop|then|is|do)\s*$/);
|
||||
if (match) {
|
||||
indent += tab;
|
||||
}
|
||||
}
|
||||
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
var complete_line = line + input;
|
||||
if (complete_line.match(/^\s*(begin|end)$/)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, session, row) {
|
||||
|
||||
var line = session.getLine(row);
|
||||
var prevLine = session.getLine(row - 1);
|
||||
var prevIndent = this.$getIndent(prevLine).length;
|
||||
var indent = this.$getIndent(line).length;
|
||||
if (indent <= prevIndent) {
|
||||
return;
|
||||
}
|
||||
|
||||
session.outdentRows(new Range(row, 0, row + 2, 0));
|
||||
};
|
||||
|
||||
|
||||
this.$id = "ace/mode/ada";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/ada"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,311 @@
|
||||
ace.define("ace/mode/alda_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var AldaHighlightRules = function() {
|
||||
|
||||
this.$rules = {
|
||||
pitch: [{
|
||||
token: "variable.parameter.operator.pitch.alda",
|
||||
regex: /(?:[+\-]+|\=)/
|
||||
}, {
|
||||
token: "",
|
||||
regex: "",
|
||||
next: "timing"
|
||||
}],
|
||||
timing: [{
|
||||
token: "string.quoted.operator.timing.alda",
|
||||
regex: /\d+(?:s|ms)?/
|
||||
}, {
|
||||
token: "",
|
||||
regex: "",
|
||||
next: "start"
|
||||
}],
|
||||
start: [{
|
||||
token: [
|
||||
"constant.language.instrument.alda",
|
||||
"constant.language.instrument.alda",
|
||||
"meta.part.call.alda",
|
||||
"storage.type.nickname.alda",
|
||||
"meta.part.call.alda"
|
||||
],
|
||||
regex: /^([a-zA-Z]{2}[\w\-+\'()]*)((?:\s*\/\s*[a-zA-Z]{2}[\w\-+\'()]*)*)(?:(\s*)(\"[a-zA-Z]{2}[\w\-+\'()]*\"))?(\s*:)/
|
||||
}, {
|
||||
token: [
|
||||
"text",
|
||||
"entity.other.inherited-class.voice.alda",
|
||||
"text"
|
||||
],
|
||||
regex: /^(\s*)(V\d+)(:)/
|
||||
}, {
|
||||
token: "comment.line.number-sign.alda",
|
||||
regex: /#.*$/
|
||||
}, {
|
||||
token: "entity.name.function.pipe.measure.alda",
|
||||
regex: /\|/
|
||||
}, {
|
||||
token: "comment.block.inline.alda",
|
||||
regex: /\(comment\b/,
|
||||
push: [{
|
||||
token: "comment.block.inline.alda",
|
||||
regex: /\)/,
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "comment.block.inline.alda"
|
||||
}]
|
||||
}, {
|
||||
token: "entity.name.function.marker.alda",
|
||||
regex: /%[a-zA-Z]{2}[\w\-+\'()]*/
|
||||
}, {
|
||||
token: "entity.name.function.at-marker.alda",
|
||||
regex: /@[a-zA-Z]{2}[\w\-+\'()]*/
|
||||
}, {
|
||||
token: "keyword.operator.octave-change.alda",
|
||||
regex: /\bo\d+\b/
|
||||
}, {
|
||||
token: "keyword.operator.octave-shift.alda",
|
||||
regex: /[><]/
|
||||
}, {
|
||||
token: "keyword.operator.repeat.alda",
|
||||
regex: /\*\s*\d+/
|
||||
}, {
|
||||
token: "string.quoted.operator.timing.alda",
|
||||
regex: /[.]|r\d*(?:s|ms)?/
|
||||
},{
|
||||
token: "text",
|
||||
regex: /([cdefgab])/,
|
||||
next: "pitch"
|
||||
}, {
|
||||
token: "string.quoted.operator.timing.alda",
|
||||
regex: /~/,
|
||||
next: "timing"
|
||||
}, {
|
||||
token: "punctuation.section.embedded.cram.alda",
|
||||
regex: /\}/,
|
||||
next: "timing"
|
||||
}, {
|
||||
token: "constant.numeric.subchord.alda",
|
||||
regex: /\//
|
||||
}, {
|
||||
todo: {
|
||||
token: "punctuation.section.embedded.cram.alda",
|
||||
regex: /\{/,
|
||||
push: [{
|
||||
token: "punctuation.section.embedded.cram.alda",
|
||||
regex: /\}/,
|
||||
next: "pop"
|
||||
}, {
|
||||
include: "$self"
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
todo: {
|
||||
token: "keyword.control.sequence.alda",
|
||||
regex: /\[/,
|
||||
push: [{
|
||||
token: "keyword.control.sequence.alda",
|
||||
regex: /\]/,
|
||||
next: "pop"
|
||||
}, {
|
||||
include: "$self"
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
token: "meta.inline.clojure.alda",
|
||||
regex: /\(/,
|
||||
push: [{
|
||||
token: "meta.inline.clojure.alda",
|
||||
regex: /\)/,
|
||||
next: "pop"
|
||||
}, {
|
||||
include: "source.clojure"
|
||||
}, {
|
||||
defaultToken: "meta.inline.clojure.alda"
|
||||
}]
|
||||
}]
|
||||
};
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
AldaHighlightRules.metaData = {
|
||||
scopeName: "source.alda",
|
||||
fileTypes: ["alda"],
|
||||
name: "Alda"
|
||||
};
|
||||
|
||||
|
||||
oop.inherits(AldaHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.AldaHighlightRules = AldaHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
||||
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||
this._getFoldWidgetBase = this.getFoldWidget;
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) {
|
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||
return "";
|
||||
}
|
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||
|
||||
if (!fw && this.startRegionRe.test(line))
|
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.startRegionRe.test(line))
|
||||
return this.getCommentRegionBlock(session, line, row);
|
||||
|
||||
var match = line.match(this.foldingStartMarker);
|
||||
if (match) {
|
||||
var i = match.index;
|
||||
|
||||
if (match[1])
|
||||
return this.openingBracketBlock(session, match[1], row, i);
|
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||
|
||||
if (range && !range.isMultiLine()) {
|
||||
if (forceMultiline) {
|
||||
range = this.getSectionRange(session, row);
|
||||
} else if (foldStyle != "all")
|
||||
range = null;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
if (foldStyle === "markbegin")
|
||||
return;
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match) {
|
||||
var i = match.index + match[0].length;
|
||||
|
||||
if (match[1])
|
||||
return this.closingBracketBlock(session, match[1], row, i);
|
||||
|
||||
return session.getCommentFoldRange(row, i, -1);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSectionRange = function(session, row) {
|
||||
var line = session.getLine(row);
|
||||
var startIndent = line.search(/\S/);
|
||||
var startRow = row;
|
||||
var startColumn = line.length;
|
||||
row = row + 1;
|
||||
var endRow = row;
|
||||
var maxRow = session.getLength();
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
if (indent === -1)
|
||||
continue;
|
||||
if (startIndent > indent)
|
||||
break;
|
||||
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||
|
||||
if (subRange) {
|
||||
if (subRange.start.row <= startRow) {
|
||||
break;
|
||||
} else if (subRange.isMultiLine()) {
|
||||
row = subRange.end.row;
|
||||
} else if (startIndent == indent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||
};
|
||||
this.getCommentRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m) continue;
|
||||
if (m[1]) depth--;
|
||||
else depth++;
|
||||
|
||||
if (!depth) break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/alda",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/alda_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var AldaHighlightRules = require("./alda_highlight_rules").AldaHighlightRules;
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = AldaHighlightRules;
|
||||
this.foldingRules = new FoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.$id = "ace/mode/alda";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/alda"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,363 @@
|
||||
ace.define("ace/mode/apache_conf_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var ApacheConfHighlightRules = function() {
|
||||
|
||||
this.$rules = { start:
|
||||
[ { token:
|
||||
[ 'punctuation.definition.comment.apacheconf',
|
||||
'comment.line.hash.ini',
|
||||
'comment.line.hash.ini' ],
|
||||
regex: '^((?:\\s)*)(#)(.*$)' },
|
||||
{ token:
|
||||
[ 'punctuation.definition.tag.apacheconf',
|
||||
'entity.tag.apacheconf',
|
||||
'text',
|
||||
'string.value.apacheconf',
|
||||
'punctuation.definition.tag.apacheconf' ],
|
||||
regex: '(<)(Proxy|ProxyMatch|IfVersion|Directory|DirectoryMatch|Files|FilesMatch|IfDefine|IfModule|Limit|LimitExcept|Location|LocationMatch|VirtualHost)(?:(\\s)(.+?))?(>)' },
|
||||
{ token:
|
||||
[ 'punctuation.definition.tag.apacheconf',
|
||||
'entity.tag.apacheconf',
|
||||
'punctuation.definition.tag.apacheconf' ],
|
||||
regex: '(</)(Proxy|ProxyMatch|IfVersion|Directory|DirectoryMatch|Files|FilesMatch|IfDefine|IfModule|Limit|LimitExcept|Location|LocationMatch|VirtualHost)(>)' },
|
||||
{ token:
|
||||
[ 'keyword.alias.apacheconf', 'text',
|
||||
'string.regexp.apacheconf', 'text',
|
||||
'string.replacement.apacheconf', 'text' ],
|
||||
regex: '(Rewrite(?:Rule|Cond))(\\s+)(.+?)(\\s+)(.+?)($|\\s)' },
|
||||
{ token:
|
||||
[ 'keyword.alias.apacheconf', 'text',
|
||||
'entity.status.apacheconf', 'text',
|
||||
'string.regexp.apacheconf', 'text',
|
||||
'string.path.apacheconf', 'text' ],
|
||||
regex: '(RedirectMatch)(?:(\\s+)(\\d\\d\\d|permanent|temp|seeother|gone))?(\\s+)(.+?)(\\s+)(?:(.+?)($|\\s))?' },
|
||||
{ token:
|
||||
[ 'keyword.alias.apacheconf', 'text',
|
||||
'entity.status.apacheconf', 'text',
|
||||
'string.path.apacheconf', 'text',
|
||||
'string.path.apacheconf', 'text' ],
|
||||
regex: '(Redirect)(?:(\\s+)(\\d\\d\\d|permanent|temp|seeother|gone))?(\\s+)(.+?)(\\s+)(?:(.+?)($|\\s))?' },
|
||||
{ token:
|
||||
[ 'keyword.alias.apacheconf', 'text',
|
||||
'string.regexp.apacheconf', 'text',
|
||||
'string.path.apacheconf', 'text' ],
|
||||
regex: '(ScriptAliasMatch|AliasMatch)(\\s+)(.+?)(\\s+)(?:(.+?)(\\s))?' },
|
||||
{ token:
|
||||
[ 'keyword.alias.apacheconf', 'text',
|
||||
'string.path.apacheconf', 'text',
|
||||
'string.path.apacheconf', 'text' ],
|
||||
regex: '(RedirectPermanent|RedirectTemp|ScriptAlias|Alias)(\\s+)(.+?)(\\s+)(?:(.+?)($|\\s))?' },
|
||||
{ token: 'keyword.core.apacheconf',
|
||||
regex: '\\b(?:AcceptPathInfo|AccessFileName|AddDefaultCharset|AddOutputFilterByType|AllowEncodedSlashes|AllowOverride|AuthName|AuthType|CGIMapExtension|ContentDigest|DefaultType|DocumentRoot|EnableMMAP|EnableSendfile|ErrorDocument|ErrorLog|FileETag|ForceType|HostnameLookups|IdentityCheck|Include|KeepAlive|KeepAliveTimeout|LimitInternalRecursion|LimitRequestBody|LimitRequestFields|LimitRequestFieldSize|LimitRequestLine|LimitXMLRequestBody|LogLevel|MaxKeepAliveRequests|NameVirtualHost|Options|Require|RLimitCPU|RLimitMEM|RLimitNPROC|Satisfy|ScriptInterpreterSource|ServerAdmin|ServerAlias|ServerName|ServerPath|ServerRoot|ServerSignature|ServerTokens|SetHandler|SetInputFilter|SetOutputFilter|TimeOut|TraceEnable|UseCanonicalName)\\b' },
|
||||
{ token: 'keyword.mpm.apacheconf',
|
||||
regex: '\\b(?:AcceptMutex|AssignUserID|BS2000Account|ChildPerUserID|CoreDumpDirectory|EnableExceptionHook|Group|Listen|ListenBacklog|LockFile|MaxClients|MaxMemFree|MaxRequestsPerChild|MaxRequestsPerThread|MaxSpareServers|MaxSpareThreads|MaxThreads|MaxThreadsPerChild|MinSpareServers|MinSpareThreads|NumServers|PidFile|ReceiveBufferSize|ScoreBoardFile|SendBufferSize|ServerLimit|StartServers|StartThreads|ThreadLimit|ThreadsPerChild|ThreadStackSize|User|Win32DisableAcceptEx)\\b' },
|
||||
{ token: 'keyword.access.apacheconf',
|
||||
regex: '\\b(?:Allow|Deny|Order)\\b' },
|
||||
{ token: 'keyword.actions.apacheconf',
|
||||
regex: '\\b(?:Action|Script)\\b' },
|
||||
{ token: 'keyword.alias.apacheconf',
|
||||
regex: '\\b(?:Alias|AliasMatch|Redirect|RedirectMatch|RedirectPermanent|RedirectTemp|ScriptAlias|ScriptAliasMatch)\\b' },
|
||||
{ token: 'keyword.auth.apacheconf',
|
||||
regex: '\\b(?:AuthAuthoritative|AuthGroupFile|AuthUserFile)\\b' },
|
||||
{ token: 'keyword.auth_anon.apacheconf',
|
||||
regex: '\\b(?:Anonymous|Anonymous_Authoritative|Anonymous_LogEmail|Anonymous_MustGiveEmail|Anonymous_NoUserID|Anonymous_VerifyEmail)\\b' },
|
||||
{ token: 'keyword.auth_dbm.apacheconf',
|
||||
regex: '\\b(?:AuthDBMAuthoritative|AuthDBMGroupFile|AuthDBMType|AuthDBMUserFile)\\b' },
|
||||
{ token: 'keyword.auth_digest.apacheconf',
|
||||
regex: '\\b(?:AuthDigestAlgorithm|AuthDigestDomain|AuthDigestFile|AuthDigestGroupFile|AuthDigestNcCheck|AuthDigestNonceFormat|AuthDigestNonceLifetime|AuthDigestQop|AuthDigestShmemSize)\\b' },
|
||||
{ token: 'keyword.auth_ldap.apacheconf',
|
||||
regex: '\\b(?:AuthLDAPAuthoritative|AuthLDAPBindDN|AuthLDAPBindPassword|AuthLDAPCharsetConfig|AuthLDAPCompareDNOnServer|AuthLDAPDereferenceAliases|AuthLDAPEnabled|AuthLDAPFrontPageHack|AuthLDAPGroupAttribute|AuthLDAPGroupAttributeIsDN|AuthLDAPRemoteUserIsDN|AuthLDAPUrl)\\b' },
|
||||
{ token: 'keyword.autoindex.apacheconf',
|
||||
regex: '\\b(?:AddAlt|AddAltByEncoding|AddAltByType|AddDescription|AddIcon|AddIconByEncoding|AddIconByType|DefaultIcon|HeaderName|IndexIgnore|IndexOptions|IndexOrderDefault|ReadmeName)\\b' },
|
||||
{ token: 'keyword.cache.apacheconf',
|
||||
regex: '\\b(?:CacheDefaultExpire|CacheDisable|CacheEnable|CacheForceCompletion|CacheIgnoreCacheControl|CacheIgnoreHeaders|CacheIgnoreNoLastMod|CacheLastModifiedFactor|CacheMaxExpire)\\b' },
|
||||
{ token: 'keyword.cern_meta.apacheconf',
|
||||
regex: '\\b(?:MetaDir|MetaFiles|MetaSuffix)\\b' },
|
||||
{ token: 'keyword.cgi.apacheconf',
|
||||
regex: '\\b(?:ScriptLog|ScriptLogBuffer|ScriptLogLength)\\b' },
|
||||
{ token: 'keyword.cgid.apacheconf',
|
||||
regex: '\\b(?:ScriptLog|ScriptLogBuffer|ScriptLogLength|ScriptSock)\\b' },
|
||||
{ token: 'keyword.charset_lite.apacheconf',
|
||||
regex: '\\b(?:CharsetDefault|CharsetOptions|CharsetSourceEnc)\\b' },
|
||||
{ token: 'keyword.dav.apacheconf',
|
||||
regex: '\\b(?:Dav|DavDepthInfinity|DavMinTimeout|DavLockDB)\\b' },
|
||||
{ token: 'keyword.deflate.apacheconf',
|
||||
regex: '\\b(?:DeflateBufferSize|DeflateCompressionLevel|DeflateFilterNote|DeflateMemLevel|DeflateWindowSize)\\b' },
|
||||
{ token: 'keyword.dir.apacheconf',
|
||||
regex: '\\b(?:DirectoryIndex|DirectorySlash)\\b' },
|
||||
{ token: 'keyword.disk_cache.apacheconf',
|
||||
regex: '\\b(?:CacheDirLength|CacheDirLevels|CacheExpiryCheck|CacheGcClean|CacheGcDaily|CacheGcInterval|CacheGcMemUsage|CacheGcUnused|CacheMaxFileSize|CacheMinFileSize|CacheRoot|CacheSize|CacheTimeMargin)\\b' },
|
||||
{ token: 'keyword.dumpio.apacheconf',
|
||||
regex: '\\b(?:DumpIOInput|DumpIOOutput)\\b' },
|
||||
{ token: 'keyword.env.apacheconf',
|
||||
regex: '\\b(?:PassEnv|SetEnv|UnsetEnv)\\b' },
|
||||
{ token: 'keyword.expires.apacheconf',
|
||||
regex: '\\b(?:ExpiresActive|ExpiresByType|ExpiresDefault)\\b' },
|
||||
{ token: 'keyword.ext_filter.apacheconf',
|
||||
regex: '\\b(?:ExtFilterDefine|ExtFilterOptions)\\b' },
|
||||
{ token: 'keyword.file_cache.apacheconf',
|
||||
regex: '\\b(?:CacheFile|MMapFile)\\b' },
|
||||
{ token: 'keyword.headers.apacheconf',
|
||||
regex: '\\b(?:Header|RequestHeader)\\b' },
|
||||
{ token: 'keyword.imap.apacheconf',
|
||||
regex: '\\b(?:ImapBase|ImapDefault|ImapMenu)\\b' },
|
||||
{ token: 'keyword.include.apacheconf',
|
||||
regex: '\\b(?:SSIEndTag|SSIErrorMsg|SSIStartTag|SSITimeFormat|SSIUndefinedEcho|XBitHack)\\b' },
|
||||
{ token: 'keyword.isapi.apacheconf',
|
||||
regex: '\\b(?:ISAPIAppendLogToErrors|ISAPIAppendLogToQuery|ISAPICacheFile|ISAPIFakeAsync|ISAPILogNotSupported|ISAPIReadAheadBuffer)\\b' },
|
||||
{ token: 'keyword.ldap.apacheconf',
|
||||
regex: '\\b(?:LDAPCacheEntries|LDAPCacheTTL|LDAPConnectionTimeout|LDAPOpCacheEntries|LDAPOpCacheTTL|LDAPSharedCacheFile|LDAPSharedCacheSize|LDAPTrustedCA|LDAPTrustedCAType)\\b' },
|
||||
{ token: 'keyword.log.apacheconf',
|
||||
regex: '\\b(?:BufferedLogs|CookieLog|CustomLog|LogFormat|TransferLog|ForensicLog)\\b' },
|
||||
{ token: 'keyword.mem_cache.apacheconf',
|
||||
regex: '\\b(?:MCacheMaxObjectCount|MCacheMaxObjectSize|MCacheMaxStreamingBuffer|MCacheMinObjectSize|MCacheRemovalAlgorithm|MCacheSize)\\b' },
|
||||
{ token: 'keyword.mime.apacheconf',
|
||||
regex: '\\b(?:AddCharset|AddEncoding|AddHandler|AddInputFilter|AddLanguage|AddOutputFilter|AddType|DefaultLanguage|ModMimeUsePathInfo|MultiviewsMatch|RemoveCharset|RemoveEncoding|RemoveHandler|RemoveInputFilter|RemoveLanguage|RemoveOutputFilter|RemoveType|TypesConfig)\\b' },
|
||||
{ token: 'keyword.misc.apacheconf',
|
||||
regex: '\\b(?:ProtocolEcho|Example|AddModuleInfo|MimeMagicFile|CheckSpelling|ExtendedStatus|SuexecUserGroup|UserDir)\\b' },
|
||||
{ token: 'keyword.negotiation.apacheconf',
|
||||
regex: '\\b(?:CacheNegotiatedDocs|ForceLanguagePriority|LanguagePriority)\\b' },
|
||||
{ token: 'keyword.nw_ssl.apacheconf',
|
||||
regex: '\\b(?:NWSSLTrustedCerts|NWSSLUpgradeable|SecureListen)\\b' },
|
||||
{ token: 'keyword.proxy.apacheconf',
|
||||
regex: '\\b(?:AllowCONNECT|NoProxy|ProxyBadHeader|ProxyBlock|ProxyDomain|ProxyErrorOverride|ProxyFtpDirCharset|ProxyIOBufferSize|ProxyMaxForwards|ProxyPass|ProxyPassReverse|ProxyPreserveHost|ProxyReceiveBufferSize|ProxyRemote|ProxyRemoteMatch|ProxyRequests|ProxyTimeout|ProxyVia)\\b' },
|
||||
{ token: 'keyword.rewrite.apacheconf',
|
||||
regex: '\\b(?:RewriteBase|RewriteCond|RewriteEngine|RewriteLock|RewriteLog|RewriteLogLevel|RewriteMap|RewriteOptions|RewriteRule)\\b' },
|
||||
{ token: 'keyword.setenvif.apacheconf',
|
||||
regex: '\\b(?:BrowserMatch|BrowserMatchNoCase|SetEnvIf|SetEnvIfNoCase)\\b' },
|
||||
{ token: 'keyword.so.apacheconf',
|
||||
regex: '\\b(?:LoadFile|LoadModule)\\b' },
|
||||
{ token: 'keyword.ssl.apacheconf',
|
||||
regex: '\\b(?:SSLCACertificateFile|SSLCACertificatePath|SSLCARevocationFile|SSLCARevocationPath|SSLCertificateChainFile|SSLCertificateFile|SSLCertificateKeyFile|SSLCipherSuite|SSLEngine|SSLMutex|SSLOptions|SSLPassPhraseDialog|SSLProtocol|SSLProxyCACertificateFile|SSLProxyCACertificatePath|SSLProxyCARevocationFile|SSLProxyCARevocationPath|SSLProxyCipherSuite|SSLProxyEngine|SSLProxyMachineCertificateFile|SSLProxyMachineCertificatePath|SSLProxyProtocol|SSLProxyVerify|SSLProxyVerifyDepth|SSLRandomSeed|SSLRequire|SSLRequireSSL|SSLSessionCache|SSLSessionCacheTimeout|SSLUserName|SSLVerifyClient|SSLVerifyDepth)\\b' },
|
||||
{ token: 'keyword.usertrack.apacheconf',
|
||||
regex: '\\b(?:CookieDomain|CookieExpires|CookieName|CookieStyle|CookieTracking)\\b' },
|
||||
{ token: 'keyword.vhost_alias.apacheconf',
|
||||
regex: '\\b(?:VirtualDocumentRoot|VirtualDocumentRootIP|VirtualScriptAlias|VirtualScriptAliasIP)\\b' },
|
||||
{ token:
|
||||
[ 'keyword.php.apacheconf',
|
||||
'text',
|
||||
'entity.property.apacheconf',
|
||||
'text',
|
||||
'string.value.apacheconf',
|
||||
'text' ],
|
||||
regex: '\\b(php_value|php_flag)\\b(?:(\\s+)(.+?)(?:(\\s+)(.+?))?)?(\\s)' },
|
||||
{ token:
|
||||
[ 'punctuation.variable.apacheconf',
|
||||
'variable.env.apacheconf',
|
||||
'variable.misc.apacheconf',
|
||||
'punctuation.variable.apacheconf' ],
|
||||
regex: '(%\\{)(?:(HTTP_USER_AGENT|HTTP_REFERER|HTTP_COOKIE|HTTP_FORWARDED|HTTP_HOST|HTTP_PROXY_CONNECTION|HTTP_ACCEPT|REMOTE_ADDR|REMOTE_HOST|REMOTE_PORT|REMOTE_USER|REMOTE_IDENT|REQUEST_METHOD|SCRIPT_FILENAME|PATH_INFO|QUERY_STRING|AUTH_TYPE|DOCUMENT_ROOT|SERVER_ADMIN|SERVER_NAME|SERVER_ADDR|SERVER_PORT|SERVER_PROTOCOL|SERVER_SOFTWARE|TIME_YEAR|TIME_MON|TIME_DAY|TIME_HOUR|TIME_MIN|TIME_SEC|TIME_WDAY|TIME|API_VERSION|THE_REQUEST|REQUEST_URI|REQUEST_FILENAME|IS_SUBREQ|HTTPS)|(.*?))(\\})' },
|
||||
{ token: [ 'entity.mime-type.apacheconf', 'text' ],
|
||||
regex: '\\b((?:text|image|application|video|audio)/.+?)(\\s)' },
|
||||
{ token: 'entity.helper.apacheconf',
|
||||
regex: '\\b(?:from|unset|set|on|off)\\b',
|
||||
caseInsensitive: true },
|
||||
{ token: 'constant.integer.apacheconf', regex: '\\b\\d+\\b' },
|
||||
{ token:
|
||||
[ 'text',
|
||||
'punctuation.definition.flag.apacheconf',
|
||||
'string.flag.apacheconf',
|
||||
'punctuation.definition.flag.apacheconf',
|
||||
'text' ],
|
||||
regex: '(\\s)(\\[)(.*?)(\\])(\\s)' } ] };
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
ApacheConfHighlightRules.metaData = { fileTypes:
|
||||
[ 'conf',
|
||||
'CONF',
|
||||
'htaccess',
|
||||
'HTACCESS',
|
||||
'htgroups',
|
||||
'HTGROUPS',
|
||||
'htpasswd',
|
||||
'HTPASSWD',
|
||||
'.htaccess',
|
||||
'.HTACCESS',
|
||||
'.htgroups',
|
||||
'.HTGROUPS',
|
||||
'.htpasswd',
|
||||
'.HTPASSWD' ],
|
||||
name: 'Apache Conf',
|
||||
scopeName: 'source.apacheconf' };
|
||||
|
||||
|
||||
oop.inherits(ApacheConfHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.ApacheConfHighlightRules = ApacheConfHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
||||
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||
this._getFoldWidgetBase = this.getFoldWidget;
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) {
|
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||
return "";
|
||||
}
|
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||
|
||||
if (!fw && this.startRegionRe.test(line))
|
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.startRegionRe.test(line))
|
||||
return this.getCommentRegionBlock(session, line, row);
|
||||
|
||||
var match = line.match(this.foldingStartMarker);
|
||||
if (match) {
|
||||
var i = match.index;
|
||||
|
||||
if (match[1])
|
||||
return this.openingBracketBlock(session, match[1], row, i);
|
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||
|
||||
if (range && !range.isMultiLine()) {
|
||||
if (forceMultiline) {
|
||||
range = this.getSectionRange(session, row);
|
||||
} else if (foldStyle != "all")
|
||||
range = null;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
if (foldStyle === "markbegin")
|
||||
return;
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match) {
|
||||
var i = match.index + match[0].length;
|
||||
|
||||
if (match[1])
|
||||
return this.closingBracketBlock(session, match[1], row, i);
|
||||
|
||||
return session.getCommentFoldRange(row, i, -1);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSectionRange = function(session, row) {
|
||||
var line = session.getLine(row);
|
||||
var startIndent = line.search(/\S/);
|
||||
var startRow = row;
|
||||
var startColumn = line.length;
|
||||
row = row + 1;
|
||||
var endRow = row;
|
||||
var maxRow = session.getLength();
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
if (indent === -1)
|
||||
continue;
|
||||
if (startIndent > indent)
|
||||
break;
|
||||
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||
|
||||
if (subRange) {
|
||||
if (subRange.start.row <= startRow) {
|
||||
break;
|
||||
} else if (subRange.isMultiLine()) {
|
||||
row = subRange.end.row;
|
||||
} else if (startIndent == indent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||
};
|
||||
this.getCommentRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m) continue;
|
||||
if (m[1]) depth--;
|
||||
else depth++;
|
||||
|
||||
if (!depth) break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/apache_conf",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/apache_conf_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var ApacheConfHighlightRules = require("./apache_conf_highlight_rules").ApacheConfHighlightRules;
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = ApacheConfHighlightRules;
|
||||
this.foldingRules = new FoldMode();
|
||||
this.$behaviour = this.$defaultBehaviour;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "#";
|
||||
this.$id = "ace/mode/apache_conf";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/apache_conf"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,457 @@
|
||||
ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var DocCommentHighlightRules = function() {
|
||||
this.$rules = {
|
||||
"start" : [ {
|
||||
token : "comment.doc.tag",
|
||||
regex : "@[\\w\\d_]+" // TODO: fix email addresses
|
||||
},
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{
|
||||
defaultToken : "comment.doc",
|
||||
caseInsensitive: true
|
||||
}]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
|
||||
|
||||
DocCommentHighlightRules.getTagRule = function(start) {
|
||||
return {
|
||||
token : "comment.doc.tag.storage.type",
|
||||
regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
|
||||
};
|
||||
};
|
||||
|
||||
DocCommentHighlightRules.getStartRule = function(start) {
|
||||
return {
|
||||
token : "comment.doc", // doc comment
|
||||
regex : "\\/\\*(?=\\*)",
|
||||
next : start
|
||||
};
|
||||
};
|
||||
|
||||
DocCommentHighlightRules.getEndRule = function (start) {
|
||||
return {
|
||||
token : "comment.doc", // closing comment
|
||||
regex : "\\*\\/",
|
||||
next : start
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
exports.DocCommentHighlightRules = DocCommentHighlightRules;
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/apex_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules","ace/mode/doc_comment_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("../mode/text_highlight_rules").TextHighlightRules;
|
||||
var DocCommentHighlightRules = require("../mode/doc_comment_highlight_rules").DocCommentHighlightRules;
|
||||
|
||||
var ApexHighlightRules = function() {
|
||||
var mainKeywordMapper = this.createKeywordMapper({
|
||||
"variable.language": "activate|any|autonomous|begin|bigdecimal|byte|cast|char|collect|const"
|
||||
+ "|end|exit|export|float|goto|group|having|hint|import|inner|into|join|loop|number|object|of|outer"
|
||||
+ "|parallel|pragma|retrieve|returning|search|short|stat|synchronized|then|this_month"
|
||||
+ "|transaction|type|when",
|
||||
"keyword": "private|protected|public|native|synchronized|abstract|threadsafe|transient|static|final"
|
||||
+ "|and|array|as|asc|break|bulk|by|catch|class|commit|continue|convertcurrency"
|
||||
+ "|delete|desc|do|else|enum|extends|false|final|finally|for|from|future|global"
|
||||
+ "|if|implements|in|insert|instanceof|interface|last_90_days|last_month"
|
||||
+ "|last_n_days|last_week|like|limit|list|map|merge|new|next_90_days|next_month|next_n_days"
|
||||
+ "|next_week|not|null|nulls|on|or|override|package|return"
|
||||
+ "|rollback|savepoint|select|set|sort|super|testmethod|this|this_week|throw|today"
|
||||
+ "|tolabel|tomorrow|trigger|true|try|undelete|update|upsert|using|virtual|webservice"
|
||||
+ "|where|while|yesterday|switch|case|default",
|
||||
"storage.type":
|
||||
"def|boolean|byte|char|short|int|float|pblob|date|datetime|decimal|double|id|integer|long|string|time|void|blob|Object",
|
||||
"constant.language":
|
||||
"true|false|null|after|before|count|excludes|first|includes|last|order|sharing|with",
|
||||
"support.function":
|
||||
"system|apex|label|apexpages|userinfo|schema"
|
||||
}, "identifier", true);
|
||||
function keywordMapper(value) {
|
||||
if (value.slice(-3) == "__c") return "support.function";
|
||||
return mainKeywordMapper(value);
|
||||
}
|
||||
|
||||
function string(start, options) {
|
||||
return {
|
||||
regex: start + (options.multiline ? "" : "(?=.)"),
|
||||
token: "string.start",
|
||||
next: [{
|
||||
regex: options.escape,
|
||||
token: "character.escape"
|
||||
}, {
|
||||
regex: options.error,
|
||||
token: "error.invalid"
|
||||
}, {
|
||||
regex: start + (options.multiline ? "" : "|$"),
|
||||
token: "string.end",
|
||||
next: options.next || "start"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
function comments() {
|
||||
return [{
|
||||
token : "comment",
|
||||
regex : "\\/\\/(?=.)",
|
||||
next : [
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{token : "comment", regex : "$|^", next : "start"},
|
||||
{defaultToken : "comment", caseInsensitive: true}
|
||||
]
|
||||
},
|
||||
DocCommentHighlightRules.getStartRule("doc-start"),
|
||||
{
|
||||
token : "comment", // multi line comment
|
||||
regex : /\/\*/,
|
||||
next : [
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{token : "comment", regex : "\\*\\/", next : "start"},
|
||||
{defaultToken : "comment", caseInsensitive: true}
|
||||
]
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
this.$rules = {
|
||||
start: [
|
||||
string("'", {
|
||||
escape: /\\[nb'"\\]/,
|
||||
error: /\\./,
|
||||
multiline: false
|
||||
}),
|
||||
comments("c"),
|
||||
{
|
||||
type: "decoration",
|
||||
token: [
|
||||
"meta.package.apex",
|
||||
"keyword.other.package.apex",
|
||||
"meta.package.apex",
|
||||
"storage.modifier.package.apex",
|
||||
"meta.package.apex",
|
||||
"punctuation.terminator.apex"
|
||||
],
|
||||
regex: /^(\s*)(package)\b(?:(\s*)([^ ;$]+)(\s*)((?:;)?))?/
|
||||
}, {
|
||||
regex: /@[a-zA-Z_$][a-zA-Z_$\d\u0080-\ufffe]*/,
|
||||
token: "constant.language"
|
||||
},
|
||||
{
|
||||
regex: /[a-zA-Z_$][a-zA-Z_$\d\u0080-\ufffe]*/,
|
||||
token: keywordMapper
|
||||
},
|
||||
{
|
||||
regex: "`#%",
|
||||
token: "error.invalid"
|
||||
}, {
|
||||
token : "constant.numeric", // float
|
||||
regex : /[+-]?\d+(?:(?:\.\d*)?(?:[LlDdEe][+-]?\d+)?)\b|\.\d+[LlDdEe]/
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : /--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/,
|
||||
next : "start"
|
||||
}, {
|
||||
token : "punctuation.operator",
|
||||
regex : /[?:,;.]/,
|
||||
next : "start"
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : /[\[]/,
|
||||
next : "maybe_soql",
|
||||
merge : false
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : /[\[({]/,
|
||||
next : "start",
|
||||
merge : false
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : /[\])}]/,
|
||||
merge : false
|
||||
}
|
||||
],
|
||||
maybe_soql: [{
|
||||
regex: /\s+/,
|
||||
token: "text"
|
||||
}, {
|
||||
regex: /(SELECT|FIND)\b/,
|
||||
token: "keyword",
|
||||
caseInsensitive: true,
|
||||
next: "soql"
|
||||
}, {
|
||||
regex: "",
|
||||
token: "none",
|
||||
next: "start"
|
||||
}],
|
||||
soql: [{
|
||||
regex: "(:?ASC|BY|CATEGORY|CUBE|DATA|DESC|END|FIND|FIRST|FOR|FROM|GROUP|HAVING|IN|LAST"
|
||||
+ "|LIMIT|NETWORK|NULLS|OFFSET|ORDER|REFERENCE|RETURNING|ROLLUP|SCOPE|SELECT"
|
||||
+ "|SNIPPET|TRACKING|TYPEOF|UPDATE|USING|VIEW|VIEWSTAT|WHERE|WITH|AND|OR)\\b",
|
||||
token: "keyword",
|
||||
caseInsensitive: true
|
||||
}, {
|
||||
regex: "(:?target_length|toLabel|convertCurrency|count|Contact|Account|User|FIELDS)\\b",
|
||||
token: "support.function",
|
||||
caseInsensitive: true
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : /[\]]/,
|
||||
next : "start",
|
||||
merge : false
|
||||
},
|
||||
string("'", {
|
||||
escape: /\\[nb'"\\]/,
|
||||
error: /\\./,
|
||||
multiline: false,
|
||||
next: "soql"
|
||||
}),
|
||||
string('"', {
|
||||
escape: /\\[nb'"\\]/,
|
||||
error: /\\./,
|
||||
multiline: false,
|
||||
next: "soql"
|
||||
}),
|
||||
{
|
||||
regex: /\\./,
|
||||
token: "character.escape"
|
||||
},
|
||||
{
|
||||
regex : /[\?\&\|\!\{\}\[\]\(\)\^\~\*\:\"\'\+\-\,\.=\\\/]/,
|
||||
token : "keyword.operator"
|
||||
}],
|
||||
|
||||
"log-start" : [ {
|
||||
token : "timestamp.invisible",
|
||||
regex : /^[\d:.() ]+\|/,
|
||||
next: "log-header"
|
||||
}, {
|
||||
token : "timestamp.invisible",
|
||||
regex : /^ (Number of|Maximum)[^:]*:/,
|
||||
next: "log-comment"
|
||||
}, {
|
||||
token : "invisible",
|
||||
regex : /^Execute Anonymous:/,
|
||||
next: "log-comment"
|
||||
}, {
|
||||
defaultToken: "text"
|
||||
}],
|
||||
"log-comment": [{
|
||||
token : "log-comment",
|
||||
regex : /.*$/,
|
||||
next: "log-start"
|
||||
}],
|
||||
"log-header": [{
|
||||
token : "timestamp.invisible",
|
||||
regex : /((USER_DEBUG|\[\d+\]|DEBUG)\|)+/
|
||||
},
|
||||
{
|
||||
token : "keyword",
|
||||
regex: "(?:EXECUTION_FINISHED|EXECUTION_STARTED|CODE_UNIT_STARTED"
|
||||
+ "|CUMULATIVE_LIMIT_USAGE|LIMIT_USAGE_FOR_NS"
|
||||
+ "|CUMULATIVE_LIMIT_USAGE_END|CODE_UNIT_FINISHED)"
|
||||
}, {
|
||||
regex: "",
|
||||
next: "log-start"
|
||||
}]
|
||||
};
|
||||
this.embedRules(DocCommentHighlightRules, "doc-",
|
||||
[ DocCommentHighlightRules.getEndRule("start") ]);
|
||||
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
|
||||
oop.inherits(ApexHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.ApexHighlightRules = ApexHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
||||
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||
this._getFoldWidgetBase = this.getFoldWidget;
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) {
|
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||
return "";
|
||||
}
|
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||
|
||||
if (!fw && this.startRegionRe.test(line))
|
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.startRegionRe.test(line))
|
||||
return this.getCommentRegionBlock(session, line, row);
|
||||
|
||||
var match = line.match(this.foldingStartMarker);
|
||||
if (match) {
|
||||
var i = match.index;
|
||||
|
||||
if (match[1])
|
||||
return this.openingBracketBlock(session, match[1], row, i);
|
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||
|
||||
if (range && !range.isMultiLine()) {
|
||||
if (forceMultiline) {
|
||||
range = this.getSectionRange(session, row);
|
||||
} else if (foldStyle != "all")
|
||||
range = null;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
if (foldStyle === "markbegin")
|
||||
return;
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match) {
|
||||
var i = match.index + match[0].length;
|
||||
|
||||
if (match[1])
|
||||
return this.closingBracketBlock(session, match[1], row, i);
|
||||
|
||||
return session.getCommentFoldRange(row, i, -1);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSectionRange = function(session, row) {
|
||||
var line = session.getLine(row);
|
||||
var startIndent = line.search(/\S/);
|
||||
var startRow = row;
|
||||
var startColumn = line.length;
|
||||
row = row + 1;
|
||||
var endRow = row;
|
||||
var maxRow = session.getLength();
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
if (indent === -1)
|
||||
continue;
|
||||
if (startIndent > indent)
|
||||
break;
|
||||
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||
|
||||
if (subRange) {
|
||||
if (subRange.start.row <= startRow) {
|
||||
break;
|
||||
} else if (subRange.isMultiLine()) {
|
||||
row = subRange.end.row;
|
||||
} else if (startIndent == indent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||
};
|
||||
this.getCommentRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m) continue;
|
||||
if (m[1]) depth--;
|
||||
else depth++;
|
||||
|
||||
if (!depth) break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/apex",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/apex_highlight_rules","ace/mode/folding/cstyle","ace/mode/behaviour/cstyle"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("../mode/text").Mode;
|
||||
var ApexHighlightRules = require("./apex_highlight_rules").ApexHighlightRules;
|
||||
var FoldMode = require("../mode/folding/cstyle").FoldMode;
|
||||
var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour;
|
||||
|
||||
function ApexMode() {
|
||||
TextMode.call(this);
|
||||
|
||||
this.HighlightRules = ApexHighlightRules;
|
||||
this.foldingRules = new FoldMode();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
}
|
||||
|
||||
oop.inherits(ApexMode, TextMode);
|
||||
|
||||
ApexMode.prototype.lineCommentStart = "//";
|
||||
|
||||
ApexMode.prototype.blockComment = {
|
||||
start: "/*",
|
||||
end: "*/"
|
||||
};
|
||||
|
||||
exports.Mode = ApexMode;
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/apex"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
ace.define("ace/mode/applescript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var AppleScriptHighlightRules = function() {
|
||||
var keywords = (
|
||||
"about|above|after|against|and|around|as|at|back|before|beginning|" +
|
||||
"behind|below|beneath|beside|between|but|by|considering|" +
|
||||
"contain|contains|continue|copy|div|does|eighth|else|end|equal|" +
|
||||
"equals|error|every|exit|fifth|first|for|fourth|from|front|" +
|
||||
"get|given|global|if|ignoring|in|into|is|it|its|last|local|me|" +
|
||||
"middle|mod|my|ninth|not|of|on|onto|or|over|prop|property|put|ref|" +
|
||||
"reference|repeat|returning|script|second|set|seventh|since|" +
|
||||
"sixth|some|tell|tenth|that|the|then|third|through|thru|" +
|
||||
"timeout|times|to|transaction|try|until|where|while|whose|with|without"
|
||||
);
|
||||
|
||||
var builtinConstants = (
|
||||
"AppleScript|false|linefeed|return|pi|quote|result|space|tab|true"
|
||||
);
|
||||
|
||||
var builtinFunctions = (
|
||||
"activate|beep|count|delay|launch|log|offset|read|round|run|say|" +
|
||||
"summarize|write"
|
||||
);
|
||||
|
||||
var builtinTypes = (
|
||||
"alias|application|boolean|class|constant|date|file|integer|list|" +
|
||||
"number|real|record|string|text|character|characters|contents|day|" +
|
||||
"frontmost|id|item|length|month|name|paragraph|paragraphs|rest|" +
|
||||
"reverse|running|time|version|weekday|word|words|year"
|
||||
);
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"support.function": builtinFunctions,
|
||||
"constant.language": builtinConstants,
|
||||
"support.type": builtinTypes,
|
||||
"keyword": keywords
|
||||
}, "identifier");
|
||||
|
||||
this.$rules = {
|
||||
"start": [
|
||||
{
|
||||
token: "comment",
|
||||
regex: "--.*$"
|
||||
},
|
||||
{
|
||||
token : "comment", // multi line comment
|
||||
regex : "\\(\\*",
|
||||
next : "comment"
|
||||
},
|
||||
{
|
||||
token: "string", // " string
|
||||
regex: '".*?"'
|
||||
},
|
||||
{
|
||||
token: "support.type",
|
||||
regex: '\\b(POSIX file|POSIX path|(date|time) string|quoted form)\\b'
|
||||
},
|
||||
{
|
||||
token: "support.function",
|
||||
regex: '\\b(clipboard info|the clipboard|info for|list (disks|folder)|' +
|
||||
'mount volume|path to|(close|open for) access|(get|set) eof|' +
|
||||
'current date|do shell script|get volume settings|random number|' +
|
||||
'set volume|system attribute|system info|time to GMT|' +
|
||||
'(load|run|store) script|scripting components|' +
|
||||
'ASCII (character|number)|localized string|' +
|
||||
'choose (application|color|file|file name|' +
|
||||
'folder|from list|remote application|URL)|' +
|
||||
'display (alert|dialog))\\b|^\\s*return\\b'
|
||||
},
|
||||
{
|
||||
token: "constant.language",
|
||||
regex: '\\b(text item delimiters|current application|missing value)\\b'
|
||||
},
|
||||
{
|
||||
token: "keyword",
|
||||
regex: '\\b(apart from|aside from|instead of|out of|greater than|' +
|
||||
"isn't|(doesn't|does not) (equal|come before|come after|contain)|" +
|
||||
'(greater|less) than( or equal)?|(starts?|ends|begins?) with|' +
|
||||
'contained by|comes (before|after)|a (ref|reference))\\b'
|
||||
},
|
||||
{
|
||||
token: keywordMapper,
|
||||
regex: "[a-zA-Z][a-zA-Z0-9_]*\\b"
|
||||
}
|
||||
],
|
||||
"comment": [
|
||||
{
|
||||
token: "comment", // closing comment
|
||||
regex: "\\*\\)",
|
||||
next: "start"
|
||||
}, {
|
||||
defaultToken: "comment"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
oop.inherits(AppleScriptHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.AppleScriptHighlightRules = AppleScriptHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
||||
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||
this._getFoldWidgetBase = this.getFoldWidget;
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) {
|
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||
return "";
|
||||
}
|
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||
|
||||
if (!fw && this.startRegionRe.test(line))
|
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.startRegionRe.test(line))
|
||||
return this.getCommentRegionBlock(session, line, row);
|
||||
|
||||
var match = line.match(this.foldingStartMarker);
|
||||
if (match) {
|
||||
var i = match.index;
|
||||
|
||||
if (match[1])
|
||||
return this.openingBracketBlock(session, match[1], row, i);
|
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||
|
||||
if (range && !range.isMultiLine()) {
|
||||
if (forceMultiline) {
|
||||
range = this.getSectionRange(session, row);
|
||||
} else if (foldStyle != "all")
|
||||
range = null;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
if (foldStyle === "markbegin")
|
||||
return;
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match) {
|
||||
var i = match.index + match[0].length;
|
||||
|
||||
if (match[1])
|
||||
return this.closingBracketBlock(session, match[1], row, i);
|
||||
|
||||
return session.getCommentFoldRange(row, i, -1);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSectionRange = function(session, row) {
|
||||
var line = session.getLine(row);
|
||||
var startIndent = line.search(/\S/);
|
||||
var startRow = row;
|
||||
var startColumn = line.length;
|
||||
row = row + 1;
|
||||
var endRow = row;
|
||||
var maxRow = session.getLength();
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
if (indent === -1)
|
||||
continue;
|
||||
if (startIndent > indent)
|
||||
break;
|
||||
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||
|
||||
if (subRange) {
|
||||
if (subRange.start.row <= startRow) {
|
||||
break;
|
||||
} else if (subRange.isMultiLine()) {
|
||||
row = subRange.end.row;
|
||||
} else if (startIndent == indent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||
};
|
||||
this.getCommentRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m) continue;
|
||||
if (m[1]) depth--;
|
||||
else depth++;
|
||||
|
||||
if (!depth) break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/applescript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/applescript_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var AppleScriptHighlightRules = require("./applescript_highlight_rules").AppleScriptHighlightRules;
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = AppleScriptHighlightRules;
|
||||
this.foldingRules = new FoldMode();
|
||||
this.$behaviour = this.$defaultBehaviour;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "--";
|
||||
this.blockComment = {start: "(*", end: "*)"};
|
||||
this.$id = "ace/mode/applescript";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/applescript"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
ace.define("ace/mode/aql_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var AqlHighlightRules = function() {
|
||||
|
||||
var keywords = (
|
||||
"for|search|outbound|inbound|any|graph|prune|options|shortest_path|to|in|return|filter|sort|limit|let|collect|remove|update|replace|insers|upsert|with"
|
||||
);
|
||||
|
||||
var builtinConstants = (
|
||||
"true|false"
|
||||
);
|
||||
|
||||
var builtinFunctions = (
|
||||
"append|contains_array|count|count_distinct|count_unique|first|flatten|intersection|last|length|minus|nth|outersection|pop|position|push|remove_nth|remove_value|remove_values|reverse|shift|slice|sorted|sorted_unique|union|union_distinct|unique|unshift|" +
|
||||
"date_now|date_iso8601|date_timestamp|is_datestring|date_dayofweek|date_year|date_month|date_day|date_hour|date_minute|date_second|date_millisecond|date_dayofyear|date_isoweek|date_leapyear|date_quarter|date_days_in_month|date_trunc|date_format|date_add|date_subtract|date_diff|date_compare|" +
|
||||
"attributes|count|has|is_same_collection|keep|length|matches|merge|merge_recursive|parse_identifier|translate|unset|unset_recursive|values|zip|" +
|
||||
"fulltext|" +
|
||||
"distance|geo_contains|geo_distance|geo_equals|geo_intersects|is_in_polygon|" +
|
||||
"not_null|first_list|first_document|check_document|collection_count|collections|count|current_user|document|length|hash|apply|assert|/ warn|call|fail|noopt|passthru|sleep|v8|version|" +
|
||||
"abs|acos|asin|atan|atan2|average|avg|ceil|cos|degrees|exp|exp2|floor|log|log2|log10|max|median|min|percentile|pi|pow|radians|rand|range|round|sin|sqrt|stddev_population|stddev_sample|stddev|sum|tan|variance_population|variance_sample|variance|" +
|
||||
"char_length|concat|concat_separator|contains|count|encode_uri_component|find_first|find_last|json_parse|json_stringify|left|length|levenshtein_distance|like|lower|ltrim|md5|random_token|regex_matches|regex_split|regex_test|regex_replace|reverse|right|rtrim|sha1|sha512|split|soundex|substitute|substring|tokens|to_base64|to_hex|trim|upper|uuid|" +
|
||||
"to_bool|to_number|to_string|to_array|to_list|is_null|is_bool|is_number|is_string|is_array|is_list|is_object|is_document|is_datestring|is_key|typename|"
|
||||
);
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"support.function": builtinFunctions,
|
||||
"keyword": keywords,
|
||||
"constant.language": builtinConstants
|
||||
}, "identifier", true);
|
||||
|
||||
this.$rules = {
|
||||
"start" : [ {
|
||||
token : "comment",
|
||||
regex : "//.*$"
|
||||
}, {
|
||||
token : "string", // " string
|
||||
regex : '".*?"'
|
||||
}, {
|
||||
token : "string", // ' string
|
||||
regex : "'.*?'"
|
||||
}, {
|
||||
token : "constant.numeric", // float
|
||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : "[\\(]"
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : "[\\)]"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
} ]
|
||||
};
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
oop.inherits(AqlHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.AqlHighlightRules = AqlHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/aql",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/aql_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var AqlHighlightRules = require("./aql_highlight_rules").AqlHighlightRules;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = AqlHighlightRules;
|
||||
this.$behaviour = this.$defaultBehaviour;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.lineCommentStart = "//";
|
||||
|
||||
this.$id = "ace/mode/aql";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/aql"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
ace.define("ace/mode/asciidoc_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var AsciidocHighlightRules = function() {
|
||||
var identifierRe = "[a-zA-Z\u00a1-\uffff]+\\b";
|
||||
|
||||
this.$rules = {
|
||||
"start": [
|
||||
{token: "empty", regex: /$/},
|
||||
{token: "literal", regex: /^\.{4,}\s*$/, next: "listingBlock"},
|
||||
{token: "literal", regex: /^-{4,}\s*$/, next: "literalBlock"},
|
||||
{token: "string", regex: /^\+{4,}\s*$/, next: "passthroughBlock"},
|
||||
{token: "keyword", regex: /^={4,}\s*$/},
|
||||
{token: "text", regex: /^\s*$/},
|
||||
{token: "empty", regex: "", next: "dissallowDelimitedBlock"}
|
||||
],
|
||||
|
||||
"dissallowDelimitedBlock": [
|
||||
{include: "paragraphEnd"},
|
||||
{token: "comment", regex: '^//.+$'},
|
||||
{token: "keyword", regex: "^(?:NOTE|TIP|IMPORTANT|WARNING|CAUTION):"},
|
||||
|
||||
{include: "listStart"},
|
||||
{token: "literal", regex: /^\s+.+$/, next: "indentedBlock"},
|
||||
{token: "empty", regex: "", next: "text"}
|
||||
],
|
||||
|
||||
"paragraphEnd": [
|
||||
{token: "doc.comment", regex: /^\/{4,}\s*$/, next: "commentBlock"},
|
||||
{token: "tableBlock", regex: /^\s*[|!]=+\s*$/, next: "tableBlock"},
|
||||
{token: "keyword", regex: /^(?:--|''')\s*$/, next: "start"},
|
||||
{token: "option", regex: /^\[.*\]\s*$/, next: "start"},
|
||||
{token: "pageBreak", regex: /^>{3,}$/, next: "start"},
|
||||
{token: "literal", regex: /^\.{4,}\s*$/, next: "listingBlock"},
|
||||
{token: "titleUnderline", regex: /^(?:={2,}|-{2,}|~{2,}|\^{2,}|\+{2,})\s*$/, next: "start"},
|
||||
{token: "singleLineTitle", regex: /^={1,5}\s+\S.*$/, next: "start"},
|
||||
|
||||
{token: "otherBlock", regex: /^(?:\*{2,}|_{2,})\s*$/, next: "start"},
|
||||
{token: "optionalTitle", regex: /^\.[^.\s].+$/, next: "start"}
|
||||
],
|
||||
|
||||
"listStart": [
|
||||
{token: "keyword", regex: /^\s*(?:\d+\.|[a-zA-Z]\.|[ixvmIXVM]+\)|\*{1,5}|-|\.{1,5})\s/, next: "listText"},
|
||||
{token: "meta.tag", regex: /^.+(?::{2,4}|;;)(?: |$)/, next: "listText"},
|
||||
{token: "support.function.list.callout", regex: /^(?:<\d+>|\d+>|>) /, next: "text"},
|
||||
{token: "keyword", regex: /^\+\s*$/, next: "start"}
|
||||
],
|
||||
|
||||
"text": [
|
||||
{token: ["link", "variable.language"], regex: /((?:https?:\/\/|ftp:\/\/|file:\/\/|mailto:|callto:)[^\s\[]+)(\[.*?\])/},
|
||||
{token: "link", regex: /(?:https?:\/\/|ftp:\/\/|file:\/\/|mailto:|callto:)[^\s\[]+/},
|
||||
{token: "link", regex: /\b[\w\.\/\-]+@[\w\.\/\-]+\b/},
|
||||
{include: "macros"},
|
||||
{include: "paragraphEnd"},
|
||||
{token: "literal", regex:/\+{3,}/, next:"smallPassthrough"},
|
||||
{token: "escape", regex: /\((?:C|TM|R)\)|\.{3}|->|<-|=>|<=|&#(?:\d+|x[a-fA-F\d]+);|(?: |^)--(?=\s+\S)/},
|
||||
{token: "escape", regex: /\\[_*'`+#]|\\{2}[_*'`+#]{2}/},
|
||||
{token: "keyword", regex: /\s\+$/},
|
||||
{token: "text", regex: identifierRe},
|
||||
{token: ["keyword", "string", "keyword"],
|
||||
regex: /(<<[\w\d\-$]+,)(.*?)(>>|$)/},
|
||||
{token: "keyword", regex: /<<[\w\d\-$]+,?|>>/},
|
||||
{token: "constant.character", regex: /\({2,3}.*?\){2,3}/},
|
||||
{token: "keyword", regex: /\[\[.+?\]\]/},
|
||||
{token: "support", regex: /^\[{3}[\w\d =\-]+\]{3}/},
|
||||
|
||||
{include: "quotes"},
|
||||
{token: "empty", regex: /^\s*$/, next: "start"}
|
||||
],
|
||||
|
||||
"listText": [
|
||||
{include: "listStart"},
|
||||
{include: "text"}
|
||||
],
|
||||
|
||||
"indentedBlock": [
|
||||
{token: "literal", regex: /^[\s\w].+$/, next: "indentedBlock"},
|
||||
{token: "literal", regex: "", next: "start"}
|
||||
],
|
||||
|
||||
"listingBlock": [
|
||||
{token: "literal", regex: /^\.{4,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "constant.numeric", regex: '<\\d+>'},
|
||||
{token: "literal", regex: '[^<]+'},
|
||||
{token: "literal", regex: '<'}
|
||||
],
|
||||
"literalBlock": [
|
||||
{token: "literal", regex: /^-{4,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "constant.numeric", regex: '<\\d+>'},
|
||||
{token: "literal", regex: '[^<]+'},
|
||||
{token: "literal", regex: '<'}
|
||||
],
|
||||
"passthroughBlock": [
|
||||
{token: "literal", regex: /^\+{4,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "literal", regex: identifierRe + "|\\d+"},
|
||||
{include: "macros"},
|
||||
{token: "literal", regex: "."}
|
||||
],
|
||||
|
||||
"smallPassthrough": [
|
||||
{token: "literal", regex: /[+]{3,}/, next: "dissallowDelimitedBlock"},
|
||||
{token: "literal", regex: /^\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "literal", regex: identifierRe + "|\\d+"},
|
||||
{include: "macros"}
|
||||
],
|
||||
|
||||
"commentBlock": [
|
||||
{token: "doc.comment", regex: /^\/{4,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "doc.comment", regex: '^.*$'}
|
||||
],
|
||||
"tableBlock": [
|
||||
{token: "tableBlock", regex: /^\s*\|={3,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "tableBlock", regex: /^\s*!={3,}\s*$/, next: "innerTableBlock"},
|
||||
{token: "tableBlock", regex: /\|/},
|
||||
{include: "text", noEscape: true}
|
||||
],
|
||||
"innerTableBlock": [
|
||||
{token: "tableBlock", regex: /^\s*!={3,}\s*$/, next: "tableBlock"},
|
||||
{token: "tableBlock", regex: /^\s*|={3,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "tableBlock", regex: /!/}
|
||||
],
|
||||
"macros": [
|
||||
{token: "macro", regex: /{[\w\-$]+}/},
|
||||
{token: ["text", "string", "text", "constant.character", "text"], regex: /({)([\w\-$]+)(:)?(.+)?(})/},
|
||||
{token: ["text", "markup.list.macro", "keyword", "string"], regex: /(\w+)(footnote(?:ref)?::?)([^\s\[]+)?(\[.*?\])?/},
|
||||
{token: ["markup.list.macro", "keyword", "string"], regex: /([a-zA-Z\-][\w\.\/\-]*::?)([^\s\[]+)(\[.*?\])?/},
|
||||
{token: ["markup.list.macro", "keyword"], regex: /([a-zA-Z\-][\w\.\/\-]+::?)(\[.*?\])/},
|
||||
{token: "keyword", regex: /^:.+?:(?= |$)/}
|
||||
],
|
||||
|
||||
"quotes": [
|
||||
{token: "string.italic", regex: /__[^_\s].*?__/},
|
||||
{token: "string.italic", regex: quoteRule("_")},
|
||||
|
||||
{token: "keyword.bold", regex: /\*\*[^*\s].*?\*\*/},
|
||||
{token: "keyword.bold", regex: quoteRule("\\*")},
|
||||
|
||||
{token: "literal", regex: quoteRule("\\+")},
|
||||
{token: "literal", regex: /\+\+[^+\s].*?\+\+/},
|
||||
{token: "literal", regex: /\$\$.+?\$\$/},
|
||||
{token: "literal", regex: quoteRule("`")},
|
||||
|
||||
{token: "keyword", regex: quoteRule("^")},
|
||||
{token: "keyword", regex: quoteRule("~")},
|
||||
{token: "keyword", regex: /##?/},
|
||||
{token: "keyword", regex: /(?:\B|^)``|\b''/}
|
||||
]
|
||||
|
||||
};
|
||||
|
||||
function quoteRule(ch) {
|
||||
var prefix = /\w/.test(ch) ? "\\b" : "(?:\\B|^)";
|
||||
return prefix + ch + "[^" + ch + "].*?" + ch + "(?![\\w*])";
|
||||
}
|
||||
|
||||
var tokenMap = {
|
||||
macro: "constant.character",
|
||||
tableBlock: "doc.comment",
|
||||
titleUnderline: "markup.heading",
|
||||
singleLineTitle: "markup.heading",
|
||||
pageBreak: "string",
|
||||
option: "string.regexp",
|
||||
otherBlock: "markup.list",
|
||||
literal: "support.function",
|
||||
optionalTitle: "constant.numeric",
|
||||
escape: "constant.language.escape",
|
||||
link: "markup.underline.list"
|
||||
};
|
||||
|
||||
for (var state in this.$rules) {
|
||||
var stateRules = this.$rules[state];
|
||||
for (var i = stateRules.length; i--; ) {
|
||||
var rule = stateRules[i];
|
||||
if (rule.include || typeof rule == "string") {
|
||||
var args = [i, 1].concat(this.$rules[rule.include || rule]);
|
||||
if (rule.noEscape) {
|
||||
args = args.filter(function(x) {
|
||||
return !x.next;
|
||||
});
|
||||
}
|
||||
stateRules.splice.apply(stateRules, args);
|
||||
} else if (rule.token in tokenMap) {
|
||||
rule.token = tokenMap[rule.token];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
oop.inherits(AsciidocHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.AsciidocHighlightRules = AsciidocHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/asciidoc",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
var Range = require("../../range").Range;
|
||||
|
||||
var FoldMode = exports.FoldMode = function() {};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
this.foldingStartMarker = /^(?:\|={10,}|[\.\/=\-~^+]{4,}\s*$|={1,5} )/;
|
||||
this.singleLineHeadingRe = /^={1,5}(?=\s+\S)/;
|
||||
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
if (!this.foldingStartMarker.test(line))
|
||||
return "";
|
||||
|
||||
if (line[0] == "=") {
|
||||
if (this.singleLineHeadingRe.test(line))
|
||||
return "start";
|
||||
if (session.getLine(row - 1).length != session.getLine(row).length)
|
||||
return "";
|
||||
return "start";
|
||||
}
|
||||
if (session.bgTokenizer.getState(row) == "dissallowDelimitedBlock")
|
||||
return "end";
|
||||
return "start";
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
var startColumn = line.length;
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
var endRow = row;
|
||||
if (!line.match(this.foldingStartMarker))
|
||||
return;
|
||||
|
||||
var token;
|
||||
function getTokenType(row) {
|
||||
token = session.getTokens(row)[0];
|
||||
return token && token.type;
|
||||
}
|
||||
|
||||
var levels = ["=","-","~","^","+"];
|
||||
var heading = "markup.heading";
|
||||
var singleLineHeadingRe = this.singleLineHeadingRe;
|
||||
function getLevel() {
|
||||
var match = token.value.match(singleLineHeadingRe);
|
||||
if (match)
|
||||
return match[0].length;
|
||||
var level = levels.indexOf(token.value[0]) + 1;
|
||||
if (level == 1) {
|
||||
if (session.getLine(row - 1).length != session.getLine(row).length)
|
||||
return Infinity;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
if (getTokenType(row) == heading) {
|
||||
var startHeadingLevel = getLevel();
|
||||
while (++row < maxRow) {
|
||||
if (getTokenType(row) != heading)
|
||||
continue;
|
||||
var level = getLevel();
|
||||
if (level <= startHeadingLevel)
|
||||
break;
|
||||
}
|
||||
|
||||
var isSingleLineHeading = token && token.value.match(this.singleLineHeadingRe);
|
||||
endRow = isSingleLineHeading ? row - 1 : row - 2;
|
||||
|
||||
if (endRow > startRow) {
|
||||
while (endRow > startRow && (!getTokenType(endRow) || token.value[0] == "["))
|
||||
endRow--;
|
||||
}
|
||||
|
||||
if (endRow > startRow) {
|
||||
var endColumn = session.getLine(endRow).length;
|
||||
return new Range(startRow, startColumn, endRow, endColumn);
|
||||
}
|
||||
} else {
|
||||
var state = session.bgTokenizer.getState(row);
|
||||
if (state == "dissallowDelimitedBlock") {
|
||||
while (row -- > 0) {
|
||||
if (session.bgTokenizer.getState(row).lastIndexOf("Block") == -1)
|
||||
break;
|
||||
}
|
||||
endRow = row + 1;
|
||||
if (endRow < startRow) {
|
||||
var endColumn = session.getLine(row).length;
|
||||
return new Range(endRow, 5, startRow, startColumn - 5);
|
||||
}
|
||||
} else {
|
||||
while (++row < maxRow) {
|
||||
if (session.bgTokenizer.getState(row) == "dissallowDelimitedBlock")
|
||||
break;
|
||||
}
|
||||
endRow = row;
|
||||
if (endRow > startRow) {
|
||||
var endColumn = session.getLine(row).length;
|
||||
return new Range(startRow, 5, endRow, endColumn - 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/asciidoc",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/asciidoc_highlight_rules","ace/mode/folding/asciidoc"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var AsciidocHighlightRules = require("./asciidoc_highlight_rules").AsciidocHighlightRules;
|
||||
var AsciidocFoldMode = require("./folding/asciidoc").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = AsciidocHighlightRules;
|
||||
|
||||
this.foldingRules = new AsciidocFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.type = "text";
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
if (state == "listblock") {
|
||||
var match = /^((?:.+)?)([-+*][ ]+)/.exec(line);
|
||||
if (match) {
|
||||
return new Array(match[1].length + 1).join(" ") + match[2];
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
} else {
|
||||
return this.$getIndent(line);
|
||||
}
|
||||
};
|
||||
this.$id = "ace/mode/asciidoc";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/asciidoc"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,421 @@
|
||||
ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var DocCommentHighlightRules = function() {
|
||||
this.$rules = {
|
||||
"start" : [ {
|
||||
token : "comment.doc.tag",
|
||||
regex : "@[\\w\\d_]+" // TODO: fix email addresses
|
||||
},
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{
|
||||
defaultToken : "comment.doc",
|
||||
caseInsensitive: true
|
||||
}]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
|
||||
|
||||
DocCommentHighlightRules.getTagRule = function(start) {
|
||||
return {
|
||||
token : "comment.doc.tag.storage.type",
|
||||
regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
|
||||
};
|
||||
};
|
||||
|
||||
DocCommentHighlightRules.getStartRule = function(start) {
|
||||
return {
|
||||
token : "comment.doc", // doc comment
|
||||
regex : "\\/\\*(?=\\*)",
|
||||
next : start
|
||||
};
|
||||
};
|
||||
|
||||
DocCommentHighlightRules.getEndRule = function (start) {
|
||||
return {
|
||||
token : "comment.doc", // closing comment
|
||||
regex : "\\*\\/",
|
||||
next : start
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
exports.DocCommentHighlightRules = DocCommentHighlightRules;
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/asl_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var ASLHighlightRules = function() {
|
||||
var keywords = (
|
||||
"Default|DefinitionBlock|Device|Method|Else|ElseIf|For|Function|If|Include|Method|Return|" +
|
||||
"Scope|Switch|Case|While|Break|BreakPoint|Continue|NoOp|Wait"
|
||||
);
|
||||
|
||||
var keywordOperators = (
|
||||
"Add|And|Decrement|Divide|Increment|Index|LAnd|LEqual|LGreater|LGreaterEqual|" +
|
||||
"LLess|LLessEqual|LNot|LNotEqual|LOr|Mod|Multiply|NAnd|NOr|Not|Or|RefOf|Revision|" +
|
||||
"ShiftLeft|ShiftRight|Subtract|XOr|DerefOf"
|
||||
);
|
||||
|
||||
var buildinFunctions = (
|
||||
"AccessAs|Acquire|Alias|BankField|Buffer|Concatenate|ConcatenateResTemplate|" +
|
||||
"CondRefOf|Connection|CopyObject|CreateBitField|CreateByteField|CreateDWordField|" +
|
||||
"CreateField|CreateQWordField|CreateWordField|DataTableRegion|Debug|" +
|
||||
"DMA|DWordIO|DWordMemory|DWordSpace|EisaId|EISAID|EndDependentFn|Event|ExtendedIO|" +
|
||||
"ExtendedMemory|ExtendedSpace|External|Fatal|Field|FindSetLeftBit|FindSetRightBit|" +
|
||||
"FixedDMA|FixedIO|Fprintf|FromBCD|GpioInt|GpioIo|I2CSerialBusV2|IndexField|" +
|
||||
"Interrupt|IO|IRQ|IRQNoFlags|Load|LoadTable|Match|Memory32|Memory32Fixed|" +
|
||||
"Mid|Mutex|Name|Notify|Offset|ObjectType|OperationRegion|Package|PowerResource|Printf|" +
|
||||
"QWordIO|QWordMemory|QWordSpace|RawDataBuffer|Register|Release|Reset|ResourceTemplate|" +
|
||||
"Signal|SizeOf|Sleep|SPISerialBusV2|Stall|StartDependentFn|StartDependentFnNoPri|" +
|
||||
"Store|ThermalZone|Timer|ToBCD|ToBuffer|ToDecimalString|ToInteger|ToPLD|ToString|" +
|
||||
"ToUUID|UARTSerialBusV2|Unicode|Unload|VendorLong|VendorShort|WordBusNumber|WordIO|" +
|
||||
"WordSpace"
|
||||
);
|
||||
|
||||
var flags = (
|
||||
"AttribQuick|AttribSendReceive|AttribByte|AttribBytes|AttribRawBytes|" +
|
||||
"AttribRawProcessBytes|AttribWord|AttribBlock|AttribProcessCall|AttribBlockProcessCall|" +
|
||||
"AnyAcc|ByteAcc|WordAcc|DWordAcc|QWordAcc|BufferAcc|" +
|
||||
"AddressRangeMemory|AddressRangeReserved|AddressRangeNVS|AddressRangeACPI|" +
|
||||
"RegionSpaceKeyword|FFixedHW|PCC|" +
|
||||
"AddressingMode7Bit|AddressingMode10Bit|" +
|
||||
"DataBitsFive|DataBitsSix|DataBitsSeven|DataBitsEight|DataBitsNine|" +
|
||||
"BusMaster|NotBusMaster|" +
|
||||
"ClockPhaseFirst|ClockPhaseSecond|ClockPolarityLow|ClockPolarityHigh|" +
|
||||
"SubDecode|PosDecode|" +
|
||||
"BigEndianing|LittleEndian|" +
|
||||
"FlowControlNone|FlowControlXon|FlowControlHardware|" +
|
||||
"Edge|Level|ActiveHigh|ActiveLow|ActiveBoth|Decode16|Decode10|" +
|
||||
"IoRestrictionNone|IoRestrictionInputOnly|IoRestrictionOutputOnly|" +
|
||||
"IoRestrictionNoneAndPreserve|Lock|NoLock|MTR|MEQ|MLE|MLT|MGE|MGT|" +
|
||||
"MaxFixed|MaxNotFixed|Cacheable|WriteCombining|Prefetchable|NonCacheable|" +
|
||||
"MinFixed|MinNotFixed|" +
|
||||
"ParityTypeNone|ParityTypeSpace|ParityTypeMark|ParityTypeOdd|ParityTypeEven|" +
|
||||
"PullDefault|PullUp|PullDown|PullNone|PolarityHigh|PolarityLow|" +
|
||||
"ISAOnlyRanges|NonISAOnlyRanges|EntireRange|ReadWrite|ReadOnly|" +
|
||||
"UserDefRegionSpace|SystemIO|SystemMemory|PCI_Config|EmbeddedControl|" +
|
||||
"SMBus|SystemCMOS|PciBarTarget|IPMI|GeneralPurposeIO|GenericSerialBus|" +
|
||||
"ResourceConsumer|ResourceProducer|Serialized|NotSerialized|" +
|
||||
"Shared|Exclusive|SharedAndWake|ExclusiveAndWake|ControllerInitiated|DeviceInitiated|" +
|
||||
"StopBitsZero|StopBitsOne|StopBitsOnePlusHalf|StopBitsTwo|" +
|
||||
"Width8Bit|Width16Bit|Width32Bit|Width64Bit|Width128Bit|Width256Bit|" +
|
||||
"SparseTranslation|DenseTranslation|TypeTranslation|TypeStatic|" +
|
||||
"Preserve|WriteAsOnes|WriteAsZeros|Transfer8|Transfer16|Transfer8_16|" +
|
||||
"ThreeWireMode|FourWireMode"
|
||||
);
|
||||
|
||||
var storageTypes = (
|
||||
"UnknownObj|IntObj|StrObj|BuffObj|PkgObj|FieldUnitObj|DeviceObj|" +
|
||||
"EventObj|MethodObj|MutexObj|OpRegionObj|PowerResObj|ProcessorObj|" +
|
||||
"ThermalZoneObj|BuffFieldObj|DDBHandleObj"
|
||||
);
|
||||
|
||||
var buildinConstants = (
|
||||
"__FILE__|__PATH__|__LINE__|__DATE__|__IASL__"
|
||||
);
|
||||
|
||||
var deprecated = (
|
||||
"Memory24|Processor"
|
||||
);
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"keyword": keywords,
|
||||
"keyword.operator": keywordOperators,
|
||||
"function.buildin": buildinFunctions,
|
||||
"constant.language": buildinConstants,
|
||||
"storage.type": storageTypes,
|
||||
"constant.character": flags,
|
||||
"invalid.deprecated": deprecated
|
||||
}, "identifier");
|
||||
|
||||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
token : "comment",
|
||||
regex : "\\/\\/.*$"
|
||||
},
|
||||
DocCommentHighlightRules.getStartRule("doc-start"),
|
||||
{
|
||||
token : "comment", // multi line comment
|
||||
regex : "\\/\\*",
|
||||
next : "comment"
|
||||
},
|
||||
DocCommentHighlightRules.getStartRule("doc-start"),
|
||||
{
|
||||
token : "comment", // ignored fields / comments
|
||||
regex : "\\\[",
|
||||
next : "ignoredfield"
|
||||
}, {
|
||||
token : "variable",
|
||||
regex : "\\Local[0-7]|\\Arg[0-6]"
|
||||
}, {
|
||||
token : "keyword", // pre-compiler directives
|
||||
regex : "#\\s*(?:define|elif|else|endif|error|if|ifdef|ifndef|include|includebuffer|line|pragma|undef|warning)\\b",
|
||||
next : "directive"
|
||||
}, {
|
||||
token : "string", // single line
|
||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
||||
}, {
|
||||
token : "constant.character", // single line
|
||||
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
||||
}, {
|
||||
token : "constant.numeric", // hex
|
||||
regex : /0[xX][0-9a-fA-F]+\b/
|
||||
}, {
|
||||
token : "constant.numeric",
|
||||
regex : /(One(s)?|Zero|True|False|[0-9]+)\b/
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "/|!|\\$|%|&|\\||\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|\\^|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\|="
|
||||
}, {
|
||||
token : "lparen",
|
||||
regex : "[[({]"
|
||||
}, {
|
||||
token : "rparen",
|
||||
regex : "[\\])}]"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}
|
||||
],
|
||||
"comment" : [
|
||||
{
|
||||
token : "comment", // closing comment
|
||||
regex : "\\*\\/",
|
||||
next : "start"
|
||||
}, {
|
||||
defaultToken : "comment"
|
||||
}
|
||||
],
|
||||
"ignoredfield" : [
|
||||
{
|
||||
token : "comment", // closing ignored fields / comments
|
||||
regex : "\\\]",
|
||||
next : "start"
|
||||
}, {
|
||||
defaultToken : "comment"
|
||||
}
|
||||
],
|
||||
"directive" : [
|
||||
{
|
||||
token : "constant.other.multiline",
|
||||
regex : /\\/
|
||||
},
|
||||
{
|
||||
token : "constant.other.multiline",
|
||||
regex : /.*\\/
|
||||
},
|
||||
{
|
||||
token : "constant.other",
|
||||
regex : "\\s*<.+?>*s",
|
||||
next : "start"
|
||||
},
|
||||
{
|
||||
token : "constant.other", // single line
|
||||
regex : '\\s*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]*s',
|
||||
next : "start"
|
||||
},
|
||||
{
|
||||
token : "constant.other", // single line
|
||||
regex : "\\s*['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']",
|
||||
next : "start"
|
||||
},
|
||||
{
|
||||
token : "constant.other",
|
||||
regex : /[^\\\/]+/,
|
||||
next : "start"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.embedRules(DocCommentHighlightRules, "doc-",
|
||||
[ DocCommentHighlightRules.getEndRule("start") ]);
|
||||
};
|
||||
|
||||
oop.inherits(ASLHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.ASLHighlightRules = ASLHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
||||
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||
this._getFoldWidgetBase = this.getFoldWidget;
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) {
|
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||
return "";
|
||||
}
|
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||
|
||||
if (!fw && this.startRegionRe.test(line))
|
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.startRegionRe.test(line))
|
||||
return this.getCommentRegionBlock(session, line, row);
|
||||
|
||||
var match = line.match(this.foldingStartMarker);
|
||||
if (match) {
|
||||
var i = match.index;
|
||||
|
||||
if (match[1])
|
||||
return this.openingBracketBlock(session, match[1], row, i);
|
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||
|
||||
if (range && !range.isMultiLine()) {
|
||||
if (forceMultiline) {
|
||||
range = this.getSectionRange(session, row);
|
||||
} else if (foldStyle != "all")
|
||||
range = null;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
if (foldStyle === "markbegin")
|
||||
return;
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match) {
|
||||
var i = match.index + match[0].length;
|
||||
|
||||
if (match[1])
|
||||
return this.closingBracketBlock(session, match[1], row, i);
|
||||
|
||||
return session.getCommentFoldRange(row, i, -1);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSectionRange = function(session, row) {
|
||||
var line = session.getLine(row);
|
||||
var startIndent = line.search(/\S/);
|
||||
var startRow = row;
|
||||
var startColumn = line.length;
|
||||
row = row + 1;
|
||||
var endRow = row;
|
||||
var maxRow = session.getLength();
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
if (indent === -1)
|
||||
continue;
|
||||
if (startIndent > indent)
|
||||
break;
|
||||
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||
|
||||
if (subRange) {
|
||||
if (subRange.start.row <= startRow) {
|
||||
break;
|
||||
} else if (subRange.isMultiLine()) {
|
||||
row = subRange.end.row;
|
||||
} else if (startIndent == indent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||
};
|
||||
this.getCommentRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m) continue;
|
||||
if (m[1]) depth--;
|
||||
else depth++;
|
||||
|
||||
if (!depth) break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/asl",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/asl_highlight_rules","ace/mode/folding/cstyle"], function (require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var ASLHighlightRules = require("./asl_highlight_rules").ASLHighlightRules;
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function () {
|
||||
this.HighlightRules = ASLHighlightRules;
|
||||
this.foldingRules = new FoldMode();
|
||||
this.$behaviour = this.$defaultBehaviour;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function () {
|
||||
this.$id = "ace/mode/asl";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/asl"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
ace.define("ace/mode/assembly_x86_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var AssemblyX86HighlightRules = function() {
|
||||
|
||||
this.$rules = { start:
|
||||
[ { token: 'keyword.control.assembly',
|
||||
regex: '\\b(?:aaa|aad|aam|aas|adc|add|addpd|addps|addsd|addss|addsubpd|addsubps|aesdec|aesdeclast|aesenc|aesenclast|aesimc|aeskeygenassist|and|andpd|andps|andnpd|andnps|arpl|blendpd|blendps|blendvpd|blendvps|bound|bsf|bsr|bswap|bt|btc|btr|bts|cbw|cwde|cdqe|clc|cld|cflush|clts|cmc|cmov(?:n?e|ge?|ae?|le?|be?|n?o|n?z)|cmp|cmppd|cmpps|cmps|cnpsb|cmpsw|cmpsd|cmpsq|cmpss|cmpxchg|cmpxchg8b|cmpxchg16b|comisd|comiss|cpuid|crc32|cvtdq2pd|cvtdq2ps|cvtpd2dq|cvtpd2pi|cvtpd2ps|cvtpi2pd|cvtpi2ps|cvtps2dq|cvtps2pd|cvtps2pi|cvtsd2si|cvtsd2ss|cvts2sd|cvtsi2ss|cvtss2sd|cvtss2si|cvttpd2dq|cvtpd2pi|cvttps2dq|cvttps2pi|cvttps2dq|cvttps2pi|cvttsd2si|cvttss2si|cwd|cdq|cqo|daa|das|dec|div|divpd|divps|divsd|divss|dppd|dpps|emms|enter|extractps|f2xm1|fabs|fadd|faddp|fiadd|fbld|fbstp|fchs|fclex|fnclex|fcmov(?:n?e|ge?|ae?|le?|be?|n?o|n?z)|fcom|fcmop|fcompp|fcomi|fcomip|fucomi|fucomip|fcos|fdecstp|fdiv|fdivp|fidiv|fdivr|fdivrp|fidivr|ffree|ficom|ficomp|fild|fincstp|finit|fnint|fist|fistp|fisttp|fld|fld1|fldl2t|fldl2e|fldpi|fldlg2|fldln2|fldz|fldcw|fldenv|fmul|fmulp|fimul|fnop|fpatan|fprem|fprem1|fptan|frndint|frstor|fsave|fnsave|fscale|fsin|fsincos|fsqrt|fst|fstp|fstcw|fnstcw|fstenv|fnstenv|fsts|fnstsw|fsub|fsubp|fisub|fsubr|fsubrp|fisubr|ftst|fucom|fucomp|fucompp|fxam|fxch|fxrstor|fxsave|fxtract|fyl2x|fyl2xp1|haddpd|haddps|husbpd|hsubps|idiv|imul|in|inc|ins|insb|insw|insd|insertps|int|into|invd|invplg|invpcid|iret|iretd|iretq|lahf|lar|lddqu|ldmxcsr|lds|les|lfs|lgs|lss|lea|leave|lfence|lgdt|lidt|llgdt|lmsw|lock|lods|lodsb|lodsw|lodsd|lodsq|lsl|ltr|maskmovdqu|maskmovq|maxpd|maxps|maxsd|maxss|mfence|minpd|minps|minsd|minss|monitor|mov|movapd|movaps|movbe|movd|movq|movddup|movdqa|movdqu|movq2q|movhlps|movhpd|movhps|movlhps|movlpd|movlps|movmskpd|movmskps|movntdqa|movntdq|movnti|movntpd|movntps|movntq|movq|movq2dq|movs|movsb|movsw|movsd|movsq|movsd|movshdup|movsldup|movss|movsx|movsxd|movupd|movups|movzx|mpsadbw|mul|mulpd|mulps|mulsd|mulss|mwait|neg|not|or|orpd|orps|out|outs|outsb|outsw|outsd|pabsb|pabsw|pabsd|packsswb|packssdw|packusdw|packuswbpaddb|paddw|paddd|paddq|paddsb|paddsw|paddusb|paddusw|palignr|pand|pandn|pause|pavgb|pavgw|pblendvb|pblendw|pclmulqdq|pcmpeqb|pcmpeqw|pcmpeqd|pcmpeqq|pcmpestri|pcmpestrm|pcmptb|pcmptgw|pcmpgtd|pcmpgtq|pcmpistri|pcmpisrm|pextrb|pextrd|pextrq|pextrw|phaddw|phaddd|phaddsw|phinposuw|phsubw|phsubd|phsubsw|pinsrb|pinsrd|pinsrq|pinsrw|pmaddubsw|pmadddwd|pmaxsb|pmaxsd|pmaxsw|pmaxsw|pmaxub|pmaxud|pmaxuw|pminsb|pminsd|pminsw|pminub|pminud|pminuw|pmovmskb|pmovsx|pmovzx|pmuldq|pmulhrsw|pmulhuw|pmulhw|pmulld|pmullw|pmuludw|pop|popa|popad|popcnt|popf|popfd|popfq|por|prefetch|psadbw|pshufb|pshufd|pshufhw|pshuflw|pshufw|psignb|psignw|psignd|pslldq|psllw|pslld|psllq|psraw|psrad|psrldq|psrlw|psrld|psrlq|psubb|psubw|psubd|psubq|psubsb|psubsw|psubusb|psubusw|test|ptest|punpckhbw|punpckhwd|punpckhdq|punpckhddq|punpcklbw|punpcklwd|punpckldq|punpckldqd|push|pusha|pushad|pushf|pushfd|pxor|prcl|rcr|rol|ror|rcpps|rcpss|rdfsbase|rdgsbase|rdmsr|rdpmc|rdrand|rdtsc|rdtscp|rep|repe|repz|repne|repnz|roundpd|roundps|roundsd|roundss|rsm|rsqrps|rsqrtss|sahf|sal|sar|shl|shr|sbb|scas|scasb|scasw|scasd|set(?:n?e|ge?|ae?|le?|be?|n?o|n?z)|sfence|sgdt|shld|shrd|shufpd|shufps|sidt|sldt|smsw|sqrtpd|sqrtps|sqrtsd|sqrtss|stc|std|stmxcsr|stos|stosb|stosw|stosd|stosq|str|sub|subpd|subps|subsd|subss|swapgs|syscall|sysenter|sysexit|sysret|teset|ucomisd|ucomiss|ud2|unpckhpd|unpckhps|unpcklpd|unpcklps|vbroadcast|vcvtph2ps|vcvtp2sph|verr|verw|vextractf128|vinsertf128|vmaskmov|vpermilpd|vpermilps|vperm2f128|vtestpd|vtestps|vzeroall|vzeroupper|wait|fwait|wbinvd|wrfsbase|wrgsbase|wrmsr|xadd|xchg|xgetbv|xlat|xlatb|xor|xorpd|xorps|xrstor|xsave|xsaveopt|xsetbv|lzcnt|extrq|insertq|movntsd|movntss|vfmaddpd|vfmaddps|vfmaddsd|vfmaddss|vfmaddsubbpd|vfmaddsubps|vfmsubaddpd|vfmsubaddps|vfmsubpd|vfmsubps|vfmsubsd|vfnmaddpd|vfnmaddps|vfnmaddsd|vfnmaddss|vfnmsubpd|vfnmusbps|vfnmusbsd|vfnmusbss|cvt|xor|cli|sti|hlt|nop|lock|wait|enter|leave|ret|loop(?:n?e|n?z)?|call|j(?:mp|n?e|ge?|ae?|le?|be?|n?o|n?z))\\b',
|
||||
caseInsensitive: true },
|
||||
{ token: 'variable.parameter.register.assembly',
|
||||
regex: '\\b(?:CS|DS|ES|FS|GS|SS|RAX|EAX|RBX|EBX|RCX|ECX|RDX|EDX|RCX|RIP|EIP|IP|RSP|ESP|SP|RSI|ESI|SI|RDI|EDI|DI|RFLAGS|EFLAGS|FLAGS|R8-15|(?:Y|X)MM(?:[0-9]|10|11|12|13|14|15)|(?:A|B|C|D)(?:X|H|L)|CR(?:[0-4]|DR(?:[0-7]|TR6|TR7|EFER)))\\b',
|
||||
caseInsensitive: true },
|
||||
{ token: 'constant.character.decimal.assembly',
|
||||
regex: '\\b[0-9]+\\b' },
|
||||
{ token: 'constant.character.hexadecimal.assembly',
|
||||
regex: '\\b0x[A-F0-9]+\\b',
|
||||
caseInsensitive: true },
|
||||
{ token: 'constant.character.hexadecimal.assembly',
|
||||
regex: '\\b[A-F0-9]+h\\b',
|
||||
caseInsensitive: true },
|
||||
{ token: 'string.assembly', regex: /'([^\\']|\\.)*'/ },
|
||||
{ token: 'string.assembly', regex: /"([^\\"]|\\.)*"/ },
|
||||
{ token: 'support.function.directive.assembly',
|
||||
regex: '^\\[',
|
||||
push:
|
||||
[ { token: 'support.function.directive.assembly',
|
||||
regex: '\\]$',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'support.function.directive.assembly' } ] },
|
||||
{ token:
|
||||
[ 'support.function.directive.assembly',
|
||||
'support.function.directive.assembly',
|
||||
'entity.name.function.assembly' ],
|
||||
regex: '(^struc)( )([_a-zA-Z][_a-zA-Z0-9]*)' },
|
||||
{ token: 'support.function.directive.assembly',
|
||||
regex: '^endstruc\\b' },
|
||||
{ token:
|
||||
[ 'support.function.directive.assembly',
|
||||
'entity.name.function.assembly',
|
||||
'support.function.directive.assembly',
|
||||
'constant.character.assembly' ],
|
||||
regex: '^(%macro )([_a-zA-Z][_a-zA-Z0-9]*)( )([0-9]+)' },
|
||||
{ token: 'support.function.directive.assembly',
|
||||
regex: '^%endmacro' },
|
||||
{ token:
|
||||
[ 'text',
|
||||
'support.function.directive.assembly',
|
||||
'text',
|
||||
'entity.name.function.assembly' ],
|
||||
regex: '(\\s*)(%define|%xdefine|%idefine|%undef|%assign|%defstr|%strcat|%strlen|%substr|%00|%0|%rotate|%rep|%endrep|%include|\\$\\$|\\$|%unmacro|%if|%elif|%else|%endif|%(?:el)?ifdef|%(?:el)?ifmacro|%(?:el)?ifctx|%(?:el)?ifidn|%(?:el)?ifidni|%(?:el)?ifid|%(?:el)?ifnum|%(?:el)?ifstr|%(?:el)?iftoken|%(?:el)?ifempty|%(?:el)?ifenv|%pathsearch|%depend|%use|%push|%pop|%repl|%arg|%stacksize|%local|%error|%warning|%fatal|%line|%!|%comment|%endcomment|__NASM_VERSION_ID__|__NASM_VER__|__FILE__|__LINE__|__BITS__|__OUTPUT_FORMAT__|__DATE__|__TIME__|__DATE_NUM__|_TIME__NUM__|__UTC_DATE__|__UTC_TIME__|__UTC_DATE_NUM__|__UTC_TIME_NUM__|__POSIX_TIME__|__PASS__|ISTRUC|AT|IEND|BITS 16|BITS 32|BITS 64|USE16|USE32|__SECT__|ABSOLUTE|EXTERN|GLOBAL|COMMON|CPU|FLOAT)\\b( ?)((?:[_a-zA-Z][_a-zA-Z0-9]*)?)',
|
||||
caseInsensitive: true },
|
||||
{ token: 'support.function.directive.assembly',
|
||||
regex: '\\b(?:d[bwdqtoy]|res[bwdqto]|equ|times|align|alignb|sectalign|section|ptr|byte|word|dword|qword|incbin)\\b',
|
||||
caseInsensitive: true },
|
||||
{ token: 'entity.name.function.assembly', regex: '^\\s*%%[\\w.]+?:$' },
|
||||
{ token: 'entity.name.function.assembly', regex: '^\\s*%\\$[\\w.]+?:$' },
|
||||
{ token: 'entity.name.function.assembly', regex: '^[\\w.]+?:' },
|
||||
{ token: 'entity.name.function.assembly', regex: '^[\\w.]+?\\b' },
|
||||
{ token: 'comment.assembly', regex: ';.*$' } ]
|
||||
};
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
AssemblyX86HighlightRules.metaData = { fileTypes: [ 'asm' ],
|
||||
name: 'Assembly x86',
|
||||
scopeName: 'source.assembly' };
|
||||
|
||||
|
||||
oop.inherits(AssemblyX86HighlightRules, TextHighlightRules);
|
||||
|
||||
exports.AssemblyX86HighlightRules = AssemblyX86HighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
var Range = require("../../range").Range;
|
||||
|
||||
var FoldMode = exports.FoldMode = function() {};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||
var range = this.indentationBlock(session, row);
|
||||
if (range)
|
||||
return range;
|
||||
|
||||
var re = /\S/;
|
||||
var line = session.getLine(row);
|
||||
var startLevel = line.search(re);
|
||||
if (startLevel == -1 || line[startLevel] != "#")
|
||||
return;
|
||||
|
||||
var startColumn = line.length;
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
var endRow = row;
|
||||
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var level = line.search(re);
|
||||
|
||||
if (level == -1)
|
||||
continue;
|
||||
|
||||
if (line[level] != "#")
|
||||
break;
|
||||
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
if (endRow > startRow) {
|
||||
var endColumn = session.getLine(endRow).length;
|
||||
return new Range(startRow, startColumn, endRow, endColumn);
|
||||
}
|
||||
};
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
var next = session.getLine(row + 1);
|
||||
var prev = session.getLine(row - 1);
|
||||
var prevIndent = prev.search(/\S/);
|
||||
var nextIndent = next.search(/\S/);
|
||||
|
||||
if (indent == -1) {
|
||||
session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
|
||||
return "";
|
||||
}
|
||||
if (prevIndent == -1) {
|
||||
if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
|
||||
session.foldWidgets[row - 1] = "";
|
||||
session.foldWidgets[row + 1] = "";
|
||||
return "start";
|
||||
}
|
||||
} else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
|
||||
if (session.getLine(row - 2).search(/\S/) == -1) {
|
||||
session.foldWidgets[row - 1] = "start";
|
||||
session.foldWidgets[row + 1] = "";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
if (prevIndent!= -1 && prevIndent < indent)
|
||||
session.foldWidgets[row - 1] = "start";
|
||||
else
|
||||
session.foldWidgets[row - 1] = "";
|
||||
|
||||
if (indent < nextIndent)
|
||||
return "start";
|
||||
else
|
||||
return "";
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/assembly_x86",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/assembly_x86_highlight_rules","ace/mode/folding/coffee"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var AssemblyX86HighlightRules = require("./assembly_x86_highlight_rules").AssemblyX86HighlightRules;
|
||||
var FoldMode = require("./folding/coffee").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = AssemblyX86HighlightRules;
|
||||
this.foldingRules = new FoldMode();
|
||||
this.$behaviour = this.$defaultBehaviour;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = [";"];
|
||||
this.$id = "ace/mode/assembly_x86";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/assembly_x86"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,230 @@
|
||||
ace.define("ace/mode/batchfile_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var BatchFileHighlightRules = function() {
|
||||
|
||||
this.$rules = { start:
|
||||
[ { token: 'keyword.command.dosbatch',
|
||||
regex: '\\b(?:append|assoc|at|attrib|break|cacls|cd|chcp|chdir|chkdsk|chkntfs|cls|cmd|color|comp|compact|convert|copy|date|del|dir|diskcomp|diskcopy|doskey|echo|endlocal|erase|fc|find|findstr|format|ftype|graftabl|help|keyb|label|md|mkdir|mode|more|move|path|pause|popd|print|prompt|pushd|rd|recover|ren|rename|replace|restore|rmdir|set|setlocal|shift|sort|start|subst|time|title|tree|type|ver|verify|vol|xcopy)\\b',
|
||||
caseInsensitive: true },
|
||||
{ token: 'keyword.control.statement.dosbatch',
|
||||
regex: '\\b(?:goto|call|exit)\\b',
|
||||
caseInsensitive: true },
|
||||
{ token: 'keyword.control.conditional.if.dosbatch',
|
||||
regex: '\\bif\\s+not\\s+(?:exist|defined|errorlevel|cmdextversion)\\b',
|
||||
caseInsensitive: true },
|
||||
{ token: 'keyword.control.conditional.dosbatch',
|
||||
regex: '\\b(?:if|else)\\b',
|
||||
caseInsensitive: true },
|
||||
{ token: 'keyword.control.repeat.dosbatch',
|
||||
regex: '\\bfor\\b',
|
||||
caseInsensitive: true },
|
||||
{ token: 'keyword.operator.dosbatch',
|
||||
regex: '\\b(?:EQU|NEQ|LSS|LEQ|GTR|GEQ)\\b' },
|
||||
{ token: ['doc.comment', 'comment'],
|
||||
regex: '(?:^|\\b)(rem)($|\\s.*$)',
|
||||
caseInsensitive: true },
|
||||
{ token: 'comment.line.colons.dosbatch',
|
||||
regex: '::.*$' },
|
||||
{ include: 'variable' },
|
||||
{ token: 'punctuation.definition.string.begin.shell',
|
||||
regex: '"',
|
||||
push: [
|
||||
{ token: 'punctuation.definition.string.end.shell', regex: '"', next: 'pop' },
|
||||
{ include: 'variable' },
|
||||
{ defaultToken: 'string.quoted.double.dosbatch' } ] },
|
||||
{ token: 'keyword.operator.pipe.dosbatch', regex: '[|]' },
|
||||
{ token: 'keyword.operator.redirect.shell',
|
||||
regex: '&>|\\d*>&\\d*|\\d*(?:>>|>|<)|\\d*<&|\\d*<>' } ],
|
||||
variable: [
|
||||
{ token: 'constant.numeric', regex: '%%\\w+|%[*\\d]|%\\w+%'},
|
||||
{ token: 'constant.numeric', regex: '%~\\d+'},
|
||||
{ token: ['markup.list', 'constant.other', 'markup.list'],
|
||||
regex: '(%)(\\w+)(%?)' }]};
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
BatchFileHighlightRules.metaData = { name: 'Batch File',
|
||||
scopeName: 'source.dosbatch',
|
||||
fileTypes: [ 'bat' ] };
|
||||
|
||||
|
||||
oop.inherits(BatchFileHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.BatchFileHighlightRules = BatchFileHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
||||
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||
this._getFoldWidgetBase = this.getFoldWidget;
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) {
|
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||
return "";
|
||||
}
|
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||
|
||||
if (!fw && this.startRegionRe.test(line))
|
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.startRegionRe.test(line))
|
||||
return this.getCommentRegionBlock(session, line, row);
|
||||
|
||||
var match = line.match(this.foldingStartMarker);
|
||||
if (match) {
|
||||
var i = match.index;
|
||||
|
||||
if (match[1])
|
||||
return this.openingBracketBlock(session, match[1], row, i);
|
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||
|
||||
if (range && !range.isMultiLine()) {
|
||||
if (forceMultiline) {
|
||||
range = this.getSectionRange(session, row);
|
||||
} else if (foldStyle != "all")
|
||||
range = null;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
if (foldStyle === "markbegin")
|
||||
return;
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match) {
|
||||
var i = match.index + match[0].length;
|
||||
|
||||
if (match[1])
|
||||
return this.closingBracketBlock(session, match[1], row, i);
|
||||
|
||||
return session.getCommentFoldRange(row, i, -1);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSectionRange = function(session, row) {
|
||||
var line = session.getLine(row);
|
||||
var startIndent = line.search(/\S/);
|
||||
var startRow = row;
|
||||
var startColumn = line.length;
|
||||
row = row + 1;
|
||||
var endRow = row;
|
||||
var maxRow = session.getLength();
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
if (indent === -1)
|
||||
continue;
|
||||
if (startIndent > indent)
|
||||
break;
|
||||
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||
|
||||
if (subRange) {
|
||||
if (subRange.start.row <= startRow) {
|
||||
break;
|
||||
} else if (subRange.isMultiLine()) {
|
||||
row = subRange.end.row;
|
||||
} else if (startIndent == indent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||
};
|
||||
this.getCommentRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m) continue;
|
||||
if (m[1]) depth--;
|
||||
else depth++;
|
||||
|
||||
if (!depth) break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/batchfile",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/batchfile_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var BatchFileHighlightRules = require("./batchfile_highlight_rules").BatchFileHighlightRules;
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = BatchFileHighlightRules;
|
||||
this.foldingRules = new FoldMode();
|
||||
this.$behaviour = this.$defaultBehaviour;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "::";
|
||||
this.blockComment = "";
|
||||
this.$id = "ace/mode/batchfile";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/batchfile"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
ace.define("ace/mode/bro_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var BroHighlightRules = function() {
|
||||
|
||||
this.$rules = {
|
||||
start: [{
|
||||
token: "punctuation.definition.comment.bro",
|
||||
regex: /#/,
|
||||
push: [{
|
||||
token: "comment.line.number-sign.bro",
|
||||
regex: /$/,
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "comment.line.number-sign.bro"
|
||||
}]
|
||||
}, {
|
||||
token: "keyword.control.bro",
|
||||
regex: /\b(?:break|case|continue|else|for|if|return|switch|next|when|timeout|schedule)\b/
|
||||
}, {
|
||||
token: [
|
||||
"meta.function.bro",
|
||||
"meta.function.bro",
|
||||
"storage.type.bro",
|
||||
"meta.function.bro",
|
||||
"entity.name.function.bro",
|
||||
"meta.function.bro"
|
||||
],
|
||||
regex: /^(\s*)(?:function|hook|event)(\s*)(.*)(\s*\()(.*)(\).*$)/
|
||||
}, {
|
||||
token: "storage.type.bro",
|
||||
regex: /\b(?:bool|enum|double|int|count|port|addr|subnet|any|file|interval|time|string|table|vector|set|record|pattern|hook)\b/
|
||||
}, {
|
||||
token: "storage.modifier.bro",
|
||||
regex: /\b(?:global|const|redef|local|&(?:optional|rotate_interval|rotate_size|add_func|del_func|expire_func|expire_create|expire_read|expire_write|persistent|synchronized|encrypt|mergeable|priority|group|type_column|log|error_handler))\b/
|
||||
}, {
|
||||
token: "keyword.operator.bro",
|
||||
regex: /\s*(?:\||&&|(?:>|<|!)=?|==)\s*|\b!?in\b/
|
||||
}, {
|
||||
token: "constant.language.bro",
|
||||
regex: /\b(?:T|F)\b/
|
||||
}, {
|
||||
token: "constant.numeric.bro",
|
||||
regex: /\b(?:0(?:x|X)[0-9a-fA-F]*|(?:[0-9]+\.?[0-9]*|\.[0-9]+)(?:(?:e|E)(?:\+|-)?[0-9]+)?)(?:\/(?:tcp|udp|icmp)|\s*(?:u?sec|min|hr|day)s?)?\b/
|
||||
}, {
|
||||
token: "punctuation.definition.string.begin.bro",
|
||||
regex: /"/,
|
||||
push: [{
|
||||
token: "punctuation.definition.string.end.bro",
|
||||
regex: /"/,
|
||||
next: "pop"
|
||||
}, {
|
||||
include: "#string_escaped_char"
|
||||
}, {
|
||||
include: "#string_placeholder"
|
||||
}, {
|
||||
defaultToken: "string.quoted.double.bro"
|
||||
}]
|
||||
}, {
|
||||
token: "punctuation.definition.string.begin.bro",
|
||||
regex: /\//,
|
||||
push: [{
|
||||
token: "punctuation.definition.string.end.bro",
|
||||
regex: /\//,
|
||||
next: "pop"
|
||||
}, {
|
||||
include: "#string_escaped_char"
|
||||
}, {
|
||||
include: "#string_placeholder"
|
||||
}, {
|
||||
defaultToken: "string.quoted.regex.bro"
|
||||
}]
|
||||
}, {
|
||||
token: [
|
||||
"meta.preprocessor.bro.load",
|
||||
"keyword.other.special-method.bro"
|
||||
],
|
||||
regex: /^(\s*)(\@load(?:-sigs)?)\b/,
|
||||
push: [{
|
||||
token: [],
|
||||
regex: /(?=\#)|$/,
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "meta.preprocessor.bro.load"
|
||||
}]
|
||||
}, {
|
||||
token: [
|
||||
"meta.preprocessor.bro.if",
|
||||
"keyword.other.special-method.bro",
|
||||
"meta.preprocessor.bro.if"
|
||||
],
|
||||
regex: /^(\s*)(\@endif|\@if(?:n?def)?)(.*$)/,
|
||||
push: [{
|
||||
token: [],
|
||||
regex: /$/,
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "meta.preprocessor.bro.if"
|
||||
}]
|
||||
}],
|
||||
"#disabled": [{
|
||||
token: "text",
|
||||
regex: /^\s*\@if(?:n?def)?\b.*$/,
|
||||
push: [{
|
||||
token: "text",
|
||||
regex: /^\s*\@endif\b.*$/,
|
||||
next: "pop"
|
||||
}, {
|
||||
include: "#disabled"
|
||||
}, {
|
||||
include: "#pragma-mark"
|
||||
}],
|
||||
comment: "eat nested preprocessor ifdefs"
|
||||
}],
|
||||
"#preprocessor-rule-other": [{
|
||||
token: [
|
||||
"text",
|
||||
"meta.preprocessor.bro",
|
||||
"meta.preprocessor.bro",
|
||||
"text"
|
||||
],
|
||||
regex: /^(\s*)(@if)((?:n?def)?)\b(.*?)(?:(?=)|$)/,
|
||||
push: [{
|
||||
token: ["text", "meta.preprocessor.bro", "text"],
|
||||
regex: /^(\s*)(@endif)\b(.*$)/,
|
||||
next: "pop"
|
||||
}, {
|
||||
include: "$base"
|
||||
}]
|
||||
}],
|
||||
"#string_escaped_char": [{
|
||||
token: "constant.character.escape.bro",
|
||||
regex: /\\(?:\\|[abefnprtv'"?]|[0-3]\d{,2}|[4-7]\d?|x[a-fA-F0-9]{,2})/
|
||||
}, {
|
||||
token: "invalid.illegal.unknown-escape.bro",
|
||||
regex: /\\./
|
||||
}],
|
||||
"#string_placeholder": [{
|
||||
token: "constant.other.placeholder.bro",
|
||||
regex: /%(?:\d+\$)?[#0\- +']*[,;:_]?(?:-?\d+|\*(?:-?\d+\$)?)?(?:\.(?:-?\d+|\*(?:-?\d+\$)?)?)?(?:hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)?[diouxXDOUeEfFgGaACcSspn%]/
|
||||
}, {
|
||||
token: "invalid.illegal.placeholder.bro",
|
||||
regex: /%/
|
||||
}]
|
||||
};
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
BroHighlightRules.metaData = {
|
||||
fileTypes: ["bro"],
|
||||
foldingStartMarker: "^(\\@if(n?def)?)",
|
||||
foldingStopMarker: "^\\@endif",
|
||||
keyEquivalent: "@B",
|
||||
name: "Bro",
|
||||
scopeName: "source.bro"
|
||||
};
|
||||
|
||||
|
||||
oop.inherits(BroHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.BroHighlightRules = BroHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
||||
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||
this._getFoldWidgetBase = this.getFoldWidget;
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) {
|
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||
return "";
|
||||
}
|
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||
|
||||
if (!fw && this.startRegionRe.test(line))
|
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.startRegionRe.test(line))
|
||||
return this.getCommentRegionBlock(session, line, row);
|
||||
|
||||
var match = line.match(this.foldingStartMarker);
|
||||
if (match) {
|
||||
var i = match.index;
|
||||
|
||||
if (match[1])
|
||||
return this.openingBracketBlock(session, match[1], row, i);
|
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||
|
||||
if (range && !range.isMultiLine()) {
|
||||
if (forceMultiline) {
|
||||
range = this.getSectionRange(session, row);
|
||||
} else if (foldStyle != "all")
|
||||
range = null;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
if (foldStyle === "markbegin")
|
||||
return;
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match) {
|
||||
var i = match.index + match[0].length;
|
||||
|
||||
if (match[1])
|
||||
return this.closingBracketBlock(session, match[1], row, i);
|
||||
|
||||
return session.getCommentFoldRange(row, i, -1);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSectionRange = function(session, row) {
|
||||
var line = session.getLine(row);
|
||||
var startIndent = line.search(/\S/);
|
||||
var startRow = row;
|
||||
var startColumn = line.length;
|
||||
row = row + 1;
|
||||
var endRow = row;
|
||||
var maxRow = session.getLength();
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
if (indent === -1)
|
||||
continue;
|
||||
if (startIndent > indent)
|
||||
break;
|
||||
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||
|
||||
if (subRange) {
|
||||
if (subRange.start.row <= startRow) {
|
||||
break;
|
||||
} else if (subRange.isMultiLine()) {
|
||||
row = subRange.end.row;
|
||||
} else if (startIndent == indent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||
};
|
||||
this.getCommentRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m) continue;
|
||||
if (m[1]) depth--;
|
||||
else depth++;
|
||||
|
||||
if (!depth) break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/bro",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/bro_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var BroHighlightRules = require("./bro_highlight_rules").BroHighlightRules;
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = BroHighlightRules;
|
||||
this.foldingRules = new FoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.$id = "ace/mode/bro";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/bro"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
ace.define("ace/mode/c9search_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
function safeCreateRegexp(source, flag) {
|
||||
try {
|
||||
return new RegExp(source, flag);
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
var C9SearchHighlightRules = function() {
|
||||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
tokenNames : ["c9searchresults.constant.numeric", "c9searchresults.text", "c9searchresults.text", "c9searchresults.keyword"],
|
||||
regex : /(^\s+[0-9]+)(:)(\d*\s?)([^\r\n]+)/,
|
||||
onMatch : function(val, state, stack) {
|
||||
var values = this.splitRegex.exec(val);
|
||||
var types = this.tokenNames;
|
||||
var tokens = [{
|
||||
type: types[0],
|
||||
value: values[1]
|
||||
}, {
|
||||
type: types[1],
|
||||
value: values[2]
|
||||
}];
|
||||
|
||||
if (values[3]) {
|
||||
if (values[3] == " ")
|
||||
tokens[1] = { type: types[1], value: values[2] + " " };
|
||||
else
|
||||
tokens.push({ type: types[1], value: values[3] });
|
||||
}
|
||||
var regex = stack[1];
|
||||
var str = values[4];
|
||||
|
||||
var m;
|
||||
var last = 0;
|
||||
if (regex && regex.exec) {
|
||||
regex.lastIndex = 0;
|
||||
while (m = regex.exec(str)) {
|
||||
var skipped = str.substring(last, m.index);
|
||||
last = regex.lastIndex;
|
||||
if (skipped)
|
||||
tokens.push({type: types[2], value: skipped});
|
||||
if (m[0])
|
||||
tokens.push({type: types[3], value: m[0]});
|
||||
else if (!skipped)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (last < str.length)
|
||||
tokens.push({type: types[2], value: str.substr(last)});
|
||||
return tokens;
|
||||
}
|
||||
},
|
||||
{
|
||||
regex : "^Searching for [^\\r\\n]*$",
|
||||
onMatch: function(val, state, stack) {
|
||||
var parts = val.split("\x01");
|
||||
if (parts.length < 3)
|
||||
return "text";
|
||||
|
||||
var options, search;
|
||||
|
||||
var i = 0;
|
||||
var tokens = [{
|
||||
value: parts[i++] + "'",
|
||||
type: "text"
|
||||
}, {
|
||||
value: search = parts[i++],
|
||||
type: "text" // "c9searchresults.keyword"
|
||||
}, {
|
||||
value: "'" + parts[i++],
|
||||
type: "text"
|
||||
}];
|
||||
if (parts[2] !== " in") {
|
||||
tokens.push({
|
||||
value: "'" + parts[i++] + "'",
|
||||
type: "text"
|
||||
}, {
|
||||
value: parts[i++],
|
||||
type: "text"
|
||||
});
|
||||
}
|
||||
tokens.push({
|
||||
value: " " + parts[i++] + " ",
|
||||
type: "text"
|
||||
});
|
||||
if (parts[i+1]) {
|
||||
options = parts[i+1];
|
||||
tokens.push({
|
||||
value: "(" + parts[i+1] + ")",
|
||||
type: "text"
|
||||
});
|
||||
i += 1;
|
||||
} else {
|
||||
i -= 1;
|
||||
}
|
||||
while (i++ < parts.length) {
|
||||
parts[i] && tokens.push({
|
||||
value: parts[i],
|
||||
type: "text"
|
||||
});
|
||||
}
|
||||
|
||||
if (search) {
|
||||
if (!/regex/.test(options))
|
||||
search = lang.escapeRegExp(search);
|
||||
if (/whole/.test(options))
|
||||
search = "\\b" + search + "\\b";
|
||||
}
|
||||
|
||||
var regex = search && safeCreateRegexp(
|
||||
"(" + search + ")",
|
||||
/ sensitive/.test(options) ? "g" : "ig"
|
||||
);
|
||||
if (regex) {
|
||||
stack[0] = state;
|
||||
stack[1] = regex;
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
},
|
||||
{
|
||||
regex : "^(?=Found \\d+ matches)",
|
||||
token : "text",
|
||||
next : "numbers"
|
||||
},
|
||||
{
|
||||
token : "string", // single line
|
||||
regex : "^\\S:?[^:]+",
|
||||
next : "numbers"
|
||||
}
|
||||
],
|
||||
numbers:[{
|
||||
regex : "\\d+",
|
||||
token : "constant.numeric"
|
||||
}, {
|
||||
regex : "$",
|
||||
token : "text",
|
||||
next : "start"
|
||||
}]
|
||||
};
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
oop.inherits(C9SearchHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.C9SearchHighlightRules = C9SearchHighlightRules;
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var Range = require("../range").Range;
|
||||
|
||||
var MatchingBraceOutdent = function() {};
|
||||
|
||||
(function() {
|
||||
|
||||
this.checkOutdent = function(line, input) {
|
||||
if (! /^\s+$/.test(line))
|
||||
return false;
|
||||
|
||||
return /^\s*\}/.test(input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(doc, row) {
|
||||
var line = doc.getLine(row);
|
||||
var match = line.match(/^(\s*\})/);
|
||||
|
||||
if (!match) return 0;
|
||||
|
||||
var column = match[1].length;
|
||||
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
||||
|
||||
if (!openBracePos || openBracePos.row == row) return 0;
|
||||
|
||||
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
||||
doc.replace(new Range(row, 0, row, column-1), indent);
|
||||
};
|
||||
|
||||
this.$getIndent = function(line) {
|
||||
return line.match(/^\s*/)[0];
|
||||
};
|
||||
|
||||
}).call(MatchingBraceOutdent.prototype);
|
||||
|
||||
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/c9search",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function() {};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /^(\S.*:|Searching for.*)$/;
|
||||
this.foldingStopMarker = /^(\s+|Found.*)$/;
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||
var lines = session.doc.getAllLines(row);
|
||||
var line = lines[row];
|
||||
var level1 = /^(Found.*|Searching for.*)$/;
|
||||
var level2 = /^(\S.*:|\s*)$/;
|
||||
var re = level1.test(line) ? level1 : level2;
|
||||
|
||||
var startRow = row;
|
||||
var endRow = row;
|
||||
|
||||
if (this.foldingStartMarker.test(line)) {
|
||||
for (var i = row + 1, l = session.getLength(); i < l; i++) {
|
||||
if (re.test(lines[i]))
|
||||
break;
|
||||
}
|
||||
endRow = i;
|
||||
}
|
||||
else if (this.foldingStopMarker.test(line)) {
|
||||
for (var i = row - 1; i >= 0; i--) {
|
||||
line = lines[i];
|
||||
if (re.test(line))
|
||||
break;
|
||||
}
|
||||
startRow = i;
|
||||
}
|
||||
if (startRow != endRow) {
|
||||
var col = line.length;
|
||||
if (re === level1)
|
||||
col = line.search(/\(Found[^)]+\)$|$/);
|
||||
return new Range(startRow, col, endRow, 0);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/c9search",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/c9search_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/c9search"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var C9SearchHighlightRules = require("./c9search_highlight_rules").C9SearchHighlightRules;
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||
var C9StyleFoldMode = require("./folding/c9search").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = C9SearchHighlightRules;
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.foldingRules = new C9StyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, doc, row) {
|
||||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/c9search";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/c9search"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,503 @@
|
||||
ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var DocCommentHighlightRules = function() {
|
||||
this.$rules = {
|
||||
"start" : [ {
|
||||
token : "comment.doc.tag",
|
||||
regex : "@[\\w\\d_]+" // TODO: fix email addresses
|
||||
},
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{
|
||||
defaultToken : "comment.doc",
|
||||
caseInsensitive: true
|
||||
}]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
|
||||
|
||||
DocCommentHighlightRules.getTagRule = function(start) {
|
||||
return {
|
||||
token : "comment.doc.tag.storage.type",
|
||||
regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
|
||||
};
|
||||
};
|
||||
|
||||
DocCommentHighlightRules.getStartRule = function(start) {
|
||||
return {
|
||||
token : "comment.doc", // doc comment
|
||||
regex : "\\/\\*(?=\\*)",
|
||||
next : start
|
||||
};
|
||||
};
|
||||
|
||||
DocCommentHighlightRules.getEndRule = function (start) {
|
||||
return {
|
||||
token : "comment.doc", // closing comment
|
||||
regex : "\\*\\/",
|
||||
next : start
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
exports.DocCommentHighlightRules = DocCommentHighlightRules;
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/c_cpp_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
var cFunctions = exports.cFunctions = "\\b(?:hypot(?:f|l)?|s(?:scanf|ystem|nprintf|ca(?:nf|lb(?:n(?:f|l)?|ln(?:f|l)?))|i(?:n(?:h(?:f|l)?|f|l)?|gn(?:al|bit))|tr(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(?:jmp|vbuf|locale|buf)|qrt(?:f|l)?|w(?:scanf|printf)|rand)|n(?:e(?:arbyint(?:f|l)?|xt(?:toward(?:f|l)?|after(?:f|l)?))|an(?:f|l)?)|c(?:s(?:in(?:h(?:f|l)?|f|l)?|qrt(?:f|l)?)|cos(?:h(?:f)?|f|l)?|imag(?:f|l)?|t(?:ime|an(?:h(?:f|l)?|f|l)?)|o(?:s(?:h(?:f|l)?|f|l)?|nj(?:f|l)?|pysign(?:f|l)?)|p(?:ow(?:f|l)?|roj(?:f|l)?)|e(?:il(?:f|l)?|xp(?:f|l)?)|l(?:o(?:ck|g(?:f|l)?)|earerr)|a(?:sin(?:h(?:f|l)?|f|l)?|cos(?:h(?:f|l)?|f|l)?|tan(?:h(?:f|l)?|f|l)?|lloc|rg(?:f|l)?|bs(?:f|l)?)|real(?:f|l)?|brt(?:f|l)?)|t(?:ime|o(?:upper|lower)|an(?:h(?:f|l)?|f|l)?|runc(?:f|l)?|gamma(?:f|l)?|mp(?:nam|file))|i(?:s(?:space|n(?:ormal|an)|cntrl|inf|digit|u(?:nordered|pper)|p(?:unct|rint)|finite|w(?:space|c(?:ntrl|type)|digit|upper|p(?:unct|rint)|lower|al(?:num|pha)|graph|xdigit|blank)|l(?:ower|ess(?:equal|greater)?)|al(?:num|pha)|gr(?:eater(?:equal)?|aph)|xdigit|blank)|logb(?:f|l)?|max(?:div|abs))|di(?:v|fftime)|_Exit|unget(?:c|wc)|p(?:ow(?:f|l)?|ut(?:s|c(?:har)?|wc(?:har)?)|error|rintf)|e(?:rf(?:c(?:f|l)?|f|l)?|x(?:it|p(?:2(?:f|l)?|f|l|m1(?:f|l)?)?))|v(?:s(?:scanf|nprintf|canf|printf|w(?:scanf|printf))|printf|f(?:scanf|printf|w(?:scanf|printf))|w(?:scanf|printf)|a_(?:start|copy|end|arg))|qsort|f(?:s(?:canf|e(?:tpos|ek))|close|tell|open|dim(?:f|l)?|p(?:classify|ut(?:s|c|w(?:s|c))|rintf)|e(?:holdexcept|set(?:e(?:nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(?:aiseexcept|ror)|get(?:e(?:nv|xceptflag)|round))|flush|w(?:scanf|ide|printf|rite)|loor(?:f|l)?|abs(?:f|l)?|get(?:s|c|pos|w(?:s|c))|re(?:open|e|ad|xp(?:f|l)?)|m(?:in(?:f|l)?|od(?:f|l)?|a(?:f|l|x(?:f|l)?)?))|l(?:d(?:iv|exp(?:f|l)?)|o(?:ngjmp|cal(?:time|econv)|g(?:1(?:p(?:f|l)?|0(?:f|l)?)|2(?:f|l)?|f|l|b(?:f|l)?)?)|abs|l(?:div|abs|r(?:int(?:f|l)?|ound(?:f|l)?))|r(?:int(?:f|l)?|ound(?:f|l)?)|gamma(?:f|l)?)|w(?:scanf|c(?:s(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?|mbs)|pbrk|ftime|len|r(?:chr|tombs)|xfrm)|to(?:b|mb)|rtomb)|printf|mem(?:set|c(?:hr|py|mp)|move))|a(?:s(?:sert|ctime|in(?:h(?:f|l)?|f|l)?)|cos(?:h(?:f|l)?|f|l)?|t(?:o(?:i|f|l(?:l)?)|exit|an(?:h(?:f|l)?|2(?:f|l)?|f|l)?)|b(?:s|ort))|g(?:et(?:s|c(?:har)?|env|wc(?:har)?)|mtime)|r(?:int(?:f|l)?|ound(?:f|l)?|e(?:name|alloc|wind|m(?:ove|quo(?:f|l)?|ainder(?:f|l)?))|a(?:nd|ise))|b(?:search|towc)|m(?:odf(?:f|l)?|em(?:set|c(?:hr|py|mp)|move)|ktime|alloc|b(?:s(?:init|towcs|rtowcs)|towc|len|r(?:towc|len))))\\b";
|
||||
|
||||
var c_cppHighlightRules = function() {
|
||||
|
||||
var keywordControls = (
|
||||
"break|case|continue|default|do|else|for|goto|if|_Pragma|" +
|
||||
"return|switch|while|catch|operator|try|throw|using"
|
||||
);
|
||||
|
||||
var storageType = (
|
||||
"asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" +
|
||||
"_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" +
|
||||
"class|wchar_t|template|char16_t|char32_t"
|
||||
);
|
||||
|
||||
var storageModifiers = (
|
||||
"const|extern|register|restrict|static|volatile|inline|private|" +
|
||||
"protected|public|friend|explicit|virtual|export|mutable|typename|" +
|
||||
"constexpr|new|delete|alignas|alignof|decltype|noexcept|thread_local"
|
||||
);
|
||||
|
||||
var keywordOperators = (
|
||||
"and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq|" +
|
||||
"const_cast|dynamic_cast|reinterpret_cast|static_cast|sizeof|namespace"
|
||||
);
|
||||
|
||||
var builtinConstants = (
|
||||
"NULL|true|false|TRUE|FALSE|nullptr"
|
||||
);
|
||||
|
||||
var keywordMapper = this.$keywords = this.createKeywordMapper({
|
||||
"keyword.control" : keywordControls,
|
||||
"storage.type" : storageType,
|
||||
"storage.modifier" : storageModifiers,
|
||||
"keyword.operator" : keywordOperators,
|
||||
"variable.language": "this",
|
||||
"constant.language": builtinConstants
|
||||
}, "identifier");
|
||||
|
||||
var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
|
||||
var escapeRe = /\\(?:['"?\\abfnrtv]|[0-7]{1,3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}U[a-fA-F\d]{8}|.)/.source;
|
||||
var formatRe = "%"
|
||||
+ /(\d+\$)?/.source // field (argument #)
|
||||
+ /[#0\- +']*/.source // flags
|
||||
+ /[,;:_]?/.source // separator character (AltiVec)
|
||||
+ /((-?\d+)|\*(-?\d+\$)?)?/.source // minimum field width
|
||||
+ /(\.((-?\d+)|\*(-?\d+\$)?)?)?/.source // precision
|
||||
+ /(hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)?/.source // length modifier
|
||||
+ /(\[[^"\]]+\]|[diouxXDOUeEfFgGaACcSspn%])/.source; // conversion type
|
||||
|
||||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
token : "comment",
|
||||
regex : "//$",
|
||||
next : "start"
|
||||
}, {
|
||||
token : "comment",
|
||||
regex : "//",
|
||||
next : "singleLineComment"
|
||||
},
|
||||
DocCommentHighlightRules.getStartRule("doc-start"),
|
||||
{
|
||||
token : "comment", // multi line comment
|
||||
regex : "\\/\\*",
|
||||
next : "comment"
|
||||
}, {
|
||||
token : "string", // character
|
||||
regex : "'(?:" + escapeRe + "|.)?'"
|
||||
}, {
|
||||
token : "string.start",
|
||||
regex : '"',
|
||||
stateName: "qqstring",
|
||||
next: [
|
||||
{ token: "string", regex: /\\\s*$/, next: "qqstring" },
|
||||
{ token: "constant.language.escape", regex: escapeRe },
|
||||
{ token: "constant.language.escape", regex: formatRe },
|
||||
{ token: "string.end", regex: '"|$', next: "start" },
|
||||
{ defaultToken: "string"}
|
||||
]
|
||||
}, {
|
||||
token : "string.start",
|
||||
regex : 'R"\\(',
|
||||
stateName: "rawString",
|
||||
next: [
|
||||
{ token: "string.end", regex: '\\)"', next: "start" },
|
||||
{ defaultToken: "string"}
|
||||
]
|
||||
}, {
|
||||
token : "constant.numeric", // hex
|
||||
regex : "0[xX][0-9a-fA-F]+(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
|
||||
}, {
|
||||
token : "constant.numeric", // float
|
||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
|
||||
}, {
|
||||
token : "keyword", // pre-compiler directives
|
||||
regex : "#\\s*(?:include|import|pragma|line|define|undef)\\b",
|
||||
next : "directive"
|
||||
}, {
|
||||
token : "keyword", // special case pre-compiler directive
|
||||
regex : "#\\s*(?:endif|if|ifdef|else|elif|ifndef)\\b"
|
||||
}, {
|
||||
token : "support.function.C99.c",
|
||||
regex : cFunctions
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : /--|\+\+|<<=|>>=|>>>=|<>|&&|\|\||\?:|[*%\/+\-&\^|~!<>=]=?/
|
||||
}, {
|
||||
token : "punctuation.operator",
|
||||
regex : "\\?|\\:|\\,|\\;|\\."
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : "[[({]"
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : "[\\])}]"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}
|
||||
],
|
||||
"comment" : [
|
||||
{
|
||||
token : "comment", // closing comment
|
||||
regex : "\\*\\/",
|
||||
next : "start"
|
||||
}, {
|
||||
defaultToken : "comment"
|
||||
}
|
||||
],
|
||||
"singleLineComment" : [
|
||||
{
|
||||
token : "comment",
|
||||
regex : /\\$/,
|
||||
next : "singleLineComment"
|
||||
}, {
|
||||
token : "comment",
|
||||
regex : /$/,
|
||||
next : "start"
|
||||
}, {
|
||||
defaultToken: "comment"
|
||||
}
|
||||
],
|
||||
"directive" : [
|
||||
{
|
||||
token : "constant.other.multiline",
|
||||
regex : /\\/
|
||||
},
|
||||
{
|
||||
token : "constant.other.multiline",
|
||||
regex : /.*\\/
|
||||
},
|
||||
{
|
||||
token : "constant.other",
|
||||
regex : "\\s*<.+?>",
|
||||
next : "start"
|
||||
},
|
||||
{
|
||||
token : "constant.other", // single line
|
||||
regex : '\\s*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]',
|
||||
next : "start"
|
||||
},
|
||||
{
|
||||
token : "constant.other", // single line
|
||||
regex : "\\s*['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']",
|
||||
next : "start"
|
||||
},
|
||||
{
|
||||
token : "constant.other",
|
||||
regex : /[^\\\/]+/,
|
||||
next : "start"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.embedRules(DocCommentHighlightRules, "doc-",
|
||||
[ DocCommentHighlightRules.getEndRule("start") ]);
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
oop.inherits(c_cppHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.c_cppHighlightRules = c_cppHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var Range = require("../range").Range;
|
||||
|
||||
var MatchingBraceOutdent = function() {};
|
||||
|
||||
(function() {
|
||||
|
||||
this.checkOutdent = function(line, input) {
|
||||
if (! /^\s+$/.test(line))
|
||||
return false;
|
||||
|
||||
return /^\s*\}/.test(input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(doc, row) {
|
||||
var line = doc.getLine(row);
|
||||
var match = line.match(/^(\s*\})/);
|
||||
|
||||
if (!match) return 0;
|
||||
|
||||
var column = match[1].length;
|
||||
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
||||
|
||||
if (!openBracePos || openBracePos.row == row) return 0;
|
||||
|
||||
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
||||
doc.replace(new Range(row, 0, row, column-1), indent);
|
||||
};
|
||||
|
||||
this.$getIndent = function(line) {
|
||||
return line.match(/^\s*/)[0];
|
||||
};
|
||||
|
||||
}).call(MatchingBraceOutdent.prototype);
|
||||
|
||||
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
||||
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||
this._getFoldWidgetBase = this.getFoldWidget;
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) {
|
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||
return "";
|
||||
}
|
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||
|
||||
if (!fw && this.startRegionRe.test(line))
|
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.startRegionRe.test(line))
|
||||
return this.getCommentRegionBlock(session, line, row);
|
||||
|
||||
var match = line.match(this.foldingStartMarker);
|
||||
if (match) {
|
||||
var i = match.index;
|
||||
|
||||
if (match[1])
|
||||
return this.openingBracketBlock(session, match[1], row, i);
|
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||
|
||||
if (range && !range.isMultiLine()) {
|
||||
if (forceMultiline) {
|
||||
range = this.getSectionRange(session, row);
|
||||
} else if (foldStyle != "all")
|
||||
range = null;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
if (foldStyle === "markbegin")
|
||||
return;
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match) {
|
||||
var i = match.index + match[0].length;
|
||||
|
||||
if (match[1])
|
||||
return this.closingBracketBlock(session, match[1], row, i);
|
||||
|
||||
return session.getCommentFoldRange(row, i, -1);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSectionRange = function(session, row) {
|
||||
var line = session.getLine(row);
|
||||
var startIndent = line.search(/\S/);
|
||||
var startRow = row;
|
||||
var startColumn = line.length;
|
||||
row = row + 1;
|
||||
var endRow = row;
|
||||
var maxRow = session.getLength();
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
if (indent === -1)
|
||||
continue;
|
||||
if (startIndent > indent)
|
||||
break;
|
||||
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||
|
||||
if (subRange) {
|
||||
if (subRange.start.row <= startRow) {
|
||||
break;
|
||||
} else if (subRange.isMultiLine()) {
|
||||
row = subRange.end.row;
|
||||
} else if (startIndent == indent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||
};
|
||||
this.getCommentRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m) continue;
|
||||
if (m[1]) depth--;
|
||||
else depth++;
|
||||
|
||||
if (!depth) break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/c_cpp",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/c_cpp_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules;
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||
var Range = require("../range").Range;
|
||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = c_cppHighlightRules;
|
||||
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.lineCommentStart = "//";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
|
||||
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
||||
var tokens = tokenizedLine.tokens;
|
||||
var endState = tokenizedLine.state;
|
||||
|
||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||
return indent;
|
||||
}
|
||||
|
||||
if (state == "start") {
|
||||
var match = line.match(/^.*[\{\(\[]\s*$/);
|
||||
if (match) {
|
||||
indent += tab;
|
||||
}
|
||||
} else if (state == "doc-start") {
|
||||
if (endState == "start") {
|
||||
return "";
|
||||
}
|
||||
var match = line.match(/^\s*(\/?)\*/);
|
||||
if (match) {
|
||||
if (match[1]) {
|
||||
indent += " ";
|
||||
}
|
||||
indent += "* ";
|
||||
}
|
||||
}
|
||||
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, doc, row) {
|
||||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/c_cpp";
|
||||
this.snippetFileId = "ace/snippets/c_cpp";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/c_cpp"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
ace.define("ace/mode/cirru_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
var CirruHighlightRules = function() {
|
||||
this.$rules = {
|
||||
start: [{
|
||||
token: 'constant.numeric',
|
||||
regex: /[\d\.]+/
|
||||
}, {
|
||||
token: 'comment.line.double-dash',
|
||||
regex: /--/,
|
||||
next: 'comment'
|
||||
}, {
|
||||
token: 'storage.modifier',
|
||||
regex: /\(/
|
||||
}, {
|
||||
token: 'storage.modifier',
|
||||
regex: /,/,
|
||||
next: 'line'
|
||||
}, {
|
||||
token: 'support.function',
|
||||
regex: /[^\(\)"\s{}\[\]]+/,
|
||||
next: 'line'
|
||||
}, {
|
||||
token: 'string.quoted.double',
|
||||
regex: /"/,
|
||||
next: 'string'
|
||||
}, {
|
||||
token: 'storage.modifier',
|
||||
regex: /\)/
|
||||
}],
|
||||
comment: [{
|
||||
token: 'comment.line.double-dash',
|
||||
regex: / +[^\n]+/,
|
||||
next: 'start'
|
||||
}],
|
||||
string: [{
|
||||
token: 'string.quoted.double',
|
||||
regex: /"/,
|
||||
next: 'line'
|
||||
}, {
|
||||
token: 'constant.character.escape',
|
||||
regex: /\\/,
|
||||
next: 'escape'
|
||||
}, {
|
||||
token: 'string.quoted.double',
|
||||
regex: /[^\\"]+/
|
||||
}],
|
||||
escape: [{
|
||||
token: 'constant.character.escape',
|
||||
regex: /./,
|
||||
next: 'string'
|
||||
}],
|
||||
line: [{
|
||||
token: 'constant.numeric',
|
||||
regex: /[\d\.]+/
|
||||
}, {
|
||||
token: 'markup.raw',
|
||||
regex: /^\s*/,
|
||||
next: 'start'
|
||||
}, {
|
||||
token: 'storage.modifier',
|
||||
regex: /\$/,
|
||||
next: 'start'
|
||||
}, {
|
||||
token: 'variable.parameter',
|
||||
regex: /[^\(\)"\s{}\[\]]+/
|
||||
}, {
|
||||
token: 'storage.modifier',
|
||||
regex: /\(/,
|
||||
next: 'start'
|
||||
}, {
|
||||
token: 'storage.modifier',
|
||||
regex: /\)/
|
||||
}, {
|
||||
token: 'markup.raw',
|
||||
regex: /^ */,
|
||||
next: 'start'
|
||||
}, {
|
||||
token: 'string.quoted.double',
|
||||
regex: /"/,
|
||||
next: 'string'
|
||||
}]
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
oop.inherits(CirruHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.CirruHighlightRules = CirruHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
var Range = require("../../range").Range;
|
||||
|
||||
var FoldMode = exports.FoldMode = function() {};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||
var range = this.indentationBlock(session, row);
|
||||
if (range)
|
||||
return range;
|
||||
|
||||
var re = /\S/;
|
||||
var line = session.getLine(row);
|
||||
var startLevel = line.search(re);
|
||||
if (startLevel == -1 || line[startLevel] != "#")
|
||||
return;
|
||||
|
||||
var startColumn = line.length;
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
var endRow = row;
|
||||
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var level = line.search(re);
|
||||
|
||||
if (level == -1)
|
||||
continue;
|
||||
|
||||
if (line[level] != "#")
|
||||
break;
|
||||
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
if (endRow > startRow) {
|
||||
var endColumn = session.getLine(endRow).length;
|
||||
return new Range(startRow, startColumn, endRow, endColumn);
|
||||
}
|
||||
};
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
var next = session.getLine(row + 1);
|
||||
var prev = session.getLine(row - 1);
|
||||
var prevIndent = prev.search(/\S/);
|
||||
var nextIndent = next.search(/\S/);
|
||||
|
||||
if (indent == -1) {
|
||||
session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
|
||||
return "";
|
||||
}
|
||||
if (prevIndent == -1) {
|
||||
if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
|
||||
session.foldWidgets[row - 1] = "";
|
||||
session.foldWidgets[row + 1] = "";
|
||||
return "start";
|
||||
}
|
||||
} else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
|
||||
if (session.getLine(row - 2).search(/\S/) == -1) {
|
||||
session.foldWidgets[row - 1] = "start";
|
||||
session.foldWidgets[row + 1] = "";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
if (prevIndent!= -1 && prevIndent < indent)
|
||||
session.foldWidgets[row - 1] = "start";
|
||||
else
|
||||
session.foldWidgets[row - 1] = "";
|
||||
|
||||
if (indent < nextIndent)
|
||||
return "start";
|
||||
else
|
||||
return "";
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/cirru",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/cirru_highlight_rules","ace/mode/folding/coffee"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var CirruHighlightRules = require("./cirru_highlight_rules").CirruHighlightRules;
|
||||
var CoffeeFoldMode = require("./folding/coffee").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = CirruHighlightRules;
|
||||
this.foldingRules = new CoffeeFoldMode();
|
||||
this.$behaviour = this.$defaultBehaviour;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "--";
|
||||
this.$id = "ace/mode/cirru";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/cirru"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
ace.define("ace/mode/clojure_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
|
||||
|
||||
var ClojureHighlightRules = function() {
|
||||
|
||||
var builtinFunctions = (
|
||||
'* *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* ' +
|
||||
'*command-line-args* *compile-files* *compile-path* *e *err* *file* ' +
|
||||
'*flush-on-newline* *in* *macro-meta* *math-context* *ns* *out* ' +
|
||||
'*print-dup* *print-length* *print-level* *print-meta* *print-readably* ' +
|
||||
'*read-eval* *source-path* *use-context-classloader* ' +
|
||||
'*warn-on-reflection* + - -> ->> .. / < <= = ' +
|
||||
'== > > >= >= accessor aclone ' +
|
||||
'add-classpath add-watch agent agent-errors aget alength alias all-ns ' +
|
||||
'alter alter-meta! alter-var-root amap ancestors and apply areduce ' +
|
||||
'array-map aset aset-boolean aset-byte aset-char aset-double aset-float ' +
|
||||
'aset-int aset-long aset-short assert assoc assoc! assoc-in associative? ' +
|
||||
'atom await await-for await1 bases bean bigdec bigint binding bit-and ' +
|
||||
'bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left ' +
|
||||
'bit-shift-right bit-test bit-xor boolean boolean-array booleans ' +
|
||||
'bound-fn bound-fn* butlast byte byte-array bytes cast char char-array ' +
|
||||
'char-escape-string char-name-string char? chars chunk chunk-append ' +
|
||||
'chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? ' +
|
||||
'class class? clear-agent-errors clojure-version coll? comment commute ' +
|
||||
'comp comparator compare compare-and-set! compile complement concat cond ' +
|
||||
'condp conj conj! cons constantly construct-proxy contains? count ' +
|
||||
'counted? create-ns create-struct cycle dec decimal? declare definline ' +
|
||||
'defmacro defmethod defmulti defn defn- defonce defstruct delay delay? ' +
|
||||
'deliver deref derive descendants destructure disj disj! dissoc dissoc! ' +
|
||||
'distinct distinct? doall doc dorun doseq dosync dotimes doto double ' +
|
||||
'double-array doubles drop drop-last drop-while empty empty? ensure ' +
|
||||
'enumeration-seq eval even? every? false? ffirst file-seq filter find ' +
|
||||
'find-doc find-ns find-var first float float-array float? floats flush ' +
|
||||
'fn fn? fnext for force format future future-call future-cancel ' +
|
||||
'future-cancelled? future-done? future? gen-class gen-interface gensym ' +
|
||||
'get get-in get-method get-proxy-class get-thread-bindings get-validator ' +
|
||||
'hash hash-map hash-set identical? identity if-let if-not ifn? import ' +
|
||||
'in-ns inc init-proxy instance? int int-array integer? interleave intern ' +
|
||||
'interpose into into-array ints io! isa? iterate iterator-seq juxt key ' +
|
||||
'keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list ' +
|
||||
'list* list? load load-file load-reader load-string loaded-libs locking ' +
|
||||
'long long-array longs loop macroexpand macroexpand-1 make-array ' +
|
||||
'make-hierarchy map map? mapcat max max-key memfn memoize merge ' +
|
||||
'merge-with meta method-sig methods min min-key mod name namespace neg? ' +
|
||||
'newline next nfirst nil? nnext not not-any? not-empty not-every? not= ' +
|
||||
'ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ' +
|
||||
'ns-refers ns-resolve ns-unalias ns-unmap nth nthnext num number? odd? ' +
|
||||
'or parents partial partition pcalls peek persistent! pmap pop pop! ' +
|
||||
'pop-thread-bindings pos? pr pr-str prefer-method prefers ' +
|
||||
'primitives-classnames print print-ctor print-doc print-dup print-method ' +
|
||||
'print-namespace-doc print-simple print-special-doc print-str printf ' +
|
||||
'println println-str prn prn-str promise proxy proxy-call-with-super ' +
|
||||
'proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot ' +
|
||||
'rand rand-int range ratio? rational? rationalize re-find re-groups ' +
|
||||
're-matcher re-matches re-pattern re-seq read read-line read-string ' +
|
||||
'reduce ref ref-history-count ref-max-history ref-min-history ref-set ' +
|
||||
'refer refer-clojure release-pending-sends rem remove remove-method ' +
|
||||
'remove-ns remove-watch repeat repeatedly replace replicate require ' +
|
||||
'reset! reset-meta! resolve rest resultset-seq reverse reversible? rseq ' +
|
||||
'rsubseq second select-keys send send-off seq seq? seque sequence ' +
|
||||
'sequential? set set-validator! set? short short-array shorts ' +
|
||||
'shutdown-agents slurp some sort sort-by sorted-map sorted-map-by ' +
|
||||
'sorted-set sorted-set-by sorted? special-form-anchor special-symbol? ' +
|
||||
'split-at split-with str stream? string? struct struct-map subs subseq ' +
|
||||
'subvec supers swap! symbol symbol? sync syntax-symbol-anchor take ' +
|
||||
'take-last take-nth take-while test the-ns time to-array to-array-2d ' +
|
||||
'trampoline transient tree-seq true? type unchecked-add unchecked-dec ' +
|
||||
'unchecked-divide unchecked-inc unchecked-multiply unchecked-negate ' +
|
||||
'unchecked-remainder unchecked-subtract underive unquote ' +
|
||||
'unquote-splicing update-in update-proxy use val vals var-get var-set ' +
|
||||
'var? vary-meta vec vector vector? when when-first when-let when-not ' +
|
||||
'while with-bindings with-bindings* with-in-str with-loading-context ' +
|
||||
'with-local-vars with-meta with-open with-out-str with-precision xml-seq ' +
|
||||
'zero? zipmap'
|
||||
);
|
||||
|
||||
var keywords = ('throw try var ' +
|
||||
'def do fn if let loop monitor-enter monitor-exit new quote recur set!'
|
||||
);
|
||||
|
||||
var buildinConstants = ("true false nil");
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"keyword": keywords,
|
||||
"constant.language": buildinConstants,
|
||||
"support.function": builtinFunctions
|
||||
}, "identifier", false, " ");
|
||||
|
||||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
token : "comment",
|
||||
regex : ";.*$"
|
||||
}, {
|
||||
token : "keyword", //parens
|
||||
regex : "[\\(|\\)]"
|
||||
}, {
|
||||
token : "keyword", //lists
|
||||
regex : "[\\'\\(]"
|
||||
}, {
|
||||
token : "keyword", //vectors
|
||||
regex : "[\\[|\\]]"
|
||||
}, {
|
||||
token : "keyword", //sets and maps
|
||||
regex : "[\\{|\\}|\\#\\{|\\#\\}]"
|
||||
}, {
|
||||
token : "keyword", // ampersands
|
||||
regex : '[\\&]'
|
||||
}, {
|
||||
token : "keyword", // metadata
|
||||
regex : '[\\#\\^\\{]'
|
||||
}, {
|
||||
token : "keyword", // anonymous fn syntactic sugar
|
||||
regex : '[\\%]'
|
||||
}, {
|
||||
token : "keyword", // deref reader macro
|
||||
regex : '[@]'
|
||||
}, {
|
||||
token : "constant.numeric", // hex
|
||||
regex : "0[xX][0-9a-fA-F]+\\b"
|
||||
}, {
|
||||
token : "constant.numeric", // float
|
||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||
}, {
|
||||
token : "constant.language",
|
||||
regex : '[!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+||=|!=|<=|>=|<>|<|>|!|&&]'
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$\\-]*\\b"
|
||||
}, {
|
||||
token : "string", // single line
|
||||
regex : '"',
|
||||
next: "string"
|
||||
}, {
|
||||
token : "constant", // symbol
|
||||
regex : /:[^()\[\]{}'"\^%`,;\s]+/
|
||||
}, {
|
||||
token : "string.regexp", //Regular Expressions
|
||||
regex : '/#"(?:\\.|(?:\\")|[^""\n])*"/g'
|
||||
}
|
||||
|
||||
],
|
||||
"string" : [
|
||||
{
|
||||
token : "constant.language.escape",
|
||||
regex : "\\\\.|\\\\$"
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '[^"\\\\]+'
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '"',
|
||||
next : "start"
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(ClojureHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.ClojureHighlightRules = ClojureHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/matching_parens_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var Range = require("../range").Range;
|
||||
|
||||
var MatchingParensOutdent = function() {};
|
||||
|
||||
(function() {
|
||||
|
||||
this.checkOutdent = function(line, input) {
|
||||
if (! /^\s+$/.test(line))
|
||||
return false;
|
||||
|
||||
return /^\s*\)/.test(input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(doc, row) {
|
||||
var line = doc.getLine(row);
|
||||
var match = line.match(/^(\s*\))/);
|
||||
|
||||
if (!match) return 0;
|
||||
|
||||
var column = match[1].length;
|
||||
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
||||
|
||||
if (!openBracePos || openBracePos.row == row) return 0;
|
||||
|
||||
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
||||
doc.replace(new Range(row, 0, row, column-1), indent);
|
||||
};
|
||||
|
||||
this.$getIndent = function(line) {
|
||||
var match = line.match(/^(\s+)/);
|
||||
if (match) {
|
||||
return match[1];
|
||||
}
|
||||
|
||||
return "";
|
||||
};
|
||||
|
||||
}).call(MatchingParensOutdent.prototype);
|
||||
|
||||
exports.MatchingParensOutdent = MatchingParensOutdent;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/clojure",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/clojure_highlight_rules","ace/mode/matching_parens_outdent"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var ClojureHighlightRules = require("./clojure_highlight_rules").ClojureHighlightRules;
|
||||
var MatchingParensOutdent = require("./matching_parens_outdent").MatchingParensOutdent;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = ClojureHighlightRules;
|
||||
this.$outdent = new MatchingParensOutdent();
|
||||
this.$behaviour = this.$defaultBehaviour;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.lineCommentStart = ";";
|
||||
this.minorIndentFunctions = ["defn", "defn-", "defmacro", "def", "deftest", "testing"];
|
||||
|
||||
this.$toIndent = function(str) {
|
||||
return str.split('').map(function(ch) {
|
||||
if (/\s/.exec(ch)) {
|
||||
return ch;
|
||||
} else {
|
||||
return ' ';
|
||||
}
|
||||
}).join('');
|
||||
};
|
||||
|
||||
this.$calculateIndent = function(line, tab) {
|
||||
var baseIndent = this.$getIndent(line);
|
||||
var delta = 0;
|
||||
var isParen, ch;
|
||||
for (var i = line.length - 1; i >= 0; i--) {
|
||||
ch = line[i];
|
||||
if (ch === '(') {
|
||||
delta--;
|
||||
isParen = true;
|
||||
} else if (ch === '(' || ch === '[' || ch === '{') {
|
||||
delta--;
|
||||
isParen = false;
|
||||
} else if (ch === ')' || ch === ']' || ch === '}') {
|
||||
delta++;
|
||||
}
|
||||
if (delta < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (delta < 0 && isParen) {
|
||||
i += 1;
|
||||
var iBefore = i;
|
||||
var fn = '';
|
||||
while (true) {
|
||||
ch = line[i];
|
||||
if (ch === ' ' || ch === '\t') {
|
||||
if(this.minorIndentFunctions.indexOf(fn) !== -1) {
|
||||
return this.$toIndent(line.substring(0, iBefore - 1) + tab);
|
||||
} else {
|
||||
return this.$toIndent(line.substring(0, i + 1));
|
||||
}
|
||||
} else if (ch === undefined) {
|
||||
return this.$toIndent(line.substring(0, iBefore - 1) + tab);
|
||||
}
|
||||
fn += line[i];
|
||||
i++;
|
||||
}
|
||||
} else if(delta < 0 && !isParen) {
|
||||
return this.$toIndent(line.substring(0, i+1));
|
||||
} else if(delta > 0) {
|
||||
baseIndent = baseIndent.substring(0, baseIndent.length - tab.length);
|
||||
return baseIndent;
|
||||
} else {
|
||||
return baseIndent;
|
||||
}
|
||||
};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
return this.$calculateIndent(line, tab);
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, doc, row) {
|
||||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/clojure";
|
||||
this.snippetFileId = "ace/snippets/clojure";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/clojure"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
ace.define("ace/mode/cobol_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var CobolHighlightRules = function() {
|
||||
var keywords = "ACCEPT|MERGE|SUM|ADD||MESSAGE|TABLE|ADVANCING|MODE|TAPE|" +
|
||||
"AFTER|MULTIPLY|TEST|ALL|NEGATIVE|TEXT|ALPHABET|NEXT|THAN|" +
|
||||
"ALSO|NO|THEN|ALTERNATE|NOT|THROUGH|AND|NUMBER|THRU|ANY|OCCURS|" +
|
||||
"TIME|ARE|OF|TO|AREA|OFF|TOP||ASCENDING|OMITTED|TRUE|ASSIGN|ON|TYPE|AT|OPEN|" +
|
||||
"UNIT|AUTHOR|OR|UNTIL|BEFORE|OTHER|UP|BLANK|OUTPUT|USE|BLOCK|PAGE|USING|BOTTOM|" +
|
||||
"PERFORM|VALUE|BY|PIC|VALUES|CALL|PICTURE|WHEN|CANCEL|PLUS|WITH|CD|POINTER|WRITE|" +
|
||||
"CHARACTER|POSITION||ZERO|CLOSE|POSITIVE|ZEROS|COLUMN|PROCEDURE|ZEROES|COMMA|PROGRAM|" +
|
||||
"COMMON|PROGRAM-ID|COMMUNICATION|QUOTE|COMP|RANDOM|COMPUTE|READ|CONTAINS|RECEIVE|CONFIGURATION|" +
|
||||
"RECORD|CONTINUE|REDEFINES|CONTROL|REFERENCE|COPY|REMAINDER|COUNT|REPLACE|DATA|REPORT|DATE|RESERVE|" +
|
||||
"DAY|RESET|DELETE|RETURN|DESTINATION|REWIND|DISABLE|REWRITE|DISPLAY|RIGHT|DIVIDE|RUN|DOWN|SAME|" +
|
||||
"ELSE|SEARCH|ENABLE|SECTION|END|SELECT|ENVIRONMENT|SENTENCE|EQUAL|SET|ERROR|SIGN|EXIT|SEQUENTIAL|" +
|
||||
"EXTERNAL|SIZE|FLASE|SORT|FILE|SOURCE|LENGTH|SPACE|LESS|STANDARD|LIMIT|START|LINE|STOP|LOCK|STRING|LOW-VALUE|SUBTRACT";
|
||||
|
||||
var builtinConstants = (
|
||||
"true|false|null"
|
||||
);
|
||||
|
||||
var builtinFunctions = (
|
||||
"count|min|max|avg|sum|rank|now|coalesce|main"
|
||||
);
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"support.function": builtinFunctions,
|
||||
"keyword": keywords,
|
||||
"constant.language": builtinConstants
|
||||
}, "identifier", true);
|
||||
|
||||
this.$rules = {
|
||||
"start" : [ {
|
||||
token : "comment",
|
||||
regex : "\\*.*$"
|
||||
}, {
|
||||
token : "string", // " string
|
||||
regex : '".*?"'
|
||||
}, {
|
||||
token : "string", // ' string
|
||||
regex : "'.*?'"
|
||||
}, {
|
||||
token : "constant.numeric", // float
|
||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : "[\\(]"
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : "[\\)]"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
} ]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(CobolHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.CobolHighlightRules = CobolHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/cobol",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/cobol_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var CobolHighlightRules = require("./cobol_highlight_rules").CobolHighlightRules;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = CobolHighlightRules;
|
||||
this.$behaviour = this.$defaultBehaviour;
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.lineCommentStart = "*";
|
||||
|
||||
this.$id = "ace/mode/cobol";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/cobol"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,400 @@
|
||||
ace.define("ace/mode/coffee_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
oop.inherits(CoffeeHighlightRules, TextHighlightRules);
|
||||
|
||||
function CoffeeHighlightRules() {
|
||||
var identifier = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*";
|
||||
|
||||
var keywords = (
|
||||
"this|throw|then|try|typeof|super|switch|return|break|by|continue|" +
|
||||
"catch|class|in|instanceof|is|isnt|if|else|extends|for|own|" +
|
||||
"finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|" +
|
||||
"or|on|unless|until|and|yes|yield|export|import|default"
|
||||
);
|
||||
|
||||
var langConstant = (
|
||||
"true|false|null|undefined|NaN|Infinity"
|
||||
);
|
||||
|
||||
var illegal = (
|
||||
"case|const|function|var|void|with|enum|implements|" +
|
||||
"interface|let|package|private|protected|public|static"
|
||||
);
|
||||
|
||||
var supportClass = (
|
||||
"Array|Boolean|Date|Function|Number|Object|RegExp|ReferenceError|String|" +
|
||||
"Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" +
|
||||
"SyntaxError|TypeError|URIError|" +
|
||||
"ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
|
||||
"Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray"
|
||||
);
|
||||
|
||||
var supportFunction = (
|
||||
"Math|JSON|isNaN|isFinite|parseInt|parseFloat|encodeURI|" +
|
||||
"encodeURIComponent|decodeURI|decodeURIComponent|String|"
|
||||
);
|
||||
|
||||
var variableLanguage = (
|
||||
"window|arguments|prototype|document"
|
||||
);
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"keyword": keywords,
|
||||
"constant.language": langConstant,
|
||||
"invalid.illegal": illegal,
|
||||
"language.support.class": supportClass,
|
||||
"language.support.function": supportFunction,
|
||||
"variable.language": variableLanguage
|
||||
}, "identifier");
|
||||
|
||||
var functionRule = {
|
||||
token: ["paren.lparen", "variable.parameter", "paren.rparen", "text", "storage.type"],
|
||||
regex: /(?:(\()((?:"[^")]*?"|'[^')]*?'|\/[^\/)]*?\/|[^()"'\/])*?)(\))(\s*))?([\-=]>)/.source
|
||||
};
|
||||
|
||||
var stringEscape = /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)/;
|
||||
|
||||
this.$rules = {
|
||||
start : [
|
||||
{
|
||||
token : "constant.numeric",
|
||||
regex : "(?:0x[\\da-fA-F]+|(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?)"
|
||||
}, {
|
||||
stateName: "qdoc",
|
||||
token : "string", regex : "'''", next : [
|
||||
{token : "string", regex : "'''", next : "start"},
|
||||
{token : "constant.language.escape", regex : stringEscape},
|
||||
{defaultToken: "string"}
|
||||
]
|
||||
}, {
|
||||
stateName: "qqdoc",
|
||||
token : "string",
|
||||
regex : '"""',
|
||||
next : [
|
||||
{token : "string", regex : '"""', next : "start"},
|
||||
{token : "paren.string", regex : '#{', push : "start"},
|
||||
{token : "constant.language.escape", regex : stringEscape},
|
||||
{defaultToken: "string"}
|
||||
]
|
||||
}, {
|
||||
stateName: "qstring",
|
||||
token : "string", regex : "'", next : [
|
||||
{token : "string", regex : "'", next : "start"},
|
||||
{token : "constant.language.escape", regex : stringEscape},
|
||||
{defaultToken: "string"}
|
||||
]
|
||||
}, {
|
||||
stateName: "qqstring",
|
||||
token : "string.start", regex : '"', next : [
|
||||
{token : "string.end", regex : '"', next : "start"},
|
||||
{token : "paren.string", regex : '#{', push : "start"},
|
||||
{token : "constant.language.escape", regex : stringEscape},
|
||||
{defaultToken: "string"}
|
||||
]
|
||||
}, {
|
||||
stateName: "js",
|
||||
token : "string", regex : "`", next : [
|
||||
{token : "string", regex : "`", next : "start"},
|
||||
{token : "constant.language.escape", regex : stringEscape},
|
||||
{defaultToken: "string"}
|
||||
]
|
||||
}, {
|
||||
regex: "[{}]", onMatch: function(val, state, stack) {
|
||||
this.next = "";
|
||||
if (val == "{" && stack.length) {
|
||||
stack.unshift("start", state);
|
||||
return "paren";
|
||||
}
|
||||
if (val == "}" && stack.length) {
|
||||
stack.shift();
|
||||
this.next = stack.shift() || "";
|
||||
if (this.next.indexOf("string") != -1)
|
||||
return "paren.string";
|
||||
}
|
||||
return "paren";
|
||||
}
|
||||
}, {
|
||||
token : "string.regex",
|
||||
regex : "///",
|
||||
next : "heregex"
|
||||
}, {
|
||||
token : "string.regex",
|
||||
regex : /(?:\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)(?:[imgy]{0,4})(?!\w)/
|
||||
}, {
|
||||
token : "comment",
|
||||
regex : "###(?!#)",
|
||||
next : "comment"
|
||||
}, {
|
||||
token : "comment",
|
||||
regex : "#.*"
|
||||
}, {
|
||||
token : ["punctuation.operator", "text", "identifier"],
|
||||
regex : "(\\.)(\\s*)(" + illegal + ")"
|
||||
}, {
|
||||
token : "punctuation.operator",
|
||||
regex : "\\.{1,3}"
|
||||
}, {
|
||||
token : ["keyword", "text", "language.support.class",
|
||||
"text", "keyword", "text", "language.support.class"],
|
||||
regex : "(class)(\\s+)(" + identifier + ")(?:(\\s+)(extends)(\\s+)(" + identifier + "))?"
|
||||
}, {
|
||||
token : ["entity.name.function", "text", "keyword.operator", "text"].concat(functionRule.token),
|
||||
regex : "(" + identifier + ")(\\s*)([=:])(\\s*)" + functionRule.regex
|
||||
},
|
||||
functionRule,
|
||||
{
|
||||
token : "variable",
|
||||
regex : "@(?:" + identifier + ")?"
|
||||
}, {
|
||||
token: keywordMapper,
|
||||
regex : identifier
|
||||
}, {
|
||||
token : "punctuation.operator",
|
||||
regex : "\\,|\\."
|
||||
}, {
|
||||
token : "storage.type",
|
||||
regex : "[\\-=]>"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "(?:[-+*/%<>&|^!?=]=|>>>=?|\\-\\-|\\+\\+|::|&&=|\\|\\|=|<<=|>>=|\\?\\.|\\.{2,3}|[!*+-=><])"
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : "[({[]"
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : "[\\]})]"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}],
|
||||
|
||||
|
||||
heregex : [{
|
||||
token : "string.regex",
|
||||
regex : '.*?///[imgy]{0,4}',
|
||||
next : "start"
|
||||
}, {
|
||||
token : "comment.regex",
|
||||
regex : "\\s+(?:#.*)?"
|
||||
}, {
|
||||
token : "string.regex",
|
||||
regex : "\\S+"
|
||||
}],
|
||||
|
||||
comment : [{
|
||||
token : "comment",
|
||||
regex : '###',
|
||||
next : "start"
|
||||
}, {
|
||||
defaultToken : "comment"
|
||||
}]
|
||||
};
|
||||
this.normalizeRules();
|
||||
}
|
||||
|
||||
exports.CoffeeHighlightRules = CoffeeHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var Range = require("../range").Range;
|
||||
|
||||
var MatchingBraceOutdent = function() {};
|
||||
|
||||
(function() {
|
||||
|
||||
this.checkOutdent = function(line, input) {
|
||||
if (! /^\s+$/.test(line))
|
||||
return false;
|
||||
|
||||
return /^\s*\}/.test(input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(doc, row) {
|
||||
var line = doc.getLine(row);
|
||||
var match = line.match(/^(\s*\})/);
|
||||
|
||||
if (!match) return 0;
|
||||
|
||||
var column = match[1].length;
|
||||
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
||||
|
||||
if (!openBracePos || openBracePos.row == row) return 0;
|
||||
|
||||
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
||||
doc.replace(new Range(row, 0, row, column-1), indent);
|
||||
};
|
||||
|
||||
this.$getIndent = function(line) {
|
||||
return line.match(/^\s*/)[0];
|
||||
};
|
||||
|
||||
}).call(MatchingBraceOutdent.prototype);
|
||||
|
||||
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
var Range = require("../../range").Range;
|
||||
|
||||
var FoldMode = exports.FoldMode = function() {};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||
var range = this.indentationBlock(session, row);
|
||||
if (range)
|
||||
return range;
|
||||
|
||||
var re = /\S/;
|
||||
var line = session.getLine(row);
|
||||
var startLevel = line.search(re);
|
||||
if (startLevel == -1 || line[startLevel] != "#")
|
||||
return;
|
||||
|
||||
var startColumn = line.length;
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
var endRow = row;
|
||||
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var level = line.search(re);
|
||||
|
||||
if (level == -1)
|
||||
continue;
|
||||
|
||||
if (line[level] != "#")
|
||||
break;
|
||||
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
if (endRow > startRow) {
|
||||
var endColumn = session.getLine(endRow).length;
|
||||
return new Range(startRow, startColumn, endRow, endColumn);
|
||||
}
|
||||
};
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
var next = session.getLine(row + 1);
|
||||
var prev = session.getLine(row - 1);
|
||||
var prevIndent = prev.search(/\S/);
|
||||
var nextIndent = next.search(/\S/);
|
||||
|
||||
if (indent == -1) {
|
||||
session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
|
||||
return "";
|
||||
}
|
||||
if (prevIndent == -1) {
|
||||
if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
|
||||
session.foldWidgets[row - 1] = "";
|
||||
session.foldWidgets[row + 1] = "";
|
||||
return "start";
|
||||
}
|
||||
} else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
|
||||
if (session.getLine(row - 2).search(/\S/) == -1) {
|
||||
session.foldWidgets[row - 1] = "start";
|
||||
session.foldWidgets[row + 1] = "";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
if (prevIndent!= -1 && prevIndent < indent)
|
||||
session.foldWidgets[row - 1] = "start";
|
||||
else
|
||||
session.foldWidgets[row - 1] = "";
|
||||
|
||||
if (indent < nextIndent)
|
||||
return "start";
|
||||
else
|
||||
return "";
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/coffee",["require","exports","module","ace/mode/coffee_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/coffee","ace/range","ace/mode/text","ace/worker/worker_client","ace/lib/oop"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var Rules = require("./coffee_highlight_rules").CoffeeHighlightRules;
|
||||
var Outdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||
var FoldMode = require("./folding/coffee").FoldMode;
|
||||
var Range = require("../range").Range;
|
||||
var TextMode = require("./text").Mode;
|
||||
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
||||
var oop = require("../lib/oop");
|
||||
|
||||
function Mode() {
|
||||
this.HighlightRules = Rules;
|
||||
this.$outdent = new Outdent();
|
||||
this.foldingRules = new FoldMode();
|
||||
}
|
||||
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
var indenter = /(?:[({[=:]|[-=]>|\b(?:else|try|(?:swi|ca)tch(?:\s+[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$|^\s*(else\b\s*)?(?:if|for|while|loop)\b(?!.*\bthen\b)/;
|
||||
|
||||
this.lineCommentStart = "#";
|
||||
this.blockComment = {start: "###", end: "###"};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
|
||||
|
||||
if (!(tokens.length && tokens[tokens.length - 1].type === 'comment') &&
|
||||
state === 'start' && indenter.test(line))
|
||||
indent += tab;
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, doc, row) {
|
||||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
this.createWorker = function(session) {
|
||||
var worker = new WorkerClient(["ace"], "ace/mode/coffee_worker", "Worker");
|
||||
worker.attachToDocument(session.getDocument());
|
||||
|
||||
worker.on("annotate", function(e) {
|
||||
session.setAnnotations(e.data);
|
||||
});
|
||||
|
||||
worker.on("terminate", function() {
|
||||
session.clearAnnotations();
|
||||
});
|
||||
|
||||
return worker;
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/coffee";
|
||||
this.snippetFileId = "ace/snippets/coffee";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/coffee"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,642 @@
|
||||
ace.define("ace/mode/crystal_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function (require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var CrystalHighlightRules = function () {
|
||||
|
||||
var builtinFunctions = (
|
||||
"puts|initialize|previous_def|typeof|as|pointerof|sizeof|instance_sizeof"
|
||||
);
|
||||
|
||||
var keywords = (
|
||||
"if|end|else|elsif|unless|case|when|break|while|next|until|def|return|class|new|getter|setter|property|lib"
|
||||
+ "|fun|do|struct|private|protected|public|module|super|abstract|include|extend|begin|enum|raise|yield|with"
|
||||
+ "|alias|rescue|ensure|macro|uninitialized|union|type|require"
|
||||
);
|
||||
|
||||
var buildinConstants = (
|
||||
"true|TRUE|false|FALSE|nil|NIL|__LINE__|__END_LINE__|__FILE__|__DIR__"
|
||||
);
|
||||
|
||||
var builtinVariables = (
|
||||
"$DEBUG|$defout|$FILENAME|$LOAD_PATH|$SAFE|$stdin|$stdout|$stderr|$VERBOSE|" +
|
||||
"root_url|flash|session|cookies|params|request|response|logger|self"
|
||||
);
|
||||
|
||||
var keywordMapper = this.$keywords = this.createKeywordMapper({
|
||||
"keyword": keywords,
|
||||
"constant.language": buildinConstants,
|
||||
"variable.language": builtinVariables,
|
||||
"support.function": builtinFunctions
|
||||
}, "identifier");
|
||||
|
||||
var hexNumber = "(?:0[xX][\\dA-Fa-f]+)";
|
||||
var decNumber = "(?:[0-9][\\d_]*)";
|
||||
var octNumber = "(?:0o[0-7][0-7]*)";
|
||||
var binNumber = "(?:0[bB][01]+)";
|
||||
var intNumber = "(?:[+-]?)(?:" + hexNumber + "|" + decNumber + "|" + octNumber + "|" + binNumber + ")(?:_?[iIuU](?:8|16|32|64))?\\b";
|
||||
var escapeExpression = /\\(?:[nsrtvfbae'"\\]|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4}|u{[\da-fA-F]{1,6}})/;
|
||||
var extEscapeExspresssion = /\\(?:[nsrtvfbae'"\\]|[0-7]{3}|x[\da-fA-F]{2}|u[\da-fA-F]{4}|u{[\da-fA-F]{1,6}}|u{(:?[\da-fA-F]{2}\s)*[\da-fA-F]{2}})/;
|
||||
|
||||
this.$rules = {
|
||||
"start": [
|
||||
{
|
||||
token: "comment",
|
||||
regex: "#.*$"
|
||||
}, {
|
||||
token: "string.regexp",
|
||||
regex: "[/]",
|
||||
push: [{
|
||||
token: "constant.language.escape",
|
||||
regex: extEscapeExspresssion
|
||||
}, {
|
||||
token: "string.regexp",
|
||||
regex: "[/][imx]*(?=[).,;\\s]|$)",
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "string.regexp"
|
||||
}]
|
||||
},
|
||||
[{
|
||||
regex: "[{}]", onMatch: function (val, state, stack) {
|
||||
this.next = val == "{" ? this.nextState : "";
|
||||
if (val == "{" && stack.length) {
|
||||
stack.unshift("start", state);
|
||||
return "paren.lparen";
|
||||
}
|
||||
if (val == "}" && stack.length) {
|
||||
stack.shift();
|
||||
this.next = stack.shift();
|
||||
if (this.next.indexOf("string") != -1)
|
||||
return "paren.end";
|
||||
}
|
||||
return val == "{" ? "paren.lparen" : "paren.rparen";
|
||||
},
|
||||
nextState: "start"
|
||||
}, {
|
||||
token: "string.start",
|
||||
regex: /"/,
|
||||
push: [{
|
||||
token: "constant.language.escape",
|
||||
regex: extEscapeExspresssion
|
||||
}, {
|
||||
token: "string",
|
||||
regex: /\\#{/
|
||||
}, {
|
||||
token: "paren.start",
|
||||
regex: /#{/,
|
||||
push: "start"
|
||||
}, {
|
||||
token: "string.end",
|
||||
regex: /"/,
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
token: "string.start",
|
||||
regex: /`/,
|
||||
push: [{
|
||||
token: "constant.language.escape",
|
||||
regex: extEscapeExspresssion
|
||||
}, {
|
||||
token: "string",
|
||||
regex: /\\#{/
|
||||
}, {
|
||||
token: "paren.start",
|
||||
regex: /#{/,
|
||||
push: "start"
|
||||
}, {
|
||||
token: "string.end",
|
||||
regex: /`/,
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
stateName: "rpstring",
|
||||
token: "string.start",
|
||||
regex: /%[Qx]?\(/,
|
||||
push: [{
|
||||
token: "constant.language.escape",
|
||||
regex: extEscapeExspresssion
|
||||
}, {
|
||||
token: "string.start",
|
||||
regex: /\(/,
|
||||
push: "rpstring"
|
||||
}, {
|
||||
token: "string.end",
|
||||
regex: /\)/,
|
||||
next: "pop"
|
||||
}, {
|
||||
token: "paren.start",
|
||||
regex: /#{/,
|
||||
push: "start"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
stateName: "spstring",
|
||||
token: "string.start",
|
||||
regex: /%[Qx]?\[/,
|
||||
push: [{
|
||||
token: "constant.language.escape",
|
||||
regex: extEscapeExspresssion
|
||||
}, {
|
||||
token: "string.start",
|
||||
regex: /\[/,
|
||||
push: "spstring"
|
||||
}, {
|
||||
token: "string.end",
|
||||
regex: /]/,
|
||||
next: "pop"
|
||||
}, {
|
||||
token: "paren.start",
|
||||
regex: /#{/,
|
||||
push: "start"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
stateName: "fpstring",
|
||||
token: "string.start",
|
||||
regex: /%[Qx]?{/,
|
||||
push: [{
|
||||
token: "constant.language.escape",
|
||||
regex: extEscapeExspresssion
|
||||
}, {
|
||||
token: "string.start",
|
||||
regex: /{/,
|
||||
push: "fpstring"
|
||||
}, {
|
||||
token: "string.end",
|
||||
regex: /}/,
|
||||
next: "pop"
|
||||
}, {
|
||||
token: "paren.start",
|
||||
regex: /#{/,
|
||||
push: "start"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
stateName: "tpstring",
|
||||
token: "string.start",
|
||||
regex: /%[Qx]?</,
|
||||
push: [{
|
||||
token: "constant.language.escape",
|
||||
regex: extEscapeExspresssion
|
||||
}, {
|
||||
token: "string.start",
|
||||
regex: /</,
|
||||
push: "tpstring"
|
||||
}, {
|
||||
token: "string.end",
|
||||
regex: />/,
|
||||
next: "pop"
|
||||
}, {
|
||||
token: "paren.start",
|
||||
regex: /#{/,
|
||||
push: "start"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
stateName: "ppstring",
|
||||
token: "string.start",
|
||||
regex: /%[Qx]?\|/,
|
||||
push: [{
|
||||
token: "constant.language.escape",
|
||||
regex: extEscapeExspresssion
|
||||
}, {
|
||||
token: "string.end",
|
||||
regex: /\|/,
|
||||
next: "pop"
|
||||
}, {
|
||||
token: "paren.start",
|
||||
regex: /#{/,
|
||||
push: "start"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
stateName: "rpqstring",
|
||||
token: "string.start",
|
||||
regex: /%[qwir]\(/,
|
||||
push: [{
|
||||
token: "string.start",
|
||||
regex: /\(/,
|
||||
push: "rpqstring"
|
||||
}, {
|
||||
token: "string.end",
|
||||
regex: /\)/,
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
stateName: "spqstring",
|
||||
token: "string.start",
|
||||
regex: /%[qwir]\[/,
|
||||
push: [{
|
||||
token: "string.start",
|
||||
regex: /\[/,
|
||||
push: "spqstring"
|
||||
}, {
|
||||
token: "string.end",
|
||||
regex: /]/,
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
stateName: "fpqstring",
|
||||
token: "string.start",
|
||||
regex: /%[qwir]{/,
|
||||
push: [{
|
||||
token: "string.start",
|
||||
regex: /{/,
|
||||
push: "fpqstring"
|
||||
}, {
|
||||
token: "string.end",
|
||||
regex: /}/,
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
stateName: "tpqstring",
|
||||
token: "string.start",
|
||||
regex: /%[qwir]</,
|
||||
push: [{
|
||||
token: "string.start",
|
||||
regex: /</,
|
||||
push: "tpqstring"
|
||||
}, {
|
||||
token: "string.end",
|
||||
regex: />/,
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
stateName: "ppqstring",
|
||||
token: "string.start",
|
||||
regex: /%[qwir]\|/,
|
||||
push: [{
|
||||
token: "string.end",
|
||||
regex: /\|/,
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}, {
|
||||
token: "string.start",
|
||||
regex: /'/,
|
||||
push: [{
|
||||
token: "constant.language.escape",
|
||||
regex: escapeExpression
|
||||
}, {
|
||||
token: "string.end",
|
||||
regex: /'|$/,
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}]
|
||||
}], {
|
||||
token: "text", // namespaces aren't symbols
|
||||
regex: "::"
|
||||
}, {
|
||||
token: "variable.instance", // instance variable
|
||||
regex: "@{1,2}[a-zA-Z_\\d]+"
|
||||
}, {
|
||||
token: "variable.fresh", // fresh variable
|
||||
regex: "%[a-zA-Z_\\d]+"
|
||||
}, {
|
||||
token: "support.class", // class name
|
||||
regex: "[A-Z][a-zA-Z_\\d]+"
|
||||
}, {
|
||||
token: "constant.other.symbol", // symbol
|
||||
regex: "[:](?:(?:===|<=>|\\[]\\?|\\[]=|\\[]|>>|\\*\\*|<<|==|!=|>=|<=|!~|=~|<|\\+|-|\\*|\\/|%|&|\\||\\^|>|!|~)|(?:(?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?))"
|
||||
}, {
|
||||
token: "constant.numeric", // float
|
||||
regex: "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?(?:_?[fF](?:32|64))?\\b"
|
||||
}, {
|
||||
token: "constant.numeric",
|
||||
regex: intNumber
|
||||
}, {
|
||||
token: "constant.other.symbol",
|
||||
regex: ':"',
|
||||
push: [{
|
||||
token: "constant.language.escape",
|
||||
regex: extEscapeExspresssion
|
||||
}, {
|
||||
token: "constant.other.symbol",
|
||||
regex: '"',
|
||||
next: "pop"
|
||||
}, {
|
||||
defaultToken: "constant.other.symbol"
|
||||
}]
|
||||
}, {
|
||||
token: "constant.language.boolean",
|
||||
regex: "(?:true|false)\\b"
|
||||
}, {
|
||||
token: "support.function",
|
||||
regex: "(?:is_a\\?|nil\\?|responds_to\\?|as\\?)"
|
||||
}, {
|
||||
token: keywordMapper,
|
||||
regex: "[a-zA-Z_$][a-zA-Z0-9_$!?]*\\b"
|
||||
}, {
|
||||
token: "variable.system",
|
||||
regex: "\\$\\!|\\$\\?"
|
||||
}, {
|
||||
token: "punctuation.separator.key-value",
|
||||
regex: "=>"
|
||||
}, {
|
||||
stateName: "heredoc",
|
||||
onMatch: function (value, currentState, stack) {
|
||||
var next = "heredoc";
|
||||
var tokens = value.split(this.splitRegex);
|
||||
stack.push(next, tokens[3]);
|
||||
return [
|
||||
{type: "constant", value: tokens[1]},
|
||||
{type: "string", value: tokens[2]},
|
||||
{type: "support.class", value: tokens[3]},
|
||||
{type: "string", value: tokens[4]}
|
||||
];
|
||||
},
|
||||
regex: "(<<-)([']?)([\\w]+)([']?)",
|
||||
rules: {
|
||||
heredoc: [{
|
||||
token: "string",
|
||||
regex: "^ +"
|
||||
}, {
|
||||
onMatch: function (value, currentState, stack) {
|
||||
if (value === stack[1]) {
|
||||
stack.shift();
|
||||
stack.shift();
|
||||
this.next = stack[0] || "start";
|
||||
return "support.class";
|
||||
}
|
||||
this.next = "";
|
||||
return "string";
|
||||
},
|
||||
regex: ".*$",
|
||||
next: "start"
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
regex: "$",
|
||||
token: "empty",
|
||||
next: function (currentState, stack) {
|
||||
if (stack[0] === "heredoc")
|
||||
return stack[0];
|
||||
return currentState;
|
||||
}
|
||||
}, {
|
||||
token: "punctuation.operator",
|
||||
regex: /[.]\s*(?![.])/,
|
||||
push: [{
|
||||
token : "punctuation.operator",
|
||||
regex : /[.]\s*(?![.])/
|
||||
}, {
|
||||
token : "support.function",
|
||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
}, {
|
||||
regex: "",
|
||||
token: "empty",
|
||||
next: "pop"
|
||||
}]
|
||||
}, {
|
||||
token: "keyword.operator",
|
||||
regex: "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|\\?|\\:|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\^|\\|"
|
||||
}, {
|
||||
token: "punctuation.operator",
|
||||
regex: /[?:,;.]/
|
||||
}, {
|
||||
token: "paren.lparen",
|
||||
regex: "[[({]"
|
||||
}, {
|
||||
token: "paren.rparen",
|
||||
regex: "[\\])}]"
|
||||
}, {
|
||||
token: "text",
|
||||
regex: "\\s+"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
oop.inherits(CrystalHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.CrystalHighlightRules = CrystalHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var Range = require("../range").Range;
|
||||
|
||||
var MatchingBraceOutdent = function() {};
|
||||
|
||||
(function() {
|
||||
|
||||
this.checkOutdent = function(line, input) {
|
||||
if (! /^\s+$/.test(line))
|
||||
return false;
|
||||
|
||||
return /^\s*\}/.test(input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(doc, row) {
|
||||
var line = doc.getLine(row);
|
||||
var match = line.match(/^(\s*\})/);
|
||||
|
||||
if (!match) return 0;
|
||||
|
||||
var column = match[1].length;
|
||||
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
||||
|
||||
if (!openBracePos || openBracePos.row == row) return 0;
|
||||
|
||||
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
||||
doc.replace(new Range(row, 0, row, column-1), indent);
|
||||
};
|
||||
|
||||
this.$getIndent = function(line) {
|
||||
return line.match(/^\s*/)[0];
|
||||
};
|
||||
|
||||
}).call(MatchingBraceOutdent.prototype);
|
||||
|
||||
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
var Range = require("../../range").Range;
|
||||
|
||||
var FoldMode = exports.FoldMode = function() {};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||
var range = this.indentationBlock(session, row);
|
||||
if (range)
|
||||
return range;
|
||||
|
||||
var re = /\S/;
|
||||
var line = session.getLine(row);
|
||||
var startLevel = line.search(re);
|
||||
if (startLevel == -1 || line[startLevel] != "#")
|
||||
return;
|
||||
|
||||
var startColumn = line.length;
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
var endRow = row;
|
||||
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var level = line.search(re);
|
||||
|
||||
if (level == -1)
|
||||
continue;
|
||||
|
||||
if (line[level] != "#")
|
||||
break;
|
||||
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
if (endRow > startRow) {
|
||||
var endColumn = session.getLine(endRow).length;
|
||||
return new Range(startRow, startColumn, endRow, endColumn);
|
||||
}
|
||||
};
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
var next = session.getLine(row + 1);
|
||||
var prev = session.getLine(row - 1);
|
||||
var prevIndent = prev.search(/\S/);
|
||||
var nextIndent = next.search(/\S/);
|
||||
|
||||
if (indent == -1) {
|
||||
session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
|
||||
return "";
|
||||
}
|
||||
if (prevIndent == -1) {
|
||||
if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
|
||||
session.foldWidgets[row - 1] = "";
|
||||
session.foldWidgets[row + 1] = "";
|
||||
return "start";
|
||||
}
|
||||
} else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
|
||||
if (session.getLine(row - 2).search(/\S/) == -1) {
|
||||
session.foldWidgets[row - 1] = "start";
|
||||
session.foldWidgets[row + 1] = "";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
if (prevIndent!= -1 && prevIndent < indent)
|
||||
session.foldWidgets[row - 1] = "start";
|
||||
else
|
||||
session.foldWidgets[row - 1] = "";
|
||||
|
||||
if (indent < nextIndent)
|
||||
return "start";
|
||||
else
|
||||
return "";
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/crystal",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/crystal_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/coffee"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var CrystalHighlightRules = require("./crystal_highlight_rules").CrystalHighlightRules;
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||
var Range = require("../range").Range;
|
||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||
var FoldMode = require("./folding/coffee").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = CrystalHighlightRules;
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.foldingRules = new FoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
this.lineCommentStart = "#";
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
|
||||
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
||||
var tokens = tokenizedLine.tokens;
|
||||
|
||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||
return indent;
|
||||
}
|
||||
|
||||
if (state == "start") {
|
||||
var match = line.match(/^.*[\{\(\[]\s*$/);
|
||||
var startingClassOrMethod = line.match(/^\s*(class|def|module)\s.*$/);
|
||||
var startingDoBlock = line.match(/.*do(\s*|\s+\|.*\|\s*)$/);
|
||||
var startingConditional = line.match(/^\s*(if|else|when)\s*/);
|
||||
if (match || startingClassOrMethod || startingDoBlock || startingConditional) {
|
||||
indent += tab;
|
||||
}
|
||||
}
|
||||
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return /^\s+(end|else)$/.test(line + input) || this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, session, row) {
|
||||
var line = session.getLine(row);
|
||||
if (/}/.test(line))
|
||||
return this.$outdent.autoOutdent(session, row);
|
||||
var indent = this.$getIndent(line);
|
||||
var prevLine = session.getLine(row - 1);
|
||||
var prevIndent = this.$getIndent(prevLine);
|
||||
var tab = session.getTabString();
|
||||
if (prevIndent.length <= indent.length) {
|
||||
if (indent.slice(-tab.length) == tab)
|
||||
session.remove(new Range(row, indent.length-tab.length, row, indent.length));
|
||||
}
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/crystal";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/crystal"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,502 @@
|
||||
ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var DocCommentHighlightRules = function() {
|
||||
this.$rules = {
|
||||
"start" : [ {
|
||||
token : "comment.doc.tag",
|
||||
regex : "@[\\w\\d_]+" // TODO: fix email addresses
|
||||
},
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{
|
||||
defaultToken : "comment.doc",
|
||||
caseInsensitive: true
|
||||
}]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
|
||||
|
||||
DocCommentHighlightRules.getTagRule = function(start) {
|
||||
return {
|
||||
token : "comment.doc.tag.storage.type",
|
||||
regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
|
||||
};
|
||||
};
|
||||
|
||||
DocCommentHighlightRules.getStartRule = function(start) {
|
||||
return {
|
||||
token : "comment.doc", // doc comment
|
||||
regex : "\\/\\*(?=\\*)",
|
||||
next : start
|
||||
};
|
||||
};
|
||||
|
||||
DocCommentHighlightRules.getEndRule = function (start) {
|
||||
return {
|
||||
token : "comment.doc", // closing comment
|
||||
regex : "\\*\\/",
|
||||
next : start
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
exports.DocCommentHighlightRules = DocCommentHighlightRules;
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/csharp_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var CSharpHighlightRules = function() {
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"variable.language": "this",
|
||||
"keyword": "abstract|async|await|event|new|struct|as|explicit|null|switch|base|extern|object|this|bool|false|operator|throw|break|finally|out|true|byte|fixed|override|try|case|float|params|typeof|catch|for|private|uint|char|foreach|protected|ulong|checked|goto|public|unchecked|class|if|readonly|unsafe|const|implicit|ref|ushort|continue|in|return|using|decimal|int|sbyte|virtual|default|interface|sealed|volatile|delegate|internal|partial|short|void|do|is|sizeof|while|double|lock|stackalloc|else|long|static|enum|namespace|string|var|dynamic",
|
||||
"constant.language": "null|true|false"
|
||||
}, "identifier");
|
||||
|
||||
this.$rules = {
|
||||
"start" : [
|
||||
{
|
||||
token : "comment",
|
||||
regex : "\\/\\/.*$"
|
||||
},
|
||||
DocCommentHighlightRules.getStartRule("doc-start"),
|
||||
{
|
||||
token : "comment", // multi line comment
|
||||
regex : "\\/\\*",
|
||||
next : "comment"
|
||||
}, {
|
||||
token : "string", // character
|
||||
regex : /'(?:.|\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n]))?'/
|
||||
}, {
|
||||
token : "string", start : '"', end : '"|$', next: [
|
||||
{token: "constant.language.escape", regex: /\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n])/},
|
||||
{token: "invalid", regex: /\\./}
|
||||
]
|
||||
}, {
|
||||
token : "string", start : '@"', end : '"', next:[
|
||||
{token: "constant.language.escape", regex: '""'}
|
||||
]
|
||||
}, {
|
||||
token : "string", start : /\$"/, end : '"|$', next: [
|
||||
{token: "constant.language.escape", regex: /\\(:?$)|{{/},
|
||||
{token: "constant.language.escape", regex: /\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n])/},
|
||||
{token: "invalid", regex: /\\./}
|
||||
]
|
||||
}, {
|
||||
token : "constant.numeric", // hex
|
||||
regex : "0[xX][0-9a-fA-F]+\\b"
|
||||
}, {
|
||||
token : "constant.numeric", // float
|
||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||
}, {
|
||||
token : "constant.language.boolean",
|
||||
regex : "(?:true|false)\\b"
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
|
||||
}, {
|
||||
token : "keyword",
|
||||
regex : "^\\s*#(if|else|elif|endif|define|undef|warning|error|line|region|endregion|pragma)"
|
||||
}, {
|
||||
token : "punctuation.operator",
|
||||
regex : "\\?|\\:|\\,|\\;|\\."
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : "[[({]"
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : "[\\])}]"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}
|
||||
],
|
||||
"comment" : [
|
||||
{
|
||||
token : "comment", // closing comment
|
||||
regex : "\\*\\/",
|
||||
next : "start"
|
||||
}, {
|
||||
defaultToken : "comment"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.embedRules(DocCommentHighlightRules, "doc-",
|
||||
[ DocCommentHighlightRules.getEndRule("start") ]);
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
oop.inherits(CSharpHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.CSharpHighlightRules = CSharpHighlightRules;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var Range = require("../range").Range;
|
||||
|
||||
var MatchingBraceOutdent = function() {};
|
||||
|
||||
(function() {
|
||||
|
||||
this.checkOutdent = function(line, input) {
|
||||
if (! /^\s+$/.test(line))
|
||||
return false;
|
||||
|
||||
return /^\s*\}/.test(input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(doc, row) {
|
||||
var line = doc.getLine(row);
|
||||
var match = line.match(/^(\s*\})/);
|
||||
|
||||
if (!match) return 0;
|
||||
|
||||
var column = match[1].length;
|
||||
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
||||
|
||||
if (!openBracePos || openBracePos.row == row) return 0;
|
||||
|
||||
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
||||
doc.replace(new Range(row, 0, row, column-1), indent);
|
||||
};
|
||||
|
||||
this.$getIndent = function(line) {
|
||||
return line.match(/^\s*/)[0];
|
||||
};
|
||||
|
||||
}).call(MatchingBraceOutdent.prototype);
|
||||
|
||||
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
||||
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||
this._getFoldWidgetBase = this.getFoldWidget;
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) {
|
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||
return "";
|
||||
}
|
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||
|
||||
if (!fw && this.startRegionRe.test(line))
|
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.startRegionRe.test(line))
|
||||
return this.getCommentRegionBlock(session, line, row);
|
||||
|
||||
var match = line.match(this.foldingStartMarker);
|
||||
if (match) {
|
||||
var i = match.index;
|
||||
|
||||
if (match[1])
|
||||
return this.openingBracketBlock(session, match[1], row, i);
|
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||
|
||||
if (range && !range.isMultiLine()) {
|
||||
if (forceMultiline) {
|
||||
range = this.getSectionRange(session, row);
|
||||
} else if (foldStyle != "all")
|
||||
range = null;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
if (foldStyle === "markbegin")
|
||||
return;
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match) {
|
||||
var i = match.index + match[0].length;
|
||||
|
||||
if (match[1])
|
||||
return this.closingBracketBlock(session, match[1], row, i);
|
||||
|
||||
return session.getCommentFoldRange(row, i, -1);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSectionRange = function(session, row) {
|
||||
var line = session.getLine(row);
|
||||
var startIndent = line.search(/\S/);
|
||||
var startRow = row;
|
||||
var startColumn = line.length;
|
||||
row = row + 1;
|
||||
var endRow = row;
|
||||
var maxRow = session.getLength();
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
if (indent === -1)
|
||||
continue;
|
||||
if (startIndent > indent)
|
||||
break;
|
||||
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||
|
||||
if (subRange) {
|
||||
if (subRange.start.row <= startRow) {
|
||||
break;
|
||||
} else if (subRange.isMultiLine()) {
|
||||
row = subRange.end.row;
|
||||
} else if (startIndent == indent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||
};
|
||||
this.getCommentRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m) continue;
|
||||
if (m[1]) depth--;
|
||||
else depth++;
|
||||
|
||||
if (!depth) break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/folding/csharp",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/cstyle"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var CFoldMode = require("./cstyle").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, CFoldMode);
|
||||
|
||||
(function() {
|
||||
this.usingRe = /^\s*using \S/;
|
||||
|
||||
this.getFoldWidgetRangeBase = this.getFoldWidgetRange;
|
||||
this.getFoldWidgetBase = this.getFoldWidget;
|
||||
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var fw = this.getFoldWidgetBase(session, foldStyle, row);
|
||||
if (!fw) {
|
||||
var line = session.getLine(row);
|
||||
if (/^\s*#region\b/.test(line))
|
||||
return "start";
|
||||
var usingRe = this.usingRe;
|
||||
if (usingRe.test(line)) {
|
||||
var prev = session.getLine(row - 1);
|
||||
var next = session.getLine(row + 1);
|
||||
if (!usingRe.test(prev) && usingRe.test(next))
|
||||
return "start";
|
||||
}
|
||||
}
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||
var range = this.getFoldWidgetRangeBase(session, foldStyle, row);
|
||||
if (range)
|
||||
return range;
|
||||
|
||||
var line = session.getLine(row);
|
||||
if (this.usingRe.test(line))
|
||||
return this.getUsingStatementBlock(session, line, row);
|
||||
|
||||
if (/^\s*#region\b/.test(line))
|
||||
return this.getRegionBlock(session, line, row);
|
||||
};
|
||||
|
||||
this.getUsingStatementBlock = function(session, line, row) {
|
||||
var startColumn = line.match(this.usingRe)[0].length - 1;
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
var endRow = row;
|
||||
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
if (/^\s*$/.test(line))
|
||||
continue;
|
||||
if (!this.usingRe.test(line))
|
||||
break;
|
||||
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
if (endRow > startRow) {
|
||||
var endColumn = session.getLine(endRow).length;
|
||||
return new Range(startRow, startColumn, endRow, endColumn);
|
||||
}
|
||||
};
|
||||
|
||||
this.getRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*#(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m)
|
||||
continue;
|
||||
if (m[1])
|
||||
depth--;
|
||||
else
|
||||
depth++;
|
||||
|
||||
if (!depth)
|
||||
break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
ace.define("ace/mode/csharp",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/csharp_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/folding/csharp"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules;
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||
var CStyleFoldMode = require("./folding/csharp").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = CSharpHighlightRules;
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.lineCommentStart = "//";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
|
||||
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
||||
var tokens = tokenizedLine.tokens;
|
||||
|
||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||
return indent;
|
||||
}
|
||||
|
||||
if (state == "start") {
|
||||
var match = line.match(/^.*[\{\(\[]\s*$/);
|
||||
if (match) {
|
||||
indent += tab;
|
||||
}
|
||||
}
|
||||
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, doc, row) {
|
||||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
|
||||
this.createWorker = function(session) {
|
||||
return null;
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/csharp";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
}); (function() {
|
||||
ace.require(["ace/mode/csharp"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user