@@ -33,6 +33,25 @@ function createButton(elementthing, elementthing2, color) {
3333 document . getElementById ( "elements" ) . appendChild ( button ) ;
3434 }
3535}
36+ function createButton2 ( elementthing , elementthing2 , color ) {
37+ if ( document . getElementById ( elementthing2 ) == null ) {
38+ var button = document . createElement ( "button" ) ;
39+ button . innerHTML = elementthing ;
40+ button . id = elementthing2 ;
41+ button . style . height = '50px' ;
42+ button . style . backgroundColor = color ;
43+ button . style . marginTop = "3px" ;
44+ button . style . marginBottom = "3px" ;
45+ button . style . marginLeft = "3px" ;
46+ button . style . marginRight = "3px" ;
47+ var rgb = color . match ( / \d + / g) ;
48+ if ( rgb [ 0 ] + rgb [ 1 ] + rgb [ 2 ] < 383 ) {
49+ button . style . color = "#FFFFFF" ;
50+ }
51+ button . setAttribute ( "onClick" , "vote()" ) ;
52+ document . getElementById ( "center" ) . appendChild ( button ) ;
53+ }
54+ }
3655function display ( elementthing , color ) {
3756 var button = document . createElement ( "button" ) ;
3857 button . innerHTML = elementthing ;
@@ -125,8 +144,14 @@ for (i = 0; i < Object.values(suggestions).length; i++) {
125144 document . getElementById ( "suggestions" ) . innerHTML = document . getElementById ( "suggestions" ) . innerHTML . concat ( ',' ) ;
126145 } ;
127146 } ;
128- document . getElementById ( "suggestions" ) . innerHTML = document . getElementById ( "suggestions" ) . innerHTML . concat ( ') =' ) ;
147+ document . getElementById ( "suggestions" ) . innerHTML = document . getElementById ( "suggestions" ) . innerHTML . concat ( ')=' ) ;
129148 var elemresult = Object . keys ( suggestions ) [ i ] ;
130149 var elemresultcolor = Object . values ( suggestions ) [ i ] [ 1 ] ;
131150 display ( elemresult , elemresultcolor ) ;
151+ likes = 'Likes:' + Object . values ( suggestions ) [ i ] [ 2 ] ;
152+ dislikes = 'Dislikes:' + Object . values ( suggestions ) [ i ] [ 3 ] ;
153+ document . getElementById ( "suggestions" ) . innerHTML = document . getElementById ( "suggestions" ) . innerHTML . concat ( '<center id="center">' ) ;
154+ createButton2 ( likes , "like" , "#44FF44" ) ;
155+ createButton2 ( dislikes , "dislike" , "#FF4444" ) ;
156+ document . getElementById ( "suggestions" ) . innerHTML = document . getElementById ( "suggestions" ) . innerHTML . concat ( '</center>' ) ;
132157}
0 commit comments