Skip to content

Commit

Permalink
Merge pull request #1839 from kujirahand/updated_create_form_func
Browse files Browse the repository at this point in the history
「フォーム作成」命令の強化 - 項目の指定を二次元配列で指定できるようにする #1829
  • Loading branch information
kujirahand authored Nov 24, 2024
2 parents 3b1eb65 + 7504ed5 commit 577dfd5
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/plugin_browser_dom_parts.mts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export default {
type: 'func',
josi: [['で', 'の'], ['を']],
pure: true,
fn: function (obj: any, s: any, sys: any) {
fn: function (obj: any, s: string|Array<string>|Array<Array<string>>, sys: any) {
const frm = sys.__exec('DOM部品作成', ['form', sys])
// 可能ならformにobjの値を移し替える
if (obj instanceof Object) {
Expand All @@ -275,13 +275,24 @@ export default {
}
}
// 入力項目をtableで作る
const rows = s.split('\n')
const table = document.createElement('table')
// 入力項目がstringの場合、改行で分割
let rows: Array<string>|Array<Array<string>>
if (typeof s === 'string') {
rows = s.split('\n')
} else {
rows = s
}
// 入力項目に合わせて行を追加
for (const rowIndex in rows) {
let row = '' + (rows[rowIndex])
if (row === '') { continue }
if (row.indexOf('=') < 0) { row += '=' }
const cols = row.split('=')
const row: Array<string>|string = rows[rowIndex]
let cols: Array<string>
if (typeof row === 'string') {
cols = row.split('=')
} else {
cols = row
}
if (cols.length < 2) { cols.push('') }
const key = cols[0]
const val = cols[1]
// key
Expand Down

0 comments on commit 577dfd5

Please sign in to comment.