");
- var all_fields = array_unique(get_all_fields(resultjson).concat(fields))
+ var all_fields = array_unique(get_all_fields(resultjson).concat(fields));
// Create sidebar field list
var fieldstr = '';
@@ -148,10 +148,10 @@ function getPage() {
var field_name = all_fields[index].toString();
var afield = field_alias(field_name) + "_field";
var mode = $.inArray(field_name,window.hashjson.fields) >= 0 ?
- 'selected' : 'unselected'
+ 'selected' : 'unselected';
fieldstr += sidebar_field_string(field_name,mode);
}
- $('#fields ul.unselected').append(fieldstr)
+ $('#fields ul.unselected').append(fieldstr);
// Store list of fields for filter use
window.field_list = $('#fields > ul > li');
@@ -183,7 +183,7 @@ function getPage() {
Date.parse(window.resultjson.kibana.time.to),
100,
window.hashjson.time.user_interval
- )
+ );
if (typeof window.sb == 'undefined') {
sbctl('show',false);
@@ -246,7 +246,7 @@ function getGraph(interval) {
} else {
if(typeof window.segment !== 'undefined')
window['segment'] = undefined;
- try { delete window['segment'] } catch (e) {}
+ try { delete window['segment']; } catch (e) {}
}
}
@@ -309,8 +309,8 @@ function getID() {
type: "GET",
cache: false,
success: function (json) {
- window.resultjson = JSON.parse(json)
- var hit = resultjson.hits.hits[0]
+ window.resultjson = JSON.parse(json);
+ var hit = resultjson.hits.hits[0];
blank_page();
setMeta(1);
@@ -320,14 +320,14 @@ function getID() {
"
Details for log ID: "+hit._id+" in "+hit._index+"
"+str);
}
});
- sbctl('hide',false)
+ sbctl('hide',false);
window.hashjson.id = undefined;
- window.hashjson.index = undefined
- window.hashjson.mode = undefined
+ window.hashjson.index = undefined;
+ window.hashjson.mode = undefined;
try{
delete window.hashjson.id;
- delete window.hashjson.index
- delete window.hashjson.mode
+ delete window.hashjson.index;
+ delete window.hashjson.mode;
}catch(e){}
}
@@ -369,7 +369,7 @@ function getAnalysis() {
Date.parse(window.resultjson.kibana.time.to),
100,
window.hashjson.time.user_interval
- )
+ );
if(resultjson.hits.total == 0) {
setMeta(resultjson.hits.total);
@@ -412,9 +412,9 @@ function getAnalysis() {
$('#logs').html(
title+CreateTableView(termsTable(resultjson),'logs analysis'));
- sbctl('hide',false)
+ sbctl('hide',false);
graphLoading();
- window.hashjson.graphmode = 'count'
+ window.hashjson.graphmode = 'count';
getGraph(window.interval);
// Calculate data for pie chart
@@ -422,19 +422,19 @@ function getAnalysis() {
$.each(resultjson.facets.terms.terms,function(i,term) {
data[i] = { label: term['term'], data: term['count'], color: window.graph_colors[i] };
});
- var remain = data.slice(window.graph_colors.length,data.length)
- var r = 0
+ var remain = data.slice(window.graph_colors.length,data.length);
+ var r = 0;
for (var x in remain) { r += remain[x].data; }
- data = data.slice(0,window.graph_colors.length)
- data.push({ label: "The Rest", data: r, color: '#AAA' })
- pieChart(data,'#piechart')
+ data = data.slice(0,window.graph_colors.length);
+ data.push({ label: "The Rest", data: r, color: '#AAA' });
+ pieChart(data,'#piechart');
break;
case 'score':
if (resultjson.hits.count == resultjson.hits.total) {
var basedon = "all "
- + resultjson.hits.count + ""
+ + resultjson.hits.count + "";
} else {
var basedon = 'the ' +
resultjson.hits.count + ' most recent';
@@ -449,9 +449,9 @@ function getAnalysis() {
' events for your query in your selected timeframe.
';
$('#logs').html(
title+CreateTableView(analysisTable(resultjson),'logs analysis'));
- sbctl('hide',false)
+ sbctl('hide',false);
graphLoading();
- window.hashjson.graphmode = 'count'
+ window.hashjson.graphmode = 'count';
getGraph(window.interval);
break;
case 'trend':
@@ -466,9 +466,9 @@ function getAnalysis() {
' and end of the selected timeframe for your query.
';
$('#logs').html(
title+CreateTableView(analysisTable(resultjson),'logs analysis'));
- sbctl('hide',false)
+ sbctl('hide',false);
graphLoading();
- window.hashjson.graphmode = 'count'
+ window.hashjson.graphmode = 'count';
getGraph(window.interval);
break;
case 'mean':
@@ -487,7 +487,7 @@ function getAnalysis() {
resultjson.facets.stats._type = undefined;
try{
- delete resultjson.facets.stats._type
+ delete resultjson.facets.stats._type;
}catch(e){}
for (var obj in resultjson.facets.stats) {
@@ -498,9 +498,9 @@ function getAnalysis() {
i++;
}
$('#logs').html(title+CreateTableView(tbl,'logs'));
- sbctl('hide',false)
+ sbctl('hide',false);
graphLoading();
- window.hashjson.graphmode = 'mean'
+ window.hashjson.graphmode = 'mean';
getGraph(window.interval);
break;
}
@@ -527,7 +527,7 @@ function analysisTable(resultjson) {
for (var count = 0; count < fields.length; count++) {
metric[fields[count]]=xmlEnt(idv[count]);
}
- var analyze_field = fields.join(' ')
+ var analyze_field = fields.join(' ');
metric['Count'] = object.count;
metric['Percent'] = Math.round(
metric['Count'] / resultjson.hits.count * 10000
@@ -568,13 +568,13 @@ function termsTable(resultjson) {
for (var count = 0; count < fields.length; count++) {
// TODO: This is so wrong, really shouldn't be matching a string here
if (typeof termv[count] === 'undefined' || termv[count] == "null" ) {
- var value = ''
+ var value = '';
} else {
- var value = xmlEnt(termv[count])
+ var value = xmlEnt(termv[count]);
}
metric[fields[count]] = value;
}
- var analyze_field = fields.join(' ')
+ var analyze_field = fields.join(' ');
metric['Count'] = addCommas(object.count);
metric['Percent'] = Math.round(
object.count / resultjson.hits.total * 10000
@@ -617,10 +617,10 @@ function popover_setup() {
$(document).click(function(e) {
if(popover_visible & popover_clickedaway & !$(e.target).is("a.micro"))
{
- $('.popover').remove()
- popover_visible = popover_clickedaway = false
+ $('.popover').remove();
+ popover_visible = popover_clickedaway = false;
} else {
- popover_clickedaway = true
+ popover_clickedaway = true;
}
});
}
@@ -649,11 +649,11 @@ function enable_popovers() {
var field = $(this).attr('data-field');
var objids = get_objids_with_field(window.resultjson,field);
var counts = get_related_fields(window.resultjson,field);
- var str = ''
+ var str = '';
if(counts.length > 0) {
- str = 'Related fields: '
- var i = 0
+ str = 'Related fields: ';
+ var i = 0;
$.each(counts, function(index,value) {
var display = i < related_limit ? 'inline-block' : 'none';
str += "blank' : xmlEnt(value[0]);
- var objids = get_objids_with_field_value(window.resultjson,field,value[0])
+ var objids = get_objids_with_field_value(window.resultjson,field,value[0]);
var field_val = " "+
""+show_val+"";
@@ -722,18 +722,18 @@ function microAnalysisTable (json,field,count) {
i = i+1;
});
return CreateTableView(table,
- 'table table-condensed table-bordered micro',false,['99%','30px','30px'])
+ 'table table-condensed table-bordered micro',false,['99%','30px','30px']);
}
function pageLinks() {
// Pagination
- var perpage = window.resultjson.kibana.per_page
+ var perpage = window.resultjson.kibana.per_page;
var str = "
";
var end = window.hashjson.offset + window.resultjson.hits.hits.length;
if (end < resultjson.hits.total)
{
- //str += " "
- str += "
";
if (window.hashjson.offset - perpage >= 0) {
@@ -751,7 +751,7 @@ function pageLinks() {
// This is very ugly
function blank_page() {
var selectors = ['#graph','#graphheader','#feedlinks','#logs','.pagelinks',
- '#fields','#analyze']
+ '#fields','#analyze'];
for (var selector in selectors) {
$(selectors[selector]).text("");
@@ -853,9 +853,9 @@ function CreateLogTable(objArray, fields, theme, enableHeader) {
}
var id = object._id;
- var alt = i % 2 == 0 ? '' : 'alt'
+ var alt = i % 2 == 0 ? '' : 'alt';
var time = prettyDateString(
- Date.parse(get_field_value(object,'@timestamp')) + tOffset);
+ Date.parse(get_field_value(object,'@timestamp')));
str += '
';
@@ -899,7 +899,7 @@ function details_table(objid,theme) {
var obj = window.resultjson.hits.hits[objid];
//obj_fields = get_object_fields(obj);
- var obj_fields = flatten_json(obj['_source'])
+ var obj_fields = flatten_json(obj['_source']);
var str = "
" +
"
Field
Action
Value
";
@@ -908,7 +908,7 @@ function details_table(objid,theme) {
var i = 1;
for (index in obj_fields) {
- var field = index
+ var field = index;
var field_id = field.replace('@', 'ATSYM');
var value = get_field_value(obj,field);
var buttons = "" + xmlEnt(value) + "" +
@@ -973,13 +973,13 @@ function mSearch(field, value, mode) {
var fields = $.trim(results[2]).split(/\s+/).slice(1);
var values = value.toString().split('||');
var query = '';
- var glue = ''
+ var glue = '';
// TODO: This only works if a query already exists I think?
for (var count = 0;count < fields.length;count++) {
value = values[count];
if (value == "null" || typeof value === "undefined") {
value = fields[count];
- field = '_missing_'
+ field = '_missing_';
} else {
field = fields[count];
}
@@ -1024,7 +1024,7 @@ function mFields(field) {
// Add column
$('#logs').find('tr.logrow').each(function(){
var obj = window.resultjson.hits.hits[$(this).attr('data-object')];
- var value = get_field_value(obj,field)
+ var value = get_field_value(obj,field);
$(this).find('td').last().after(
'
' + xmlEnt(wbr(value, 10)) + '
');
});
@@ -1054,7 +1054,7 @@ function mFields(field) {
$.each(window.resultjson.kibana.default_fields, function(index,field){
$('#logs').find('tr.logrow').each(function(){
var obj = window.resultjson.hits.hits[$(this).attr('data-object')];
- var value = get_field_value(obj,field)
+ var value = get_field_value(obj,field);
$(this).find('td').last().after(
'
' +
xmlEnt(wbr(value, 10)) + '
');
@@ -1084,7 +1084,7 @@ function feedLinks(obj) {
"export " +
" "+
"stream " +
- ""
+ "";
}
$(function () {
@@ -1111,7 +1111,7 @@ $(function () {
window.hashjson.mode = mode;
if (mode == 'columns')
- window.hashjson.fields = field.split(',,')
+ window.hashjson.fields = field.split(',,');
else
window.hashjson.analyze_field = field;
}
@@ -1136,7 +1136,7 @@ function datepickers(from,to) {
hour:60*60*1000,
day:60*60*24*1000
};
- var options = ''
+ var options = '';
$.each(interval_opts,function(i,interval) {
options += '';
@@ -1151,22 +1151,22 @@ function datepickers(from,to) {
"");
- var from_date = utc_date_obj(new Date(from - tOffset))
- var to_date = utc_date_obj(new Date(to - tOffset));
+ var from_date = new Date(from + window.ltOffset);
+ var to_date = new Date(to + window.ltOffset);
$('#timefrom').datetimeEntry({
maxDatetime : to_date,
datetimeFormat: 'Y-O-D H:M:S',
spinnerImage: ''
});
- $('#timefrom').datetimeEntry('setDatetime',from_date)
+ $('#timefrom').datetimeEntry('setDatetime',from_date);
$('#timeto').datetimeEntry({
minDatetime: $('#timefrom').datetimeEntry('getDatetime'),
- maxDatetime: utc_date_obj(new Date()),
+ maxDateTime: new Date(new Date().getTime() + window.ltOffset),
datetimeFormat: 'Y-O-D H:M:S',
spinnerImage: ''
- },to);
- $('#timeto').datetimeEntry('setDatetime',to_date)
+ });
+ $('#timeto').datetimeEntry('setDatetime',to_date);
// LOL Wat? o_from and o_to are globals?! I should be beaten with a hose for
@@ -1174,52 +1174,47 @@ function datepickers(from,to) {
$('#timefrom,#timeto').datepicker({
format: 'yyyy-mm-dd'
}).on('show', function(ev) {
- o_from = local_date_obj(
- new Date($('#timefrom').datetimeEntry('getDatetime').getTime() - tOffset));
- o_to = local_date_obj(
- new Date($('#timeto').datetimeEntry('getDatetime').getTime() - tOffset));
+ o_from = $('#timefrom').datetimeEntry('getDatetime');
+ o_to = $('#timeto').datetimeEntry('getDatetime');
});
}
// Render the date/time picker
// Must make this pretty
function renderDateTimePicker(from, to, force) {
- $('.datepicker').remove()
-
- from = from + tOffset
- to = to + tOffset
+ $('.datepicker').remove();
if (!$('#timechange').length || force == true) {
- datepickers(from,to)
+ datepickers(from,to);
$('#timefrom').datepicker().on('changeDate', function(ev) {
- o_from.setUTCFullYear(ev.date.getFullYear())
- o_from.setUTCMonth(ev.date.getMonth())
- o_from.setUTCDate(ev.date.getDate())
- $('.datepicker').remove()
+ o_from.setFullYear(ev.date.getFullYear());
+ o_from.setMonth(ev.date.getMonth());
+ o_from.setDate(ev.date.getDate());
+ $('.datepicker').remove();
renderDateTimePicker(
- o_from.getTime() + tOffset,
- o_to.getTime() + tOffset,
+ o_from.getTime() - window.ltOffset,
+ o_to.getTime() - window.ltOffset,
true
);
- window.hashjson.timeframe = 'custom'
+ window.hashjson.timeframe = 'custom';
$('#timeinput').val('custom');
- })
+ });
$('#timeto').datepicker().on('changeDate', function(ev) {
- o_to.setUTCFullYear(ev.date.getFullYear())
- o_to.setUTCMonth(ev.date.getMonth())
- o_to.setUTCDate(ev.date.getDate())
- $('.datepicker').remove()
+ o_to.setFullYear(ev.date.getFullYear());
+ o_to.setMonth(ev.date.getMonth());
+ o_to.setDate(ev.date.getDate());
+ $('.datepicker').remove();
renderDateTimePicker(
- o_from.getTime() + tOffset,
- o_to.getTime() + tOffset,
+ o_from.getTime() - window.ltOffset,
+ o_to.getTime() - window.ltOffset,
true
);
- window.hashjson.timeframe = 'custom'
+ window.hashjson.timeframe = 'custom';
$('#timeinput').val('custom');
- })
+ });
$('input.datetimeRange').datetimeEntry({datetimeFormat: 'Y-O-D H:M:S'}).
change(function() {
@@ -1229,7 +1224,7 @@ function renderDateTimePicker(from, to, force) {
});
$('#user_interval').change(function () {
- var interval = $('#user_interval').val()
+ var interval = $('#user_interval').val();
if(typeof window.hashjson.time == 'undefined')
window.hashjson.time = {user_interval:interval};
else
@@ -1265,9 +1260,8 @@ function renderDateTimePicker(from, to, force) {
function field_time(selector) {
var tz_offset = int_to_tz(window.tOffset);
- var str = ISODateString(
- new Date($(selector).datetimeEntry('getDatetime').getTime())
- ) + tz_offset;
+ var str = ISODateString($(selector).datetimeEntry('getDatetime'))
+ + tz_offset;
return str;
}
@@ -1304,26 +1298,24 @@ function logGraph(data, interval, metric) {
if(typeof window.resultjson.kibana.time !== 'undefined') {
// add null value at time from.
if(window.hashjson.timeframe != 'all') {
- from = Date.parse(window.resultjson.kibana.time.from) + tOffset
- array.push(
- Array(from, null));
+ from = Date.parse(window.resultjson.kibana.time.from);
+ array.push(Array(from, null));
}
}
for (var index in data) {
var value = data[index][metric];
- array.push(Array(data[index].time + tOffset, value));
+ array.push(Array(data[index].time, value));
}
if(typeof window.resultjson.kibana.time !== 'undefined') {
// add null value at time to.
- to = Date.parse(window.resultjson.kibana.time.to) + tOffset
- array.push(
- Array(to, null));
+ to = Date.parse(window.resultjson.kibana.time.to);
+ array.push(Array(to, null));
}
from = array[0][0];
- to = array[array.length -1][0]
+ to = array[array.length -1][0];
renderDateTimePicker(from,to,true);
@@ -1336,17 +1328,16 @@ function logGraph(data, interval, metric) {
$('#graph').bind("plotselected", function (event, ranges) {
if (!intset) {
intset = true;
- var from = utc_date_obj(new Date(parseInt(ranges.xaxis.from.toFixed(0))))
- var to = utc_date_obj(new Date(parseInt(ranges.xaxis.to.toFixed(0))))
+ var from = parseInt(ranges.xaxis.from.toFixed(0));
+ var to = parseInt(ranges.xaxis.to.toFixed(0));
var time = {
- "from": ISODateString(from)+int_to_tz(window.tOffset),
- "to": ISODateString(to)+int_to_tz(window.tOffset)
+ "from": ISODateString(from + window.ltOffset)+int_to_tz(window.tOffset),
+ "to": ISODateString(to + window.ltOffset)+int_to_tz(window.tOffset)
};
window.hashjson.offset = 0;
window.hashjson.time = time;
window.hashjson.timeframe = "custom";
setHash(window.hashjson);
-
}
});
@@ -1396,7 +1387,10 @@ function logGraph(data, interval, metric) {
},
xaxis: {
mode: "time",
- timeformat: "%H:%M:%S %m-%d",
+ tickFormatter: function (val, axis) {
+ var d = new Date(parseInt(val) + window.ltOffset);
+ return d.format("HH:MM:ss mm-dd");
+ },
label: "Datetime",
color: "#000"
},
@@ -1473,22 +1467,22 @@ function sbctl(mode,user_selected) {
}
function move_column(field,dir) {
- var x = dir == 'right' ? 1 : -2
- var len = $('#logs thead th').length
+ var x = dir == 'right' ? 1 : -2;
+ var len = $('#logs thead th').length;
if (len == 2)
- return
- var thi = $('#logs th.column[data-field="'+field+'"]').index()
+ return;
+ var thi = $('#logs th.column[data-field="'+field+'"]').index();
- dest = thi+x
+ dest = thi+x;
if (x == -2 && thi == 1)
- dest = len-1
+ dest = len-1;
if (x == 1 && thi == (len-1))
- dest = 0
+ dest = 0;
- var th1 = $('#logs thead th:eq('+thi+')')
- var th2 = $('#logs thead th:eq('+dest+')')
- th1.detach().insertAfter(th2)
+ var th1 = $('#logs thead th:eq('+thi+')');
+ var th2 = $('#logs thead th:eq('+dest+')');
+ th1.detach().insertAfter(th2);
$('#logs tr.logrow').each(function() {
var tr = $(this);
@@ -1500,7 +1494,7 @@ function move_column(field,dir) {
window.hashjson.fields = $('#logs th.column').map(
function(){return $(this).attr("data-field");}
- ).get()
+ ).get();
}
function showError(title,text) {
@@ -1518,7 +1512,7 @@ function showError(title,text) {
Date.parse(window.hashjson.time.to)+tOffset
);
}
- sbctl('hide')
+ sbctl('hide');
}
function getGraphColor(mode) {
@@ -1549,13 +1543,13 @@ function resetAll() {
function highlight_events(objids) {
for (objid in objids) {
- $('#logs tr#logrow_'+objids[objid]).addClass('highlight')
+ $('#logs tr#logrow_'+objids[objid]).addClass('highlight');
}
}
function unhighlight_events(objids) {
for (objid in objids) {
- $('#logs tr#logrow_'+objids[objid]).removeClass('highlight')
+ $('#logs tr#logrow_'+objids[objid]).removeClass('highlight');
}
}
@@ -1567,7 +1561,7 @@ function bind_clicks() {
$('body').delegate("i.shift_column", "click",
function () {
- move_column($(this).parent().attr('data-field'),$(this).attr('data-mode'))
+ move_column($(this).parent().attr('data-field'),$(this).attr('data-mode'));
});
// Side bar expand/collapse
@@ -1591,10 +1585,9 @@ function bind_clicks() {
window.hashjson.timeframe = $(this).val();
if (window.hashjson.timeframe == "custom") {
//Initialize the date picker with a 15 minute window into the past
- var d = new Date()
- var startDate = new Date(d - (15 * 60 * 1000));
- renderDateTimePicker(
- startDate, d);
+ var to = new Date().getTime();
+ var from = to - (15 * 60 * 1000);
+ renderDateTimePicker(from, to);
}
});
@@ -1626,7 +1619,7 @@ function bind_clicks() {
$("#logs").delegate("a.page", "click",
function () {
var per_page = window.resultjson.kibana.per_page;
- var action = $(this).attr('data-action')
+ var action = $(this).attr('data-action');
switch (action) {
case 'nextpage':
window.hashjson.offset += per_page;
@@ -1646,7 +1639,7 @@ function bind_clicks() {
window.hashjson.offset = 0;
var mode = $(this).attr('rel');
var field = $(this).attr('data-field');
- analyzeField(field, mode)
+ analyzeField(field, mode);
});
// Analysis table rescore
diff --git a/public/lib/js/shared.js b/public/lib/js/shared.js
index b29f39681..4ae1dd94f 100644
--- a/public/lib/js/shared.js
+++ b/public/lib/js/shared.js
@@ -1,6 +1,6 @@
function get_object_fields(obj) {
var field_array = [];
- obj = flatten_json(obj._source)
+ obj = flatten_json(obj._source);
for (field in obj) {
field_array.push(field);
}
@@ -39,7 +39,7 @@ function array_unique(arr) {
results.push(sorted_arr[i]);
}
}
- return results
+ return results;
}
function get_objids_with_field(json,field) {
@@ -57,7 +57,7 @@ function get_objids_with_field_value(json,field,value) {
for (hit in json.hits.hits) {
var hit_obj = json.hits.hits[hit];
if(has_field(hit_obj,field)) {
- var field_val = get_field_value(hit_obj,field,'raw')
+ var field_val = get_field_value(hit_obj,field,'raw');
if($.isArray(field_val)) {
if($.inArray(value,field_val) >= 0) {
objid_array.push(hit);
@@ -76,9 +76,9 @@ function get_objids_with_field_value(json,field,value) {
}
function get_related_fields(json,field) {
- var field_array = []
+ var field_array = [];
for (hit in json.hits.hits) {
- var obj_fields = get_object_fields(json.hits.hits[hit])
+ var obj_fields = get_object_fields(json.hits.hits[hit]);
if ($.inArray(field,obj_fields) >= 0) {
field_array.push.apply(field_array,obj_fields);
}
@@ -104,7 +104,7 @@ function get_field_value(object,field,opt) {
var value = recurse_field_dots(object['_source'],field);
if(value === null)
- return ''
+ return '';
if($.isArray(value))
if (opt == 'raw') {
return value;
@@ -115,7 +115,7 @@ function get_field_value(object,field,opt) {
if (typeof(el) == 'object') {
complex = true;
}
- })
+ });
if (complex) {
return JSON.stringify(value, null, 4);
}
@@ -124,7 +124,7 @@ function get_field_value(object,field,opt) {
if(typeof value === 'object' && value != null)
// Leaving this out for now
//return opt == 'raw' ? value : JSON.stringify(value,null,4)
- return JSON.stringify(value,null,4)
+ return JSON.stringify(value,null,4);
return (value != null) ? value.toString() : '';
}
@@ -135,7 +135,7 @@ function get_field_value(object,field,opt) {
function get_all_values_for_field(json,field) {
var field_array = [];
for (hit in json.hits.hits) {
- var value = get_field_value(json.hits.hits[hit],field,'raw')
+ var value = get_field_value(json.hits.hits[hit],field,'raw');
if(typeof value === 'object' && value != null) {
field_array.push.apply(field_array,value);
} else {
@@ -168,14 +168,14 @@ function count_values_in_array(array) {
for (var i = 0; i < tuples.length; i++) {
var key = tuples[i][0];
var value = tuples[i][1];
- count_array.push([key,value])
+ count_array.push([key,value]);
}
return count_array;
}
function top_field_values(json,field,count) {
var result = count_values_in_array(get_all_values_for_field(json,field));
- return result.slice(0,count)
+ return result.slice(0,count);
}
/**
@@ -256,7 +256,7 @@ function ISODateString(d) {
}
function pad(n) {
- return n < 10 ? '0' + n : n
+ return n < 10 ? '0' + n : n;
}
return d.getFullYear() + '-' +
pad(d.getMonth() + 1) + '-' +
@@ -267,25 +267,24 @@ function ISODateString(d) {
}
function pickDateString(d) {
- return dateFormat(d,'yyyy-mm-dd HH:MM:ss')
+ return dateFormat(d,'yyyy-mm-dd HH:MM:ss');
}
function prettyDateString(d) {
- d = new Date(parseInt(d));
- d = utc_date_obj(d);
+ d = new Date(parseInt(d) + window.ltOffset);
return dateFormat(d,window.time_format);
}
function utc_date_obj(d) {
return new Date(
- d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(),
+ d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(),
d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(),
d.getUTCMilliseconds());
}
function local_date_obj(d) {
return new Date(Date.UTC(
- d.getFullYear(), d.getMonth(), d.getDate(),
+ d.getFullYear(), d.getMonth(), d.getDate(),
d.getHours(), d.getMinutes(), d.getSeconds()));
}
@@ -299,17 +298,17 @@ function is_int(value) {
function flatten_json(object,root,array) {
if (typeof array === 'undefined')
- var array = {};
+ array = {};
if (typeof root === 'undefined')
- var root = '';
+ root = '';
for(var index in object) {
- var obj = object[index]
+ var obj = object[index];
var rootname = root.length == 0 ? index : root + '.' + index;
if(typeof obj == 'object' ) {
if($.isArray(obj))
array[rootname] = typeof obj === 'undefined' ? null : obj.join(',');
else
- flatten_json(obj,rootname,array)
+ flatten_json(obj,rootname,array);
} else {
array[rootname] = typeof obj === 'undefined' ? null : obj;
}
@@ -328,9 +327,9 @@ function xmlEnt(value) {
.replace(/ /g, ' ')
.replace(/<del>/g, '')
.replace(/<\/del>/g, '');
- return stg1
+ return stg1;
} else {
- return value
+ return value;
}
}
@@ -354,25 +353,25 @@ function sortObj(arr) {
// WTF. Has to be a better way to do this. Hi Tyler.
function int_to_tz(offset) {
- var hour = offset / 1000 / 3600
- var str = ""
+ var hour = offset / 1000 / 3600;
+ var str = "";
if (hour == 0) {
- str = "+0000"
+ str = "+0000";
}
if (hour < 0) {
if (hour > -10)
- str = "-0" + (hour * -100)
+ str = "-0" + (hour * -100);
else
- str = "-" + (hour * -100)
+ str = "-" + (hour * -100);
}
if (hour > 0) {
if (hour < 10)
- str = "+0" + (hour * 100)
+ str = "+0" + (hour * 100);
else
- str = "+" + (hour * 100)
+ str = "+" + (hour * 100);
}
str = str.substring(0,3) + ":" + str.substring(3);
- return str
+ return str;
}
// Sets #hash, thus refreshing results
@@ -400,11 +399,11 @@ function wbr(str, num) {
str = htmlEntities(str);
return str.replace(
RegExp("(@?\\w{" + num + "}|[:;,])([\\w\"'])([\\w@]*)", "g"),
- function (all, text, char, trailer) {
+ function (all, text, ch, trailer) {
if (/@KIBANA_\w+_(START|END)@/.test(all)) {
- return text + char + trailer;
+ return text + ch + trailer;
} else {
- return text + "" + char + trailer;
+ return text + "" + ch + trailer;
}
}
);
@@ -416,4 +415,4 @@ function htmlEntities(str) {
//g, '>').replace(
/"/g, '"');
-}
\ No newline at end of file
+}
diff --git a/public/lib/js/stream.js b/public/lib/js/stream.js
index ab5a9b447..27f2c534d 100644
--- a/public/lib/js/stream.js
+++ b/public/lib/js/stream.js
@@ -51,7 +51,7 @@ function getStream() {
var maxEvents = 100;
var b64json = encodeURIComponent(Base64.encode(JSON.stringify(window.hashjson)));
var cacheBuster = "?cacheBuster=" + new Date().getTime();
- var from = ""
+ var from = "";
if (window.last_time != "") {
from = "/" + window.last_time;
@@ -60,17 +60,17 @@ function getStream() {
$.getJSON("api/stream/" + b64json + from + cacheBuster, null, function(data) {
if (data != null) {
window.i++;
- var fields = window.hashjson.fields
+ var fields = window.hashjson.fields;
var has_time = false;
var id = "";
var hit = "";
var i = 0;
data.hits.hits = data.hits.hits.reverse();
for (var obj in data.hits.hits) {
- hit = data.hits.hits[obj]
+ hit = data.hits.hits[obj];
- id = hit['_id']
- index = hit['_index']
+ id = hit['_id'];
+ index = hit['_index'];
if (!(has_time)) {
window.last_time = get_field_value(hit,'@timestamp');
has_time = true;
@@ -91,7 +91,7 @@ function getStream() {
var jlink = $('').addClass('jlink').attr('href', "../#" + hash).html($('').addClass('icon-link'));
var linkTableData = $("
").css('white-space', 'nowrap');
- linkTableData.text(prettyDateString(Date.parse(get_field_value(hit,'@timestamp')) + tOffset)).prepend(jlink);
+ linkTableData.text(prettyDateString(Date.parse(get_field_value(hit,'@timestamp')))).prepend(jlink);
tableRow.append(linkTableData);
for (var field in fields) {
tableRow.append($("
").text(get_field_value(hit,fields[field])));
@@ -115,19 +115,19 @@ function getStream() {
}
}
- var now = new Date()
+ var now = new Date();
if (typeof window.stream_arr === 'undefined') {
- var now = new Date
- var range = 900
- window.stream_arr = []
+ var now = new Date;
+ var range = 900;
+ window.stream_arr = [];
while(range > 0) {
- window.stream_arr.push([new Date(now.getTime() - range*1000).getTime(),0])
+ window.stream_arr.push([new Date(now.getTime() - range*1000).getTime(),0]);
range = range-10;
}
}
- window.stream_arr.shift()
- window.stream_arr.push([now.getTime(),rate])
+ window.stream_arr.shift();
+ window.stream_arr.push([now.getTime(),rate]);
$.plot(
$("#streamgraph"), [
@@ -156,4 +156,4 @@ function getStream() {
function field_slim(field) {
return field.replace(/(.*)\.(.*)/,"$1. $2");
-}
\ No newline at end of file
+}
diff --git a/views/timezone.erb b/views/timezone.erb
index a235136be..3bb9b23c2 100644
--- a/views/timezone.erb
+++ b/views/timezone.erb
@@ -1,13 +1,18 @@
var tmp_offset = "<%="#{
KibanaConfig::Timezone == 'user' ?
'user' : ((TZInfo::Timezone.get(KibanaConfig::Timezone).current_period.offset.utc_total_offset).to_f / 3600.0).to_s
-}"%>"
+}"%>";
+
+window.time_format = "<%= defined?(KibanaConfig::Time_format) ? KibanaConfig::Time_format : "mm/dd HH:MM:ss" %>";
-window.time_format = "<%= defined?(KibanaConfig::Time_format) ? KibanaConfig::Time_format : "mm/dd HH:MM:ss" %>"
if (tmp_offset == 'user') {
- var d = new Date()
+ var d = new Date();
window.tOffset = -d.getTimezoneOffset() * 60 * 1000;
} else {
window.tOffset = parseFloat(tmp_offset) * 3600 * 1000;
-}
\ No newline at end of file
+}
+
+// = KibanaConfig::Timezone - local timezone
+window.ltOffset = window.tOffset -
+ (- new Date().getTimezoneOffset() * 60 * 1000);