aboutsummaryrefslogtreecommitdiff
path: root/tools/gui/resources/web/main.js
blob: 3a5e418db6e7dadb24b62bf54b5d64a52aa54041 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Notifications.init($("#notifications"));

Popup.init($("#popup"), $("#popup-table"));

Dependencies.init($("#search-btn"), $("#query"), $("#dependencies"));

ProjectLocation.init($("#cwd"), $("#name"));

["#create-project-btn", "#copy-project-btn", "#flow-create-btn", "#flow-copy-btn"].forEach(id => $(id)[0].disabled = false);

$("#flow-copy-btn")[0].style.width = $("#flow-create-btn")[0].offsetWidth + "px";

function setFlowCreate() {
  $("#flow-create").show();
  $("#flow-copy").hide();

  let createBtn = $("#flow-create-btn");
  let copyBtn = $("#flow-copy-btn");
  createBtn.blur();
  createBtn[0].disabled = true;
  copyBtn[0].disabled = false;

  ProjectLocation.updateName($("#name").val());
}

function createProject() {
  let button = $("#create-project-btn")[0];
  let buttonText = button.innerHTML;
  button.innerHTML = "...";
  button.blur();
  button.disabled = true;
  ajax("/project/new", {
    name: $("#name").val(),
    pack: $("#package").val(),
    dependencies: Dependencies.serialize(),
    flags: getFlags()
  }, "post").done(() => {
    Notifications.show("Project created.");
  }).always(() => {
    button.innerHTML = buttonText;
    button.disabled = false;
  });
}

function setFlowCopy() {
  $("#flow-copy").show();
  $("#flow-create").hide();

  let createBtn = $("#flow-create-btn");
  let copyBtn = $("#flow-copy-btn");
  copyBtn.blur();
  copyBtn[0].disabled = true;
  createBtn[0].disabled = false;

  Examples.unselectExample();

  Examples.fetchExamples();
}

function copyProject() {
  let name = $("#selected-example").html();
  let button = $("#copy-project-btn")[0];
  let buttonText = button.innerHTML;
  button.innerHTML = "...";
  button.blur();
  button.disabled = true;
  ajax("/project/copy", {name: name}, "post").done(() => {
    Notifications.show("Project copied.");
  }).always(() => {
    button.innerHTML = buttonText;
    button.disabled = false;
  });
}