blogplus备份
<!DOCTYPE html>
<html>
<body>
<script id="func">
function titl(){
alert("title!");
}
</script>
<div id="tool" style="position:float;display:inline-block">
<button id="title" onclick="titl()">T</button>
<button id="bold"><strong>B</strong></button>
<button id="underline"><u>U</u></button>
<button id="italic"><em>I</em></button>
</div>
<div class="editable" id="textarea" contenteditable="true" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"><br></div>
<script>
var tinner="";
var tinnerold="";
function setCursor(num) {
var tag = document.getElementById("textarea");
// Creates range object
var setpos = document.createRange();
// Creates object for selection
var set = window.getSelection();
// Set start position of range
setpos.setStart(tag.childNodes[0],num);
// Collapse range within its boundary points
// Returns boolean
setpos.collapse(true);
// Remove all ranges set
set.removeAllRanges();
// Add range with respect to range object.
set.addRange(setpos);
// Set cursor on focus
tag.focus();
}
function clic(){
var textarea=document.getElementById("textarea");
if(textarea.innerHTML=="<br>"){
setCursor(0);
}
else if(textarea.innerText.length==0){
textarea.innerHTML="<br>";
setCursor(0);
}
}
function runtextarea(){
var textarea = document.getElementById("textarea");
tinner=textarea.innerHTML;
//alert(tinner)
tinnerold=tinner;
cursor= getCaretCharacterOffsetWithin(textarea);
}
function getCaretCharacterOffsetWithin(element) {
var caretOffset = 0;
var doc = element.ownerDocument || element.document;
var win = doc.defaultView || doc.parentWindow;
var sel;
if (typeof win.getSelection != "undefined") {
sel = win.getSelection();
if (sel.rangeCount > 0) {
var range = win.getSelection().getRangeAt(0);
var preCaretRange = range.cloneRange();
preCaretRange.selectNodeContents(element);
preCaretRange.setEnd(range.endContainer, range.endOffset);
caretOffset = preCaretRange.toString().length;
}
} else if ( (sel = doc.selection) && sel.type != "Control") {
var textRange = sel.createRange();
var preCaretTextRange = doc.body.createTextRange();
preCaretTextRange.moveToElementText(element);
preCaretTextRange.setEndPoint("EndToEnd", textRange);
caretOffset = preCaretTextRange.text.length;
}
return caretOffset;
}
window.addEventListener("click",function(){
clic();
});
window.addEventListener("keyup",function(){runtextarea()});
window.addEventListener("paste",function(){
runtextarea();
});
</script>
<style>
body{
background-color:#FCFCF9;
}
#textarea {
outline:none;
font-family:sans-serif;
padding: 5px;
border:2px solid #F6F6E4;
border-radius:5px;
width:76%;
height:38em;
font-size:2em;
margin-left:12%;
margin-right:12%;
margin-top:8%;
margin-bottom:8%;
overflow:auto;
}
#textarea:focus,#textarea:hover{
border:1px solid #FAFAF0;
}
button{
border:1px solid #FCFCF9;
border-radius:5px;
background-color:#FFFFFB;
font-size:1.5em;
color:#323232;
width:3em;height:2em;
}
strong {
font-weight: bold;
}
em{
font-style:italic;
}
u{
font-style:underline;
}
</style>
</body>
</html>
91
<!DOCTYPE html>
<html>
<body>
<title>Markdown plus simple- blogplus1.0,mooling</title>
<script id="func">
function titl(num){
alert("title!");
}
</script>
<div id="tool" style="position:float;display:inline-block">
<button id="bold"><strong>B</strong></button>
<button id="linethrough"><s>S</s></button>
<button id="italic"><em>I</em></button>
<button id="underline"><u>U</u></button>
<p>|</p>
<button id="h1" onclick="titl(1)">H1</button>
<button id="h2" onclick="titl(2)">H2</button>
<button id="h3" onclick="titl(3)">H3</button>
<button id="h4" onclick="titl(4)">H4</button>
<button id="h5" onclick="titl(5)">H5</button>
<button id="h6" onclick="titl(6)">H6</button>
<p>|</p>
<button id="ul" onclick="titl(1)">ul</button>
<button id="ol" onclick="titl(2)">ol</button>
<p>|</p>
<button id="image" onclick="titl(1)">img</button>
<button id="link" onclick="titl(2)">link</button>
<button id="code" onclick="titl(1)">code</button>
<button id="table" onclick="titl(2)">table</button>
<p>|</p>
<button id="mdhtml" onclick="titl(1)">see</button>
<button id="style" onclick="titl(1)">style</button>
</div>
<div class="editable" id="textarea" contenteditable="true" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"><br></div>
<script>
var tinner="";
var tinnerold="";
function setCursor(num) {
var tag = document.getElementById("textarea");
var setpos = document.createRange();
var set = window.getSelection();
setpos.setStart(tag.childNodes[0],num);
// Collapse range within its boundary points
// Returns boolean
setpos.collapse(true);
set.removeAllRanges();
set.addRange(setpos);
tag.focus();
}
function clic(){
var textarea=document.getElementById("textarea");
if(textarea.innerHTML=="<br>"){
setCursor(0);
}
else if(textarea.innerText.length==0){
textarea.innerHTML="<br>";
setCursor(0);
}
}
function runtextarea(){
var textarea = document.getElementById("textarea");
thtml=textarea.innerHTML;
text=textarea.innerText;
tmphtml="";
//cursor of Text
cursor = getCursor(textarea);
alert(thtml);
told = thtml;
}
function getCursor(element) {
var caretOffset = 0;
var doc = element.ownerDocument || element.document;
var win = doc.defaultView || doc.parentWindow;
var sel;
if (typeof win.getSelection != "undefined") {
sel = win.getSelection();
if (sel.rangeCount > 0) {
var range = win.getSelection().getRangeAt(0);
var preCaretRange = range.cloneRange();
preCaretRange.selectNodeContents(element);
preCaretRange.setEnd(range.endContainer, range.endOffset);
caretOffset = preCaretRange.toString().length;
}
} else if ( (sel = doc.selection) && sel.type != "Control") {
var textRange = sel.createRange();
var preCaretTextRange = doc.body.createTextRange();
preCaretTextRange.moveToElementText(element);
preCaretTextRange.setEndPoint("EndToEnd", textRange);
caretOffset = preCaretTextRange.text.length;
}
return caretOffset;
}
window.addEventListener("click",function(){
clic();
});
window.addEventListener("input",function(){runtextarea()});
window.addEventListener("paste",function(){
runtextarea();
});
</script>
<style>
body{
background-color:#FDFDFC;
}
#textarea {
outline:none;
font-family:Microsoft Yahei,Microsoft Yahei UI,sans-serif;
padding: 5px;
border:2px solid #F6F6F0;
border-radius:5px;
width:76%;
height:60em;
font-size:1.2em;
margin-left:12%;
margin-right:12%;
margin-top:8%;
margin-bottom:8%;
overflow:auto;
color:#111111;
}
#textarea:focus,#textarea:hover{
border:1px solid #FAFAF0;
}
#tool{
width:100%;height:1.8em;
background-color:#FFFFFF;
border-image:linear-gradient(to bottom,#222222,#FFFFFF) 0 0 3 0;
border-bottom:solid 3px;
}
button{
border:1px solid #FEFEFA;
border-radius:2px;
font-size:1em;
color:#515151;
height:1.5em;
background:none;
}
button::-moz-focus-inner {
border: 0;
}
strong,b{
font-weight: bold;
}
em{
font-style:italic;
}
u{
text-decoration:underline;
}
s{
text-decoration:line-through;
}
#tool p{
color:#A0A0A0;
display:inline;
}
</style>
</body>
</html>
97
<!DOCTYPE html>
<html>
<body>
<title>Markdown+ 1.0 - blogplus,cnblogs by mooling</title>
<script src="file:///storage/emulated/0/mdscript.js"></script>
<link rel="stylesheet" href="file:///storage/emulated/0/mdstyle.css">
<div id="bignav">
<div class="navtool" id="nav" style="position:float;display:inline-block">
<button id="back">≡ Markdown+</button>
<button id="ok">发布文章</button>
<button id="save">save</button>
<button id="addtool" onclick="addtool()">+</button>
</div>
<div class="navtool" id="tool" style="position:float;">
<button id="bold" onclick="tool('b')"><strong>B</strong></button>
<button id="italic" onclick="tool('i')"><em>I</em></button>
<button id="underline" onclick="tool('u')"><u>U</u></button>
<button id="linethrough" onclick="tool('s')"><s>S</s></button>
<p>|</p>
<button id="h1" onclick="tool('h1')">H1</button>
<button id="h2" onclick="tool('h2')">H2</button>
<button id="h3" onclick="tool('h3')">H3</button>
<button id="h4" onclick="tool('h4')">H4</button>
<button id="h5" onclick="tool('h5')">H5</button>
<button id="h6" onclick="tool('h6')">H6</button>
<p>|</p>
<button id="ul" onclick="tool('ul')">ul</button>
<button id="ol" onclick="tool('ol')">ol</button>
<p>|</p>
<button id="image" onclick="tool('img')">img</button>
<button id="link" onclick="tool('link')">link</button>
<button id="code" onclick="tool('code')">code</button>
<button id="table" onclick="tool('table')">table</button>
<p>|</p>
<button id="showhtml" onclick="showhtml()">html</button>
<button id="style" onclick="stylemd()">style</button>
</div>
</div>
<div id="twodiv">
<div class="editable" id="textarea" contenteditable="true" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"><br></div>
<div id="outputhtml"><div>
</div>
<script>
window.addEventListener("click",function(){
clic();
});
window.addEventListener("input",function(){runmd()});
window.addEventListener("paste",function(){
runmd();
});
//init
document.getElementById("tool").style.display="none";
</script>
</body>
</html>
var oldbr=-1;
function tool(str){
}
function stylemd(){
}
function showhtml(){
}
function mdtohtml(mdtext){
return mdtext;
}
function htmltomd(htmltext){
}
function highlightmd(mdhtml){
//return html
return mdhtml;
}
function runmd(){
var textarea = document.getElementById("textarea"),outputhtml=document.getElementById("outputhtml");
//< <> >& &(space)
md=textarea.innerText;
mdhtml=textarea.innerHTML;
//cursor of plain Text
cursor = getCursor(textarea);
textarea.innerHTML = highlightmd( mdhtml);
outputhtml.innerHTML= mdtohtml(md);
setCursor(cursor);
}
function ishtmlthat(htmltext,i,that){
for(j=i;j<i+that.length;j++){
if(htmltext[j]!=that[j-i]){
return 0;
}
}
return 1;
}
function getCursor(element) {
var caretOffset = 0;
var doc = element.ownerDocument || element.document;
var win = doc.defaultView || doc.parentWindow;
var sel;
if (typeof win.getSelection != "undefined") {
sel = win.getSelection();
if (sel.rangeCount > 0) {
var range = win.getSelection().getRangeAt(0);
var preCaretRange = range.cloneRange();
preCaretRange.selectNodeContents(element);
preCaretRange.setEnd(range.endContainer, range.endOffset);
caretOffset = preCaretRange.toString().length;
}
} else if ( (sel = doc.selection) && sel.type != "Control") {
var textRange = sel.createRange();
var preCaretTextRange = doc.body.createTextRange();
preCaretTextRange.moveToElementText(element);
preCaretTextRange.setEndPoint("EndToEnd", textRange);
caretOffset = preCaretTextRange.text.length;
}
return caretOffset;
}
function setCursor(num) {
var tag = document.getElementById("textarea");
var setpos = document.createRange();
var set = window.getSelection();
setpos.setStart(tag.childNodes[0],num);
// Collapse range within its boundary points
// Returns boolean
setpos.collapse(true);
set.removeAllRanges();
set.addRange(setpos);
tag.focus();
}
function addtool(){
tool= document.getElementById("tool")
bttn= document.getElementById("addtool")
if(tool.style.display=="none"){
tool.style.display="inline-block"
bttn.innerText="-";
}
else{
tool.style.display="none"
bttn.innerText="+";
}
}
body{
background-color:#FDFDFC;
/*background-image:flex*/
overflow:hidden;
}
div{
display:block;
}
span{
display:inline;
}
#twodiv{
column-count:2;
-moz-column-count:2;
-webkit-column-count:2;
column-gap:0px;
-moz-column-gap:0px;
-webkit-column-gap:0px;
}
#textarea,#outputhtml{
width:30em;
height:60em;
padding:1.2em;
box-sizing:border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
}
#textarea {
background-color:#FAFAF9;
outline:none;
font-family:微软雅黑,Microsoft Yahei,Microsoft Yahei UI,consolas,sans-serif;
padding:1.2em;
box-shadow:1px 0px 0.5px #DDDDDD;
font-size:1em;
margin-left:0px;
margin-right:50%;
margin-top:0px;
margin-bottom:0px;
overflow:auto;
color:#111111;
float:left;
}
#outputhtml{
font-family:微软雅黑,Microsoft Yahei,Microsoft Yahei UI,consolas,sans-serif;
font-size:1em;
outline:none;
overflow:auto;
margin-top:0px;
float:left;
}
.navtool{
width:100%;height:1.8em;
background-color:#FFFFFF;
}
#textarea:focus{
border-right:1px solid #FCFCFA;
}
button{
border:0px solid #FEFEFA;
border-radius:2px;
font-size:1em;
color:#515151;
height:1.5em;
background:none;
outline:none;
}
button::-moz-focus-inner {
border: 0;
}
strong,b{
font-weight: bold;
}
em{
font-style:italic;
}
u{
text-decoration:underline;
}
s{
text-decoration:line-through;
}
.navtool p{
color:#A0A0A0;
display:inline;
}
#nav{
height:2em;
}
#nav button{
text-align:center;
outline:none;
}
#bignav{
border-image:linear-gradient(to bottom,#222222,#FFFFFF) 0 0 3 0;
border-bottom:solid 3px;
}
#nav button:not(#back){
float:right;
}
918
<!DOCTYPE html>
<html>
<body>
<title>Markdown2.0 - blogplus,cnblogs. By moolng</title>
<script src="file:///storage/emulated/0/mdscript.js"></script>
<link rel="stylesheet" href="file:///storage/emulated/0/mdstyle.css">
<div id="bignav">
<div class="navtool" id="nav" style="position:float;display:inline-block">
<button id="back">≡ Markdown+</button>
<button id="ok">发布文章</button>
<button id="save">save</button>
<button id="addtool" onclick="addtool()">+</button>
</div>
<div class="navtool" id="tool" style="position:float;">
<button id="bold" onclick="tool('b')"><strong>B</strong></button>
<button id="italic" onclick="tool('i')"><em>I</em></button>
<button id="underline" onclick="tool('u')"><u>U</u></button>
<button id="linethrough" onclick="tool('s')"><s>S</s></button>
<p>|</p>
<button id="h1" onclick="tool('h1')">H1</button>
<button id="h2" onclick="tool('h2')">H2</button>
<button id="h3" onclick="tool('h3')">H3</button>
<button id="h4" onclick="tool('h4')">H4</button>
<button id="h5" onclick="tool('h5')">H5</button>
<button id="h6" onclick="tool('h6')">H6</button>
<p>|</p>
<button id="ul" onclick="tool('ul')">ul</button>
<button id="ol" onclick="tool('ol')">ol</button>
<p>|</p>
<button id="image" onclick="tool('img')">img</button>
<button id="link" onclick="tool('link')">link</button>
<button id="code" onclick="tool('code')">code</button>
<button id="table" onclick="tool('table')">table</button>
<p>|</p>
<button id="showhtml" onclick="showhtml()">html</button>
<button id="style" onclick="stylemd()">style</button>
</div>
</div>
<div id="twodiv">
<div class="editable" id="textarea" contenteditable="true" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"><div id="letternow"><br></div><strong>strong</strong><u>underline</u></div>
<div id="outputhtml"><div>
</div>
<script>
window.addEventListener("keyup",function(){runmd()});
window.addEventListener("input",function(){runmd()});
window.addEventListener("mousedown",function(){runmd()});
window.addEventListener("paste",function(){
runmd();
});
//init
document.getElementById("tool").style.display="none";
</script>
</body>
</html>
body{
background-color:#FDFDFC;
/*background-image:flex*/
overflow:hidden;
}
div{
display:block;
}
span{
display:inline;
}
#twodiv{
column-count:2;
-moz-column-count:2;
-webkit-column-count:2;
column-gap:0px;
-moz-column-gap:0px;
-webkit-column-gap:0px;
}
#textarea,#outputhtml{
width:30em;
height:60em;
padding:1.2em;
box-sizing:border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
}
#textarea {
background-color:#FAFAF9;
outline:none;
font-family:微软雅黑,Microsoft Yahei,Microsoft Yahei UI,consolas,sans-serif;
padding:1.2em;
box-shadow:1px 0px 0.5px #DDDDDD;
font-size:1em;
margin-left:0px;
margin-right:50%;
margin-top:0px;
margin-bottom:0px;
overflow:auto;
color:#111111;
float:left;
}
#outputhtml{
font-family:微软雅黑,Microsoft Yahei,Microsoft Yahei UI,consolas,sans-serif;
font-size:1em;
outline:none;
overflow:auto;
margin-top:0px;
float:left;
}
.navtool{
width:100%;height:1.8em;
background-color:#FFFFFF;
}
#textarea:focus{
border-right:1px solid #FCFCFA;
}
button{
border:0px solid #FEFEFA;
border-radius:2px;
font-size:1em;
color:#515151;
height:1.5em;
background:none;
outline:none;
}
button::-moz-focus-inner {
border: 0;
}
strong,b{
font-weight: bold;
}
em{
font-style:italic;
}
u{
text-decoration:underline;
}
s{
text-decoration:line-through;
}
.navtool p{
color:#A0A0A0;
display:inline;
}
#nav{
height:2em;
}
#nav button{
text-align:center;
outline:none;
}
#bignav{
border-image:linear-gradient(to bottom,#222222,#FFFFFF) 0 0 3 0;
border-bottom:solid 3px;
}
#nav button:not(#back){
float:right;
}
function tohtmlencode(str)
{
str=str.replace("&","&");
str=str.replace("<","<");
str=str.replace(">",">");
str=str.replace("'","'");
str=str.replace('"',""");
str=str.replace("\n","<br>");
str=str.replace(" "," ");
str=str.replace("\t"," ");
return str;
}
function tool(str){
}
function stylemd(){
}
function showhtml(){
}
function mdtohtml(mdtext){
return mdtext;
}
function htmltomd(htmltext){
}
function highlightmd(mdhtml){
//return html
return mdhtml;
}
function runmd(){
var textarea = document.getElementById("textarea"),outputhtml=document.getElementById("outputhtml");
md=textarea.innerText;
mdhtml=textarea.innerHTML;
//cursor of plain Text and space (without \n,\t)
cursor = getCursor(textarea);
var startsubstring,endsubstring;
//substring start to end-1
var status="none";
for(i=0;i<;i++){
if(istextthat(md,i,"\n")){
}
letter++;
}
//dont highlight if nothing change
//textarea.innerHTML = highlightmd(mdhtml);
//setCursor(cursor);
}
function istextthat(text,i,that){
for(j=i;j<i+that.length;j++){
if(text[j]!=that[j-i]){
return 0;
}
}
return 1;
}
function getCursor(element) {
var caretOffset = 0;
var doc = element.ownerDocument || element.document;
var win = doc.defaultView || doc.parentWindow;
var sel;
if (typeof win.getSelection != "undefined") {
sel = win.getSelection();
if (sel.rangeCount > 0) {
var range = win.getSelection().getRangeAt(0);
var preCaretRange = range.cloneRange();
preCaretRange.selectNodeContents(element);
preCaretRange.setEnd(range.endContainer, range.endOffset);
caretOffset = preCaretRange.toString().length;
}
} else if ( (sel = doc.selection) && sel.type != "Control") {
var textRange = sel.createRange();
var preCaretTextRange = doc.body.createTextRange();
preCaretTextRange.moveToElementText(element);
preCaretTextRange.setEndPoint("EndToEnd", textRange);
caretOffset = preCaretTextRange.text.length;
}
return caretOffset;
}
function setCursor(num) {
var tag = document.getElementById("textarea");
var setpos = document.createRange();
var set = window.getSelection();
setpos.setStart(tag.childNodes[0],num);
// Collapse range within its boundary points
// Returns boolean
setpos.collapse(true);
set.removeAllRanges();
set.addRange(setpos);
tag.focus();
}
function addtool(){
tool= document.getElementById("tool")
bttn= document.getElementById("addtool")
if(tool.style.display=="none"){
tool.style.display="inline-block"
bttn.innerText="-";
}
else{
tool.style.display="none"
bttn.innerText="+";
}
}
大改动
<!doctype html> <head> <title>write · 纸船</title> <link href="boatstyle.css" rel="stylesheet"> </head> <body> <div id="writetools" class="tools"> </div> <div id="content" contenteditable="true"><br></div> <div id="guidetools" class="tools"> </div> </body> <footer> <script src="creative.js"></script> </footer>
boat
*{
outline:none;
}
*::-moz-focus-inner{
border:0;
}
body{
width:100%;
height:100%;
}
.tools{
height:50px;
background-color:#EFEFEF;
width:100%;
position:float;
}
#writetools{
margin-top:0px;
}
#guidetools{
margin-top:100%;
}
console.log("hello~ boat.")
console.log("page ok!")

浙公网安备 33010602011771号