5
5
{% block main %}
6
6
< h1 > Edit Contest</ h1 >
7
7
< form autocomplete ="off " method ="post " id ="edit " name ="edit ">
8
- < input class ="form-control form-group " type ="text " id ="name " name ="name " placeholder ="Name " value ="{{ data[ " name " ] }}" required>
8
+ < input class ="form-control form-group " type ="text " id ="name " name ="name " placeholder ="Name " value ="{{ data[' name' ] }} " required >
9
9
< div style ="position: relative; ">
10
10
< textarea class ="form-control form-group md-preview " id ="description " name ="description " rows ="20 " placeholder ="Description " required > {{ data["description"] }}</ textarea >
11
11
< div id ="description-out " class ="md-preview "> </ div >
12
12
</ div >
13
- < input class ="form-control form-group dtl " type ="text " id ="start " name ="start " placeholder ="Start Date & Time " value ="{{ data[ " start " ] }}" required>
14
- < input class ="form-control form-group dtl " type ="text " id ="end " name ="end " placeholder ="End Date & Time " value ="{{ data[ " end " ] }}" required>
13
+ < input class ="form-control form-group dtl " type ="datetime-local " id ="start " name ="start " placeholder ="Start Date & Time " value ="{{ data[' start' ] }} " required >
14
+ < input class ="form-control form-group dtl " type ="datetime-local " id ="end " name ="end " placeholder ="End Date & Time " value ="{{ data[' end' ] }} " required >
15
15
< input class ="btn btn-primary " type ="submit " id ="submit " name ="submit " value ="Edit ">
16
16
< input type ="hidden " name ="csrf_token " value ="{{ csrf_token() }} "/>
17
17
</ form >
@@ -20,10 +20,19 @@ <h1>Edit Contest</h1>
20
20
var product = converter . makeHtml ( document . getElementById ( 'description' ) . value ) ;
21
21
$ ( '#description-out' ) . html ( product ) ;
22
22
$ ( '#description' ) . css ( 'height' , $ ( '#description-out' ) . css ( 'height' ) ) ;
23
- } ) ;
24
23
25
- $ ( ".dtl" ) . focus ( function ( ) {
26
- $ ( this ) . attr ( "type" , "datetime-local" ) ;
24
+ document . querySelectorAll ( ".dtl" ) . forEach ( function ( e ) {
25
+ var split = e . getAttribute ( "value" ) . split ( " " ) ;
26
+ var date_split = split [ 0 ] . split ( "-" ) ;
27
+ var final = date_split [ 1 ] + "/" + date_split [ 2 ] + "/" + date_split [ 0 ] + " " + split [ 1 ] ;
28
+ var parsed = new Date ( final + " UTC" ) . toString ( ) . split ( " " ) ;
29
+ e . value = parsed [ 3 ] + "-" + getMonthFromString ( parsed [ 1 ] ) + "-" + parsed [ 2 ] + "T" + parsed [ 4 ] ;
30
+
31
+ function getMonthFromString ( mon ) {
32
+ var str = ( new Date ( Date . parse ( mon + " 1, 2012" ) ) . getMonth ( ) + 1 ) . toString ( ) ;
33
+ return str . length == 2 ? str : "0" + str ;
34
+ }
35
+ } ) ;
27
36
} ) ;
28
37
29
38
$ ( '#description' ) . bind ( 'input propertychange' , function ( ) {
0 commit comments