本文整理汇总了C++中WString::jsStringLiteral方法的典型用法代码示例。如果您正苦于以下问题:C++ WString::jsStringLiteral方法的具体用法?C++ WString::jsStringLiteral怎么用?C++ WString::jsStringLiteral使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WString
的用法示例。
在下文中一共展示了WString::jsStringLiteral方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: chatSetUser
void Home::chatSetUser(const WString& userName)
{
WApplication::instance()->doJavaScript
("if (window.chat && window.chat.emit) {"
"""try {"
"" "window.chat.emit(window.chat, 'login', "
"" "" + userName.jsStringLiteral() + "); "
"""} catch (e) {"
"" "window.chatUser=" + userName.jsStringLiteral() + ";"
"""}"
"} else "
"""window.chatUser=" + userName.jsStringLiteral() + ";");
}
示例2: setText
void setText(const WString& text) {
WApplication::instance()->doJavaScript
(bufferText_->jsRef() + ".innerHTML="
"'<pre class=\"prettyprint\">' + prettyPrintOne("
+ text.jsStringLiteral() + ", " + bufferText_->jsRef()
+ ") + '</pre>';");
}
示例3: setText
void MessageBox::setText(const WString& text)
{
text_ = text;
if (!hidden_)
WApplication::instance()
->doJavaScript(elRef() + ".updateText(" + text.jsStringLiteral() + ");");
}
示例4: tellClient
/// Call this to push a server side validation result to the client side (complete with message)
static void tellClient(WFormWidget* widget, const WString& value, Result validationResult) {
widget->setJavaScriptMember("serverValidationResult",
"{ value:" + value.jsStringLiteral() + ","
"valid:" + (validationResult.state() == WValidator::Valid ? "true," : "false,") +
"message:" + validationResult.message().jsStringLiteral() + "}");
Wt::WApplication* app = Wt::WApplication::instance();
app->doJavaScript( app->javaScriptClass() + ".WT.validate(" + widget->jsRef() + ");" );
}
示例5: setToolTip
void WFormWidget::setToolTip(const WString& text, TextFormat textFormat)
{
WInteractWidget::setToolTip(text, textFormat);
if (validator_ && textFormat == PlainText) {
setJavaScriptMember("defaultTT", text.jsStringLiteral());
validate();
}
}
示例6: asJSLiteral
std::string asJSLiteral(const boost::any& v, TextFormat textFormat)
{
if (v.empty())
return std::string("''");
else if (v.type() == typeid(WString)) {
WString s = boost::any_cast<WString>(v);
bool plainText = false;
if (textFormat == XHTMLText) {
if (s.literal())
plainText = !WWebWidget::removeScript(s);
} else
plainText = true;
if (plainText && textFormat != XHTMLUnsafeText)
s = WWebWidget::escapeText(s);
return s.jsStringLiteral();
} else if (v.type() == typeid(std::string)
|| v.type() == typeid(const char *)) {
WString s = v.type() == typeid(std::string)
? WString::fromUTF8(boost::any_cast<std::string>(v))
: WString::fromUTF8(boost::any_cast<const char *>(v));
bool plainText;
if (textFormat == XHTMLText)
plainText = !WWebWidget::removeScript(s);
else
plainText = true;
if (plainText && textFormat != XHTMLUnsafeText)
s = WWebWidget::escapeText(s);
return s.jsStringLiteral();
} else if (v.type() == typeid(bool)) {
bool b = boost::any_cast<bool>(v);
return b ? "true" : "false";
} else if (v.type() == typeid(WDate)) {
const WDate& d = boost::any_cast<WDate>(v);
return "new Date(" + boost::lexical_cast<std::string>(d.year())
+ ',' + boost::lexical_cast<std::string>(d.month() - 1)
+ ',' + boost::lexical_cast<std::string>(d.day())
+ ')';
} else if (v.type() == typeid(WDateTime)) {
const WDateTime& dt = boost::any_cast<WDateTime>(v);
const WDate& d = dt.date();
const WTime& t = dt.time();
return "new Date(" + boost::lexical_cast<std::string>(d.year())
+ ',' + boost::lexical_cast<std::string>(d.month() - 1)
+ ',' + boost::lexical_cast<std::string>(d.day())
+ ',' + boost::lexical_cast<std::string>(t.hour())
+ ',' + boost::lexical_cast<std::string>(t.minute())
+ ',' + boost::lexical_cast<std::string>(t.second())
+ ',' + boost::lexical_cast<std::string>(t.msec())
+ ')';
}
#define ELSE_LEXICAL_ANY(TYPE) \
else if (v.type() == typeid(TYPE)) \
return boost::lexical_cast<std::string>(boost::any_cast<TYPE>(v))
ELSE_LEXICAL_ANY(short);
ELSE_LEXICAL_ANY(unsigned short);
ELSE_LEXICAL_ANY(int);
ELSE_LEXICAL_ANY(unsigned int);
ELSE_LEXICAL_ANY(long);
ELSE_LEXICAL_ANY(unsigned long);
ELSE_LEXICAL_ANY(::int64_t);
ELSE_LEXICAL_ANY(::uint64_t);
ELSE_LEXICAL_ANY(long long);
ELSE_LEXICAL_ANY(unsigned long long);
ELSE_LEXICAL_ANY(float);
ELSE_LEXICAL_ANY(double);
#undef ELSE_LEXICAL_ANY
else {