Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cards
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tie
ohj2
esimerkit
cards
Commits
debb97a0
Commit
debb97a0
authored
3 months ago
by
Vesa Lappalainen
Browse files
Options
Downloads
Patches
Plain Diff
new pali examples
parent
f499713a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
README.md
+7
-1
7 additions, 1 deletion
README.md
pali2.html
+37
-0
37 additions, 0 deletions
pali2.html
pali3.html
+60
-0
60 additions, 0 deletions
pali3.html
pali4.html
+3
-3
3 additions, 3 deletions
pali4.html
pali5.html
+108
-0
108 additions, 0 deletions
pali5.html
with
215 additions
and
4 deletions
README.md
+
7
−
1
View file @
debb97a0
# cards
Esimerkkejä TIMiin upotettavista kompononenteista
Examples of components to be used inside
[
TIM
](
tim.jyu.fi
)
See:
-
<https://tim.jyu.fi/view/tim/components/js/jsframekomponentti>
-
<https://tim.jyu.fi/view/tim/components/cards/korttipelit>
-
<https://tim.jyu.fi/view/tim/components/cards/jarjestamispelit>
This diff is collapsed.
Click to expand it.
pali2.html
0 → 100644
+
37
−
0
View file @
debb97a0
<!DOCTYPE html>
<html
lang=
"fi"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Palindromi
</title>
</head>
<body>
<div>
<label
for=
"word"
>
Anna sana:
</label>
<input
id=
"word"
type=
"text"
name=
"word"
>
<span
id=
"icon"
></span>
</div>
<script>
const
input
=
document
.
getElementById
(
"
word
"
);
input
.
addEventListener
(
'
input
'
,
()
=>
this
.
checkPalindrome
());
function
checkPalindrome
()
{
const
word
=
document
.
getElementById
(
"
word
"
).
value
;
const
icon
=
document
.
getElementById
(
"
icon
"
);
let
isPalindrome
=
true
;
for
(
let
i
=
0
,
j
=
word
.
length
-
1
;
i
<
j
;
i
++
,
j
--
)
{
if
(
word
[
i
]
!==
word
[
j
])
{
isPalindrome
=
false
;
break
;
}
}
if
(
isPalindrome
)
{
icon
.
textContent
=
'
✔
'
;
icon
.
style
.
color
=
'
green
'
;
}
else
{
icon
.
textContent
=
'
✘
'
;
icon
.
style
.
color
=
'
red
'
;
}
}
</script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pali3.html
0 → 100644
+
60
−
0
View file @
debb97a0
<!DOCTYPE html>
<html
lang=
"fi"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Palindromi
</title>
</head>
<body>
<div
id=
"container"
>
<label
id=
"label"
for=
"word"
>
Anna sana:
</label>
<input
id=
"word"
type=
"text"
name=
"word"
>
<span
id=
"icon"
></span>
</div>
<script>
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
const
container
=
document
.
getElementById
(
'
container
'
);
new
Pali
(
container
);
});
class
Pali
{
constructor
(
container
)
{
this
.
settings
=
{
inputChars
:
10
,
// input alueen leveys
minChars
:
0
,
// sanassa tarvittavien merkkien minimimäärä
labelText
:
"
Anna sana:
"
,
// labelin teksti
}
this
.
container
=
container
;
this
.
createContent
();
}
createContent
()
{
const
s
=
this
.
settings
;
this
.
input
=
this
.
container
.
querySelector
(
"
#word
"
);
this
.
icon
=
this
.
container
.
querySelector
(
"
#icon
"
);
const
label
=
this
.
container
.
querySelector
(
"
#label
"
);
label
.
textContent
=
s
.
labelText
.
replace
(
'
${count}
'
,
s
.
minChars
);
this
.
input
.
style
.
width
=
s
.
inputChars
+
'
ch
'
;
this
.
input
.
addEventListener
(
'
input
'
,
()
=>
this
.
checkPalindrome
());
}
checkPalindrome
()
{
const
word
=
this
.
input
.
value
;
let
isPalindrome
=
true
;
for
(
let
i
=
0
,
j
=
word
.
length
-
1
;
i
<
j
;
i
++
,
j
--
)
{
if
(
word
[
i
]
!==
word
[
j
])
{
isPalindrome
=
false
;
break
;
}
}
if
(
isPalindrome
&&
this
.
settings
.
minChars
<=
word
.
length
)
{
this
.
icon
.
textContent
=
'
✔
'
;
this
.
icon
.
style
.
color
=
'
green
'
;
}
else
{
this
.
icon
.
textContent
=
'
✘
'
;
this
.
icon
.
style
.
color
=
'
red
'
;
}
}
}
</script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pali
yhd
.html
→
pali
4
.html
+
3
−
3
View file @
debb97a0
...
...
@@ -41,9 +41,9 @@ class Pali {
}
createContent
()
{
const
s
=
this
.
settings
;
this
.
input
=
document
.
getElementById
(
"
word
"
);
this
.
icon
=
document
.
getElementById
(
"
icon
"
);
const
label
=
document
.
getElementById
(
"
label
"
);
this
.
input
=
this
.
container
.
querySelector
(
"
#
word
"
);
this
.
icon
=
this
.
container
.
querySelector
(
"
#
icon
"
);
const
label
=
this
.
container
.
querySelector
(
"
#
label
"
);
label
.
textContent
=
s
.
labelText
.
replace
(
'
${count}
'
,
s
.
minChars
);
this
.
input
.
style
.
width
=
s
.
inputChars
+
'
ch
'
;
...
...
This diff is collapsed.
Click to expand it.
pali5.html
0 → 100644
+
108
−
0
View file @
debb97a0
<!DOCTYPE html>
<html
lang=
"fi"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Palindromi
</title>
<script>
if
(
window
.
self
===
window
.
top
)
{
// lokaali ajo
window
.
jsframedata
=
{
params
:
{
inputChars
:
8
,
minChars
:
6
,
labelText
:
'
Anna palindromi, jossa vähintään ${count} kirjainta:
'
}
};
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
onInit
();
setData
({
c
:
{
text
:
'
kissa
'
}
});
}
);
}
</script>
</head>
<body>
<div
id=
"container"
>
<p>
<label
id=
"label"
for=
"word"
>
Anna sana:
</label>
<input
id=
"word"
type=
"text"
name=
"word"
>
<span
id=
"icon"
></span>
</p>
</div>
<script>
function
onInit
()
{
const
container
=
document
.
getElementById
(
'
container
'
);
window
.
pali
=
new
Pali
(
container
,
window
.
jsframedata
);
}
function
setData
(
data
)
{
if
(
!
window
.
pali
)
onInit
();
// varulta
window
.
pali
.
setData
(
data
);
}
function
saveData
(
data
)
{
window
.
port2
.
postMessage
({
msg
:
"
datasave
"
,
data
:
{
...
data
}
});
}
function
getData
()
{
return
{
c
:
{
text
:
`
${
window
.
hullu
.
counterLeft
.
value
}
;
${
window
.
hullu
.
counter
.
value
}
`
}
};
}
function
updateData
(
data
)
{
window
.
port2
.
postMessage
({
msg
:
"
update
"
,
data
:
{
...
data
}
});
}
class
Pali
{
constructor
(
container
,
data
)
{
this
.
settings
=
{
inputChars
:
10
,
// input alueen leveys
minChars
:
0
,
// sanassa tarvittavien merkkien minimimäärä
labelText
:
"
Anna sana:
"
,
// labelin teksti
}
if
(
data
)
Object
.
assign
(
this
.
settings
,
data
.
params
);
this
.
container
=
container
;
this
.
createContent
();
}
createContent
()
{
const
s
=
this
.
settings
;
this
.
input
=
this
.
container
.
querySelector
(
"
#word
"
);
this
.
icon
=
this
.
container
.
querySelector
(
"
#icon
"
);
const
label
=
this
.
container
.
querySelector
(
"
#label
"
);
label
.
textContent
=
s
.
labelText
.
replace
(
'
${count}
'
,
s
.
minChars
);
this
.
input
.
style
.
width
=
s
.
inputChars
+
'
ch
'
;
this
.
input
.
addEventListener
(
'
input
'
,
()
=>
this
.
checkPalindrome
());
}
checkPalindrome
()
{
const
word
=
this
.
input
.
value
;
let
isPalindrome
=
true
;
for
(
let
i
=
0
,
j
=
word
.
length
-
1
;
i
<
j
;
i
++
,
j
--
)
{
if
(
word
[
i
]
!==
word
[
j
])
{
isPalindrome
=
false
;
break
;
}
}
if
(
isPalindrome
&&
this
.
settings
.
minChars
<=
word
.
length
)
{
this
.
icon
.
textContent
=
'
✔
'
;
this
.
icon
.
style
.
color
=
'
green
'
;
}
else
{
this
.
icon
.
textContent
=
'
✘
'
;
this
.
icon
.
style
.
color
=
'
red
'
;
}
updateData
(
getData
());
}
getData
()
{
return
{
c
:
{
text
:
this
.
input
.
value
}
};
}
setData
(
data
)
{
this
.
input
.
value
=
data
.
c
.
text
;
this
.
checkPalindrome
();
}
}
</script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment