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(); } }
void Home::createHome() { WTemplate *result = new WTemplate(tr("template"), root()); homePage_ = result; WContainerWidget *languagesDiv = new WContainerWidget(); languagesDiv->setId("top_languages"); for (unsigned i = 0; i < languages.size(); ++i) { if (i != 0) new WText("- ", languagesDiv); const Lang& l = languages[i]; new WAnchor(WLink(WLink::InternalPath, l.path_), WString::fromUTF8(l.longDescription_), languagesDiv); } WStackedWidget *contents = new WStackedWidget(); WAnimation fade(WAnimation::Fade, WAnimation::Linear, 250); contents->setTransitionAnimation(fade); contents->setId("main_page"); mainMenu_ = new WMenu(contents, Vertical); mainMenu_->addItem (tr("introduction"), introduction())->setPathComponent(""); mainMenu_->addItem (tr("blog"), deferCreate(boost::bind(&Home::blog, this))); mainMenu_->addItem (tr("features"), wrapView(&Home::features), WMenuItem::PreLoading); mainMenu_->addItem (tr("documentation"), wrapView(&Home::documentation), WMenuItem::PreLoading); mainMenu_->addItem (tr("examples"), examples(), WMenuItem::PreLoading)->setPathComponent("examples/"); mainMenu_->addItem (tr("download"), deferCreate(boost::bind(&Home::download, this)), WMenuItem::PreLoading); mainMenu_->addItem (tr("community"), wrapView(&Home::community), WMenuItem::PreLoading); mainMenu_->addItem (tr("other-language"), wrapView(&Home::otherLanguage), WMenuItem::PreLoading); mainMenu_->itemSelectRendered().connect(this, &Home::updateTitle); mainMenu_->itemSelected().connect(this, &Home::googleAnalyticsLogger); // Make the menu be internal-path aware. mainMenu_->setInternalPathEnabled("/"); sideBarContent_ = new WContainerWidget(); result->bindWidget("languages", languagesDiv); result->bindWidget("menu", mainMenu_); result->bindWidget("contents", contents); result->bindWidget("sidebar", sideBarContent_); }