CommentsContainerWidget::CommentsContainerWidget(string videoId, Session* session, WContainerWidget* parent) : WContainerWidget(parent), d(videoId, session) { string querysql = "select content,last_updated,\ auth_info.email as email,\ auth_identity.identity as identity\ from comment\ inner join auth_info on comment.user_id = auth_info.user_id\ inner join auth_identity on auth_info.id = auth_identity.auth_info_id\ "; wApp->log("notice") << "comments query: " << querysql; auto query = d->session->query<CommentTuple>(querysql); query.where("media_id = ?").bind(videoId); query.where("auth_identity.provider = 'loginname'"); query.orderBy("last_updated DESC"); addWidget(WW<WText>(wtr("comments.label")).css("label").setInline(false)); WTextArea* newCommentContent = new WTextArea(); newCommentContent->setRows(3); newCommentContent->setInline(false); WPushButton* insertComment = WW<WPushButton>(wtr("comments.addcomment.button")).css("btn btn-primary btn-sm").onClick([=](WMouseEvent){ if(newCommentContent->text().empty()) return; Comment *comment = new Comment(videoId, d->session->user(), newCommentContent->text().toUTF8()); Dbo::Transaction t(*d->session); Dbo::ptr< Comment > newComment = d->session->add(comment); t.commit(); newCommentContent->setText(""); commentViewers.commentAdded(videoId, newComment.id()); }); newCommentContent->keyWentUp().connect([=](WKeyEvent){ insertComment->setEnabled(!newCommentContent->text().empty()); }); insertComment->setEnabled(false); // newCommentContent->setWidth(500); newCommentContent->addStyleClass("col-md-8"); addWidget(WW<WContainerWidget>().css("add-comment-box row").add(newCommentContent).add(insertComment).setContentAlignment(AlignCenter)); addWidget(d->commentsContainer = WW<WContainerWidget>().css("container") ); Dbo::Transaction t(*d->session); for(CommentTuple comment : query.resultList()) d->commentsContainer->addWidget(new CommentView(comment) ); auto commentAdded = [=] (string commentVideoId, long commentId) { if(commentVideoId != videoId) return; Dbo::Transaction t(*d->session); auto query = d->session->query<CommentTuple>(querysql).where("comment.id = ?").bind(commentId); query.where("auth_identity.provider = 'loginname'"); d->commentsContainer->insertWidget(0, new CommentView(query.resultValue())); d->commentsContainer->refresh(); wApp->triggerUpdate(); }; commentViewers.addClient(wApp->sessionId(), commentAdded); }
WWidget *FormWidgets::wTextArea() { WContainerWidget *result = new WContainerWidget(); topic("WTextArea", result); addText(tr("formwidgets-WTextArea"), result); WTextArea *ta = new WTextArea(result); ta->setColumns(80); ta->setRows(15); ta->setText(tr("formwidgets-WTextArea-contents")); ed_->showSignal(ta->changed(), "Text area changed"); addText(tr("formwidgets-WTextArea-related"), result); return result; }
void Recaptcha::update_impl() { if (!implementation()) { setImplementation(new WContainerWidget()); } get_impl()->clear(); WText* title = new WText("reCAPTCHA", get_impl()); title->addStyleClass("wc_recaptcha_title"); if (js()) { WContainerWidget* image = new WContainerWidget(get_impl()); image->setId("recaptcha_image"); response_field_ = input_ ? input_ : new WLineEdit(get_impl()); challenge_field_ = new WLineEdit(get_impl()); // not challenge_field_->hide() to get its .text() doJavaScript("$(" + challenge_field_->jsRef() + ").hide();"); response_field_->setId("recaptcha_response_field"); doJavaScript("Recaptcha.create('" + public_key_ + "', ''," "{theme: 'custom'});"); if (buttons_enabled_) { add_buttons(); } doJavaScript("clearTimeout($(" + jsRef() + ").data('timer'));"); doJavaScript("$(" + jsRef() + ").data('timer'," "setInterval(function() {" "$(" + challenge_field_->jsRef() + ")" ".val(Recaptcha.get_challenge());" "}, 200));"); } else { WTemplate* iframe = new WTemplate(get_impl()); iframe->setTemplateText("<iframe src='https://www.google.com/recaptcha/" "api/noscript?k=" + public_key_ + "' height='300' width='500' frameborder='0'>" "</iframe>", XHTMLUnsafeText); if (input_) { challenge_field_ = input_; } else { WTextArea* ta = new WTextArea(get_impl()); ta->setColumns(40); ta->setRows(3); challenge_field_ = ta; } response_field_ = new WLineEdit("manual_challenge", get_impl()); response_field_->hide(); } }
CShowLog::CShowLog(WContainerWidget *parent): WContainerWidget(parent) { refreshCount=0; string strTemp1,strTemp2; OBJECT objRes=LoadResource("default", "localhost"); if( objRes !=INVALID_VALUE ) { MAPNODE ResNode=GetResourceNode(objRes); if( ResNode != INVALID_VALUE ) { FindNodeValue(ResNode,"IDS_LogShow",strMainTitle); FindNodeValue(ResNode,"IDS_ReadLogError",strTemp1); FindNodeValue(ResNode,"IDS_MonitorLogContext",strTemp2); } CloseResource(objRes); } char buf_tmp[4096]={0}; int nSize =4095; GetEnvironmentVariable( "QUERY_STRING", buf_tmp,nSize); //char * tmpquery; //tmpquery = getenv( "QUERY_STRING"); //if(tmpquery) // strcpy(buf_tmp,tmpquery); if(buf_tmp != NULL) { std::string buf1 = buf_tmp; int pos = buf1.find("=", 0); querystr = buf1.substr(pos+1, buf1.size() - pos - 1); } strPath = ""; strPath += GetSiteViewRootPath(); strPath += "\\data\\Temp\\"; strPath += querystr; strPath += ".txt"; string strTemp; string strOutput; try { ifstream Input(strPath.c_str(), ios::out); //获取日志行数 nTotleLine = 0; nCurLine = 0; nPageLine = 100; if(Input.is_open()) { while(!Input.eof()) { nTotleLine++; getline(Input, strTemp , '\n'); //puts(strTemp.c_str()); } Input.close(); } //获取日志最新100行数数据 nStartLine = nTotleLine - nPageLine; //Input.open(strPath.c_str(), ios::out, 0); ifstream Input1(strPath.c_str(), ios::out); if(Input1.is_open()) { while(!Input1.eof()) { if(nTotleLine <= nPageLine) { getline(Input1, strTemp , '\n'); strOutput += strTemp; strOutput += "\n"; } else { if(nCurLine >= nStartLine) { getline(Input1, strTemp , '\n'); strOutput += strTemp; strOutput += "\n"; } else getline(Input1, strTemp , '\n'); nCurLine++; } } Input1.close(); } } catch(...) { strOutput = strTemp1; } WTable * pContainTable = new WTable(this); //日志标题 string strLogTitle = GetDeviceTitle(querystr); strLogTitle += ":"; strLogTitle += GetMonitorPropValue(querystr, "sv_name"); strLogTitle += strTemp2; pContainTable ->setStyleClass("t5"); //pContainTable->setStyleClass("StatsTable"); WText * pReportTitle = new WText(strLogTitle, (WContainerWidget*)pContainTable->elementAt(0, 0)); pContainTable->elementAt(0, 0)->setContentAlignment(AlignTop | AlignCenter); WFont font1; font1.setSize(WFont::Large, WLength(60, WLength::Pixel)); pReportTitle ->decorationStyle().setFont(font1); //日志内容 WTextArea * pStateTextArea = new WTextArea(strOutput, (WContainerWidget*)pContainTable->elementAt(1, 0)); //pContainTable->elementAt(1, 0)->setStyleClass("t5"); pContainTable->elementAt(1, 0)->resize(WLength(100,WLength::Percentage), WLength(100,WLength::Percentage)); pStateTextArea->setRows(nPageLine); pStateTextArea->setColumns(60); pStateTextArea ->setStyleClass("testingresult2"); //pStateTextArea->resize(WLength(100,WLength::Percentage), WLength(100,WLength::Percentage)); pStateTextArea->resize(WLength(100,WLength::Percentage), WLength(100,WLength::Percentage)); strcpy(pStateTextArea->contextmenu_ , "readonly=\"readonly\""); //strPageTitle = ""; //new WText("日志内容:", pMainTable->elementAt(4, 0)); //new WText(strOutput, pMainTable->elementAt(2,0)); //版权信息 WText * bottomTitle = new WText("Copyright SiteView", pContainTable->elementAt(2, 0)); bottomTitle ->decorationStyle().setFont(font1); pContainTable->elementAt(2, 0)->setContentAlignment(AlignTop | AlignCenter); bottomTitle->decorationStyle().setForegroundColor(Wt::blue); }