-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-old.php
123 lines (111 loc) · 4.07 KB
/
create-old.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
include 'scripts/functions/main.php';
$functions = new Main();
?>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<?php $functions->getStylesheet(); ?>">
<title>Spot - Create a New Spot</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
//This replaces the file upload button with something nicer
$(document).ready(function(){
document.querySelector('#filebutton').addEventListener('click', function(e) {
// Use the native click() of the file input.
document.querySelector('#userimage').click();
}, false);
});
</script>
<script>
$(document).ready(function() {
$('#submit-button').hide();
var randomName = Math.floor(Math.random()*10000000001);
var response = '';
$('#userimage').change(function(){
var imageToUpload = document.getElementById("userimage").files[0];
var formData = new FormData();
formData.append("file", imageToUpload);
formData.append("newname", randomName);
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "scripts/functions/upload.php", false);
xmlhttp.send(formData);
randomName = xmlhttp.responseXML.getElementsByTagName('filename')[0].childNodes[0].nodeValue;
document.getElementById("image-preview").setAttribute("src", "images/temporary/"+randomName);
$('#submit-button').show();
});
$('#name').keyup(function(){
var value = $("#name").val();
if (value === "") {value = "Title Preview";}
$('#title-preview').html(value);
});
$('#caption').keyup(function(){
var caption = $("#caption").val();
if (caption === "") {caption = "Caption Preview";}
$('#comment-preview').html(caption);
});
$('#submit-button').click(function() {
document.getElementById("name").innerHTML = randomName;
var submitName = $('#name').val();
var caption = $('#caption').val();
var submitData = new FormData();
submitData.append("spotname", submitName);
submitData.append("caption", caption);
submitData.append("filename", randomName);
var submitHttp = new XMLHttpRequest();
submitHttp.open("POST", "scripts/functions/submit.php", false);
submitHttp.send(submitData);
response = submitHttp.responseXML;
var qrimagepath = response.getElementsByTagName("qrcode")[0].childNodes[0].nodeValue;
//$('#photo').append('<img src=\"'+qrimagepath+'\" />');
$('#image-preview').attr('src', qrimagepath);
document.getElementById("name").innerHTML = "<a href=\"location.php?id="+response.getElementsByTagName("location")[0].childNodes[0].nodeValue+"\">New Location</a>";
});
});
</script>
</head>
<body>
<div id="main">
<div id="header-regular">
<h1 id="regular">Create a New Spot</h1>
</div>
<div id="navigation">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="create.php">Create New Spot</a></li>
</ul>
</div>
<div id="content">
<div id="newspotform">
<h3>Upload</h3>
<label>Name:</label>
<input type="text" name="name" id="name" />
<label>Image:</label>
<button id="filebutton" class="orange">Select Image</button><br />
<label>Caption:</label>
<textarea name="caption" id="caption"></textarea>
</div>
<div id="preview">
<h3>Preview</h3>
<h4 id="title-preview" class="grey-out">Title Preview</h4>
<image id="image-preview" src="images/layout/image-preview.png" alt="image preview" />
<p id="comment-preview" class="grey-out">Caption Preview</p>
</div>
<div id="submit">
<button id="submit-button">Generate Your Spot</button>
</div>
</div>
<div id="footer">
<div id="footer-navigation">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="create.php">Create New Spot</a></li>
<li><a href="create.php">Contact</a></li>
</ul>
</div>
<p>Copyright 2013 - Nick Cassiani</p>
</div>
</div>
<input type="file" name="image" id="userimage" />
</body>
</html>