Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var express = require('express')
- var app = express();
- app.set('port', (process.env.PORT ||8080));
- app.use(express.static(__dirname + '/public'));
- app.get('/', function(request, response) {
- response.send(dynamicCSS())
- })
- var loginElements = {
- username: '',
- password: ''
- }
- function dynamicCSS(){
- var username, password
- x = ''
- if ((Math.random()*2) > 1)
- x += '<style>.btnSubmit,.password,.username{position:absolute;left:10}.username{top:50px}.password{top:80px}.btnSubmit{top:110px}</style>'
- else
- x += '<style>.btnSubmit,.password,.username{position:absolute;left:10}.username{top:80px}.password{top:110px}.btnSubmit{top:140px}</style>'
- x += '<form>'
- x += '<h1>Please Login</h1>'
- y = Math.floor((Math.random()*5)) + 2
- console.log(y)
- for (var a=0; a<y; ++a){
- username = randonString()
- password = randonString()
- x += '<input type="text" class="username" id="' + username + '" name="' + username + '" placeholder="Enter Username"></input>'
- x += '<input type="password" class="password" id="' + password + '" name="' + password + '" placeholder="Enter Password"></input>'
- loginElements.username = username
- loginElements.password = password
- }
- x += '<button class="btnSubmit" type="submit">Log in</button>'
- x += '</form>'
- return x
- }
- function randonString(){
- chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('')
- chars.sort(function() {
- return 0.5 - Math.random()
- })
- return chars.splice(0, 8).toString().replace(/,/g, '')
- }
- app.listen(app.get('port'), function() {
- console.log("Node app is running at localhost:" + app.get('port'))
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement