Skip to content

Commit

Permalink
beta1
Browse files Browse the repository at this point in the history
beta1
  • Loading branch information
KuoKongQingYun committed Jan 5, 2015
1 parent dd4cbbc commit 667db64
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 48 deletions.
22 changes: 18 additions & 4 deletions FlashAndShare.xdk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"projectTypeName": "com.intel.xdk.projecttype.jsapp",
"src": "appDesigner",
"projectGuid": "ed855410-8d0d-4ef1-b3ff-d3c4e4de0b3a",
"lastModifiedDate": 1420370076146,
"lastModifiedDate": 1420430356610,
"creationDate": 1420291580458
},
"XDK-app-designer": "true",
Expand Down Expand Up @@ -34,7 +34,8 @@
"cordovaPluginsDirectory": "plugins",
"cordovaPlugins": [
{
"id": "intel.xdk.camera",
"id": "org.apache.cordova.file",
"version": "1.1.0",
"selectedState": "Included",
"data": {},
"paramvals": {}
Expand All @@ -45,6 +46,19 @@
"selectedState": "Included",
"data": {},
"paramvals": {}
},
{
"id": "org.apache.cordova.camera",
"version": "0.2.9",
"selectedState": "Included",
"data": {},
"paramvals": {}
},
{
"id": "intel.xdk.camera",
"selectedState": "Included",
"data": {},
"paramvals": {}
}
],
"buildConfigurations": {
Expand All @@ -59,7 +73,7 @@
},
"isActive_": true,
"appName_": "FlashAndShare",
"appID_": "xdk.intel.ad.template",
"appID_": "cn.linzhihao.flashandshare.flashandshare",
"appAccess_": "*",
"icons_": [],
"splashes_": [],
Expand All @@ -70,7 +84,7 @@
"crosswalkVersion_": "stable",
"appVersion_": "0.0.1",
"appDescription_": "Take photo and share!",
"appAuthor_": "",
"appAuthor_": "何婷",
"appVersionCode_": "1"
},
"Android-Crosswalk": {
Expand Down
12 changes: 3 additions & 9 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
<script src="xdk/init-dev.js"></script>
<!-- normalizes device and document ready events, see file for details -->
<script type="application/javascript" src="lib/jquery.min.js"></script>
<script type="application/javascript" src="js/button_event_handlers.js"></script>
<script type="application/javascript" src="js/taking_photo_event_handlers.js"></script>
<script type="application/javascript" src="js/uploading_event_handlers.js"></script>
<script type="application/javascript" src="xdk/appdesigner/js/rest-of-space.js"></script>
<script type="application/javascript" src="xdk/ad/bs_subpage.js"></script>
<script type="application/javascript" src="js/index_user_scripts.js"></script>
</head>

<body>
Expand Down Expand Up @@ -91,13 +91,7 @@
<figcaption data-position="bottom"></figcaption>
</figure>
</div>
<div class="widget uib_w_8 d-margins" data-uib="media/text" data-ver="0" id="progress">
<div class="widget-container left-receptacle"></div>
<div class="widget-container right-receptacle"></div>
<div>
<p>&nbsp;</p>
</div>
</div>

<div class="table-thing widget uib_w_7 d-margins" data-uib="twitter%20bootstrap/text_area" data-ver="1">
<label class="narrow-control label-inline">URL地址</label>
<textarea rows="2" class="wide-control form-control" wrap="hard" id="URL"></textarea>
Expand Down
13 changes: 0 additions & 13 deletions www/js/button_event_handlers.js

This file was deleted.

28 changes: 28 additions & 0 deletions www/js/index_user_scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(function()
{
"use strict";
/*
hook up event handlers
*/
function register_event_handlers()
{


/* button 咔嚓 */
$(document).on("click", ".uib_w_2", function(evt)
{
intel.xdk.camera.takePicture(80,false,"jpg");
/* your code goes here */
});

/* button 复制到剪切板 */
$(document).on("click", ".uib_w_6", function(evt)
{
intel.xdk.device.copyToClipboard($["#URL"].html());
alert("已复制到剪切板");
/* your code goes here */
});

}
document.addEventListener("app.Ready", register_event_handlers, false);
})();
29 changes: 22 additions & 7 deletions www/js/taking_photo_event_handlers.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
(function() {
"use strict";
function upload_success(r) {
$("#URL").html(r.response);
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
}
function upload_fail(error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}

function onTakingPhoto(event) {
if (event.success === true) {
var imagesrc = intel.xdk.camera.getPictureURL(event.filename);
$("#photo").attr("src", imagesrc);



var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = imagesrc.substr(fileURL.lastIndexOf('/') + 1);
options.fileName = imagesrc.substr(imagesrc.lastIndexOf('/') + 1);
options.mimeType = "image/jpeg";
var ft = new FileTransfer();
ft.upload(imagesrc,encodeURI("http://flashandshare.linzhihao.cn/index.php"), upload_success, upload_fail, options);
//intel.xdk.file.uploadToServer(imagesrc,"http://flashandshare.linzhihao.cn/uploadImage.php", "", "image/jpeg", "updateUploadProgress");
//xmlHttpRequest = createXmlHttpRequest();

try {
var ft = new FileTransfer();
} catch(e) {
alert(e.message);
}
ft.upload(imagesrc, encodeURI("http://flashandshare.linzhihao.cn/index.php"), upload_success, upload_fail, options);

} else {
if (event.message !== undefined) {
alert(event.message);
Expand Down
15 changes: 0 additions & 15 deletions www/js/uploading_event_handlers.js

This file was deleted.

52 changes: 52 additions & 0 deletions www/xdk/ad/bs_subpage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

function activate_subpage(sel, have_state)
{
var $dn = $(sel);
$dn.parents(".upage").find(".upage-content").addClass("hidden");
$dn.removeClass("hidden");
var parent_sel = "#" + $dn.parents(".upage").attr("id");
var parent_vis = $(parent_sel).is(":visible");
if(parent_vis)
{
$(document).trigger("pagechange");
if(!have_state){ window.history.pushState({usubpage:sel}, sel, document.location.origin + document.location.pathname + "#" +sel); }
}
else
{
//now activate parent page
activate_page(parent_sel);
window.history.replaceState({usubpage:sel}, sel, document.location.origin + document.location.pathname + "#" + sel);
}
}


/* this function not used by jQueryMobile or Intel App Framework */
function activate_page(sel, have_state)
{
var $dn = $(sel);
var is_vis = $dn.is(":visible");
if(!is_vis)
{
$dn.parents("body").find(".upage").addClass("hidden");
$dn.removeClass("hidden");

if(!have_state){ window.history.pushState({upage:sel}, sel, document.location.origin + document.location.pathname +sel); }
}
$(document).trigger("pagechange");
}




window.onpopstate = function(event)
{
//console.log("onpopstate location: " + document.location + ", state: " + JSON.stringify(event.state), ", length:", window.history.length);
if(event.state)
{
if(event.state.usubpage){ activate_subpage(event.state.usubpage, true); }
else if(event.state.upage){ activate_page(event.state.upage, true); }
}
};


$(document).ready(function(){ setTimeout(function(){ var sel = "#mainsub"; window.history.pushState({usubpage:sel}, sel, document.location.origin + document.location.pathname + "#" + sel); }, 300); });

0 comments on commit 667db64

Please sign in to comment.