Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wt/WApplication>
- #include <Wt/WEnvironment>
- #include <Wt/WContainerWidget>
- #include <Wt/WPushButton>
- #include <Wt/WText>
- #include <Wt/WBreak>
- using namespace Wt;
- class ProgressionTestApplication : public WApplication
- {
- public:
- ProgressionTestApplication(const WEnvironment& env);
- void printajaxinfo();
- private:
- WPushButton* upgradeButton;
- WContainerWidget* outputBox;
- WText* progressedText;
- WText* jsEnabledText;
- WText* ajaxEnabledText;
- WText* wsEnabledText;
- bool progressed;
- protected:
- void enableAjax();
- };
- ProgressionTestApplication::ProgressionTestApplication(const WEnvironment& env)
- : WApplication(env)
- {
- setTitle("Progression Test: Will Progressive BootStrap upgrade to AJAX then WebSockets?");
- progressed = false;
- upgradeButton = new WPushButton(root());
- upgradeButton->setText("Upgrade!");
- upgradeButton->clicked().connect(this,&ProgressionTestApplication::printajaxinfo);
- outputBox = new WContainerWidget(root());
- progressedText = new WText("Has WT Progressed to AJAX: No",outputBox);
- outputBox->addWidget(new WBreak());
- jsEnabledText = new WText("Is JavaScript Enabled: N/A",outputBox);
- outputBox->addWidget(new WBreak());
- ajaxEnabledText = new WText("Is AJAX Enabled: N/A",outputBox);
- }
- void ProgressionTestApplication::printajaxinfo( void )
- {
- bool jse = environment().javaScript();
- bool ajaxe = environment().ajax();
- progressedText->setText("Has WT Progressed to AJAX: " + WString(progressed ? "Yes" : "No"));
- jsEnabledText->setText("Is JavaScript Enabled: " + WString(jse ? "Yes" : "No"));
- ajaxEnabledText->setText("Is AJAX Enabled: " + WString(ajaxe ? "Yes" : "No"));
- }
- void ProgressionTestApplication::enableAjax()
- {
- progressed = true;
- WApplication::enableAjax();
- printajaxinfo();
- }
- WApplication *createApplication(const WEnvironment& env)
- {
- return new ProgressionTestApplication(env);
- }
- int main(int argc, char **argv)
- {
- return WRun(argc, argv, &createApplication);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement