Skip to content

Commit

Permalink
Rebuild welcomes to es6 and fix some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzhixin committed Jan 6, 2025
1 parent 8a36d41 commit 148db82
Show file tree
Hide file tree
Showing 89 changed files with 1,433 additions and 985 deletions.
2 changes: 1 addition & 1 deletion assets/js/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function _beautifySource (data) {
}))
lines = result.concat(lines.slice(scriptEnd + 1))

const mountedStart = lines.indexOf(' function mounted() {')
const mountedStart = lines.indexOf(' function mounted () {')
const mountedEnd = lines.indexOf(' }', mountedStart)

lines[mountedStart] = ' $(function() {'
Expand Down
14 changes: 6 additions & 8 deletions crud/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h5 class="modal-title"></h5>
stargazers_count: 0,
forks_count: 0,
description: ''
} // default row value
} // default row value

$modal.data('id', row.id)
$modal.find('.modal-title').text(title)
Expand All @@ -90,7 +90,7 @@ <h5 class="modal-title"></h5>
}

function showAlert (title, type) {
$alert.attr('class', `alert alert-${type}` || 'success')
$alert.attr('class', `alert alert-${type || 'success'}`)
.html(`<i class="glyphicon glyphicon-check"></i> ${title}`).show()
setTimeout(function () {
$alert.hide()
Expand Down Expand Up @@ -128,12 +128,10 @@ <h5 class="modal-title"></h5>
field: 'action',
title: 'Action',
align: 'center',
formatter: function actionFormatter (value) {
return [
'<a class="update mr10" href="javascript:" title="Update Item"><i class="fa fa-edit"></i></a>',
'<a class="remove" href="javascript:" title="Delete Item"><i class="fa fa-remove"></i></a>'
].join('')
},
formatter: () => [
'<a class="update mr10" href="javascript:" title="Update Item"><i class="fa fa-edit"></i></a>',
'<a class="remove" href="javascript:" title="Delete Item"><i class="fa fa-remove"></i></a>'
].join(''),
events: {
'click .update' (e, value, row) {
showModal($(e.currentTarget).attr('title'), row)
Expand Down
5 changes: 5 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,6 +15,10 @@ export default [
'webpack-starter/'
]
},
{
files: ['**/*.html'],
plugins: { html }
},
...eslintConfig,
...vue.configs['flat/recommended'],
{
Expand Down
2 changes: 1 addition & 1 deletion extensions/custom-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ <h3 class="mb-0">%SNIPPETS%</h3>
})
}

function customViewFormatter (data) {
window.customViewFormatter = data => {
const template = $('#profileTemplate').html()
let view = ''

Expand Down
2 changes: 1 addition & 1 deletion extensions/fixed-columns.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
checkbox: true,
valign: 'middle'
}
]
]
const data = []

for (i = 0; i < cells; i++) {
Expand Down
4 changes: 2 additions & 2 deletions extensions/treegrid.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
})
}

function typeFormatter (value, row, index) {
window.typeFormatter = value => {
if (value === 'menu') {
return '菜单'
}
Expand All @@ -77,7 +77,7 @@
return '-'
}

function statusFormatter (value, row, index) {
window.statusFormatter = value => {
if (value === 1) {
return '<span class="label label-success">正常</span>'
}
Expand Down
4 changes: 2 additions & 2 deletions issues/1167.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
</template>

<script>
var $table = $('#table')
const $table = $('#table')

function mounted() {
function mounted () {
$('#checkAll').click(function () {
$table.bootstrapTable('togglePagination').bootstrapTable('checkAll').bootstrapTable('togglePagination')
})
Expand Down
7 changes: 4 additions & 3 deletions issues/137.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
</template>

<script>
var $table = $('#table')
function mounted() {
const $table = $('#table')

function mounted () {
$table.bootstrapTable({
data: [
{
Expand All @@ -49,7 +50,7 @@
]
})
$('#button').click(function () {
$table.bootstrapTable('refresh', {url: 'json/data1.json'})
$table.bootstrapTable('refresh', { url: 'json/data1.json' })
})
}
</script>
4 changes: 2 additions & 2 deletions issues/152.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@
</template>

<script>
function queryParams(params) {
window.queryParams = params => {
params.your_param1 = 1 // add param1
params.your_param2 = 2 // add param2
// console.log(JSON.stringify(params));
// {"limit":10,"offset":0,"order":"asc","your_param1":1,"your_param2":2}
return params
}

function postQueryParams(params) {
window.postQueryParams = params => {
params.your_param1 = 1 // add param1
params.your_param2 = 2 // add param2
return params // body data
Expand Down
20 changes: 10 additions & 10 deletions issues/177.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@
</template>

<script>
var data = [
const data = [
{
'firstName': 'zhixin',
'lastName': 'wen',
'field1': 'field1',
'field2': 'field2',
'field3': 'field3'
firstName: 'zhixin',
lastName: 'wen',
field1: 'field1',
field2: 'field2',
field3: 'field3'
}
]

function mounted() {
function mounted () {
$('#table').bootstrapTable({
data: data,
data,
columns: [
{
field: 'fullName',
title: 'Full Name',
formatter: function (value, row) {
formatter (value, row) {
return [row.firstName, row.lastName].join(' ')
}
},
{
field: 'field',
title: 'Field',
formatter: function (value, row) {
formatter (value, row) {
return [row.field1, row.field2, row.field3].join('+')
}
}
Expand Down
2 changes: 1 addition & 1 deletion issues/188.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</template>

<script>
function mounted() {
function mounted () {
$('#table').bootstrapTable()
}
</script>
4 changes: 2 additions & 2 deletions issues/220.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
</template>

<script>
var $table = $('#table')
const $table = $('#table')

function mounted() {
function mounted () {
$('#button').click(function () {
$table.bootstrapTable('hideColumn', 'state')
})
Expand Down
5 changes: 3 additions & 2 deletions issues/221.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
</template>

<script>
function cellStyle(value, row, index) {
var classes = ['active', 'success', 'info', 'warning', 'danger']
window.cellStyle = (value, row, index) => {
const classes = ['active', 'success', 'info', 'warning', 'danger']

if (index % 2 === 0 && index / 2 < classes.length) {
return {
css: {
Expand Down
2 changes: 1 addition & 1 deletion issues/2619.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</template>

<script>
function stateFormatter(value, row, index) {
window.stateFormatter = (value, row, index) => {
if (index === 2) {
return { disabled: true }
}
Expand Down
38 changes: 19 additions & 19 deletions issues/283.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,48 @@
</script>

<script>
var $table = $('#table')
const $table = $('#table')

function buildTable($el, cells, rows) {
var i
var j
var row
var columns = []
var data = []
function buildTable ($el, cells, rows) {
let i
let j
let row
const columns = []
const data = []

for (i = 0; i < cells; i++) {
columns.push({
field: 'field' + i,
title: 'Cell' + i
field: `field${i}`,
title: `Cell${i}`
})
}
for (i = 0; i < rows; i++) {
row = {}
for (j = 0; j < cells; j++) {
row['field' + j] = 'Row-' + i + '-' + j
row[`field${j}`] = `Row-${i}-${j}`
}
data.push(row)
}
$el.bootstrapTable('destroy').bootstrapTable({
columns: columns,
data: data
columns,
data
})
}

function mounted() {
function mounted () {
buildTable($('#table'), 10, 50)

var $d = $('#d')
var width = $d.width()
const $d = $('#d')
let width = $d.width()

$('#b').click(function() {
$('#b').click(function () {
width += 100
$d.css('width', width + 'px')
$d.css('width', `${width}px`)
$table.bootstrapTable('resetView')
})
$('#s').click(function() {
$('#s').click(function () {
width -= 100
$d.css('width', width + 'px')
$d.css('width', `${width}px`)
$table.bootstrapTable('resetView')
})
}
Expand Down
6 changes: 3 additions & 3 deletions issues/3345.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
</template>

<script>
var checkAll = false
let checkAll = false

function mounted() {
function mounted () {
$('#checkAll').click(function () {
checkAll = true
$('#table').bootstrapTable('checkAll')
Expand All @@ -67,7 +67,7 @@
})
}

function responseHandler(res) {
window.responseHandler = res => {
res.rows.forEach(function (item) {
item.state = checkAll
})
Expand Down
2 changes: 1 addition & 1 deletion issues/371.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</template>

<script>
function mounted() {
function mounted () {
$('form').submit(function (event) {
event.preventDefault()
alert($(this).serialize())
Expand Down
4 changes: 2 additions & 2 deletions issues/3784.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</script>

<script>
var ps
let ps

function mounted() {
function mounted () {
$('#table').on('post-body.bs.table', function () {
if (ps) ps.destroy()
ps = new window.PerfectScrollbar('.fixed-table-body')
Expand Down
4 changes: 2 additions & 2 deletions issues/383.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</script>

<script>
var $table = $('#table')
const $table = $('#table')

function mounted() {
function mounted () {
$table.on('post-body.bs.table', function () {
$(':checkbox').each(function () {
if (!$(this).parent().hasClass('checkbox')) {
Expand Down
9 changes: 5 additions & 4 deletions issues/3830.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@
</template>

<script>
var $table = $('#table')
const $table = $('#table')

function mounted() {
function mounted () {
$table.bootstrapTable()
}

function queryParams(params) {
var options = $table.bootstrapTable('getOptions')
window.queryParams = params => {
const options = $table.bootstrapTable('getOptions')

if (!options.pagination) {
params.limit = options.totalRows
}
Expand Down
16 changes: 7 additions & 9 deletions issues/386.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@
</template>

<script>
function queryParams(params) {
return {
page: params.pageNumber,
pageLimit: params.pageSize,
searchRecord: params.searchText,
sortName: params.sortName,
sortOrder: params.sortOrder
}
}
window.queryParams = params => ({
page: params.pageNumber,
pageLimit: params.pageSize,
searchRecord: params.searchText,
sortName: params.sortName,
sortOrder: params.sortOrder
})
</script>
Loading

0 comments on commit 148db82

Please sign in to comment.