Verified Commit 10484741 authored by Marco Kellershoff's avatar Marco Kellershoff 🤸
Browse files

Add eslint config and add output.php as helper

parent d8f554b0
{
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"rules": {
"accessor-pairs": "error",
"array-bracket-newline": "off",
"array-bracket-spacing": [
"error",
"never"
],
"array-callback-return": "error",
"array-element-newline": "off",
"arrow-body-style": "error",
"arrow-parens": "error",
"arrow-spacing": [
"error",
{
"after": true,
"before": true
}
],
"block-scoped-var": "error",
"block-spacing": [
"error",
"never"
],
"brace-style": "off",
"callback-return": "off",
"camelcase": "off",
"capitalized-comments": "off",
"class-methods-use-this": "error",
"comma-dangle": "off",
"comma-spacing": "off",
"comma-style": [
"error",
"last"
],
"complexity": "error",
"computed-property-spacing": [
"error",
"never"
],
"consistent-return": "off",
"consistent-this": "off",
"curly": "off",
"default-case": "error",
"dot-location": "error",
"dot-notation": "error",
"eol-last": "error",
"eqeqeq": "error",
"for-direction": "error",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": [
"error",
"never"
],
"func-style": [
"error",
"expression"
],
"function-paren-newline": "error",
"generator-star-spacing": "error",
"getter-return": "error",
"global-require": "error",
"guard-for-in": "off",
"handle-callback-err": "off",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"implicit-arrow-linebreak": [
"error",
"beside"
],
"indent": "off",
"indent-legacy": "off",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "error",
"keyword-spacing": "off",
"line-comment-position": "off",
"linebreak-style": [
"error",
"unix"
],
"lines-around-comment": "error",
"lines-around-directive": "error",
"lines-between-class-members": "error",
"max-depth": "error",
"max-len": "off",
"max-lines": "off",
"max-nested-callbacks": "error",
"max-params": "error",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-comment-style": [
"error",
"separate-lines"
],
"new-cap": "error",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "error",
"no-alert": "off",
"no-array-constructor": "error",
"no-await-in-loop": "error",
"no-bitwise": "error",
"no-buffer-constructor": "error",
"no-caller": "error",
"no-catch-shadow": "error",
"no-confusing-arrow": "error",
"no-continue": "off",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "off",
"no-empty": [
"error",
{
"allowEmptyCatch": true
}
],
"no-empty-function": "off",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-extra-parens": "off",
"no-floating-decimal": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-inner-declarations": [
"error",
"functions"
],
"no-invalid-this": "off",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-mixed-operators": "error",
"no-mixed-requires": "error",
"no-multi-assign": "error",
"no-multi-spaces": "error",
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-negated-in-lhs": "error",
"no-nested-ternary": "error",
"no-new": "off",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "off",
"no-path-concat": "error",
"no-plusplus": "off",
"no-process-env": "error",
"no-process-exit": "error",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "error",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sync": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-undefined": "error",
"no-underscore-dangle": "off",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-use-before-define": "error",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "off",
"no-void": "error",
"no-warning-comments": "error",
"no-whitespace-before-property": "error",
"no-with": "error",
"nonblock-statement-body-position": "error",
"object-curly-newline": "off",
"object-curly-spacing": [
"error",
"never"
],
"object-property-newline": "error",
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": "error",
"operator-assignment": "off",
"operator-linebreak": "error",
"padded-blocks": "off",
"padding-line-between-statements": "error",
"prefer-arrow-callback": "off",
"prefer-const": "error",
"prefer-destructuring": "off",
"prefer-numeric-literals": "error",
"prefer-promise-reject-errors": "error",
"prefer-reflect": "off",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "off",
"quote-props": "off",
"quotes": "off",
"radix": [
"error",
"always"
],
"require-await": "error",
"require-jsdoc": "error",
"rest-spread-spacing": "error",
"semi": "error",
"semi-spacing": [
"error",
{
"after": true,
"before": false
}
],
"semi-style": [
"error",
"last"
],
"sort-imports": "error",
"sort-keys": "off",
"sort-vars": "off",
"space-before-blocks": "off",
"space-before-function-paren": "off",
"space-in-parens": "off",
"space-infix-ops": "off",
"space-unary-ops": "error",
"spaced-comment": "off",
"strict": "error",
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": [
"error",
"never"
],
"valid-jsdoc": "error",
"vars-on-top": "off",
"wrap-regex": "error",
"yield-star-spacing": "error",
"yoda": [
"error",
"never"
]
}
}
\ No newline at end of file
......@@ -30,7 +30,6 @@
'yaml'
],
EDITOR = null,
compression = {},
my_lzma = new window.LZMA('assets/lzma_worker.js');
this.version = 3;
......@@ -176,7 +175,8 @@
'iframe',
null,
[
['id', 'output']
['id', 'output'],
['name', 'output']
]
)
],
......@@ -214,8 +214,7 @@
});
},
decompress: function(data, cb) {
var byte_arr = self.compression.convertFormatedHexToBytes(data),
error = false;
var byte_arr = self.compression.convertFormatedHexToBytes(data);
my_lzma.decompress(byte_arr, function (result) {
if (result === false) cb(true, []);
else cb(false, result);
......@@ -299,6 +298,9 @@
window.mockhtml();
var app = document.querySelector('#app');
var logo = document.querySelector('#logo');
var col1 = document.querySelector('#col1');
var col2 = document.querySelector('#col2');
var $ = window.$;
var drawertoggle = document.querySelector('#drawer-toggle');
var drawerlabel = document.querySelector('#drawer-toggle-label');
var drawer = document.querySelector('#drawer');
......@@ -355,7 +357,7 @@
self.hideLoading();
});
} catch(ex) {
console.log(ex);
window.console.log(ex);
window.alert('No valid token received');
self.hideLoading();
}
......@@ -365,15 +367,15 @@
};
this.showLoading = function() {
app.style.display = 'none';
$('#loading').css({display: 'block'});
$('#drawer-toggle-label').css({display: 'none'});
document.querySelector('#app').style.display = 'none';
window.$('#loading').css({display: 'block'});
window.$('#drawer-toggle-label').css({display: 'none'});
};
this.hideLoading = function() {
$( "#loading" ).fadeOut("slow", function() {
$('#drawer-toggle-label').fadeIn("slow");
$(app).fadeIn("slow");
window.$( "#loading" ).fadeOut("slow", function() {
window.$('#drawer-toggle-label').fadeIn("slow");
window.$('#app').fadeIn("slow");
});
};
......@@ -412,25 +414,25 @@
this.showAndHideOutput = function() {
var is_compilable = self.isCompilable();
if (is_compilable === false) {
$(col1).removeClass('col-xs-6');
$(col1).addClass('col-xs-12');
$(col2).addClass('hidden');
window.$('#col1').removeClass('col-xs-6');
window.$('#col1').addClass('col-xs-12');
window.$('col2').addClass('hidden');
} else {
$(col1).addClass('col-xs-6');
$(col1).removeClass('col-xs-12');
$(col2).removeClass('hidden');
window.$('col1').addClass('col-xs-6');
window.$('col1').removeClass('col-xs-12');
window.$('col2').removeClass('hidden');
}
};
this.showAndHideRun = function() {
var is_compilable = self.isCompilable();
$(col1).removeClass('col-xs-6');
$(col1).addClass('col-xs-12');
$(col2).addClass('hidden');
window.$('col1').removeClass('col-xs-6');
window.$('col1').addClass('col-xs-12');
window.$('col2').addClass('hidden');
if (is_compilable === false) {
btn_run.style.display = 'none';
window.$('#btn_run').get(0).style.display = 'none';
} else {
btn_run.style.display = 'inline-block';
window.$('#btn_run').get(0).style.display = 'inline-block';
}
};
......@@ -472,7 +474,7 @@
};
this.initGoogleApiKeys = function(cb) {
$.ajax({
window.$.ajax({
url: 'googleapikeys.json',
method: "GET",
}).done(function(data){
......@@ -490,7 +492,7 @@
self.shortenUrl(longUrl, cb);
});
} else {
$.ajax({
window.$.ajax({
url: 'https://www.googleapis.com/urlshortener/v1/url?key=' + apikey,
method: "POST",
processData: false,
......@@ -506,7 +508,7 @@
};
this.showShareWindow = function(link) {
var $shareDialogue = $('#shareDialogue');
var $shareDialogue = window.$('#shareDialogue');
var shareUrlBox = $shareDialogue.find('#shareUrlBox');
shareUrlBox.val(link);
$shareDialogue.modal('toggle');
......@@ -514,7 +516,7 @@
this.init = function() {
self.showLoading();
new Clipboard('#copyShareUrlButton');
new window.Clipboard('#copyShareUrlButton');
self.setupHtml();
document.getElementById('templates').onchange = function() {
var templates = window.localStorage.getItem(LOCAL_STORAGE_TEMPLATE_NAME) || '{}';
......@@ -529,13 +531,13 @@
self.fillTemplates();
btn_run.onclick = function(evt){
window.$('#btn_run').get(0).onclick = function(evt){
evt.preventDefault();
self.showAndHideOutput();
window.mockhtml();
};
btn_add.onclick = function(evt){
window.$('#btn_add').get(0).onclick = function(evt){
evt.preventDefault();
var tpl_name = window.prompt('Save as template? Enter a name for the template', '');
if (tpl_name !== null && tpl_name.length) {
......@@ -550,7 +552,7 @@
}
};
btn_delete.onclick = function(evt){
window.$('#btn_delete').get(0).onclick = function(evt){
evt.preventDefault();
self.deleteTemplate();
};
......@@ -592,37 +594,38 @@
}
};
btn_share.onclick = function(evt) {
window.$('#btn_share').get(0).onclick = function(evt) {
evt.preventDefault();
getShareableLink({}, getShareableLinkCallback);
};
window.mockhtml = function(){
var val = '';
var syntax = self.getEditorSyntax();
if (syntax === 'html') {
val = EDITOR.getValue();
} else if (syntax === 'javascript') {
val = '<!DOCTYPE html><html><head><title></title></head>' +
'<body style="background-color: black;"><script>' +
EDITOR.getValue() +
'</script></body></html>';
}
var ifrm = document.getElementById('output');
ifrm.style.backgroundColor = '#fff';
ifrm = ifrm.contentWindow || ifrm.contentDocument || ifrm.contentDocument.body;
ifrm.document.open();
try {
ifrm.document.write(val);
} catch (ifrdocwrite_ex) {
console.log(ifrdocwrite_ex);
}
ifrm.document.close();
var ifr = document.getElementById('output');
var form = document.createElement('form');
form.style.visibility = 'hidden';
form.method = 'POST';
form.target = 'output';
form.action = 'output.php';
var inputSyntax = document.createElement('input');
inputSyntax.name = 'syntax';
inputSyntax.type = 'hidden';
inputSyntax.value = self.getEditorSyntax();
var inputInput = document.createElement('input');
inputInput.name = 'input';
inputInput.type = 'hidden';
inputInput.value = EDITOR.getValue();
form.appendChild(inputSyntax);
form.appendChild(inputInput);
document.body.appendChild(form);
ifr.onload = function() {
form.parentNode.removeChild(form);
};
form.submit();
return false;
};
ace.require("ace/ext/language_tools");
EDITOR = ace.edit('textarea');
window.ace.require("ace/ext/language_tools");
EDITOR = window.ace.edit('textarea');
EDITOR.setTheme('ace/theme/tomorrow_night_eighties');
EDITOR.getSession().setMode('ace/mode/html');
......@@ -639,7 +642,7 @@
self.fillSyntax();
document.getElementById('syntax').onchange = function(evt) {
document.getElementById('syntax').onchange = function() {
var sel_index = this.selectedIndex,
sel_item = this.children[sel_index];
self.setEditorSyntax(sel_item.innerHTML);
......@@ -647,8 +650,8 @@
document.addEventListener('keydown', function(evt){
if(getWidth() <= window_min_width && evt.key === 'Escape') {
col1.style.display = 'block';
col2.style.display = 'none';
window.$('#col1').get(0).style.display = 'block';
window.$('#col2').get(0).style.display = 'none';
EDITOR.focus();
}
else if (evt.ctrlKey === true && evt.key === 'Enter') {
......@@ -666,29 +669,29 @@
}
};
document.getElementById('file').addEventListener('change', loadFromFile, false);
btn_file.onclick = function(){
file.click();
window.$('#btn_file').get(0).onclick = function(){
document.getElementById('file').click();
};
$("#shareDialogue").on("hidden.bs.modal", function () {
$('#shortenUrlCheckbox').prop('checked', false);
window.$("#shareDialogue").on("hidden.bs.modal", function () {
window.$('#shortenUrlCheckbox').prop('checked', false);
});
$('#shortenUrlCheckbox').on('change', function(){
window.$('#shortenUrlCheckbox').on('change', function(){
if (this.checked === true) {
self.shortenUrl($('#shareUrlBox').val(), function(data) {
self.shortenUrl(window.$('#shareUrlBox').val(), function(data) {
if (data.kind === 'urlshortener#url') {
$('#shareUrlBox').val(data.id);
window.$('#shareUrlBox').val(data.id);
}
});
} else {
getShareableLink({}, function(err, link){
if (err === false) {
$('#shareUrlBox').val(link);
window.$('#shareUrlBox').val(link);
}
});
}
});
$(window).on('hashchange', function(){window.location.reload();});
$('#drawer-toggle-label').on('click', function(){
window.$(window).on('hashchange', function(){window.location.reload();});
window.$('#drawer-toggle-label').on('click', function(){
window.setTimeout(function(){EDITOR.resize();}, 1);
});
self.loadFromHash();
......
<?php
$input = '';
$syntax = '';
$output = '';
if (isset($_POST['syntax'])) {
$syntax = $_POST['syntax'];
} else if (isset($argv) && count($argv) > 2) {
$syntax = $argv[1];
}
if ($syntax === '') die();
if (isset($_POST['input'])) {
$input = $_POST['input'];
} else if (isset($argv) && count($argv) > 2) {
$input = $argv[2];
}
if ($input === '') die();
switch($syntax) {
case 'javascript':
$output = '<script>'.$input.'</script>';
break;
default:
$output = $input;
break;
}
header("X-XSS-Protection: 0");
echo $output . "\n";
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!