99 < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
1010 < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
1111 < title > Shitty Code Share</ title >
12- < link rel ="stylesheet " href ="//fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic ">
12+ < link rel ="stylelesheet " href ="//fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic ">
1313 < link rel ="stylesheet " href ="{% static 'css/normalize.css' %} ">
1414 < link rel ="stylesheet " href ="{% static 'css/milligram.css' %} ">
15+ < script type ="text/javascript " crossorigin ="anonymous " src ="{% static 'js/submit_button_handler.js' %} "> </ script >
16+ <!-- <script src="https://code.jquery.com/jquery-3.2.1.min.js"
17+ integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
18+ crossorigin="anonymous"></script> -->
1519
1620 </ head >
1721 < body >
1822 < a href ="{% url 'code_share:app_home'%} " style ="color:inherit; ">
19- < h3 style ="padding-top:10px; padding-bottom:20px; padding-left:10px "> Shitty Code Share</ h3 >
23+ < h3 style ="padding-top:10px; padding-bottom:20px; padding-left:10px; "> Shitty Code Share</ h3 >
2024 </ a >
2125
2226 < div class ="container ">
@@ -41,7 +45,7 @@ <h3 style="padding-top:10px; padding-bottom:20px; padding-left:10px">Shitty Code
4145
4246 {%endif%}
4347
44- < textarea id ="code_snippet " name ="code_snippet "> {{code_share.code}}</ textarea > < br >
48+ < textarea id ="code_snippet " name ="code_snippet " onkeyup =" control_submit_button() " > {{code_share.code}}</ textarea > < br >
4549 < input id ="submit_edit " type ="submit " value ="edit ">
4650 < br >
4751 < a href ="{% url 'code_share:app_home'%} " >
@@ -51,8 +55,8 @@ <h3 style="padding-top:10px; padding-bottom:20px; padding-left:10px">Shitty Code
5155 {%else%}
5256 < input type ="text " id ="file_field " name ="file_name " placeholder ="File Name " value ="{{code_share.file_name}} ">
5357
54- < textarea id ="code_snippet " name ="code_snippet " placeholder ="Code Snippet "> {{code_share.code}}</ textarea > < br >
55- < input id ="submit_new " type ="submit " value ="submit " onmouseover =" check_content(this) " > < br >
58+ < textarea id ="code_snippet " name ="code_snippet " placeholder ="Code Snippet " onkeyup =" control_submit_button() " > {{code_share.code}}</ textarea > < br >
59+ < input id ="submit_new " type ="submit " value ="submit " > < br >
5660
5761 {%endif%}
5862
@@ -68,61 +72,4 @@ <h3 style="padding-top:10px; padding-bottom:20px; padding-left:10px">Shitty Code
6872
6973 </ body >
7074
71- < script
72- src ="https://code.jquery.com/jquery-3.2.1.min.js "
73- integrity ="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4= "
74- crossorigin ="anonymous "> </ script >
75-
76- < script >
77-
78-
79- // disables the submit button upon document ready
80- window . onload = function ( ) {
81-
82- if ( document . getElementById ( "submit_new" ) ) {
83- document . getElementById ( "submit_new" ) . disabled = true ;
84- }
85-
86- if ( document . getElementById ( "submit_edit" ) ) {
87- document . getElementById ( "submit_edit" ) . disabled = true ;
88- }
89-
90- } ;
91-
92-
93- /*enables the submit button on checking if there is
94- content in the code_snippet textarea.
95-
96- EventListener on Keyup on the textarea(code_snippet) calls this method.
97- Content in the textarea is checked and according to that
98- submit buttons are disabled/enabled.
99- */
100- code_snippet . addEventListener ( "keyup" , ( event ) => {
101-
102- if ( document . getElementById ( "code_snippet" ) . value != "" ) {
103-
104- if ( document . getElementById ( "submit_new" ) ) {
105- document . getElementById ( "submit_new" ) . disabled = false ;
106- }
107- if ( document . getElementById ( "submit_edit" ) ) {
108- document . getElementById ( "submit_edit" ) . disabled = false ;
109- }
110-
111- }
112-
113- else {
114-
115- if ( document . getElementById ( "submit_new" ) ) {
116- document . getElementById ( "submit_new" ) . disabled = true ;
117- }
118-
119- if ( document . getElementById ( "submit_edit" ) ) {
120- document . getElementById ( "submit_edit" ) . disabled = true ;
121- }
122- }
123-
124- } ) ;
125-
126- </ script >
127-
128- </ html >
75+ </ html >
0 commit comments