Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple text expander for "New Dweet" editor #391

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions dwitter/static/js/expander.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
if(localStorage.getItem("expandKey")==null) localStorage.setItem("expandKey"," ")
expKey = localStorage.getItem("expandKey")
editor = document.getElementById("editor")
function u_repl(str,old_,new_){return str.split(old_).join(new_)}
function expand(c)
{
var start = c.selectionStart, end = c.selectionEnd;
c.value = u_repl(c.value,"hsl;"+expKey,"`hsl(${},99%,50%)`;")
c.value = u_repl(c.value,"hsla;"+expKey,"`hsla(${},99%,50%,.5)`;")
c.value = u_repl(c.value,"x.fs="+expKey,"x.fillStyle=;")
c.value = u_repl(c.value,"x.ss="+expKey,"x.strokeStyle=;")
c.value = u_repl(c.value,"x.fr"+expKey,"x.fillRect(x,y,w,h);")
c.value = u_repl(c.value,"x.bp;"+expKey,"x.beginPath();")
c.value = u_repl(c.value,"x.fl;"+expKey,"x.fill();")
c.value = u_repl(c.value,"x.sk;"+expKey,"x.stroke();")
c.value = u_repl(c.value,"x.sr"+expKey,"x.strokeRect(x,y,w,h);")
c.value = u_repl(c.value,"clear;"+expKey,"c.width^=0;")
c.value = u_repl(c.value,"middle;"+expKey,"x.translate(960,540);")
c.value = u_repl(c.value,"1time"+expKey,"t?0:event;")
c.value = u_repl(c.value,"x.gcop="+expKey,"x.globalCompositeOperation=;")
c.value = u_repl(c.value,"x.dri"+expKey,"x.drawImage(c,0,0);")
c.value = u_repl(c.value,"m.ab"+expKey,"Math.abs(n);")
c.value = u_repl(c.value,"m.rn"+expKey,"Math.random(n);")
c.value = u_repl(c.value,"..rb"+expKey,Math.random()<.5?'1':'0')
c.value = u_repl(c.value,"..for"+expKey,"for(i=0;i++<10;)")
c.value = u_repl(c.value,"gr1"+expKey,"α")
c.value = u_repl(c.value,"gr2"+expKey,"β")
c.value = u_repl(c.value,"gr3"+expKey,"θ")
c.value = u_repl(c.value,"gr4"+expKey,"τ")
c.value = u_repl(c.value,"gr5"+expKey,"λ")
c.value = u_repl(c.value,";\n",";")
c.setSelectionRange(start, end);
}
setInterval(function(){expand(editor)},50)
1 change: 1 addition & 0 deletions dwitter/templates/feed.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<script src="{% static "js/scrolling.js" %}"></script>
<script src="{% static "js/ajax-handling.js" %}"></script>
<script src="{% static "js/feed.js" %}"></script>
<script src="{% static "js/expander.js" %}"></script>
<!--<script src="{% static 'js/submit-view.js' %}"></script> -->
{% endcompress %}

Expand Down