-
Notifications
You must be signed in to change notification settings - Fork 0
/
pinch.php
184 lines (168 loc) · 6.44 KB
/
pinch.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Pinchapp</title>
<meta charset="utf-8">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="jquery.mobile-1.2.0.css" />
<link rel="stylesheet" href="style.css" />
<link rel="apple-touch-icon" href="appicon.png" />
<link rel="apple-touch-startup-image" href="upstart.png">
<script src="jquery-1.8.2.min.js"></script>
<script src="jquery.mobile-1.2.0.js"></script>
<script src="hammer.js"></script>
<script src="jquery.hammer.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="updateImage.js"></script>
</head>
<body>
<!-- Start of pinch page: #pinch -->
<div data-role="page" id="main">
<script src="myLogic.js"></script>
<script src="thumbnailer.js"></script>
<script>
window.URL = window.URL || window.webkitURL;
$(document).on('pageshow', function() {
imageSelect = document.getElementById("imageSelect");
fileSelect = document.getElementById("fileSelect");
fileSelect.onclick = function (e)
{
if (imageSelect)
{
imageSelect.click();
}
e.preventDefault();
}
});
function displayPhotoOptions()
{
}
//Handle Files handles all input files from the user//
//This will display a selected image and then post
//to the database
function handleFiles(files)
{
if (files.length > 0)
{
var img = document.createElement("img");
img.src = window.URL.createObjectURL(files[0]);
img.onload = function()
{
if (img.width > img.height)
img.width = 200;
else
img.height = 200;
var formData = new FormData(document.getElementById("imageForm"));
var xhr = new XMLHttpRequest();
xhr.open('POST', 'upload.php/no-cache?' + Date.now(), true);
xhr.setRequestHeader("pragma", "no-cache");
xhr.send(formData);
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4 && xhr.status==200)
{
var zoomDiv = document.createElement('div');
zoomDiv.setAttribute("id", xhr.responseText);
zoomDiv.setAttribute("class", "zoomProps");
var styleDiv = document.createElement('div');
styleDiv.setAttribute('class', 'polaroid upSky');
zoomDiv.appendChild(styleDiv);
styleDiv.appendChild(img);
document.getElementById("main").appendChild(zoomDiv);
var imgID = "#" + xhr.responseText;
var hammerString = "#" + xhr.responseText + " :first";
var z = new ZoomView(imgID, hammerString);
$(imgID).bind('tap', function(e)
{
tappedImg = this; //The image that we tapped //
tappedImg.style.webkitUserSelect = "auto";
if ( document.getElementById("tapOptions").style.display == "none")
{
document.getElementById("foot").style.display = "none";
document.getElementById("tapOptions").style.display= "inline";
$('#save').bind('click', function()
{
var i = document.createElement("img");
i.setAttribute("id", "saveImg");
i.src = tappedImg.getElementsByTagName("img")[0].src;
i.onload = function()
{
if (i.width > i.height)
i.width = 200;
else
i.height = 200;
var save_image_content = document.getElementById("save_image_content");
save_image_content.innerHTML = "";
save_image_content.appendChild(i);
}
});
$('#delete').bind('click', function(e)
{
tappedImg.parentNode.removeChild(tappedImg);
document.getElementById("foot").style.display = "inline";
document.getElementById("tapOptions").style.display = "none";
});
}
else
{
document.getElementById("foot").style.display = "inline";
document.getElementById("tapOptions").style.display = "none";
}
});
}
}
}
}
}
</script>
<div data-role="header" id="output" style="height:auto;"><!-- added output here -->
<h1>Pinch</h1>
<!-- Hidden form for that uploads image to server as soon as it has been selected -->
<form id="imageForm" method="post" enctype="multipart/form-data" style="hidden">
<input type="file" name="file" id="imageSelect" class="ui-btn-right" style="display:none" onchange="handleFiles(this.files)"/>
</form>
<a data-icon="Camera-icon.gif" id="fileSelect" class="ui-btn-right">Photos</a>
<a class="ui-btn-left" href="logout.php">Log Out <?php echo $_SESSION['Username'] ?> </a>
</div><!-- /header -->
<div id="alert"> <h1> You pinched a photo! </h1></div>
<div id="pinch" style="top:40px; bottom:30px; width:100%; position:absolute; -webkit-user-select: auto !important;"><!-- /Overlay handling drop detection -->
</div>
<div data-role="footer" id="tapOptions" data-id="samebar" class="nav-glyphis-example" data-position="fixed" data-tap-toggle="false" style="display:none">
<div data-role="navbar" class="nav-glyphish-example">
<ul>
<li><a id="save" href="#saver" data-icon="custom">Save</a></li>
<li><a id="delete" data-icon="custom">Delete</a></li>
</ul>
</div>
</div>
<div data-role="footer" id="foot" data-id="samebar" class="nav-glyphish-example" data-position="fixed" data-tap-toggle="false">
<div data-role="navbar" class="nav-glyphish-example">
<ul>
<li><a href="loggedIn.php" id="home" data-icon="custom" >Home</a></li>
<li><a href="pinch.php" id="beer" data-icon="custom" class="ui-btn-active">Pinch</a></li>
<li><a href="help.php" id="help" data-icon="custom">Help</a></li>
</ul>
</div>
</div>
</div><!-- / pinch page -->
<div data-role="page" id="saver" data-theme="a" data-url="saver" tabindex="0" class="ui-page ui-body-a" style="min-height: 125px;">
<div data-role="header" class="ui-header ui-bar-a" role="banner">
Tap and hold image to save
</div>
<div id="save_image_content" style="position:absolute;">
</div>
<div data-role="footer" id="saveHome" data-id="samebar" class="nav-glyphis-example" data-position="fixed" data-tap-toggle="false">
<div data-role="navbar" class="nav-glyphish-example">
<ul>
<li><a href="pinch.php" id="back" data-icon="custom" data-prefetch>Back to Pinch</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>