remove comments and update js
							parent
							
								
									8f31f5896c
								
							
						
					
					
						commit
						f2362a6dcf
					
				
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
				
			
			@ -1,5 +1,8 @@
 | 
			
		|||
$(document).ready(function() {
 | 
			
		||||
  $(document).pjax('a', '#container');
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$(document).on('ready pjax:success', function() {
 | 
			
		||||
  $('.scroll').perfectScrollbar();
 | 
			
		||||
 | 
			
		||||
  $("#preview").click(function(e) {
 | 
			
		||||
| 
						 | 
				
			
			@ -45,9 +48,7 @@ $(document).ready(function() {
 | 
			
		|||
      button = $(this).find("input[type=submit]:focus"),
 | 
			
		||||
      action = button.val();
 | 
			
		||||
 | 
			
		||||
    console.log(data);
 | 
			
		||||
 | 
			
		||||
    /*$.ajax({
 | 
			
		||||
    $.ajax({
 | 
			
		||||
      type: 'POST',
 | 
			
		||||
      url: url,
 | 
			
		||||
      data: data,
 | 
			
		||||
| 
						 | 
				
			
			@ -68,7 +69,7 @@ $(document).ready(function() {
 | 
			
		|||
        type: 'error'
 | 
			
		||||
      });
 | 
			
		||||
      console.log(data);
 | 
			
		||||
    }); */
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  $("#logout").click(function(e) {
 | 
			
		||||
| 
						 | 
				
			
			@ -95,32 +96,4 @@ $(document).ready(function() {
 | 
			
		|||
    fieldset.append("<input name=\"" + fieldset.attr("name") + "\" id=\"" + fieldset.attr("name") + "\" value=\"\"></input><br>");
 | 
			
		||||
    return false;
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
$.fn.serializeForm = function() {
 | 
			
		||||
  var result = {};
 | 
			
		||||
  this.each(function() {
 | 
			
		||||
    $(this).find(".data > *").each(function() {
 | 
			
		||||
      var $this = $(this);
 | 
			
		||||
      var name = $this.attr("name");
 | 
			
		||||
 | 
			
		||||
      if ($this.is("fieldset") && name) {
 | 
			
		||||
        if ($this.attr("type") == "array") {
 | 
			
		||||
          result[this.name] = [];
 | 
			
		||||
 | 
			
		||||
          $.each($this.serializeArray(), function() {
 | 
			
		||||
            result[this.name].push(this.value);
 | 
			
		||||
          });
 | 
			
		||||
        } else {
 | 
			
		||||
          result[name] = $this.serializeForm();
 | 
			
		||||
        }
 | 
			
		||||
      } else {
 | 
			
		||||
        $.each($this.serializeArray(), function() {
 | 
			
		||||
          result[this.name] = this.value;
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
  return result;
 | 
			
		||||
};
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			@ -145,107 +145,4 @@ func rawToPretty(config interface{}, parent *frontmatter) interface{} {
 | 
			
		|||
	settings = append(settings, objects...)
 | 
			
		||||
 | 
			
		||||
	return settings
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		objects := make([]interface{}, len(objectsNames))
 | 
			
		||||
 | 
			
		||||
		for index := range objectsNames {
 | 
			
		||||
			c := new(frontmatter)
 | 
			
		||||
			c.Type = "object"
 | 
			
		||||
			c.Title = objectsNames[index]
 | 
			
		||||
 | 
			
		||||
			if parent.Name == "" {
 | 
			
		||||
				c.Name = c.Title
 | 
			
		||||
			} else {
 | 
			
		||||
				c.Name = parent.Name + "[" + c.Name + "]"
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			c.Content = rawToPretty(config.(map[string]interface{})[c.Title], c)
 | 
			
		||||
			log.Print("\n\nObject Name:\n")
 | 
			
		||||
			log.Print(c.Name)
 | 
			
		||||
			objects[index] = c
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		arrays := make([]interface{}, len(arraysNames))
 | 
			
		||||
 | 
			
		||||
		for index := range arraysNames {
 | 
			
		||||
			c := new(frontmatter)
 | 
			
		||||
			c.Type = "array"
 | 
			
		||||
			c.Title = arraysNames[index]
 | 
			
		||||
			c.Name = parent.Name + c.Title + "[]"
 | 
			
		||||
			c.Content = rawToPretty(config.(map[string]interface{})[c.Title], c)
 | 
			
		||||
			log.Print("\n\nArray Name:\n")
 | 
			
		||||
			log.Print(c.Name)
 | 
			
		||||
			arrays[index] = c
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/*strings := make([]interface{}, len(stringsNames))*/
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
		for index := range stringsNames {
 | 
			
		||||
			c := new(frontmatter)
 | 
			
		||||
			c.Title = stringsNames[index]
 | 
			
		||||
			c.Name = giveName(c.Title, parent)
 | 
			
		||||
 | 
			
		||||
			log.Print(c.Name)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/*	names := append(stringsNames, mapsNames...)
 | 
			
		||||
 | 
			
		||||
			settings := make([]interface{}, len(names))
 | 
			
		||||
 | 
			
		||||
			for index := range names {
 | 
			
		||||
				c := new(frontmatter)
 | 
			
		||||
				c.Name = names[index]
 | 
			
		||||
				c.Parent = parent
 | 
			
		||||
 | 
			
		||||
				i := config.(map[string]interface{})[names[index]]
 | 
			
		||||
 | 
			
		||||
				if utils.IsMap(i) {
 | 
			
		||||
					c.Type = "object"
 | 
			
		||||
					c.Content = rawToPretty(i, c.Name, "object")
 | 
			
		||||
				} else if utils.IsSlice(i) {
 | 
			
		||||
					c.Type = "array"
 | 
			
		||||
					c.Content = rawToPretty(i, c.Name, "array")
 | 
			
		||||
				} else {
 | 
			
		||||
					c.Type = "text"
 | 
			
		||||
					c.Content = i
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				settings[index] = c
 | 
			
		||||
			}
 | 
			
		||||
	*/
 | 
			
		||||
	//	settings := append(strings, slices..., maps...)
 | 
			
		||||
 | 
			
		||||
	/*if utils.IsSlice(config) {
 | 
			
		||||
		settings := make([]interface{}, len(config.([]interface{})))
 | 
			
		||||
 | 
			
		||||
		// TODO: improve this function
 | 
			
		||||
 | 
			
		||||
		for index, element := range config.([]interface{}) {
 | 
			
		||||
			c := new(frontmatter)
 | 
			
		||||
			c.Name = master
 | 
			
		||||
			c.Parent = parent
 | 
			
		||||
 | 
			
		||||
			if utils.IsMap(element) {
 | 
			
		||||
				c.Type = "object"
 | 
			
		||||
				c.Content = rawToPretty(element, c.Name, "object")
 | 
			
		||||
			} else if utils.IsSlice(element) {
 | 
			
		||||
				c.Type = "array"
 | 
			
		||||
				c.Content = rawToPretty(element, c.Name, "array")
 | 
			
		||||
			} else {
 | 
			
		||||
				c.Type = "text"
 | 
			
		||||
				c.Content = element
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			settings[index] = c
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return settings
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	*/
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,9 +4,7 @@
 | 
			
		|||
<div class="content">
 | 
			
		||||
  <h1>Settings</h1>
 | 
			
		||||
  <form method="POST" action="/admin/settings">
 | 
			
		||||
    <div class="data">
 | 
			
		||||
      {{ template "frontmatter" . }}
 | 
			
		||||
    </div>
 | 
			
		||||
  {{ template "frontmatter" . }}
 | 
			
		||||
  <input type="submit" data-message="Settings updated." value="Save">
 | 
			
		||||
  </form>
 | 
			
		||||
</div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue