Fossil

Check-in [c6785fab]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Move all inline javascript associated with the login screen into a separate script file.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c6785fabf96f38d0a9598110feafdfb5394d21cffb40af6aa5cffc30c8224cf6
User & Date: drh 2017-12-06 11:14:27
Context
2017-12-06
13:48
Remove the last bits of in-line javascript from the timelines. check-in: b799891b user: drh tags: trunk
11:14
Move all inline javascript associated with the login screen into a separate script file. check-in: c6785fab user: drh tags: trunk
10:28
Move the in-line javascript associated with the user capability editing into a separate script file. check-in: ef63351d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/login.c.

   630    630       }else if( anonFlag ){
   631    631         @ <p>Login as <b>anonymous</b> or any named user
   632    632         @ to access page <b>%h(zAbbrev)</b>.
   633    633       }else{
   634    634         @ <p>Login as a named user to access page <b>%h(zAbbrev)</b>.
   635    635       }
   636    636     }
   637         -  form_begin(0, "%R/login");
          637  +  if( g.sslNotAvailable==0
          638  +   && strncmp(g.zBaseURL,"https:",6)!=0
          639  +   && db_get_boolean("https-login",0)
          640  +  ){
          641  +    form_begin(0, "https:%s/login", g.zBaseURL+5);
          642  +  }else{
          643  +    form_begin(0, "%R/login");
          644  +  }
   638    645     if( zGoto ){
   639    646       @ <input type="hidden" name="g" value="%h(zGoto)" />
   640    647     }else if( zReferer && strncmp(g.zBaseURL, zReferer, strlen(g.zBaseURL))==0 ){
   641    648       @ <input type="hidden" name="g" value="%h(zReferer)" />
   642    649     }
   643    650     if( anonFlag ){
   644    651       @ <input type="hidden" name="anon" value="1" />
................................................................................
   665    672     if( g.zLogin==0 && (anonFlag || zGoto==0) ){
   666    673       zAnonPw = db_text(0, "SELECT pw FROM user"
   667    674                            " WHERE login='anonymous'"
   668    675                            "   AND cap!=''");
   669    676     }
   670    677     @ <tr>
   671    678     @   <td></td>
   672         -  @   <td><input type="submit" name="in" value="Login"
   673         -  @        onClick="chngAction(this.form)" /></td>
          679  +  @   <td><input type="submit" name="in" value="Login">
   674    680     @ </tr>
   675    681     @ </table>
   676         -  @ <script>
   677         -  @   gebi('u').focus()
   678         -  @   function chngAction(form){
   679         -  if( g.sslNotAvailable==0
   680         -   && strncmp(g.zBaseURL,"https:",6)!=0
   681         -   && db_get_boolean("https-login",0)
   682         -  ){
   683         -     char *zSSL = mprintf("https:%s", &g.zBaseURL[5]);
   684         -     @  if( form.u.value!="anonymous" ){
   685         -     @     form.action = "%h(zSSL)/login";
   686         -     @  }
   687         -  }
   688         -  @ }
   689         -  @ </script>
   690    682     @ <p>Pressing the Login button grants permission to store a cookie.</p>
   691    683     if( db_get_boolean("self-register", 0) ){
   692    684       @ <p>If you do not have an account, you can
   693    685       @ <a href="%R/register?g=%T(P("G"))">create one</a>.
   694    686     }
   695    687     if( zAnonPw ){
   696    688       unsigned int uSeed = captcha_seed();
................................................................................
   701    693       @ <p><input type="hidden" name="cs" value="%u(uSeed)" />
   702    694       @ Visitors may enter <b>anonymous</b> as the user-ID with
   703    695       @ the 8-character hexadecimal password shown below:</p>
   704    696       @ <div class="captcha"><table class="captcha"><tr><td><pre>
   705    697       @ %h(zCaptcha)
   706    698       @ </pre></td></tr></table>
   707    699       if( bAutoCaptcha ) {
   708         -        @ <input type="button" value="Fill out captcha"
   709         -        @  onclick="gebi('u').value='anonymous'; gebi('p').value='%s(zDecoded)';" />
          700  +       @ <input type="button" value="Fill out captcha" id='autofillButton' \
          701  +       @ data-af='%s(zDecoded)' />
          702  +       style_load_one_js_file("login.js");
   710    703       }
   711    704       @ </div>
   712    705       free(zCaptcha);
   713    706     }
   714    707     @ </form>
   715    708     if( g.zLogin && g.perm.Password ){
   716    709       @ <hr />

Added src/login.js.

            1  +/* Javascript code to handle button actions on the login page */
            2  +var autofillButton = document.getElementById('autofillButton');
            3  +autofillButton.onclick = function(){
            4  +  document.getElementById('u').value = 'anonymous';
            5  +  document.getElementById('p').value = autofillButton.getAttribute('data-af');
            6  +};

Changes to src/main.mk.

   194    194     $(SRCDIR)/../skins/xekri/css.txt \
   195    195     $(SRCDIR)/../skins/xekri/details.txt \
   196    196     $(SRCDIR)/../skins/xekri/footer.txt \
   197    197     $(SRCDIR)/../skins/xekri/header.txt \
   198    198     $(SRCDIR)/diff.tcl \
   199    199     $(SRCDIR)/graph.js \
   200    200     $(SRCDIR)/href.js \
          201  +  $(SRCDIR)/login.js \
   201    202     $(SRCDIR)/markdown.md \
   202    203     $(SRCDIR)/menu.js \
   203    204     $(SRCDIR)/sbsdiff.js \
   204    205     $(SRCDIR)/sorttable.js \
   205    206     $(SRCDIR)/tree.js \
   206    207     $(SRCDIR)/useredit.js \
   207    208     $(SRCDIR)/wiki.wiki

Changes to win/Makefile.mingw.

   603    603     $(SRCDIR)/../skins/xekri/css.txt \
   604    604     $(SRCDIR)/../skins/xekri/details.txt \
   605    605     $(SRCDIR)/../skins/xekri/footer.txt \
   606    606     $(SRCDIR)/../skins/xekri/header.txt \
   607    607     $(SRCDIR)/diff.tcl \
   608    608     $(SRCDIR)/graph.js \
   609    609     $(SRCDIR)/href.js \
          610  +  $(SRCDIR)/login.js \
   610    611     $(SRCDIR)/markdown.md \
   611    612     $(SRCDIR)/menu.js \
   612    613     $(SRCDIR)/sbsdiff.js \
   613    614     $(SRCDIR)/sorttable.js \
   614    615     $(SRCDIR)/tree.js \
   615    616     $(SRCDIR)/useredit.js \
   616    617     $(SRCDIR)/wiki.wiki

Changes to win/Makefile.msc.

   529    529           $(SRCDIR)\../skins/xekri/css.txt \
   530    530           $(SRCDIR)\../skins/xekri/details.txt \
   531    531           $(SRCDIR)\../skins/xekri/footer.txt \
   532    532           $(SRCDIR)\../skins/xekri/header.txt \
   533    533           $(SRCDIR)\diff.tcl \
   534    534           $(SRCDIR)\graph.js \
   535    535           $(SRCDIR)\href.js \
          536  +        $(SRCDIR)\login.js \
   536    537           $(SRCDIR)\markdown.md \
   537    538           $(SRCDIR)\menu.js \
   538    539           $(SRCDIR)\sbsdiff.js \
   539    540           $(SRCDIR)\sorttable.js \
   540    541           $(SRCDIR)\tree.js \
   541    542           $(SRCDIR)\useredit.js \
   542    543           $(SRCDIR)\wiki.wiki