- ajax(
- "/news",
- edit ? "PUT" : "POST",
- {news: this.curnews},
- (res) => {
- if (edit)
- {
- let n = this.newsList.find(n => n.id == this.curnews.id);
- if (!!n)
- n.content = this.curnews.content;
- }
- else
- {
- const newNews = {
- content:this.curnews.content,
- added:Date.now(),
- uid: this.st.user.id,
- id: res.id
- };
- this.newsList = this.newsList.concat([newNews]);
- }
- document.getElementById("modalNews").checked = false;
- this.infoMsg = "";
- this.resetCurnews();
+ ajax("/news", edit ? "PUT" : "POST", { news: this.curnews }, res => {
+ if (edit) {
+ let n = this.newsList.find(n => n.id == this.curnews.id);
+ if (n) n.content = this.curnews.content;
+ } else {
+ const newNews = {
+ content: this.curnews.content,
+ added: Date.now(),
+ uid: this.st.user.id,
+ id: res.id
+ };
+ this.newsList = [newNews].concat(this.newsList);