rejetto forum

2.4 template-making guide

rejetto · 67 · 46413

0 Members and 1 Guest are viewing this topic.

Offline dj

  • Tireless poster
  • ****
    • Posts: 291
  • 👣 🐾
    • View Profile
    • PWAs
@danny
I can't reproduce your problem.

I found "username not found" neither in your template nor in the default template.
So perhaps it can be a problem with the login section.
Try to rename the 'login' section to 'signin' and also the links.
Try to test 'unauth' without redirect.


Offline danny

  • Tireless poster
  • ****
    • Posts: 281
    • View Profile
@danny
I can't reproduce your problem.

I found "username not found" neither in your template nor in the default template.
So perhaps it can be a problem with the login section.
Try to rename the 'login' section to 'signin' and also the links.
Try to test 'unauth' without redirect.
Thanks!!!
And, yes, there is an intermittent/rare problem with that.  The 'good problem' is that it mostly works.  The function is more likely to fail with an older android phone (although an updated pc can do that sometimes/rarely).  The problem is least likely to happen if you have menu/users/specify directory redirect after login (still possible--less frequently).  So, there is a testing hardship with both vfs options variety and browser variety. 
Trouble is:  The result of login is not confined to useable output (some of the output is not clickable) and may appear broken.
Goal is: Confine the outcome to only what is clickable/usable (nothing else).

Seems useful to add a fallback-redirect so the responses/error doesn't linger on-screen?
« Last Edit: June 23, 2020, 08:59:01 AM by danny »


Offline NaitLee

  • Tireless poster
  • ****
    • Posts: 203
  • Computer-brain boy
    • View Profile
How can I change the login section to avoid the "white screen" (bare server response) problem? 

dj's code instantly sent ("submit") changepwd data to server side, parsed by the macro from takeback.

In your code the form instantly submitted password to server, and instantly got the changepwd result, which is simply a plain string "OK (1)".
Seems page XHR response and page refresh happens at same time, that's may why your problem appears with a chance.
Additionally, dj's code should get a responce "ok" (not "OK (1)"), then recognizes changepwd success, otherwise fails with only "user or password don't match".

In takeback I did not use a form, (this is not standard, I'm going to correct it with a form and override its submit() function, just like HFS default tpl)
 by clicking "Okay" the password data is sent to server via XHR, returning that "OK (1)", and dealt by an alert().

You can have a look of my code, then adapt it to password form's submit():

Code: [Select]
function changePwd(newpass) {
        var xhr = new XMLHttpRequest();
        xhr.open('POST', '?mode=section&id=ajax.changepwd');
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xhr.onreadystatechange = function() {
        if (xhr.readyState === 4 && xhr.status === 200) {
            console.log(xhr.responseText);
            var code = ( xhr.responseText.split('(')[1] == undefined ? -1 : xhr.responseText.split('(')[1].split(')')[0] );
            if (code == "1") {
                alert('{.!Complete! Use your new password next time!.}');
                beforeRedirect();
            } else {
                if (code == "0") {
                    alert("{.!You cannot change your password!.}");
                } else if (code == "3") {
                    alert("{.!Failed: Old password you input is wrong!.}");
                } else if (code == "4") {
                    alert("{.!Macro is detected in your input. Please do not attack..}");
                } else if (xhr.responseText.trim() == "bad session") {
                    alert("{.!Bad session. Try to refresh the page..}");
                } else {
                    alert('{.!Unknown error.}: \n'+xhr.responseText.trim());
                }
            }
            }
        };
        xhr.send("token={.cookie|HFS_SID_.}" + "&old=" + sha256(oldpwd.value) + "&new="+btoa(unescape(encodeURIComponent(newpass))));
    }

Or adapt dj's changepwd ajax.
Takeback's changepwd ajax is updated too, have a look as well.
« Last Edit: June 22, 2020, 11:02:42 AM by NaitLee »
"Computation is not forbidden magic."
Takeback Template | PHFS


Offline danny

  • Tireless poster
  • ****
    • Posts: 281
    • View Profile
Should the usage of HFS now be confined to either those degreed in javascript or only-default?  I need to know.  For all other cases then [login] section should not have been redacted from HFS2.4.  This is a very good time to decide what happens when the users try to log-in. 
The varieties need to be restricted to what is useful (and clickable--phone/mobile needs clickable).  Anyway there is need of a restricted set of fixed parameters.

P.S.  It usually does work well.  But, we need to control/define/specify what happens when it doesn't. It is a goal.
« Last Edit: June 23, 2020, 09:02:28 AM by danny »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
I found "username not found" neither in your template nor in the default template.
So perhaps it can be a problem with the login section.

"username not found" is  in the EXE, one of the errors the login can return.

Should the usage of HFS now be confined to either those degreed in javascript or only-default?  I need to know. 

at the moment javascript is needed, yes.
This doesn't mean you need to master it, you can just copy and adapt from the default tpl.
For example, adding these lines to your tpl will let you execute showLogin() which in turn will show the dialog.
Like for example  <input type=button onclick="showlogin()" value="Login please" />

Code: [Select]
<script>
var HFS = { user: '{.js encode|%user%.}', sid: '{.cookie|HFS_SID_.}', }
</script>
<link rel="stylesheet" href="/~style.css" type="text/css">
<script type="text/javascript" src="/?mode=jquery"></script>
<script type="text/javascript" src="/~lib.js"></script>

This is not the only way, i just wrote it now.
Probably there is space for improv to let other tpl take just as little as needed for the login.
I know this stuff is much more complicated, guys, but the result is much better, the experience is more what people expect. This is how every bloody website has been loggin you in in the last 10 years. We were stuck in the past.
Maybe with more time I'll be able to give you an alternative that won't force you into javascript, but I fear final 2.4.0 will be like this.


Offline danny

  • Tireless poster
  • ****
    • Posts: 281
    • View Profile
...Probably there is space for improv to let other tpl take just as little as needed for the login...
That could be good.  Currently, login is working nicely with no external calls (no jquery, no css, no extras).  So, maybe a simplified/minimized example could be made? 


Offline dj

  • Tireless poster
  • ****
    • Posts: 291
  • 👣 🐾
    • View Profile
    • PWAs
Maybe with more time I'll be able to give you an alternative

additional manual add [api level] to template
tested with Throwback


Offline danny

  • Tireless poster
  • ****
    • Posts: 281
    • View Profile
Instead of <a href="/~login>log-in/out</a> with [login|public],
Is it possible to link to [login] (private)? 
« Last Edit: June 26, 2020, 01:42:59 PM by danny »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
(Going to make multi-file select to Takeback. Almost done.)
A question: in a folder, after getting (only) selected filenames, how to archive them without jQuery?

something like this
[...document.getElementsByClassName('selector')].filter(x=> x.checked).map(x=> x.parentNode.getAttribute('href'))


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
Instead of <a href="/~login>log-in/out</a> with [login|public],
Is it possible to link to [login] (private)? 

nope, that's the whole sense of public/private, nothing else


Offline danny

  • Tireless poster
  • ****
    • Posts: 281
    • View Profile
nope, that's the whole sense of public/private, nothing else
Thanks!!!
I was just double-checking to see if I got the concept. 



Offline danny

  • Tireless poster
  • ****
    • Posts: 281
    • View Profile
How do I do a streamlined macro, such as:
if this and this and this all true, then do task, else do other

This could be useful for validation. 
It seems best to validate for at least 2 favorable conditions before doing upload:
%number-addresses-downloading%*%speed-out% < 7500 AND %connections% < 40
then do upload, else javascript 5 sec recheck. 

Throwback14 initial and current check only %number-addresses-downloading%*%speed-out% < 7500 (somewhat less than max workload) then do upload, else recheck in 5s.  That came from  Throwback13 gigabit support. 
Trouble is that 97 ongoing connections on slow-rate internet (workload undetected) could still stop an upload. 
So, it is necessary to test for more-than-one favorable condition before making an upload.
It is straightforward to do if this if then else, but I'm not clear how to macro for if these (several), if then else.

P.S.
Do we have %number-addresses-uploading% or other clue if there were ongoing uploads?  Because I'd like to do, if ongoing uploads, hide archive button. 


Offline dj

  • Tireless poster
  • ****
    • Posts: 291
  • 👣 🐾
    • View Profile
    • PWAs
{ if | {and | A | B} | C  | D }
wiki
« Last Edit: July 14, 2020, 09:08:03 AM by dj »


Offline danny

  • Tireless poster
  • ****
    • Posts: 281
    • View Profile