[js linting] use airbnb eslint settings (#796)

* add airbnb eslint settings and lint all the code

* fix linting erros
This commit is contained in:
Alanna Scott
2016-07-27 16:57:05 -07:00
committed by GitHub
parent f43e5f18d5
commit 1101de5ae4
20 changed files with 1006 additions and 1132 deletions

View File

@@ -1,93 +1,80 @@
var $ = window.$ = require('jquery');
var jQuery = window.jQuery = $;
var showModal = require('./modules/utils.js').showModal;
const $ = window.$ = require('jquery');
const showModal = require('./modules/utils.js').showModal;
require('./caravel-select2.js');
require('datatables.net-bs');
require('../node_modules/datatables-bootstrap3-plugin/media/css/datatables-bootstrap3.css');
require('bootstrap');
var ace = require('brace');
const ace = require('brace');
require('brace/mode/sql');
require('brace/theme/crimson_editor');
require('../stylesheets/sql.css');
$(document).ready(function () {
function getParam(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
/* eslint no-param-reassign: 0 */
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
const regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
const results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
function initSqlEditorView() {
var database_id = $('#database_id').val();
var editor = ace.edit("sql");
const databaseId = $('#databaseId').val();
const editor = ace.edit('sql');
editor.$blockScrolling = Infinity;
editor.getSession().setUseWrapMode(true);
$('#sql').hide();
editor.setTheme("ace/theme/crimson_editor");
editor.setTheme('ace/theme/crimson_editor');
editor.setOptions({
minLines: 16,
maxLines: Infinity,
});
editor.getSession().setMode("ace/mode/sql");
editor.getSession().setMode('ace/mode/sql');
editor.focus();
$("select").select2({
dropdownAutoWidth: true,
});
$('select').select2({ dropdownAutoWidth: true });
function showTableMetadata() {
$(".metadata").load(
'/caravel/table/' + database_id + '/' + $("#dbtable").val() + '/');
$('.metadata').load('/caravel/table/' + databaseId + '/' + $('#dbtable').val() + '/');
}
$("#dbtable").on("change", showTableMetadata);
$('#dbtable').on('change', showTableMetadata);
showTableMetadata();
$("#create_view").click(function () {
$('#create_view').click(function () {
showModal({
title: "Error",
body: "Sorry, this feature is not yet implemented",
title: 'Error',
body: 'Sorry, this feature is not yet implemented',
});
});
$(".sqlcontent").show();
$('.sqlcontent').show();
function selectStarOnClick() {
$.ajax('/caravel/select_star/' + database_id + '/' + $("#dbtable").val() + '/')
.done(function (msg) {
const url = '/caravel/select_star/' + databaseId + '/' + $('#dbtable').val() + '/';
$.ajax(url).done(function (msg) {
editor.setValue(msg);
});
}
$("#select_star").click(selectStarOnClick);
$('#select_star').click(selectStarOnClick);
editor.setValue(getParam('sql'));
$(window).bind("popstate", function (event) {
$(window).bind('popstate', function () {
// Could do something more lightweight here, but we're not optimizing
// for the use of the back button anyways
editor.setValue(getParam('sql'));
$("#run").click();
$('#run').click();
});
$("#run").click(function () {
$('#run').click(function () {
$('#results').hide(0);
$('#loading').show(0);
history.pushState({}, document.title, '?sql=' + encodeURIComponent(editor.getValue()));
$.ajax({
type: "POST",
type: 'POST',
url: '/caravel/runsql/',
data: {
data: JSON.stringify({
database_id: $('#database_id').val(),
databaseId: $('#databaseId').val(),
sql: editor.getSession().getValue(),
}),
},
success: function (data) {
success(data) {
$('#loading').hide(0);
$('#results').show(0);
$('#results').html(data);
$('table.sql_results').DataTable({
retrieve: true,
paging: false,
@@ -95,7 +82,7 @@ $(document).ready(function () {
aaSorting: [],
});
},
error: function (err, err2) {
error(err) {
$('#loading').hide(0);
$('#results').show(0);
$('#results').html(err.responseText);