// Open or create a new database if not found
// Use Cordova sqlite plugin
// API : https://github.com/brodysoft/Cordova-SQLitePlugin/blob/master/README.md
+ /*
var db = window.sqlitePlugin.openDatabase({name: "nodesk.db"});
db.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS user (idUser integer primary key, name text, surname text, photo text, timestamp integer)');
tx.executeSql('CREATE TABLE IF NOT EXISTS option (idOption integer primary key, optionJSON text, timestamp integer)');
})
+ */
});
})
+.factory('inputForm',function(){
+ var inputTmp;
+ var tmp={};
+
+ tmp.getInput=function(){return inputTmp;}
+ tmp.setInput=function(newInput){
+ inputTmp=newInput;
+ }
+
+ return tmp;
+
+})
.factory('remoteService',function(){
var remoteServer="localhost:8000";
var server={};
};
})
+.controller('InputCtrl', function($scope,inputForm) {
-.controller('EditorCtrl', function($scope,$sce,$state,$ionicPopup, $timeout,$ionicModal,$http) {
+ $scope.updateFromInput=function(test){
+ inputForm.setInput(test);
+ alert(test.files[0].name);
+ };
+
+})
+.controller('EditorCtrl', function($scope,$sce,$state,$ionicPopup, $timeout,$ionicModal,$http,inputForm) {
$scope.currentTemplate;
/*Cordova/phonegap */
);
};
+ $scope.getPictureFromDevice=function(imageField){
+
+ navigator.camera.getPicture(
+ function(imageData){ imageField.value = "data:image/jpeg;base64," + imageData;},
+ function(message){ alert('Failed because: ' + message);},
+ { quality: 50, destinationType: Camera.DestinationType.DATA_URL, sourceType:Camera.PictureSourceType.PHOTOLIBRARY}
+ );
+ };
+
$scope.getAudio=function(soundField){
// capture callback
var captureSuccess = function(mediaFiles) {
'message: ' + error.message + '\n');
}
- navigator.geolocation.getCurrentPosition(onSuccess, onError);
+ navigator.geolocation.getCurrentPosition(onSuccess, onError,{maximumAge:3000,timeout:5000,enableHighAccuracy:true});
};
scope: $scope,
buttons: [
{ type: 'button button-icon icon ion-folder',
- onTap: function(refValue) {
+ onTap: function() {
//Cordova/phoneGap Files explorer
//MIME-type image
+ $scope.getPictureFromDevice(refValue);
return ;
}
},
$scope.showImage=function(){
alert($scope.currentTemplate[2].value);
- }
+ };
+
$scope.addSound=function(refValue){
var myPopup2 = $ionicPopup.show({
title: 'Selectionner fichier audio',
- template: '<input type="file" id="fileInput">', // String (optional). The html template to place in the popup body.
+ template:'<div class="fileinputs"> <input ng-controller="InputCtrl" type="file" class="file" onchange=angular.element(this).scope().updateFromInput(this) /> <div class="fakefile icon ion-folder"> </div> </div>',
scope: $scope,
buttons: [
{ type: 'button button-icon icon ion-folder',
- onTap: function(refValue) {
+ onTap: function() {
//Cordova/phoneGap Files explorer
//MIME-type audio
+ refValue.value=inputForm.getInput().files[0];
return;
}
},
var myPopup3 = $ionicPopup.show({
title: 'Selectionner video',
scope: $scope,
+ template:'<div class="fileinputs"> <input ng-controller="InputCtrl" type="file" class="file" onchange=angular.element(this).scope().updateFromInput(this) /> <div class="fakefile icon ion-folder"> </div> </div>',
buttons: [
{ type: 'button button-icon icon ion-folder',
- onTap: function(refValue) {
+ onTap: function() {
//Cordova/phoneGap Files explorer
//MIME-type video
+ refValue.value=inputForm.getInput().files[0];
return;
}
},