new.tpl.html

  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
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
{{template "prelude.tpl.html" .}}
<title>New Post</title>
</head>
<body>
    <header class="container">
        {{ template "header.tpl.html" .}}
    </header>
<main class="container">
	{{$aa := .ActiveAccount}}
<div>
	<h2>Swtich Accounts</h2>
<form method="post" action="/switch">
  <fieldset>
    <label>
      Account
      <select name="account" id="account">
		{{range .Accounts}}
			{{if eq .UserName $aa.UserName}}
			<option value="{{.UserNamePlain}}" selected="selected">{{.Name}}</option>
	
			{{else}}
			<option value="{{.UserNamePlain}}" >{{.Name}}</option>
			{{end}}
		{{end}}
	 </select>
    </label>
	</fieldset>
	  <input
    type="submit"
    value="Switch"
  />
	</form>

  <h2>Post A New Post</h2>

<form method="post" onsubmit="return getContent()">
  <fieldset>
    <label>
      Account
      <select name="account" id="account">
		{{range .Accounts}}
		{{if eq .UserName $aa.UserName}}
		<option value="{{.UserNamePlain}}" selected="selected">{{.Name}}</option>
		{{else}}
		<option value="{{.UserNamePlain}}" >{{.Name}}</option>
		{{end}}
		{{end}}
	 </select>
    </label>
    <label>
      Reply To
      <input name="replyto" id="replyto" value="{{.ReplyToRef}}"/>
    </label>
    <label>
		Post
	    </label>
    <div class="sample-toolbar">
		<a href="javascript:void(0)" onclick="format('bold')"><span class="fa fa-bold fa-fw"></span></a>
		<a href="javascript:void(0)" onclick="format('italic')"><span class="fa fa-italic fa-fw"></span></a>
		<a href="javascript:void(0)" onclick="format('insertunorderedlist')"><span class="fa fa-list fa-fw"></span></a>
		<a href="javascript:void(0)" onclick="setUrl()"><span class="fa fa-link fa-fw"></span></a>
       <span><input id="txtFormatUrl" placeholder="url" class="form-control"></span>
	</div>
      <div 
		class="editor"
		contenteditable="true"
        id="postedit"
        placeholder="Write a post"
        minlength="10"
		
      >{{.ReplyContents}}</div>
	     <input type="hidden" id="post" name="post"/>

  </fieldset>

  <input
    type="submit"
    value="Post"
  />
</form>
</div>
</main>

{{template "footer.tpl.html" .}}


	<script>
		window.addEventListener('load', function(){
			document.getElementById('sampleeditor').setAttribute('contenteditable', 'true');
        });

		function format(command, value) {
			document.execCommand(command, false, value);
		}

		function setUrl() {
			var url = document.getElementById('txtFormatUrl').value;
			var sText = document.getSelection();
			document.execCommand('insertHTML', false, '<a href="' + url + '" target="_blank">' + sText + '</a>');
			document.getElementById('txtFormatUrl').value = '';
		}

		function getContent(){
        	document.getElementById("post").value = document.getElementById("postedit").innerHTML;
    	}

	</script>
</body>
</html>