Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
workaround for js keystroke issue
Browse files Browse the repository at this point in the history
  • Loading branch information
arthtyagi committed Aug 27, 2020
1 parent 4294645 commit e8d8d7c
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fusion/templates/fusion/fusion_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
<textarea rows="1" cols="1" style="height: 5%;" id="ytcode"
placeholder="Insert YouTube Video Embed Code ( adjust height and width accordingly )"
oninput="ytpreview()"></textarea>
<textarea id="htmlCode" placeholder="HTML Code" oninput="showPreview()"></textarea>
<textarea id="htmlCode" placeholder="HTML Code" onblur="showPreview()"></textarea>
<textarea id="cssCode" placeholder="CSS Code" oninput="showPreview()"></textarea>
<textarea id="jsCode" placeholder="JavaScript Code" oninput="showPreview()"></textarea> 
<textarea id="jsCode" placeholder="JavaScript Code" onblur="showPreview()"></textarea> 
</div>
<div class="preview-area">
<iframe id="preview-window"></iframe>
Expand Down
109 changes: 109 additions & 0 deletions notes/static/js/dist/script.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
"use strict";

$(document).ready(function () {
function updateText(btn, newCount, verb) {
btn.text(newCount + " " + verb);
btn.attr("data-likes", newCount);
}

$("#like").click(function (e) {
e.preventDefault();
var this_ = $(this);
var likeUrl = this_.attr("data-href");
var likeCount = parseInt(this_.attr("data-likes")) | 0;
var addLike = likeCount + 1;
var removeLike = likeCount - 1;

if (likeUrl) {
$.ajax({
url: likeUrl,
method: "GET",
data: {},
success: function success(data) {
console.log(data);

if (data.liked) {
updateText(this_, addLike, "Likes");
} else {
updateText(this_, removeLike, "Likes");
}
},
error: function error(_error) {
console.log(_error);
console.log("error");
}
});
}
});
});
$(document).ready(function () {
function updateText(btn, newCount, verb) {
btn.text(newCount + " " + verb);
btn.attr("data-likes", newCount);
}

$("#like1").click(function (e) {
e.preventDefault();
var this_ = $(this);
var likeUrl = this_.attr("data-href");
var likeCount = parseInt(this_.attr("data-likes")) | 0;
var addLike = likeCount + 1;
var removeLike = likeCount - 1;

if (likeUrl) {
$.ajax({
url: likeUrl,
method: "GET",
data: {},
success: function success(data) {
console.log(data);

if (data.liked) {
updateText(this_, addLike, "Likes");
} else {
updateText(this_, removeLike, "Likes");
}
},
error: function error(_error2) {
console.log(_error2);
console.log("error");
}
});
}
});
});
var element = document.getElementById('back-link'); // Provide a standard href to facilitate standard browser features such as
// - Hover to see link
// - Right click and copy link
// - Right click and open in new tab

element.setAttribute('href', document.referrer); // We can't let the browser use the above href for navigation. If it does,
// the browser will think that it is a regular link, and place the current
// page on the browser history, so that if the user clicks "back" again,
// it'll actually return to this page. We need to perform a native back to
// integrate properly into the browser's history behavior

element.onclick = function () {
history.back();
return false;
};

function showPreview() {
var htmlCode = document.getElementById("htmlCode").value;
var cssCode = "<style>" + document.getElementById("cssCode").value + "</style>";
var jsCode = "<scri" + "pt>" + document.getElementById("jsCode").value + "</scri" + "pt>";
var frame = document.getElementById("preview-window").contentWindow.document;
frame.open();
frame.write(htmlCode + cssCode + jsCode);
frame.close();
}

function ytpreview() {
var ytcode = document.getElementById("ytcode").value;
var ytframe = document.getElementById("ytvideo").contentWindow.document;
ytframe.open();
ytframe.write(ytcode);
ytframe.close();
}

var CKEDITOR_BASEPATH = '/static/ckeditor/ckeditor/';

0 comments on commit e8d8d7c

Please sign in to comment.