I have the following app structure:
Main Page : Choose Login Type A or B
if the user choses login type A then navigate to > Page A1 Credentials for A type
if the user choses login type B then navigate to > Page B1 Credentials for B type
if Login is successfull for page A1 navigate to > Page A2
if Login is successfull for page B1 navigate to > Page B2
Page A1 --- Login Successful ---> Page A2
/
/
/
Page 1 \
\
\
Page B1 --- Login Successful ---> Page B2
If the user is in Page A1 or B1, I would like to allow him to go back to page 1 if he wants. However if the user logs in either using type 1 or 2 and reaches either A2 or B2, he shouldn't be allowed to go back.
Here is my code :
Before going to pages A2 or B2 I run. (This code executes in pages A1, B1) :
public static void RemoveAllPagesFromNavigation(INavigation Navigation)
{
var existingPages = Navigation.NavigationStack.ToList();
foreach (var page in existingPages)
{
if (page != null)
{
Navigation.RemovePage(page);
}
}
}
RemoveAllPagesFromNavigation(this.Navigation);
await Navigation.PushAsync(new PageA2()); // Or PageB2
But the function RemoveAllPagesFromNavigation raises an exception saying that the first element of the NavigationStack is null;
I added a condition to skip the case where the first page is null, the function runs but the end user is still able to go back to page Page 1.
Does anyone know how to prevent user from going back to the pages 1, A1 or B2 ?
Thanks.
According to Shell navigation / Absolute routes, the use of // at beginning of a route will replace the current nav stack. Thus there will be nowhere to go back to.
await Shell.Current.GoToAsync("//Page2");
FYI ALTERNATIVE:
There is an alternative navigation paradigm, NavigationPage that lacks appshell features such as "Routes". Advantage is simple, direct, programmatic control over the navigation stack. (Without the subtleties that AppShell introduces. One of which you have encountered.)
Consider using NavigationPage during the login sequence, only going to AppShell once user is in your main content. (Or omit AppShell completely, just use NavigationPage for your app.)
To do so, in App.xaml.cs, replace:
MainPage = new AppShell();
with:
MainPage = new NavigationPage();.
Then use NavigationPage features to show first login page, etc. Don't use anything from that AppShell navigation doc I linked earlier.
If after login success, you want to use AppShell navigation, do:
Application.Current.MainPage = new AppShell();.
THIRD ALTERNATIVE:
Do Application.Current.MainPage = new MyNextFascinatingPage(); to step through the login sequence. Thus there is nowhere for user to go back to, during these steps. (If you want them to go back, you do so explicitly, by creating a new copy of earlier page.)
After login success, do:
Application.Current.MainPage = new AppShell();.
When you successful navigate to Page A2 or Page B2, you will have 3 pages in the NavigationStack, so remove first 2 pages which is (Page 1 and (Page A1 or Page B1)) then the Page A2 or Page B2 will be the root page.
you can use
public Main()
{
NavigationPage.SetHasNavigationBar(this, false);
NavigationPage.SetHasBackButton(this, false);
InitializeComponent();
}
on the page that you want user not be able to back from.
Related
I'm using Foundation 6 to make my websites frontend. Above the header of my website I want to show a promotionbar, which should be closeable / dismisable.
Therefore I'm using a close-button, coming out of the box with Foundation, to hide / dismis the promotionbar.
Now I want, that if the user closes / hides the promotionbar, that (for the rest of the session) the bar will not be shown anymore.
As the closebutton just "hides" the element, the bar will be shown again if I go to another subpage (for example, coming from a blogpost -> going back to the frontpage).
Is there a simple way to keep the bar hidden, after I've clicked on the closebutton for the rest of the session?
If the user stops by another day, the bar should be shown again.
https://foundation.zurb.com/sites/docs/close-button.html
Thank you in advance!
Thank you #daniel-ruf - I've solved it the following way if anybody is looking for a solution
Give the promotionbar an unique ID (id="promotionbar")
Add a class to the promotionbar (class="hider")
Add display:none, to the class via CSS File (.hider {display:none;})
Add onClick action the closebutton
button class="close-button" data-close="" onclick="promotionhide()">×
in App.js add
var cacheKeyNoPromo = 'promotionhide';
var nopromo = readFromCache(cacheKeyNoPromo);
if (!nopromo) {
document.getElementById("promotionbar").classList.remove("hider");
}
var promotionhide = function() {
writeToCache(cacheKeyNoPromo, true, 24 * 60 * 60 * 1000 /* 1D */);
document.getElementById("promotionbar").classList.add("hider");
};
works for me.
I have a number of Panels which, when expanded, show the corresponding questions for that particular 'Category'
The issue I have is, say for example I answer the questions for the 1st panel, the content will scroll down, eventually hiding the panel... fair enough.
However, when I click on the Next Category (Production Area), I need to the page to scroll back up to the first question in the Category, or maybe even just display the selected category at the top of the page.
Is this possible?
Currently, the user has to continually scroll back if when they select the next Category.
You can achieve it using scrollToElement()
var oPage = sap.ui.getCore().byId("pageId"); // you page ID
var oList = sap.ui.getCore().byId("ListId"); // element ID to which it has to scroll
if (oPage && oList) oPage.scrollToElement(oList, 1000);
Execute the above code inside the panel event expand.
you can try to use this control instead which suits your needs
https://sapui5.hana.ondemand.com/#/entity/sap.uxap.ObjectPageLayout
After trying everything, this is what worked for me.
onExpand: function (oEvent) {
if (oEvent.getParameters().expand) {
var focusID = oEvent.getParameter("id");
var elmnt = sap.ui.getCore().byId(focusID);
elmnt.getDomRef().scrollIntoView(true);
I'm trying to make Greasemonkey script that clicks on a button at intervals and also clicks on it at the first load without wait.
I made this code which clicks every 120 seconds but the first time the page loads I have to wait 120 seconds for the code to click the GO button or I have to manually do it. :
window.setTimeout(function(){document.getElementById("masterPage_cphPageBody_btnGo").click()},120000)
and here is the source code related to it from the website
<input id="masterPage_cphPageBody_btnGo" name="masterPage$cphPageBody$btnGo" value="Go" onclick="SetSearchDate();showWaitpage();" class="btn2" type="submit">
How can I add a line to click on the GO the first time the page loads and 120 seconds there after?
the webpage before and after pressing the GO button has the same exact URL so adding the click on GO button without wait time will send hte page into a loop of
URL loaded GO clicked
URL Loaded GO clicked
URL Loaded GO clicked
...
checked the differences of the page before and after the first time GO button is clicked...
so I need the script to click Go button immidiately only if the following page does NOT show on the page
<span id="masterPage_cphPageBody_lblSelectAvailableTime" class="bodyBold">Select an available time</span>
but if "Select an available time" text show on page the script should wait 120 secon
I'm running: Greasemonkey, Windows 8 64, Firefox
Use a named function instead on an anonymous one (Often a good idea anyway).
Then use document.querySelector to check if that element is present. (That function has much more flexibility than getElementById.)
So your code becomes:
if (null === document.querySelector ("#masterPage_cphPageBody_lblSelectAvailableTime") ) {
clickGoButton (); //-- Initial, immediate click.
}
window.setTimeout (clickGoButton, 120000);
function clickGoButton () {
document.getElementById ("masterPage_cphPageBody_btnGo").click ();
}
Considering the post and pre Go button URL are the same to avoid the boot loop I found a textual difference between post and pre click and used it to avoid the loop
here is the code that worked for me at last
if (/Select an available time/i.test (document.body.innerHTML) )
{
window.setTimeout (clickGoButton, 120000);
}
else {
clickGoButton ();
}
function clickGoButton () {
document.getElementById ("masterPage_cphPageBody_btnGo").click ();
}
I am using datatable version 1.9.x.
I want to get the page number if the user directly clicks on the page number, like 3 or 4.
I am able to get page number when he clicks next button using fnPagingInfo , but I am not able to get page number when he clicks the page directly.
This is my code :
$('#xyz').on('page dt', function () {
var info = bill_ov_np.selected.table.fnPagingInfo();
console.log(info);
});
I can get the page number from above function, but only when user clicks next button, not when the page number is directly selected.
Thanks in advance.
$(document).bind('click',"div.pagination li",function(evt){
var info = bill_ov_np.selected.table.fnPagingInfo();
});
This is the solution which I found and it is working for me.
I cannot find an answer on the following issue. I have managed to reload a specific part of my page (page A) by using AJAX (through document.getElementById). I would like to know if there is a way to choose which part of the document (page B) will be used to reload the content of page A. In other words, pick a specific DIV from a 2nd page (same domain) and use it to refresh the contents of my page. I have seen in other threads that it is not possible to do it with pages that aren't from the same domain. But in my case I will use a page from the same domain. Any ideas?
Thanks.
If you have page A loaded and your scripts run there, so this will do:
var ifr = document.createElement('iframe');
ifr.src = 'page B URL';
ifr.style.position = 'absolute';
ifr.style.left = '-1000px';
ifr.onload = function() {
document.getElementById('page A div id').innerHTML =
ifr.contentDocument.getElementById('page B div id');
}
document.getElementsByTagName('body')[0].appendChild(ifr);
Note: page B loads and runs completely. If you need the only div to be passed through the Internet connection, you need to implement server side logic.