Just one line of code, easy to implement an online editor _javascript tips

Source: Internet
Author: User

In most people's eyes, the technical curtilage gives the impression that the person is taciturn, always can not penetrate what he thought in mind, keep each other distance. As half of the programmers, I think the real technical house most of the time to find fun, tinker with various ideas, and most people's geek mentality is the same, programmers also love to tell jokes, also like cooking food, although most of it is to reduce the pressure, so it seems that there is nothing different from ordinary person.

Not the same place, technology curtilage advocating the ultimate, like minimalism, but also hope that simplicity is not simple, behind the technical house full of thoughts of the constant attempt, I was watching a play in the stage:



"The programmer Jose Jesus Perez Aguinaga shared a little tip in Coderwall: Enter a line of code in the browser's address bar: data:text/html,

As you can see from the intro, it's just a short snippet of code: data:text/html,

Copy Code code as follows:

Data:text/html,
<style type= "Text/css" >
#e {
Position:absolute;
top:0;
right:0;
bottom:0;
left:0;
font-size:16px;
}
</style>
<div id= "E" ></div>
<script src= "Http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" ></script>
<script src= "Http://code.jquery.com/jquery-1.9.0.min.js" ></script>
<script>
var mykey= "Secretkeyz";
$ (document). Ready (function () {
var e = ace.edit ("E");
var url = "http://api.openkeyval.org/" +mykey;
$.ajax ({
Url:url,
DataType: "Jsonp",
Success:function (data) {
E.settheme ("Ace/theme/tomorrow_night_eighties");
E.getsession (). SetMode ("Ace/mode/markdown");
E.setvalue (data);
}
});

$ ("#e"). On ("KeyDown", function (b) {
if (b.ctrlkey && B.which = =) {
B.preventdefault ();
var data = mykey+ "=" +encodeuricomponent (E.getvalue ());
$.ajax ({
Data:data,
URL: "Http://api.openkeyval.org/store/",
DataType: "Jsonp",
Success:function (data) {
Alert ("Saved.");
}
});
}
});
});
</script>


Copy the above code completely, paste into the chrome or Firefox,safari browser address bar (do not support the low version of IE browser), enter open, wait a moment an online editor that supports CTRL + S save content is present.

Only one line of code, the implementation of functions equivalent to the system of Notepad program, feeling the art of technical curtilage it? ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.