From 04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 9 Jan 2020 10:55:03 +0100 Subject: phpmyadmin working --- srcs/phpmyadmin/js/transformations/image_upload.js | 28 ++++++++++++++++++++++ srcs/phpmyadmin/js/transformations/json.js | 18 ++++++++++++++ srcs/phpmyadmin/js/transformations/json_editor.js | 17 +++++++++++++ srcs/phpmyadmin/js/transformations/sql_editor.js | 11 +++++++++ srcs/phpmyadmin/js/transformations/xml.js | 18 ++++++++++++++ srcs/phpmyadmin/js/transformations/xml_editor.js | 16 +++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 srcs/phpmyadmin/js/transformations/image_upload.js create mode 100644 srcs/phpmyadmin/js/transformations/json.js create mode 100644 srcs/phpmyadmin/js/transformations/json_editor.js create mode 100644 srcs/phpmyadmin/js/transformations/sql_editor.js create mode 100644 srcs/phpmyadmin/js/transformations/xml.js create mode 100644 srcs/phpmyadmin/js/transformations/xml_editor.js (limited to 'srcs/phpmyadmin/js/transformations') diff --git a/srcs/phpmyadmin/js/transformations/image_upload.js b/srcs/phpmyadmin/js/transformations/image_upload.js new file mode 100644 index 0000000..0590364 --- /dev/null +++ b/srcs/phpmyadmin/js/transformations/image_upload.js @@ -0,0 +1,28 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Image upload transformations plugin js + * + * @package PhpMyAdmin + */ + +AJAX.registerOnload('transformations/image_upload.js', function () { + // Change thumbnail when image file is selected + // through file upload dialog + $('input.image-upload').on('change', function () { + if (this.files && this.files[0]) { + var reader = new FileReader(); + var $input = $(this); + reader.onload = function (e) { + $input.prevAll('img').attr('src', e.target.result); + }; + reader.readAsDataURL(this.files[0]); + } + }); +}); + +/** + * Unbind all event handlers before tearing down a page + */ +AJAX.registerTeardown('transformations/image_upload.js', function () { + $('input.image-upload').off('change'); +}); diff --git a/srcs/phpmyadmin/js/transformations/json.js b/srcs/phpmyadmin/js/transformations/json.js new file mode 100644 index 0000000..81ddaf2 --- /dev/null +++ b/srcs/phpmyadmin/js/transformations/json.js @@ -0,0 +1,18 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * JSON syntax highlighting transformation plugin + */ +AJAX.registerOnload('transformations/json.js', function () { + var $elm = $('#page_content').find('code.json'); + $elm.each(function () { + var $json = $(this); + var $pre = $json.find('pre'); + /* We only care about visible elements to avoid double processing */ + if ($pre.is(':visible')) { + var $highlight = $('
'); + $json.append($highlight); + CodeMirror.runMode($json.text(), 'application/json', $highlight[0]); + $pre.hide(); + } + }); +}); diff --git a/srcs/phpmyadmin/js/transformations/json_editor.js b/srcs/phpmyadmin/js/transformations/json_editor.js new file mode 100644 index 0000000..affae4b --- /dev/null +++ b/srcs/phpmyadmin/js/transformations/json_editor.js @@ -0,0 +1,17 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * JSON syntax highlighting transformation plugin + * + * @package PhpMyAdmin + */ +AJAX.registerOnload('transformations/json_editor.js', function () { + $('textarea.transform_json_editor').each(function () { + CodeMirror.fromTextArea(this, { + lineNumbers: true, + matchBrackets: true, + indentUnit: 4, + mode: 'application/json', + lineWrapping: true + }); + }); +}); diff --git a/srcs/phpmyadmin/js/transformations/sql_editor.js b/srcs/phpmyadmin/js/transformations/sql_editor.js new file mode 100644 index 0000000..18139f3 --- /dev/null +++ b/srcs/phpmyadmin/js/transformations/sql_editor.js @@ -0,0 +1,11 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * SQL syntax highlighting transformation plugin js + * + * @package PhpMyAdmin + */ +AJAX.registerOnload('transformations/sql_editor.js', function () { + $('textarea.transform_sql_editor').each(function () { + Functions.getSqlEditor($(this), {}, 'both'); + }); +}); diff --git a/srcs/phpmyadmin/js/transformations/xml.js b/srcs/phpmyadmin/js/transformations/xml.js new file mode 100644 index 0000000..3fdf152 --- /dev/null +++ b/srcs/phpmyadmin/js/transformations/xml.js @@ -0,0 +1,18 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * XML syntax highlighting transformation plugin + */ +AJAX.registerOnload('transformations/xml.js', function () { + var $elm = $('#page_content').find('code.xml'); + $elm.each(function () { + var $json = $(this); + var $pre = $json.find('pre'); + /* We only care about visible elements to avoid double processing */ + if ($pre.is(':visible')) { + var $highlight = $('
'); + $json.append($highlight); + CodeMirror.runMode($json.text(), 'application/xml', $highlight[0]); + $pre.hide(); + } + }); +}); diff --git a/srcs/phpmyadmin/js/transformations/xml_editor.js b/srcs/phpmyadmin/js/transformations/xml_editor.js new file mode 100644 index 0000000..7d2533d --- /dev/null +++ b/srcs/phpmyadmin/js/transformations/xml_editor.js @@ -0,0 +1,16 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * XML editor plugin + * + * @package PhpMyAdmin + */ +AJAX.registerOnload('transformations/xml_editor.js', function () { + $('textarea.transform_xml_editor').each(function () { + CodeMirror.fromTextArea(this, { + lineNumbers: true, + indentUnit: 4, + mode: 'application/xml', + lineWrapping: true + }); + }); +}); -- cgit