Skip to content

Instantly share code, notes, and snippets.

@xuboying
Last active April 18, 2016 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xuboying/d732d9d4f509b07c8a2041ef6bc7c755 to your computer and use it in GitHub Desktop.
Save xuboying/d732d9d4f509b07c8a2041ef6bc7c755 to your computer and use it in GitHub Desktop.

Converter

Converts two whitespaces to Chinese wide whitespace, so it can be displayed in browser properly

Paste following entire javascript code to bookmark address

Tested in Firefox

javascript:(function(){
	var A=document.createElement('div');
    A.style=`
        border: solid 1px blue;
        position: fixed;
        left: 50%;
        top: 50%;
        background-color: white;
        z-index: 100;
        height: 400px;
        margin-top: -200px;
        width: 600px;
        margin-left: -300px;
    `;
    var box1=document.createElement('textarea');
    box1.value="(paste code here)";
    box1.style="width:95%;height:90%";
    var btn1=document.createElement('input');
    btn1.type="button";
    btn1.value="Convert";
    btn1.addEventListener("click", function(){
        box1.value=box1.value.replace(/  /g," ");
        box1.value=box1.value+"\n\n### Warning: Above code may contain Chinese wide whitespace for human friendly reading in web browser. \n### Do: replace them back to double space in your favorite text editor to satisfy you compiler/interpreted.";
    });
    var btn2=document.createElement('input');
    btn2.type="button";
    btn2.value="Go Away";
    btn2.addEventListener("click", function(){
        A.removeChild(btn1);
        A.removeChild(btn2);
        A.removeChild(box1);
        A.parentNode.removeChild(A);
    });
    A.appendChild(box1);
    A.appendChild(btn1);
    A.appendChild(btn2);
    document.getElementsByTagName("body")[0].appendChild(A);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment