From 340eb45bc284ce2b7e0ff9bd347261613f25a586 Mon Sep 17 00:00:00 2001 From: zhixin Date: Sun, 5 Jan 2025 21:30:36 +0800 Subject: [PATCH] Rebuild welcomes to es6 and fix some errors --- assets/js/template.js | 28 +- crud/index.html | 14 +- eslint.config.js | 5 + extensions/custom-view.html | 2 +- extensions/fixed-columns.html | 2 +- extensions/treegrid.html | 4 +- issues/1167.html | 4 +- issues/137.html | 7 +- issues/152.html | 4 +- issues/177.html | 20 +- issues/188.html | 2 +- issues/220.html | 4 +- issues/221.html | 5 +- issues/2619.html | 2 +- issues/283.html | 38 +-- issues/3345.html | 6 +- issues/371.html | 2 +- issues/3784.html | 4 +- issues/383.html | 4 +- issues/3830.html | 9 +- issues/386.html | 16 +- issues/3949.html | 12 +- issues/395.html | 8 +- issues/409.html | 4 +- issues/415.html | 9 +- issues/4210.html | 10 +- issues/4214.html | 2 +- issues/431.html | 9 +- issues/457.html | 2 +- issues/4586.html | 4 +- issues/563.html | 8 +- issues/579.html | 12 +- issues/639.html | 15 +- issues/917.html | 15 +- issues/986.html | 14 +- issues/987.html | 15 +- methods/expand-collapse-all-rows.html | 2 +- methods/expand-collapse-row-by-uniqueid.html | 2 +- methods/expand-collapse-row.html | 2 +- methods/toggle-detail-view.html | 2 +- options/buttons.html | 40 ++- options/custom-search.html | 8 +- options/custom-sort.html | 2 +- options/custom-toolbar.html | 6 +- options/data-type.html | 4 +- options/detail-filter.html | 4 +- options/detail-view-align.html | 18 +- options/detail-view-icon.html | 2 +- options/detail-view-unique-id.html | 2 +- options/detail-view.html | 2 +- options/footer-field.html | 12 +- options/footer-style.html | 62 ++-- options/header-style.html | 30 +- options/id-field.html | 2 - options/ignore-click-to-select-on.html | 8 +- options/large-columns.html | 4 +- options/loading-template.html | 2 +- options/query-params-type.html | 2 +- options/query-params.html | 2 +- options/row-attributes.html | 26 +- options/row-style.html | 4 +- options/search-accent-neutralise.html | 22 +- options/search-highlight.html | 6 +- options/server-sort.html | 4 +- options/show-footer.html | 14 +- options/sort-empty-last.html | 2 +- options/sort-stable.html | 212 ++++++------ options/table-ajax.html | 2 +- options/undefined-text.html | 2 +- package.json | 6 +- tools/lint.sh | 2 + welcome.html | 329 ++++++++++++------- welcomes/flat-json.html | 54 ++- welcomes/from-data.html | 37 ++- welcomes/from-html.html | 199 +++++++---- welcomes/from-url.html | 34 +- welcomes/group-columns.html | 50 ++- welcomes/large-data.html | 78 +++-- welcomes/modal-table-bootstrap3.html | 97 ++++-- welcomes/modal-table-bootstrap4.html | 99 ++++-- welcomes/modal-table-bulma.html | 81 +++-- welcomes/modal-table-foundation.html | 71 ++-- welcomes/modal-table-materialize.html | 68 ++-- welcomes/modal-table-semantic.html | 66 ++-- welcomes/modal-table.html | 95 ++++-- welcomes/multiple-table.html | 170 +++++----- welcomes/no-data.html | 16 +- welcomes/sub-table.html | 34 +- welcomes/vue-component.html | 18 +- 89 files changed, 1449 insertions(+), 990 deletions(-) diff --git a/assets/js/template.js b/assets/js/template.js index a7fd34c0..845e29e6 100644 --- a/assets/js/template.js +++ b/assets/js/template.js @@ -106,7 +106,7 @@ function _scripts (scripts, callback) { } function _themeUpdate (_data) { - const data = _data.replace('', '') + const data = _data if (/bootstrap3.html$/.test(location.pathname)) { return data.replace(/btn-secondary/g, 'btn-default') @@ -151,25 +151,33 @@ function _beautifySource (data) { let lines = data.split('\n') const scriptStart = lines.indexOf('', scriptStart) - let strings = lines.slice(scriptStart + 1, scriptEnd) + const strings = lines.slice(scriptStart + 1, scriptEnd) + .map(s => s.trim()) + const templateStart = lines.indexOf('', scriptStart) + const templates = lines.slice(templateStart + 1, templateEnd) + .map(s => s.replace(/^ {2}/, '')) - strings = $.map(strings, function (s) { - return $.trim(s) - }) /* eslint-disable no-control-regex */ const obj = eval(`(${strings.join('').replace(/[^\u0000-\u007E]/g, '') .replace(/^init\((.*)\)$/, '$1')})`) let result = [] + const addEmptyLine = () => { + if (result[result.length - 1] !== '') { + result.push('') + } + } result = result.concat($.map(obj.links, _getLink)) - result.push('') + addEmptyLine() result = result.concat($.map(obj.scripts, function (script) { return _getScript(script, true) })) - lines = result.concat(lines.slice(scriptEnd + 1)) + addEmptyLine() + lines = result.concat(templates, lines.slice(templateEnd + 1)) - const mountedStart = lines.indexOf(' function mounted() {') + const mountedStart = lines.indexOf(' function mounted () {') const mountedEnd = lines.indexOf(' }', mountedStart) lines[mountedStart] = ' $(function() {' @@ -205,7 +213,9 @@ $(function () { $('#source').text(_beautifySource(data)) window.hljs.highlightAll() } else { - $('#example').html(data.replace(/ data-toggle="table"/g, ' data-toggle="bootstrap-table"')) + $('#example').html(data + .replace('', '') + .replace(/ data-toggle="table"/g, ' data-toggle="bootstrap-table"')) } }, error () { diff --git a/crud/index.html b/crud/index.html index db1c1f88..dadb6c2d 100644 --- a/crud/index.html +++ b/crud/index.html @@ -77,7 +77,7 @@ stargazers_count: 0, forks_count: 0, description: '' - } // default row value + } // default row value $modal.data('id', row.id) $modal.find('.modal-title').text(title) @@ -90,7 +90,7 @@ } function showAlert (title, type) { - $alert.attr('class', `alert alert-${type}` || 'success') + $alert.attr('class', `alert alert-${type || 'success'}`) .html(` ${title}`).show() setTimeout(function () { $alert.hide() @@ -128,12 +128,10 @@ field: 'action', title: 'Action', align: 'center', - formatter: function actionFormatter (value) { - return [ - '', - '' - ].join('') - }, + formatter: () => [ + '', + '' + ].join(''), events: { 'click .update' (e, value, row) { showModal($(e.currentTarget).attr('title'), row) diff --git a/eslint.config.js b/eslint.config.js index aa2d1838..02c82c36 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,4 +1,5 @@ import eslintConfig from 'bootstrap-table/eslint.config.js' +import html from 'eslint-plugin-html' import vue from 'eslint-plugin-vue' const globals = eslintConfig[eslintConfig.length - 1].languageOptions.globals @@ -14,6 +15,10 @@ export default [ 'webpack-starter/' ] }, + { + files: ['**/*.html'], + plugins: { html } + }, ...eslintConfig, ...vue.configs['flat/recommended'], { diff --git a/extensions/custom-view.html b/extensions/custom-view.html index 94dea56a..adf347c5 100644 --- a/extensions/custom-view.html +++ b/extensions/custom-view.html @@ -215,7 +215,7 @@

%SNIPPETS%

}) } - function customViewFormatter (data) { + window.customViewFormatter = data => { const template = $('#profileTemplate').html() let view = '' diff --git a/extensions/fixed-columns.html b/extensions/fixed-columns.html index 3d74d3bd..4d273a03 100644 --- a/extensions/fixed-columns.html +++ b/extensions/fixed-columns.html @@ -90,7 +90,7 @@ checkbox: true, valign: 'middle' } - ] + ] const data = [] for (i = 0; i < cells; i++) { diff --git a/extensions/treegrid.html b/extensions/treegrid.html index 15c64491..fcca92f8 100644 --- a/extensions/treegrid.html +++ b/extensions/treegrid.html @@ -64,7 +64,7 @@ }) } - function typeFormatter (value, row, index) { + window.typeFormatter = value => { if (value === 'menu') { return '菜单' } @@ -77,7 +77,7 @@ return '-' } - function statusFormatter (value, row, index) { + window.statusFormatter = value => { if (value === 1) { return '正常' } diff --git a/issues/1167.html b/issues/1167.html index 288ed1df..417a8ac3 100644 --- a/issues/1167.html +++ b/issues/1167.html @@ -51,9 +51,9 @@ diff --git a/issues/152.html b/issues/152.html index c7474b24..cf5b7b10 100644 --- a/issues/152.html +++ b/issues/152.html @@ -65,7 +65,7 @@ diff --git a/issues/220.html b/issues/220.html index c84b9746..690d6087 100644 --- a/issues/220.html +++ b/issues/220.html @@ -44,9 +44,9 @@ diff --git a/issues/3949.html b/issues/3949.html index e914c6eb..cb437c94 100644 --- a/issues/3949.html +++ b/issues/3949.html @@ -26,19 +26,19 @@ diff --git a/issues/4210.html b/issues/4210.html index fbab43d0..da66d167 100644 --- a/issues/4210.html +++ b/issues/4210.html @@ -51,17 +51,17 @@ diff --git a/issues/4214.html b/issues/4214.html index 2af5bb54..75edb57f 100644 --- a/issues/4214.html +++ b/issues/4214.html @@ -41,7 +41,7 @@ diff --git a/issues/457.html b/issues/457.html index df98fd52..4007e4e2 100644 --- a/issues/457.html +++ b/issues/457.html @@ -29,7 +29,7 @@ diff --git a/issues/639.html b/issues/639.html index fbf3bd87..8649ab82 100644 --- a/issues/639.html +++ b/issues/639.html @@ -8,21 +8,22 @@ diff --git a/issues/987.html b/issues/987.html index fcf39277..8e81e80f 100644 --- a/issues/987.html +++ b/issues/987.html @@ -47,19 +47,20 @@ diff --git a/options/custom-search.html b/options/custom-search.html index 5704a166..5da21dd9 100644 --- a/options/custom-search.html +++ b/options/custom-search.html @@ -39,9 +39,7 @@ }) } - function customSearch (data, text) { - return data.filter(function (row) { - return row.price.indexOf(text) > -1 - }) - } + window.customSearch = (data, text) => data.filter(function (row) { + return row.price.indexOf(text) > -1 + }) diff --git a/options/custom-sort.html b/options/custom-sort.html index 417d778a..dfa10fa7 100644 --- a/options/custom-sort.html +++ b/options/custom-sort.html @@ -41,7 +41,7 @@ + + + diff --git a/welcomes/flat-json.html b/welcomes/flat-json.html index ab73888d..b49d8390 100644 --- a/welcomes/flat-json.html +++ b/welcomes/flat-json.html @@ -7,19 +7,41 @@ }) - - - - - - - - - -
NameStargazersForksDescription
+ diff --git a/welcomes/from-data.html b/welcomes/from-data.html index a9445d68..29896686 100644 --- a/welcomes/from-data.html +++ b/welcomes/from-data.html @@ -7,22 +7,30 @@ }) - - - - - - - - -
IDItem NameItem Price
+ diff --git a/welcomes/from-html.html b/welcomes/from-html.html index a63c3442..353cabd8 100644 --- a/welcomes/from-html.html +++ b/welcomes/from-html.html @@ -7,64 +7,141 @@ }) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameDetail
StarsForksDescription
- bootstrap-table - 88273603An extended Bootstrap table with radio, checkbox, sort, pagination, and other added features. (supports twitter bootstrap v2 and v3) -
- multiple-select - 1615623A jQuery plugin to select multiple elements with checkboxes :) -
- bootstrap-show-password - 22085Show/hide password plugin for twitter bootstrap. -
- bootstrap-table-examples - 17341532Bootstrap Table Examples
- scutech-redmine - 2418Redmine notification tools for chrome extension.
+ diff --git a/welcomes/from-url.html b/welcomes/from-url.html index 64566c88..b4366462 100644 --- a/welcomes/from-url.html +++ b/welcomes/from-url.html @@ -7,16 +7,24 @@ }) - - - - - - - - -
IDItem NameItem Price
+ diff --git a/welcomes/group-columns.html b/welcomes/group-columns.html index 6125c8c8..54685d62 100644 --- a/welcomes/group-columns.html +++ b/welcomes/group-columns.html @@ -7,21 +7,35 @@ }) - - - - - - - - - - - -
Item DetailItem ID
Item NameItem Price
+ diff --git a/welcomes/large-data.html b/welcomes/large-data.html index 59555879..c863caca 100644 --- a/welcomes/large-data.html +++ b/welcomes/large-data.html @@ -7,41 +7,61 @@ }) -
- - - Total rows: -
+ - -