From 25ddb17f35ae06ba0ff09cf48aa0c524aeab3e93 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 25 Aug 2016 12:47:09 +0200 Subject: [PATCH] Alpha version --- forms/cms/contact/contact.js | 2 +- hedera.php | 3 +- index.php | 3 +- js/hedera/tpv.js | 2 +- js/htk/field/image.js | 2 +- js/htk/image-editor.js | 32 ++++++++++------------ js/htk/image-editor.xml | 9 ++---- js/vn/json-request.js | 9 ++++++ json.php | 3 +- pages/main/main.js | 4 +-- rest.php | 3 +- rest/core/captcha.php | 4 +-- rest/core/log.php | 6 ++-- rest/core/login.php | 2 +- rest/core/query.php | 4 +-- rest/dms/invoice.php | 4 +-- rest/image/image.php | 6 ++-- rest/image/resize.php | 9 +++--- rest/image/sync.php | 17 ++++++++---- rest/image/thumb.php | 11 ++++---- rest/image/upload.php | 14 +++++----- rest/image/{image-request.php => util.php} | 14 +++++----- rest/misc/visits-sync.php | 16 +++++------ rest/tpv/confirm-soap.php | 4 +-- rest/tpv/tpv.php | 4 +-- rest/tpv/transaction.php | 12 +++----- vn/hedera/hedera.php | 9 ------ vn/web/http-request.php | 12 -------- vn/web/json-app.php | 1 + vn/web/json-request.php | 3 +- vn/web/rest-app.php | 1 + vn/web/rest-request.php | 32 ++++++++++++++++++++++ 32 files changed, 134 insertions(+), 123 deletions(-) rename rest/image/{image-request.php => util.php} (79%) delete mode 100755 vn/hedera/hedera.php delete mode 100644 vn/web/http-request.php create mode 100644 vn/web/rest-request.php diff --git a/forms/cms/contact/contact.js b/forms/cms/contact/contact.js index 2b631fcd..a52f06df 100644 --- a/forms/cms/contact/contact.js +++ b/forms/cms/contact/contact.js @@ -6,7 +6,7 @@ Vn.Contact = new Class ,activate: function () { var self = this; - var form = this.$('contact-form').onsubmit = function () + this.$('contact-form').onsubmit = function () { self.onSubmit (); return false; }; this.refreshCaptcha (); diff --git a/hedera.php b/hedera.php index 65d89264..6fa654af 100755 --- a/hedera.php +++ b/hedera.php @@ -1,9 +1,8 @@ run (); ?> diff --git a/index.php b/index.php index 7615150d..0bb41cf7 100755 --- a/index.php +++ b/index.php @@ -1,9 +1,8 @@ run (); ?> diff --git a/js/hedera/tpv.js b/js/hedera/tpv.js index 33714bb6..d9ed1af1 100644 --- a/js/hedera/tpv.js +++ b/js/hedera/tpv.js @@ -41,7 +41,7 @@ Vn.Tpv = new Class ,'company': company }; - var request = new Vn.JsonRequest ('tpv'); + var request = new Vn.JsonRequest ('tpv/transaction'); request.send (params, this._onTransactionStart.bind (this)); } diff --git a/js/htk/field/image.js b/js/htk/field/image.js index f9c142f2..aa52bd4e 100644 --- a/js/htk/field/image.js +++ b/js/htk/field/image.js @@ -198,7 +198,7 @@ Htk.Image = new Class ,_onFileUpload: function (cell, editor) { this._stamp = new Date ().getTime (); - this.setSrc (cell); + this._refreshSrc (cell); this.popup.hide (); } diff --git a/js/htk/image-editor.js b/js/htk/image-editor.js index 0884e975..0d5dcae9 100644 --- a/js/htk/image-editor.js +++ b/js/htk/image-editor.js @@ -14,9 +14,9 @@ Htk.ImageEditor = new Class { this.builderInit (this.constructor.Xml); - this.$('max-size').value = 10 /* MB */ * 1048576; - this.$('form').action = - '//'+ Vn.Config['image_host'] +'/rest.php?action=image'; + var self = this; + this.$('form').onsubmit = function () + { self.onSubmit (); return false; }; this.parent (props); } @@ -31,30 +31,28 @@ Htk.ImageEditor = new Class this.signalEmit ('name-changed', newValue); } - ,onFormSubmit: function () + ,onSubmit: function () { this.$('submit').disabled = true; this.$('spinner').start (); + + var request = new Vn.JsonRequest (); + request.sendFormMultipart (this.$('form'), + this.onResponse.bind (this)); } - ,onIframeLoad: function () + ,onResponse: function (request, json, error) { this.$('submit').disabled = false; this.$('spinner').stop (); - try { - var responseText = this.$('iframe').contentDocument.body.textContent; - var response = eval ('('+ responseText +')'); - - if (response.data) - { - this.signalEmit ('file-uploaded', this.$('name').value); - Htk.Toast.showMessage (_('ImageAdded')); - } - else - Htk.Toast.showError (response.error.message +' ('+ response.error.code +')'); + if (json) + { + Htk.Toast.showMessage (_('ImageAdded')); + this.signalEmit ('file-uploaded', this.$('name').value); } - catch (e) {} + else + Htk.Toast.showError (error.message); } ,setData: function (image, directory) diff --git a/js/htk/image-editor.xml b/js/htk/image-editor.xml index ade7773c..5f508659 100644 --- a/js/htk/image-editor.xml +++ b/js/htk/image-editor.xml @@ -3,9 +3,8 @@
+ action="json.php?method=image/upload" + enctype="multipart/form-data">
@@ -22,9 +21,5 @@ -