Banking

Do doctors in UK not make bank? UK Olympic marathoner Phil Sesemann may give up being a doc to run marathons as a pro


<\/div>”,
post_url: “https:\/\/www.letsrun.com\/forum\/flat_read.php?thread=&page=-1#post-“,
user_activity_url: “https:\/\/www.letsrun.com\/forum\/flat_read.php?thread=&page=-1#post-“,
},
session: {
user: null,
csrf: null,
},
postInitiated: false,
sessionInitiated: false,
submitting: false,

isAuthenticated() {
return Boolean(this.session.user);
},
setCategory(input) {
this.newPost.main_category = Boolean(input.mainCategoryId) ? input.mainCategoryId : null
this.newPost.sub_category = Boolean(input.subCategoryId) ? input.subCategoryId : null
},
createElementFromHTML(html) {
var div = document.createElement(“div”);
div.innerHTML = html.trim();

return div
},
processPastedNodes(nodes) {
nodes.forEach(node => {
if(this.isValidUrl(node.textContent)) {
axios.post(“/api/forum/post-links”, {
url: node.textContent,
})
}
})
},
isValidUrl(string) {
let url;

try {
url = new URL(string);
} catch (_) {
return false;
}

return url.protocol === “http:” || url.protocol === “https:”;
},
quoteReplyToPost(){
let postContent = this.getBody();

let div = document.createElement(“div”);
div.innerHTML = postContent;
this.removePostQuote(div)

div.prepend(this.getQuoteElementFromReplyToPost())

// Remove blockquotes more than three levels deep
div.querySelectorAll(“blockquote blockquote figure”).forEach((x)=>{x.remove()});
div.querySelectorAll(“blockquote blockquote blockquote”).forEach((x)=>{x.remove()});
div.querySelectorAll(“blockquote blockquote blockquote > *”).forEach((x)=>{x.remove()});
div.querySelectorAll(“[data-forum-deleted-quoted-post-id]”).forEach(el => el.remove());

// Remove vendor Html
div.querySelectorAll(“blockquote .embed-content-container”).forEach((x)=>{x.remove()});
div.querySelectorAll(“blockquote .vendor-html-embed”).forEach((x)=>{x.remove()});
div.querySelectorAll(“blockquote .link-citation svg”).forEach((x)=>{x.remove()});

// Remove empty paragraphs.
div.querySelectorAll(“*:empty:not(br)”).forEach((x)=>{x.remove()});

// Append a paragraph
div.append(document.createElement(“p”))

// Remove embeds
this.removeLinkEmbeds(div)

// Update editor and scroll to point.
this.setBody(div.innerHTML)

this.scrollToBottomOfEditor()

this.newPost.has_quote = true
this.newPost.has_nested_quoted = this.hasNestedQuote(div)
this.newPost.quoted_post_id = this.replyToPost.id

this.focusEditor()
},
hasNestedQuote(div) {
return !! div.querySelector(“blockquote blockquote”)
},
scrollToBottomOfEditor() {
document.getElementById(“postCreateEditor”).scrollIntoView()
},
sanitizeQuoteHtml(html) {
html = this.removeReservedClasses(html);
html = this.replaceLineBreaksWithParagraphs(html);

return html
},
removeReservedClasses(html) {
let el = this.createElementFromHTML(html);

var prefix = “rx-“;
const allElementsWithPrefix = el.querySelectorAll(“*[class*=\”” + prefix + “\”]”);

allElementsWithPrefix.forEach(node => {
const classes = node.className.split(” “).filter(c => !c.startsWith(prefix));
node.className = classes.join(” “).trim();
})

return el.innerHTML
},
replaceLineBreaksWithParagraphs(html) {
if(! html.includes(“
“)) {
return html;
}

html = html.trim()
html = html.replace(/(\r\n|\n|\r)/gm, “”);

// If it does not start and end with Ps, wrap in p
if(! (html.startsWith(“

“) && html.endsWith(“

“))) {
html = “

” + html + “


}

html = html.replaceAll(“

“, “

“)

return html
},
getQuoteElementFromReplyToPost(postContent) {
let blockQuote = document.createElement(“figure”);
blockQuote.classList.add(“parent-quote”);
blockQuote.setAttribute(“data-forum-quoted-post-id”, this.replyToPost.id)

var quoteHtml = this.sanitizeQuoteHtml(this.replyToPost.body_html)

var authorLink = this.replyToPost.hasOwnProperty(“user_activity_url”) && Boolean(this.replyToPost.user_activity_url)
? `${this.replyToPost.author}`
: this.replyToPost.author

blockQuote.innerHTML = `

${authorLink} wrote:

${quoteHtml}

`;

return blockQuote
},
removeQuote() {
let postContent = this.getBody();

let div = document.createElement(“div”);
div.innerHTML = postContent;
this.removePostQuote(div)

this.setBody(div.innerHTML)

this.newPost.has_quote = false
this.newPost.has_nested_quoted = false
this.newPost.quoted_post_id = null

this.scrollToBottomOfEditor()

if(this.isDesktop()) {
this.focusEditor()
}
},
removeNestedQuote() {
let postContent = this.getBody();

let div = document.createElement(“div”);
div.innerHTML = postContent;
this.removePostNestedQuote(div)

this.setBody(div.innerHTML)

this.newPost.has_nested_quoted = false

this.scrollToBottomOfEditor()

if(this.isDesktop()) {
this.focusEditor()
}
},
removePostQuote(postHtmlElement) {
postHtmlElement.querySelectorAll(“.parent-quote”).forEach(el => el.remove());
},
removePostNestedQuote(postHtmlElement) {
// remove nested blockquotes and then any empty elements
postHtmlElement.querySelectorAll(“blockquote blockquote”).forEach(el => el.remove());
postHtmlElement.querySelectorAll(“*:empty:not(br)”).forEach((x)=>{x.remove()});
postHtmlElement.append(document.createElement(“p”))
},
removeLinkEmbeds(postHtmlElement) {
postHtmlElement.querySelectorAll(“.embedly-card”).forEach(el => el.classList.remove(“embedly-card”));
},
getBody() {
return RedactorX(“#postCreateEditor”).app.editor.getContent()
},
setBody(html) {
RedactorX(“#postCreateEditor”).app.editor.setContent({ html })
},
removeEmptyElements(html) {
var div = document.createElement(“div”);
div.innerHTML = html
div.querySelectorAll(“*:empty:not(br)”).forEach((x)=>{x.remove()});

return div.innerHTML
},
setCsrf(csrfToken) {
this.session.csrf = csrfToken
window.axios.defaults.headers.common = {
“X-Requested-With”: “XMLHttpRequest”,
“X-CSRF-TOKEN”: csrfToken
};
},
checkForInput() {
this.hasContent = Boolean(this.getBody())
},
showPreview() {
this.previewing = true
this.previewHtml = this.getBody()
},
hidePreview() {
this.previewing = false

this.focusEditor()
},
postReply() {
this.newPost.body = this.removeEmptyElements(this.getBody())
this.errors = {}

window.dispatchEvent(new CustomEvent(“reply-” + this.replyToPost.id + “-submitted”, { bubbles: true } ));

this.submitPost(“reply”)
},
createThread() {
this.newPost.body = this.removeEmptyElements(this.getBody())
this.errors = {}

this.submitPost(“thread”)
},
submitPost(create) {
this.submitting = true
var createName = create === “reply” ? “post” : “thread”
var createAction = create === “reply” ? “View Post” : “View Thread”

var that = this;
axios.post(“/forum/posts”, this.newPost)
.then(response => {
that.open = false;
that.submitting = false;

if(create === “reply”) {
window.dispatchEvent(new CustomEvent(“reply-” + that.replyToPost.id + “-saved”, { bubbles: true }));
}

flash(`Redirecting to your ${createName}…`, “info”, 0, response.data.post.post_url_timestamped, createAction)

setTimeout(() => {
window.location.href = response.data.post.post_url_timestamped
}, 250)
})
.catch(error => {
that.errors = error.response.data.errors
that.submitting = false

if(create === “reply”) {
window.dispatchEvent(new CustomEvent(“reply-” + that.replyToPost.id + “-validation-failed”, { bubbles: true }));
}
})

},
focusEditor() {
// Do not focus editor on mobile
if(this.isDesktop()) {
setTimeout(() => {
RedactorX(“#postCreateEditor”).app.editor.setFocus(“end”)
RedactorX(“#postCreateEditor”).app.container.setFocus()
}, 1);
}
},
isMobile() {
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
},
isDesktop() {
return ! this.isMobile()
},
isFirefox() {
return /Firefox/i.test(navigator.userAgent)
},
isAndroid() {
return /Android/i.test(navigator.userAgent)
},
isAndroidFirefox() {
return this.isAndroid() && this.isFirefox()
}
,
loadReplyPost(postId) {
var that = this;
axios.get(`/api/forum/posts/${postId}`)
.then(response => {
that.replyToPost = response.data.post;
});
},
loadReplyQueuedPost(replyToPostData) {
this.replyToPost = replyToPostData.postData
},
initSession() {
var that = this;
axios.get(“/user/session”)
.then(response => {
that.session.user = response.data.user;
that.setCsrf(response.data.csrf_token);
that.sessionInitiated = true;
});
},
elementIsVisible(el) {
return el.offsetWidth > 0 && el.offsetHeight > 0;
},
hasTextboxSelected() {
// If selecting an input or the post editor, return true. Thanks Habs.
if (document.activeElement.tagName === “INPUT” || document.activeElement.classList.contains(“rx-editor”)){
return true;
}

// If a modal or slide overlay is open, return true.
var modalOverlays = Array.from(document.getElementsByClassName(“modal-overlay”))
var slideOverlays = Array.from(document.getElementsByClassName(“slide-up-overlay”))
var overLays = modalOverlays.concat(slideOverlays)

return overLays.map(overlay => this.elementIsVisible(overlay)).includes(true)
},
openReplyFromHotKeys(event) {
// Ignore if reply is open or the user is on mobile
if(this.open || this.isMobile()) {
return;
}

// Ignore if there is an overlay.
if(this.hasTextboxSelected()) {
return;
}

// Ignore if someone is trying to reload.
if (event.ctrlKey && event.keyCode == 82) {
return;
}

if (event.metaKey && event.keyCode == 82) {
return;
}

this.initReplyToPost(this.replyToPost)

window.dispatchEvent(new CustomEvent(“reply-button-clicked”, { detail: {id: 12621339 }, bubbles: true } ));
},
initReplyToPost(replyToPost) {
this.previewing = false;

const hasContent = Boolean(this.getBody());

this.newPost.started_writing = 1711773851;
this.newPost.reply_to = replyToPost.id;
this.replyToPost.id = replyToPost.id;
this.replyToPost.post_rank = replyToPost.post_rank;
this.replyToPost.author = replyToPost.author;

if(! this.sessionInitiated) {
this.initSession();
}

if(replyToPost.queued) {
this.loadReplyQueuedPost(replyToPost)
} else {
this.loadReplyPost(replyToPost.id);
}

this.postInitiated = true;
this.open = true;

if(! this.firstInitComplete && this.isDesktop() && this.isAuthenticated() && this.newPost.author) {
var that = this
this.$nextTick(() => { that.focusEditor() })
} else if(! this.firstInitComplete && this.isDesktop() && ! this.isAuthenticated() && this.newPost.author) {
var that = this
this.$nextTick(() => { that.focusEditor() })
} else if(! this.firstInitComplete && this.isDesktop() && ! this.isAuthenticated()) {
this.$nextTick(() => { document.getElementById(“author”).focus() })
}

this.firstInitComplete = true
}
}”
x-on:forum-category-input.window=”setCategory($event.detail)”
x-cloak

>



Source link

Leave a Response