Quantcast
Channel: jQuery Forum
Viewing all 12211 articles
Browse latest View live

Re : Cookies or Sessions for JQuery Mobile?

$
0
0
Sounds pretty draconian . You can just start off a setTimeout whenever you hit a new page.

  1. clearTimeout( draconianLogout );
  2. draconianLogout = setTimeout( function(){
  3.       location.href="logout.php"
  4. }, 10*60*1000 /*tenMinutes */);


JΛ̊KE

Re : Cookies or Sessions for JQuery Mobile?

$
0
0
If you want to actually enforce it, you HAVE to do it on your server.

And, at that, all you can do is require the user to log-in again to access server resources. Some JS can "log out" the user, and "prevent" the user from viewing things in the webpage, but not really. If somebody want to go in and change the Javascript, or go snooping through the HTML/JS/CSS raw content, Ajax requests and responses, etc. there is nothing you can do to stop them.

NEVER rely on Javascript for any part of security. (The one exception is browser plugins. Although it makes me nervous, browser plugins like LastPass can be used to manage passwords, if the author doesn't mess-up in some way...)

Once the browser has gotten it, there is no real enforcement actually possible - only barriers to unsophisticated attacks.


Re : Cookies or Sessions for JQuery Mobile?

$
0
0
I am using the server side now but what I wanted is to show a popup when the session is expired which can only be done using jquery

Re : Cookies or Sessions for JQuery Mobile?

$
0
0
Perfect. Add your popup instead of 
  1.       location.href="logout.php"


JΛ̊KE

Re : Cookies or Sessions for JQuery Mobile?

$
0
0
Hello sorry for stupid comment here, want respond and digging jake post above, jake may i ask about this code 
  1. clearTimeout( draconianLogout );
  2. draconianLogout = setTimeout( function(){
  3.       location.href="logout.php"
  4. }, 10*60*1000 /*tenMinutes */);
logout.php is refers to kick users to logout from website ya?

thanks

Re : Cookies or Sessions for JQuery Mobile?

$
0
0

logout.php is refers to kick users to logout from website ya?
Yes.

But, look up draconian first.


JΛ̊KE

Dialogs working fine on desktop but flashing and disappears on mobile.

$
0
0
Hello,
Could someone tell me why dialogs don't wait for action on mobile?
All are working fine on desktop, but when I test on mobile I remarks stranger behaviours.
when I click on link to show the dialog:
The dialog appear for some ms an disappear.
if I click a second time, sometime the dialog work fine or not ???


Thanks for advices

Re : Cookies or Sessions for JQuery Mobile?

$
0
0
but there is an issue here Jake 

first, here is my final code with your help:

event.preventDefault();

  1. var draconianLogout;

  2. clearTimeout( draconianLogout );

  3. draconianLogout = setTimeout( function()
  4. {
  5. $('#divTitle').css("background-color", "#006400");
  6. $('#msgHeader').text("BlueFile");
  7. $('#msgAlert').html("Your Session was expired. Please sign in again.");
  8. $('#msgButton').text("SIgn in");
  9. $('#dialogAlert').popup();
  10. $("#dialogAlert").popup("open");
  11. $( "#dialogAlert" ).on("popupafterclose", function( event, ui ) { window.location.href = "http://localhost/bluefile-mobile/index.php?signout=true"; } );
  12. }, 1*60*1000 /*tenMinutes */);

it's working perfect and when the user has no activity the session expiry popup will show.

but 

if the user doesn't click sign in button and refresh the page instead then he will still be able to access it.

How can I fix this?


Thanks,



Re : Cookies or Sessions for JQuery Mobile?

$
0
0
I though of having a signout.php file and run this file using ajax before showing the popup.

Is this the best way to do it?


Re : Cookies or Sessions for JQuery Mobile?

$
0
0
It really depends where you put the code.   Since this is JQM, it needs to be melded in with the JQM events.

The server has already logged the user out. You said you do session timeout on the server already. So go to a sign in page 



JΛ̊KE

Re : Cookies or Sessions for JQuery Mobile?

$
0
0
Hi,

It was allworking when I had all code in one file but now I tried to separate the session code in a separate file like this:

  1. <head>
  2.     <meta charset="utf-8">
  3.     <script src="bluefile.js"></script>
  4.     <script src="session.js"></script>
  5. </head>

but it's showing the popup anymore.

my bluefile.js is like this:

  1. $(document).on("pagecreate", function(event)
  2. {
  3. $(document).on("click", "#linkSignout", function ()
  4. {
  5. $.mobile.loading("show", {theme:"b", text:"Please wait..", textonly: false, textVisible: true});
  6. });


  7. $(document).on("swipeleft", function(e)
  8. {
  9. if ($.mobile.activePage.find("#nav-panel").is(":visible"))
  10. {
  11. if (e.type === "swipeleft")
  12. {
  13. $("#nav-panel").panel("open");
  14. }
  15. }
  16. });
  17. });


and my session.js is:

  1. $(document).on("pagecreate", function(event)
  2. {
  3. event.preventDefault();
  4. var draconianLogout;
  5. clearTimeout( draconianLogout );
  6. draconianLogout = setTimeout( function()
  7. {
  8. $.ajax({
  9. method: 'POST',
  10. url: "signout.php",
  11. }).done(function(data)
  12. {
  13. $('#divTitle').css("background-color", "#006400");
  14. $('#msgHeader').text("BlueFile");
  15. $('#msgAlert').html("Your Session was expired. Please sign in again.");
  16. $('#msgButton').text("Sign in");
  17. $('#dialogAlert').popup();
  18. $("#dialogAlert").popup("open");
  19. $( "#dialogAlert" ).on("popupafterclose", function( event, ui ) { window.location.href = "index.php?signout=true"; } );
  20. }).fail(function(jqXHR, message)
  21. {
  22. alert('Error: ' + message);
  23. window.location.href = "index.php?signout=true";
  24. })
  25. }, 1*60*1000 /*tenMinutes */);
  26. });

Re : Dialogs working fine on desktop but flashing and disappears on mobile.

$
0
0
Please provide us with your current code. Make a testcase using plnkr.co

Re : Dialogs working fine on desktop but flashing and disappears on mobile.

$
0
0
http://www.dumpy.be/O-diab/wwwonly informations and aliments are set for the moment


also I don't understand why button generated dynamycally don't works?


I've generate it by:


('#P_Aliments').on('click', '#CollAlim a', function (event)
{
event.preventDefault(); // You probably want to prevent the default action
$('#Pop_Detail_Alim').html("");
var htmlDetailAlim = "";
var $a = $(this);
var product = $a.data('product');
var sqlSelectAlim = "SELECT * FROM T_Aliments WHERE id =" + product;
db.transaction(function (tx)
{
tx.executeSql(sqlSelectAlim, undefined, function (tx, result)
{
if (result.rows.length)
{
for (var i = 0; i < result.rows.length; i++)
{
var row = result.rows.item(i);
var Id = row.id;
var Type = row.Type;
var Desc = row.Description;
var Q = row.Quantite;
var IG = row.IG;
var Cal = row.Calories;
var Glu = row.Glucides;
var Lip = row.Lipides;
var Eau = row.Eau;
var Rem = row.Remarque;
htmlDetailAlim += "<div data-role='header' data-theme='d'>";
htmlDetailAlim += "<a href='#P_Aliments' class='ui-btn ui-icon-back ui-btn-icon-notext ui-corner-all'>retour</a>";
htmlDetailAlim += "<h3>" + Desc + "</h3>";
htmlDetailAlim += "</div>";
htmlDetailAlim += "<div data-role='content' data-theme='d'>";
htmlDetailAlim += "<div class='ui-grid-a data-inset='true'>'";
htmlDetailAlim += "<div class='ui-block-a'><h4>Quantité de référence :</h4></div>";
htmlDetailAlim += "<div class='ui-block-b'><input value='" + Q + "'/></div>";
switch (true) {
case (IG > 70):
htmlDetailAlim += "<div class='ui-block-a'><h4>Indice glycémique :</h4></div>";
htmlDetailAlim += "<div class='ui-block-b'><input class='Input_Red' value='" + IG + "'/></div>";
break;
case ((IG > 50) && (IG <= 70)):
htmlDetailAlim += "<div class='ui-block-a'><h4>Indice glycémique :</h4></div>";
htmlDetailAlim += "<div class='ui-block-b'><input class='Input_Orange' value='" + IG + "'/></div>";
break;
default:
htmlDetailAlim += "<div class='ui-block-a'><h4>Indice glycémique :</h4></div>";
htmlDetailAlim += "<div class='ui-block-b'><input class='Input_Green' value='" + IG + "'/></div>";
break;
}
htmlDetailAlim += "<div class='ui-block-a'><h4>Calories :</h4></div>";
htmlDetailAlim += "<div class='ui-block-b'><input value='" + Cal + " cal.'/></div>";
htmlDetailAlim += "<div class='ui-block-a'><h4>Glucides :</h4></div>";
htmlDetailAlim += "<div class='ui-block-b'><input value='" + Glu + "gr'/></div>";
htmlDetailAlim += "<div class='ui-block-a'><h4>Lipides :</h4></div>";
htmlDetailAlim += "<div class='ui-block-b'><input value='" + Lip + "gr'/></div>";
htmlDetailAlim += "<div class='ui-block-a'><h4>Eau :</h4></div>";
htmlDetailAlim += "<div class='ui-block-b'><input value='" + Eau + "'/></div>";
htmlDetailAlim += "<div class='ui-block-a' ><h4>Remarques :</h4></div>";
htmlDetailAlim += "<div><textarea data-theme='d' value='" + Rem + "'></textarea></div>";
htmlDetailAlim += "<br/>";
htmlDetailAlim += "</div>";
htmlDetailAlim += "<div data-role='controlgroup' data-inline='true' data-type='horizontal' class='PorteBouton'>";
htmlDetailAlim += "<button href='#P_Aliments' class='ui-btn ui-btn-inline'>Retour</button>";
htmlDetailAlim += "<button id='B_MaJ_Aliments' class='ui-btn ui-btn-inline'>Modifier</button>";
htmlDetailAlim += "<button id='B_Sup_Aliments' class='ui-btn ui-btn-inline'>Supprimer</button>";
htmlDetailAlim += "</div>";

htmlDetailAlim += "<br />";
htmlDetailAlim += "</div>";
}
} else
{
htmlDetailAlim = "<h3>Table vide</h3>";
}
console.log(htmlDetailAlim);
$(htmlDetailAlim).appendTo("#Pop_Detail_Alim");
$.mobile.changePage($("#Pop_Detail_Alim"), {transition: "flip", reverse: true});
$("#Pop_Detail_Alim").enhanceWithin();
}, erreur_bd);
});



and the html code is: <div data-role='page' id='Pop_Detail_Alim' data-theme="d">

Re : Dialogs working fine on desktop but flashing and disappears on mobile.

$
0
0
Dialogs work fine in Safari Mobile (iPhone iOS 9.x). #P_Aliments page contains no elements at all.

Re : Dialogs working fine on desktop but flashing and disappears on mobile.

$
0
0
It is well populated for me on my iPhone. 
 Something to see with your settings on your I think, avoiding the creation of the sqlite db.



Re : Dialogs working fine on desktop but flashing and disappears on mobile.

$
0
0
#P_Aliments works in Mobile but not Desktop. List items within collapsible are working too. What's your problem?

Re : Cookies or Sessions for JQuery Mobile?

$
0
0
Make a small demo with as little extra code, and I will take a look.

JΛ̊KE

Re : Dialogs working fine on desktop but flashing and disappears on mobile.

$
0
0

#P_Aliments works in Mobile but not Desktop
 
Are you working on ms windows (not tested) i'm on Mac

Like i've said in title, the dialogs don't work correctly, they just flashing in for some ms then disappears.
They don't wait that the users click on button to close them. 
the second problem is that buttons neither by href neither by 
$("B_Retour").on("click", function (event)
{
    $.mobile.changePage($("#P_Aliments"), {transition: "flip", reverse: true});
});

react like they should! (nothing happen)
is it because they where generate dynamically ? (see red part of the code)

I think I should forget JQM and do it in pure Javascript, to many things don't react normally and I waste our time in trying to understand why!

Re : Dialogs working fine on desktop but flashing and disappears on mobile.

$
0
0
I'm using FF/Chrome Win10 and iPhone 6+ 9.x

<button href='#P_Aliments' class='ui-btn ui-btn-inline'>Retour</button>

You cant use href in <button> , this is invalid , use anchor <a> .

For dynamically created elements, you have to delegate event .

  1. $(document).on("event", ".dynamic_element", function () { /* do stuff */ });

If you do the below, it won't work.

  1. $(".dynamic_element").on("event", function () { /* do stuff */ });

Re : Dialogs working fine on desktop but flashing and disappears on mobile.

$
0
0
To expand on what Omar said - some browsers are more tolerant of broken HTML than others. You should validate your HTML.


I use a desktop version on OSX:


The desktop version is particularly handy if you want to validate from a local server that is't on the Internet.

You continue to use IDs for things you should not use IDs for. Your code is going to fail when you navigate from one page to the next and have a duplicate ID.
Viewing all 12211 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>