Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F10360936
field_type.text.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
984 B
Referenced Files
None
Subscribers
None
field_type.text.js
View Options
var
Sealious
=
require
(
"../main.js"
);
var
Promise
=
require
(
"bluebird"
);
var
sanitizeHtml
=
require
(
"sanitize-html"
);
var
field_type_text
=
Sealious
.
ChipTypes
.
FieldType
({
name
:
"text"
,
is_proper_value
:
function
(
accept
,
reject
,
context
,
params
,
new_value
){
if
(
params
==
undefined
||
params
.
max_length
===
undefined
){
accept
()
}
else
{
if
(
new_value
.
length
<=
params
.
max_length
){
accept
()
}
else
{
reject
(
"Text '"
+
new_value
+
"' has exceeded max length of "
+
params
.
max_length
+
" chars."
);
}
}
},
encode
:
function
(
value_in_code
,
params
){
if
(
params
&&
params
.
strip_html
===
true
){
var
stripped
=
sanitizeHtml
(
value_in_code
.
toString
(),
{
allowedTags
:
[]
})
return
Promise
.
resolve
(
stripped
);
}
else
{
if
(
value_in_code
instanceof
Object
){
return
Promise
.
resolve
(
JSON
.
stringify
(
value_in_code
));
}
else
if
(
value_in_code
==
null
){
return
Promise
.
resolve
(
""
);
}
else
{
return
Promise
.
resolve
(
value_in_code
.
toString
());
}
}
}
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 8, 10:02 (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1034440
Default Alt Text
field_type.text.js (984 B)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment