Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F41923771
caesar.html
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
caesar.html
View Options
<
h2
>
Caesar cipher
</
h2
>
<
form
>
<
div
class
=
"row collapse"
style
=
"margin-bottom: 1em;"
>
<
h3
>
Source text
</
h3
>
<
textarea
rows
=
"4"
name
=
"text"
id
=
"text"
placeholder
=
"Lorem ipsum dolor sit amet nunc abuntur - Write here the text to rewrite."
></
textarea
>
<
h3
>
Permutations
</
h3
>
<
div
id
=
"permutations"
><
em
>
Write some text above to compute permutations.
</
em
></
div
>
</
div
>
</
form
>
<
script
>
function
shiftLetter
(
c
,
k
)
{
const
baseValue
=
c
.
charCodeAt
(
0
)
-
64
if
(
baseValue
<
0
||
baseValue
>
26
)
{
return
c
}
shiftedValue
=
(
baseValue
+
26
-
k
)
%
26
if
(
shiftedValue
===
0
)
{
shiftedValue
=
26
// Z and not @
}
return
String
.
fromCharCode
(
64
+
shiftedValue
)
}
function
permute
(
sourceText
,
targetElement
)
{
targetElement
.
empty
()
for
(
let
k
=
1
;
k
<
26
;
k
++
)
{
permutedText
=
sourceText
.
split
(
''
)
.
map
(
c
=>
shiftLetter
(
c
,
k
))
.
join
(
''
)
targetElement
.
append
(
"<p>"
+
permutedText
+
"</p>"
)
}
}
$
(
'#text'
).
bind
(
'input propertychange'
,
function
()
{
permute
(
$
(
this
).
val
().
toUpperCase
(),
$
(
"#permutations"
))
})
</
script
>
File Metadata
Details
Attached
Mime Type
text/html
Expires
Sat, Aug 8, 03:05 (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3961809
Default Alt Text
caesar.html (1 KB)
Attached To
Mode
rTOOLS Nasqueron Tools
Attached
Detach File
Event Timeline
Log In to Comment