Advertisement
Guest User

Untitled

a guest
Sep 5th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. var express = require('express')
  2. var app = express();
  3.  
  4. app.set('port', (process.env.PORT ||8080));
  5. app.use(express.static(__dirname + '/public'));
  6.  
  7. app.get('/', function(request, response) {
  8. response.send(dynamicCSS())
  9. })
  10.  
  11. var loginElements = {
  12. username: '',
  13. password: ''
  14. }
  15.  
  16. function dynamicCSS(){
  17. var username, password
  18. x = ''
  19. if ((Math.random()*2) > 1)
  20. x += '<style>.btnSubmit,.password,.username{position:absolute;left:10}.username{top:50px}.password{top:80px}.btnSubmit{top:110px}</style>'
  21. else
  22. x += '<style>.btnSubmit,.password,.username{position:absolute;left:10}.username{top:80px}.password{top:110px}.btnSubmit{top:140px}</style>'
  23. x += '<form>'
  24. x += '<h1>Please Login</h1>'
  25. y = Math.floor((Math.random()*5)) + 2
  26. console.log(y)
  27. for (var a=0; a<y; ++a){
  28. username = randonString()
  29. password = randonString()
  30. x += '<input type="text" class="username" id="' + username + '" name="' + username + '" placeholder="Enter Username"></input>'
  31. x += '<input type="password" class="password" id="' + password + '" name="' + password + '" placeholder="Enter Password"></input>'
  32. loginElements.username = username
  33. loginElements.password = password
  34. }
  35. x += '<button class="btnSubmit" type="submit">Log in</button>'
  36. x += '</form>'
  37. return x
  38. }
  39.  
  40. function randonString(){
  41. chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('')
  42. chars.sort(function() {
  43. return 0.5 - Math.random()
  44. })
  45. return chars.splice(0, 8).toString().replace(/,/g, '')
  46. }
  47.  
  48. app.listen(app.get('port'), function() {
  49. console.log("Node app is running at localhost:" + app.get('port'))
  50. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement