import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';

import './main.html';

Template.sidebar.onCreated(function() {
  this.apiname = new ReactiveVar("An API");
});

Template.sidebar.helpers({
  apiname() {
    return Template.instance().apiname.get();
  },
});

Template.container.onCreated(function() {

})

Template.container.helpers({
    apiEditor() {
        return "apied-info"
    }
})

Template["apied-info"].events = {
    "submit form": function(event, template) {
        event.preventDefault()
        $("#temporaryOutput").html(JSON.stringify($("#api-basic-data").serializeObject(), null, "    "))
    }
}

$.assignValue = function(obj, keyPath, value) {
    lastKeyIndex = keyPath.length-1;
    for (var i = 0; i < lastKeyIndex; ++ i) {
        key = keyPath[i];
        if (!(key in obj)) {
            obj[key] = {}
        }
        obj = obj[key];
    }
    obj[keyPath[lastKeyIndex]] = value;
}

$.fn.serializeObject = function() {
    let obj = {}
    let arr = this.serializeArray()
    $.each(arr, function() {
        $.assignValue(obj, this.name.split("."), this.value)
    })
    return obj
}

@@ -37,17 +37,16 @@
 plating'
-;
 %0Aimport 
@@ -87,17 +87,16 @@
 ive-var'
-;
 %0A%0Aimport
@@ -109,17 +109,16 @@
 in.html'
-;
 %0A%0ATempla
@@ -197,13 +197,11 @@
 PI%22)
-;
 %0A%7D)
-;
 %0A%0ATe
@@ -287,17 +287,16 @@
 et()
-;
 %0A  %7D,%0A%7D)
 ;%0A%0AT
@@ -291,17 +291,16 @@
 %0A  %7D,%0A%7D)
-;
 %0A%0ATempla
@@ -734,17 +734,16 @@
 length-1
-;
 %0A    for
@@ -805,17 +805,16 @@
 yPath%5Bi%5D
-;
 %0A       
@@ -893,17 +893,16 @@
 obj%5Bkey%5D
-;
 %0A    %7D%0A 
@@ -938,17 +938,16 @@
  = value
-;
 %0A%7D%0A%0A$.fn

Unify semicolon usage