Exemple #1
0
        public void saveCurrentPage()
        {
            var currentPage = WikiPage_TextBox.get_Text();

            if (WikiApi.loggedIn().isFalse())
            {
                StatusLabel.set_Text("You need to be logged in to save pages").textColor(Color.Red);
                var credential = ascx_AskUserForLoginDetails.ask();
                if (credential.notNull())
                {
                    WikiApi.login(credential.UserName, credential.Password);
                    if (WikiApi.loggedIn())
                    {
                        StatusLabel.set_Text("You are now logged in as user: {0}".format(credential.UserName)).textColor(Color.DarkGreen);
                    }
                    else
                    {
                        StatusLabel.set_Text("Login failed for user: {0}".format(credential.UserName)).textColor(Color.Red);
                    }
                }
            }
            else
            {
                StatusLabel.set_Text("saving page {0} ".format(currentPage)).textColor(Color.Black);

                // save content
                WikiApi.save(currentPage, WikiTextEditor.get_Text());

                // reload content and show it
                var wikiText = WikiApi.wikiText(currentPage);
                BrowserPreview.open("about:blank");
                //BrowserPreview.set_Text(WikiApi.parseText(wikiText,true));
                BrowserCurrent.set_Text(WikiApi.html(currentPage));
                StatusLabel.set_Text("Page {0} saved".format(currentPage)).textColor(Color.DarkGreen);
            }
        }