linting js code
parent
f87d629e44
commit
2ee66b4a01
@ -1,93 +1,100 @@
|
||||
// requires DropZone ª toMarkdown
|
||||
if (typeof jQuery === 'undefined') {
|
||||
throw new Error('YavscRemoteFs script requires jQuery');
|
||||
}
|
||||
if (typeof Dropzone === 'undefined') {
|
||||
throw new Error('YavscRemoteFs requires Dropzone');
|
||||
}
|
||||
if (typeof updateMD === 'undefined') {
|
||||
throw new Error('YavscRemoteFs requires md-helpers.js');
|
||||
}
|
||||
|
||||
window.RemoteFS = (function ($) {
|
||||
var Combine = function (patha, pathb) {
|
||||
if (!patha) return pathb;
|
||||
if (!pathb) return patha;
|
||||
return patha + '/' + pathb;
|
||||
};
|
||||
(function($, Dropzone, updateMD) {
|
||||
|
||||
var OpenDir = function ($view, sub) {
|
||||
$view.data('path', sub);
|
||||
InitDir($view);
|
||||
};
|
||||
window.RemoteFS = (function ($) {
|
||||
|
||||
/*
|
||||
var Combine = function (patha, pathb) {
|
||||
if (!patha) return pathb;
|
||||
if (!pathb) return patha;
|
||||
return patha + '/' + pathb;
|
||||
}; */
|
||||
|
||||
var OpenDir = function ($view, sub) {
|
||||
$view.data('path', sub);
|
||||
InitDir($view);
|
||||
};
|
||||
|
||||
var InitDir = function ($view) {
|
||||
|
||||
var path = $view.data('path');
|
||||
var owner = $view.data('owner');
|
||||
var url = path ? '/api/fs/' + path : '/api/fs';
|
||||
var fsiourl = path ? '/api/fs/' + path : '/api/fs';
|
||||
|
||||
$view.empty();
|
||||
$.get(url, function(data) {
|
||||
|
||||
$('<button>' + owner + '</button>').click(function() {
|
||||
OpenDir($view, null);
|
||||
}).appendTo($view);
|
||||
|
||||
var npath = null;
|
||||
$.get(fsiourl, function(data) {
|
||||
$('<button>' + owner + '</button>').click(function() {
|
||||
OpenDir($view, null);
|
||||
}).appendTo($view);
|
||||
|
||||
if (path) $.each(path.split('/'), function () {
|
||||
var part = this;
|
||||
if (npath) npath = npath + '/' + part;
|
||||
else npath = part;
|
||||
$('<button>').append(part).click(function() {
|
||||
OpenDir($view, npath)
|
||||
}).appendTo($view)
|
||||
});
|
||||
var npath = null;
|
||||
|
||||
$.each(data.SubDirectories, function () {
|
||||
var item = this;
|
||||
var spath = (path) ? path + '/' + item.Name : item.Name;
|
||||
$('<button>').append(item.Name).click(function() {
|
||||
OpenDir($view, spath);
|
||||
}).appendTo($view);
|
||||
});
|
||||
var $ftable = $('<table>').append('<tr class="fileheaders"><th>Nom</th><th>Taille</th><th>Modification</th></tr>');
|
||||
$.each(data.Files, function () {
|
||||
var item = this;
|
||||
var $tr = $('<tr></tr>');
|
||||
var $td = $('<td></td>')
|
||||
$('<a></a>').append(item.Name).click(function() {
|
||||
document.location = '/' + owner + '/' + npath + '/' + item.Name
|
||||
}).appendTo($td);
|
||||
$td.appendTo($tr);
|
||||
$('<td>' + item.Size + '</td>').appendTo($tr);
|
||||
$('<td>' + item.LastModified + '</td>').appendTo($tr);
|
||||
$tr.appendTo($ftable)
|
||||
});
|
||||
$ftable.appendTo($view);
|
||||
})
|
||||
};
|
||||
if (path) $.each(path.split('/'), function () {
|
||||
var part = this;
|
||||
if (npath) npath = npath + '/' + part;
|
||||
else npath = part;
|
||||
$('<button>').append(part).click(function() {
|
||||
OpenDir($view, npath);
|
||||
}).appendTo($view);
|
||||
});
|
||||
|
||||
$(document).ready(function ($) {
|
||||
OpenDir($('.dirinfo'));
|
||||
});
|
||||
$.each(data.SubDirectories, function () {
|
||||
var item = this;
|
||||
var spath = (path) ? path + '/' + item.Name : item.Name;
|
||||
$('<button>').append(item.Name).click(function() {
|
||||
OpenDir($view, spath);
|
||||
}).appendTo($view);
|
||||
});
|
||||
var $ftable = $('<table>').append('<tr class="fileheaders"><th>Nom</th><th>Taille</th><th>Modification</th></tr>');
|
||||
$.each(data.Files, function () {
|
||||
var item = this;
|
||||
var $tr = $('<tr></tr>');
|
||||
var $td = $('<td></td>');
|
||||
$('<a></a>').append(item.Name).click(function() {
|
||||
document.location = '/' + owner + '/' + npath + '/' + item.Name;
|
||||
}).appendTo($td);
|
||||
$td.appendTo($tr);
|
||||
$('<td>' + item.Size + '</td>').appendTo($tr);
|
||||
$('<td>' + item.LastModified + '</td>').appendTo($tr);
|
||||
$tr.appendTo($ftable);
|
||||
});
|
||||
$ftable.appendTo($view);
|
||||
});
|
||||
};
|
||||
$(document).ready(function () {
|
||||
OpenDir($('.dirinfo'));
|
||||
});
|
||||
})($);
|
||||
|
||||
})(window.jQuery);
|
||||
|
||||
Dropzone.options.postfiles= {
|
||||
Dropzone.options.postfiles = {
|
||||
maxFilesize: 20, // MB TODO: let sell it.
|
||||
autoProcessQueue: true,
|
||||
accept: function(file, done) {
|
||||
if (file.name == "justinbieber.jpg") {
|
||||
done("Naha, you don't.")
|
||||
}
|
||||
else { done() }
|
||||
if (file.name == 'justinbieber.jpg') {
|
||||
done('Naha, you don\'t.');
|
||||
} else { done(); }
|
||||
},
|
||||
success: function (file, response) {
|
||||
console.log('response:');
|
||||
console.log(response);
|
||||
for (var i = 0; i < response.length; i++) {
|
||||
var filer = response[i];
|
||||
console.log('response item:');
|
||||
console.log(filer);
|
||||
|
||||
$('<p><a href="/files/@User.GetUserName()/' + filer.FileName + '">' + filer.FileName + '</a></p>').appendTo('#ql-editor-2');
|
||||
updateMD ('Content', $('#contentview').html())
|
||||
updateMD('Content', $('#contentview').html());
|
||||
}
|
||||
},
|
||||
url: '/api/fs'
|
||||
};
|
||||
|
||||
})($, Dropzone, updateMD);
|
||||
|
||||
|
@ -1,22 +1,22 @@
|
||||
var markdownize = function(content) {
|
||||
if (!content) return '';
|
||||
var html = content.split("\n").map($.trim).filter(function(line) {
|
||||
return line != "";
|
||||
}).join("\n");
|
||||
var html = content.split('\n').map($.trim).filter(function(line) {
|
||||
return line != '';
|
||||
}).join('\n');
|
||||
return toMarkdown(html);
|
||||
};
|
||||
|
||||
var converter = new showdown.Converter();
|
||||
|
||||
var htmlize = function(content) {
|
||||
var htmlize = function(content) {
|
||||
return converter.makeHtml(content);
|
||||
};
|
||||
|
||||
var updateMD = function(id,content) {
|
||||
if (!content) return jQuery('#'+id).val('') ;
|
||||
var updateMD = function(id,content) {
|
||||
if (!content) return jQuery('#' + id).val('');
|
||||
var markdown = markdownize(content);
|
||||
if (jQuery('#'+id).val() === markdown) {
|
||||
if (jQuery('#' + id).val() === markdown) {
|
||||
return;
|
||||
}
|
||||
jQuery('#'+id).val( markdown );
|
||||
jQuery('#' + id).val(markdown);
|
||||
};
|
||||
|
@ -1 +1,3 @@
|
||||
var markdownize=function(r){if(!r)return"";var n=r.split("\n").map($.trim).filter(function(r){return""!=r}).join("\n");return toMarkdown(n)},converter=new showdown.Converter,htmlize=function(r){return converter.makeHtml(r)},updateMD=function(r,n){if(!n)return jQuery("#"+r).val("");var e=markdownize(n);jQuery("#"+r).val()!==e&&jQuery("#"+r).val(e)};
|
||||
|
||||
var markdownize=function(content){if(!content)return'';var html=content.split('\n').map($.trim).filter(function(line){return line!='';}).join('\n');return toMarkdown(html);};var converter=new showdown.Converter();var htmlize=function(content){return converter.makeHtml(content);};var updateMD=function(id,content){if(!content)return jQuery('#'+id).val('');var markdown=markdownize(content);if(jQuery('#'+id).val()===markdown){return;}
|
||||
jQuery('#'+id).val(markdown);};
|
Loading…
Reference in New Issue