Permalink
Browse files

json uebertragung zu save methode geändert

  • Loading branch information...
1 parent 1aca666 commit 914ef3661e9590f2022137e5e09b42293ebc7458 Stephan committed Nov 30, 2012
Showing with 26 additions and 20 deletions.
  1. +5 −5 app/modules/localeEdit/localeEdit.js
  2. +2 −3 app/router.js
  3. +1 −1 index.html
  4. +16 −1 localeEditFileManager.js
  5. +2 −10 server.js
@@ -72,6 +72,7 @@ function(app, jquery, Views ) {
deferred: Function.constructor.prototype,
fetchSuccess: function (collection, response) {
collection.deferred.resolve();
+ jquery('#loadIndicator').fadeOut('slow');
},
fetchError: function (collection, response) {
throw new Error("getworkinglocales fetch did get collection from API");
@@ -84,16 +85,15 @@ function(app, jquery, Views ) {
Localeedit.SaveLocales = function(data) {
var dataAsJson = JSON.stringify(data);
- console.log(dataAsJson);
-
+ jquery('#loadIndicator').show();
$.ajax({
url: '/api/savelocales',
type: 'POST',
- data: {
- Locales: dataAsJson
- }
+ contentType: 'text/json',
+ data: dataAsJson
}).success(function(data) {
+ jquery('#loadIndicator').fadeOut('slow');
console.log('Saved successfully');
})
View
@@ -28,7 +28,7 @@ function(app,LocaleEdit,jquery) {
jquery('ul.nav li').removeClass('active');
jquery('ul.nav a[href="#overview"]').parent().addClass('active');
- jquery('#loadIndicator').hide();
+ jquery('#loadIndicator').fadeOut('slow');
});
});
},
@@ -42,7 +42,7 @@ function(app,LocaleEdit,jquery) {
.done(function(){
jquery('ul.nav li').removeClass('active');
jquery('ul.nav a[href="#index"]').parent().addClass('active');
- jquery('#loadIndicator').hide();
+ jquery('#loadIndicator').fadeOut('slow');
});
});
},
@@ -58,7 +58,6 @@ function(app,LocaleEdit,jquery) {
.done(function(){
jquery('ul.nav li').removeClass('active');
jquery('ul.nav a[href="#edit"]').parent().addClass('active');
- jquery('#loadIndicator').hide();
}).done(function(){
collection.fetch();
});
View
@@ -39,7 +39,7 @@
<div class="pull-left">
<img src="/assets/img/logo.png">
</div>
- <div id="loadIndicator" class="pull-right loading">
+ <div id="loadIndicator" class="pull-right loading" style="display:none;">
<img src="/assets/img/loading.gif">
</div>
<div class="clearfix">
View
@@ -74,8 +74,23 @@ exports.GetUserFiles = function(req, res) {
exports.SaveLocales = function(req, res) {
- var data = req.body.Locales;
+
+ var data = "",
+ jsonData ;
+ req.addListener('data', function(chunk) { data += chunk; });
+ req.addListener('end', function() {
+ jsonData = JSON.parse(data);
+ saveLocaleJsonToFiles(jsonData,function(){
+ res.writeHead(200, {'content-type': 'text/plain' });
+ res.end()
+ })
+ });
+};
+
+function saveLocaleJsonToFiles = function(data, callback){
+
+ callback();
}
exports.DeleteUserFile = function(req, res) {
View
@@ -83,7 +83,7 @@ app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view options', { layout: false });
app.set('view engine', 'ejs');
-// app.use(express.logger());
+ app.use(express.logger());
app.use(express.cookieParser());
//app.use(express.bodyParser());
app.use(express.methodOverride());
@@ -160,16 +160,14 @@ app.get('/files/*', function(req, res){
}
else {
- console.log('---');
- console.log(req.url);
- console.log('---');
res.writeHead(404);
res.end();
//throw new NotFound;
}
});
});
+
//get a array of uploaded js files which represent the basis for our future work
app.get('/api/currentfiles', filemanager.GetUserFiles);
//get the locales as json array of locale objects
@@ -188,11 +186,8 @@ app.get('/assets/*', staticRequest);
function staticRequest (req, res){
- console.log(req.url);
var filePath = '.' + req.url.split('?')[0];
-
var extname = path.extname(filePath);
- console.log(extname);
var contentType = 'text/html';
switch (extname) {
case '.js':
@@ -225,9 +220,6 @@ function staticRequest (req, res){
res.end();
});
}else{
- console.log('---');
- console.log(req.url);
- console.log('---');
res.writeHead(404);
res.end();
//throw new NotFound;

0 comments on commit 914ef36

Please sign in to comment.