Fossil SCM

Move all inline javascript associated with the login screen into a separate script file.

drh 2017-12-06 11:14 trunk
Commit c6785fabf96f38d0a9598110feafdfb5394d21cffb40af6aa5cffc30c8224cf6
+12 -19
--- src/login.c
+++ src/login.c
@@ -632,11 +632,18 @@
632632
@ to access page <b>%h(zAbbrev)</b>.
633633
}else{
634634
@ <p>Login as a named user to access page <b>%h(zAbbrev)</b>.
635635
}
636636
}
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
+ }
638645
if( zGoto ){
639646
@ <input type="hidden" name="g" value="%h(zGoto)" />
640647
}else if( zReferer && strncmp(g.zBaseURL, zReferer, strlen(g.zBaseURL))==0 ){
641648
@ <input type="hidden" name="g" value="%h(zReferer)" />
642649
}
@@ -667,28 +674,13 @@
667674
" WHERE login='anonymous'"
668675
" AND cap!=''");
669676
}
670677
@ <tr>
671678
@ <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">
674680
@ </tr>
675681
@ </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>
690682
@ <p>Pressing the Login button grants permission to store a cookie.</p>
691683
if( db_get_boolean("self-register", 0) ){
692684
@ <p>If you do not have an account, you can
693685
@ <a href="%R/register?g=%T(P("G"))">create one</a>.
694686
}
@@ -703,12 +695,13 @@
703695
@ the 8-character hexadecimal password shown below:</p>
704696
@ <div class="captcha"><table class="captcha"><tr><td><pre>
705697
@ %h(zCaptcha)
706698
@ </pre></td></tr></table>
707699
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");
710703
}
711704
@ </div>
712705
free(zCaptcha);
713706
}
714707
@ </form>
715708
716709
ADDED src/login.js
--- src/login.c
+++ src/login.c
@@ -632,11 +632,18 @@
632 @ to access page <b>%h(zAbbrev)</b>.
633 }else{
634 @ <p>Login as a named user to access page <b>%h(zAbbrev)</b>.
635 }
636 }
637 form_begin(0, "%R/login");
 
 
 
 
 
 
 
638 if( zGoto ){
639 @ <input type="hidden" name="g" value="%h(zGoto)" />
640 }else if( zReferer && strncmp(g.zBaseURL, zReferer, strlen(g.zBaseURL))==0 ){
641 @ <input type="hidden" name="g" value="%h(zReferer)" />
642 }
@@ -667,28 +674,13 @@
667 " WHERE login='anonymous'"
668 " AND cap!=''");
669 }
670 @ <tr>
671 @ <td></td>
672 @ <td><input type="submit" name="in" value="Login"
673 @ onClick="chngAction(this.form)" /></td>
674 @ </tr>
675 @ </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 @ <p>Pressing the Login button grants permission to store a cookie.</p>
691 if( db_get_boolean("self-register", 0) ){
692 @ <p>If you do not have an account, you can
693 @ <a href="%R/register?g=%T(P("G"))">create one</a>.
694 }
@@ -703,12 +695,13 @@
703 @ the 8-character hexadecimal password shown below:</p>
704 @ <div class="captcha"><table class="captcha"><tr><td><pre>
705 @ %h(zCaptcha)
706 @ </pre></td></tr></table>
707 if( bAutoCaptcha ) {
708 @ <input type="button" value="Fill out captcha"
709 @ onclick="gebi('u').value='anonymous'; gebi('p').value='%s(zDecoded)';" />
 
710 }
711 @ </div>
712 free(zCaptcha);
713 }
714 @ </form>
715
716 DDED src/login.js
--- src/login.c
+++ src/login.c
@@ -632,11 +632,18 @@
632 @ to access page <b>%h(zAbbrev)</b>.
633 }else{
634 @ <p>Login as a named user to access page <b>%h(zAbbrev)</b>.
635 }
636 }
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 }
645 if( zGoto ){
646 @ <input type="hidden" name="g" value="%h(zGoto)" />
647 }else if( zReferer && strncmp(g.zBaseURL, zReferer, strlen(g.zBaseURL))==0 ){
648 @ <input type="hidden" name="g" value="%h(zReferer)" />
649 }
@@ -667,28 +674,13 @@
674 " WHERE login='anonymous'"
675 " AND cap!=''");
676 }
677 @ <tr>
678 @ <td></td>
679 @ <td><input type="submit" name="in" value="Login">
 
680 @ </tr>
681 @ </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
682 @ <p>Pressing the Login button grants permission to store a cookie.</p>
683 if( db_get_boolean("self-register", 0) ){
684 @ <p>If you do not have an account, you can
685 @ <a href="%R/register?g=%T(P("G"))">create one</a>.
686 }
@@ -703,12 +695,13 @@
695 @ the 8-character hexadecimal password shown below:</p>
696 @ <div class="captcha"><table class="captcha"><tr><td><pre>
697 @ %h(zCaptcha)
698 @ </pre></td></tr></table>
699 if( bAutoCaptcha ) {
700 @ <input type="button" value="Fill out captcha" id='autofillButton' \
701 @ data-af='%s(zDecoded)' />
702 style_load_one_js_file("login.js");
703 }
704 @ </div>
705 free(zCaptcha);
706 }
707 @ </form>
708
709 DDED src/login.js
--- a/src/login.js
+++ b/src/login.js
@@ -0,0 +1,6 @@
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
+};
--- a/src/login.js
+++ b/src/login.js
@@ -0,0 +1,6 @@
 
 
 
 
 
 
--- a/src/login.js
+++ b/src/login.js
@@ -0,0 +1,6 @@
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 };
--- src/main.mk
+++ src/main.mk
@@ -196,10 +196,11 @@
196196
$(SRCDIR)/../skins/xekri/footer.txt \
197197
$(SRCDIR)/../skins/xekri/header.txt \
198198
$(SRCDIR)/diff.tcl \
199199
$(SRCDIR)/graph.js \
200200
$(SRCDIR)/href.js \
201
+ $(SRCDIR)/login.js \
201202
$(SRCDIR)/markdown.md \
202203
$(SRCDIR)/menu.js \
203204
$(SRCDIR)/sbsdiff.js \
204205
$(SRCDIR)/sorttable.js \
205206
$(SRCDIR)/tree.js \
206207
--- src/main.mk
+++ src/main.mk
@@ -196,10 +196,11 @@
196 $(SRCDIR)/../skins/xekri/footer.txt \
197 $(SRCDIR)/../skins/xekri/header.txt \
198 $(SRCDIR)/diff.tcl \
199 $(SRCDIR)/graph.js \
200 $(SRCDIR)/href.js \
 
201 $(SRCDIR)/markdown.md \
202 $(SRCDIR)/menu.js \
203 $(SRCDIR)/sbsdiff.js \
204 $(SRCDIR)/sorttable.js \
205 $(SRCDIR)/tree.js \
206
--- src/main.mk
+++ src/main.mk
@@ -196,10 +196,11 @@
196 $(SRCDIR)/../skins/xekri/footer.txt \
197 $(SRCDIR)/../skins/xekri/header.txt \
198 $(SRCDIR)/diff.tcl \
199 $(SRCDIR)/graph.js \
200 $(SRCDIR)/href.js \
201 $(SRCDIR)/login.js \
202 $(SRCDIR)/markdown.md \
203 $(SRCDIR)/menu.js \
204 $(SRCDIR)/sbsdiff.js \
205 $(SRCDIR)/sorttable.js \
206 $(SRCDIR)/tree.js \
207
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -605,10 +605,11 @@
605605
$(SRCDIR)/../skins/xekri/footer.txt \
606606
$(SRCDIR)/../skins/xekri/header.txt \
607607
$(SRCDIR)/diff.tcl \
608608
$(SRCDIR)/graph.js \
609609
$(SRCDIR)/href.js \
610
+ $(SRCDIR)/login.js \
610611
$(SRCDIR)/markdown.md \
611612
$(SRCDIR)/menu.js \
612613
$(SRCDIR)/sbsdiff.js \
613614
$(SRCDIR)/sorttable.js \
614615
$(SRCDIR)/tree.js \
615616
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -605,10 +605,11 @@
605 $(SRCDIR)/../skins/xekri/footer.txt \
606 $(SRCDIR)/../skins/xekri/header.txt \
607 $(SRCDIR)/diff.tcl \
608 $(SRCDIR)/graph.js \
609 $(SRCDIR)/href.js \
 
610 $(SRCDIR)/markdown.md \
611 $(SRCDIR)/menu.js \
612 $(SRCDIR)/sbsdiff.js \
613 $(SRCDIR)/sorttable.js \
614 $(SRCDIR)/tree.js \
615
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -605,10 +605,11 @@
605 $(SRCDIR)/../skins/xekri/footer.txt \
606 $(SRCDIR)/../skins/xekri/header.txt \
607 $(SRCDIR)/diff.tcl \
608 $(SRCDIR)/graph.js \
609 $(SRCDIR)/href.js \
610 $(SRCDIR)/login.js \
611 $(SRCDIR)/markdown.md \
612 $(SRCDIR)/menu.js \
613 $(SRCDIR)/sbsdiff.js \
614 $(SRCDIR)/sorttable.js \
615 $(SRCDIR)/tree.js \
616
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -531,10 +531,11 @@
531531
$(SRCDIR)\../skins/xekri/footer.txt \
532532
$(SRCDIR)\../skins/xekri/header.txt \
533533
$(SRCDIR)\diff.tcl \
534534
$(SRCDIR)\graph.js \
535535
$(SRCDIR)\href.js \
536
+ $(SRCDIR)\login.js \
536537
$(SRCDIR)\markdown.md \
537538
$(SRCDIR)\menu.js \
538539
$(SRCDIR)\sbsdiff.js \
539540
$(SRCDIR)\sorttable.js \
540541
$(SRCDIR)\tree.js \
541542
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -531,10 +531,11 @@
531 $(SRCDIR)\../skins/xekri/footer.txt \
532 $(SRCDIR)\../skins/xekri/header.txt \
533 $(SRCDIR)\diff.tcl \
534 $(SRCDIR)\graph.js \
535 $(SRCDIR)\href.js \
 
536 $(SRCDIR)\markdown.md \
537 $(SRCDIR)\menu.js \
538 $(SRCDIR)\sbsdiff.js \
539 $(SRCDIR)\sorttable.js \
540 $(SRCDIR)\tree.js \
541
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -531,10 +531,11 @@
531 $(SRCDIR)\../skins/xekri/footer.txt \
532 $(SRCDIR)\../skins/xekri/header.txt \
533 $(SRCDIR)\diff.tcl \
534 $(SRCDIR)\graph.js \
535 $(SRCDIR)\href.js \
536 $(SRCDIR)\login.js \
537 $(SRCDIR)\markdown.md \
538 $(SRCDIR)\menu.js \
539 $(SRCDIR)\sbsdiff.js \
540 $(SRCDIR)\sorttable.js \
541 $(SRCDIR)\tree.js \
542

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button