commento/frontend/js/dashboard-import.js
Anton Linevych 9e3935b3b2 frontend: use gulp, eslint, code refactor
Apologies in advance for the insanely huge commit. This commit is
primarily based on Anton Linevych's amazing work found here [1]. While
he had gone through the pains of making small, atomic changes to each
file, I had put off reviewing the PR for a long time. By the time I
finally got around to it, the project had changed so much that it didn't
make sense to keep the commits the same way. So I've cherry-picked most
of his commits, with some changes here and there, and I've squashed them
into one commit.

[1] https://gitlab.com/linevych/commento-ce/tree/feature/frontend_building_improvements
2018-12-20 04:14:48 -05:00

38 lines
896 B
JavaScript

(function (global, document) {
"use strict";
(document);
// Opens the import window.
global.importOpen = function() {
$(".view").hide();
$("#import-view").show();
}
global.importDisqus = function() {
var url = $("#disqus-url").val();
var data = global.dashboard.$data;
var json = {
"ownerToken": global.cookieGet("commentoOwnerToken"),
"domain": data.domains[data.cd].domain,
"url": url,
}
global.buttonDisable("#disqus-import-button");
global.post(global.origin + "/api/domain/import/disqus", json, function(resp) {
global.buttonEnable("#disqus-import-button");
if (!resp.success) {
global.globalErrorShow(resp.message);
return;
}
$("#disqus-import-button").hide();
global.globalOKShow("Imported " + resp.numImported + " comments!");
});
}
} (window.commento, document));