Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7189041
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
1 KB
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
=
new
Sealious
.
ChipTypes
.
FieldType
({
name
:
"text"
,
get_description
:
function
(
context
,
params
){
return
"Text with a maximum length "
+
params
.
max_length
},
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
(
context
,
params
,
value_in_code
){
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
(
null
);
}
else
{
return
Promise
.
resolve
(
value_in_code
.
toString
());
}
}
}
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jul 8, 08:42 (2 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
810354
Default Alt Text
field_type.text.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment