Define events for snippet actions
This commit is contained in:
parent
17d2249ec3
commit
70f6e5bc2c
1 changed files with 45 additions and 0 deletions
|
@ -1136,6 +1136,8 @@ ui.toolbar.export.googleDrive.click(function (e) {
|
||||||
});
|
});
|
||||||
//export to gist
|
//export to gist
|
||||||
ui.toolbar.export.gist.attr("href", noteurl + "/gist");
|
ui.toolbar.export.gist.attr("href", noteurl + "/gist");
|
||||||
|
//export to snippet
|
||||||
|
ui.toolbar.export.snippet.attr("href", noteurl + "/snippet");
|
||||||
//import from dropbox
|
//import from dropbox
|
||||||
ui.toolbar.import.dropbox.click(function () {
|
ui.toolbar.import.dropbox.click(function () {
|
||||||
var options = {
|
var options = {
|
||||||
|
@ -1188,6 +1190,10 @@ function buildImportFromGoogleDrive() {
|
||||||
ui.toolbar.import.gist.click(function () {
|
ui.toolbar.import.gist.click(function () {
|
||||||
//na
|
//na
|
||||||
});
|
});
|
||||||
|
//import from snippet
|
||||||
|
ui.toolbar.import.snippet.click(function () {
|
||||||
|
//na
|
||||||
|
});
|
||||||
//import from clipboard
|
//import from clipboard
|
||||||
ui.toolbar.import.clipboard.click(function () {
|
ui.toolbar.import.clipboard.click(function () {
|
||||||
//na
|
//na
|
||||||
|
@ -1355,6 +1361,45 @@ $("#gistImportModalConfirm").click(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// snippet import modal
|
||||||
|
$("#snippetImportModalClear").click(function () {
|
||||||
|
$("#snippetImportModalContent").val('');
|
||||||
|
});
|
||||||
|
$("#snippetImportModalConfirm").click(function () {
|
||||||
|
var snippeturl = $("#snippetImportModalContent").val();
|
||||||
|
if (!snippeturl) return;
|
||||||
|
$('#snippetImportModal').modal('hide');
|
||||||
|
$("#snippetImportModalContent").val('');
|
||||||
|
if (!isValidURL(snippeturl)) {
|
||||||
|
showMessageModal('<i class="fa fa-gitlab"></i> Import from Snippet', 'Not a valid URL :(', '', '', false);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// TODO: Validate against config.gitlab.baseURL
|
||||||
|
ui.spinner.show();
|
||||||
|
$.get(snippeturl)
|
||||||
|
.success(function (data) {
|
||||||
|
if (data.files) {
|
||||||
|
var contents = "";
|
||||||
|
Object.keys(data.files).forEach(function (key) {
|
||||||
|
contents += key;
|
||||||
|
contents += '\n---\n';
|
||||||
|
contents += data.files[key].content;
|
||||||
|
contents += '\n\n';
|
||||||
|
});
|
||||||
|
replaceAll(contents);
|
||||||
|
} else {
|
||||||
|
showMessageModal('<i class="fa fa-gitlab"></i> Import from Snippet', 'Unable to fetch snippet files :(', '', '', false);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.error(function (data) {
|
||||||
|
showMessageModal('<i class="fa fa-gitlab"></i> Import from Snippet', 'Not a valid Snippet URL :(', '', JSON.stringify(data), false);
|
||||||
|
})
|
||||||
|
.complete(function () {
|
||||||
|
ui.spinner.hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function parseToEditor(data) {
|
function parseToEditor(data) {
|
||||||
var parsed = toMarkdown(data);
|
var parsed = toMarkdown(data);
|
||||||
if (parsed)
|
if (parsed)
|
||||||
|
|
Loading…
Reference in a new issue