Last active
August 30, 2016 22:13
-
-
Save theawesomecoder61/03f263063c0981c8c74c5c96876fe7a7 to your computer and use it in GitHub Desktop.
With this script, RenWeb is now faster and cleaner with awesome features.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createChart(a,b,c,d,e){var f=100,g=(2*Math.PI,d3.scale.linear().domain([0,100]).range([0,2*Math.PI])),h=d3.select("body").select(a).append("svg").attr("width",2*f).attr("height",2*f),i=h.append("g").attr("transform","translate("+f+", "+f+")"),j=d3.svg.arc().innerRadius(f-10).outerRadius(f).startAngle(0).endAngle(g(d));i.append("path").attr("d",j).style("fill",b),i.append("text").text(c).attr("x",0).attr("y",-16).attr("class","classname link").style("fill",b).on("click",function(){window.open(e)}),i.append("text").text(d+"%").attr("x",0).attr("y",32).attr("class","grade link").style("fill",b).on("click",function(a){d3.select(this).text()==numberToLetterGrade(d)?d3.select(this).text(d+"%"):d3.select(this).text(numberToLetterGrade(d))})}function addStyle(a){var b=document.createElement("link");b.rel="stylesheet",b.href=a,document.getElementsByTagName("head")[0].appendChild(b)}function addScript(a,b){var c=document.createElement("script");c.src=a,c.onload=b,document.getElementsByTagName("head")[0].appendChild(c)}function createElement(a,b){var c=document.createElement(a);c.id=b,document.getElementsByTagName("body")[0].appendChild(c)}function displayElements(a,b){for(var c=0;c<a.length;c++)document.querySelector(a[c]).style.display=1==b?"block":"none"}function createHeader(a,b,c){var d=document.createElement("h"+a);d.innerText=b,document.querySelector(c).appendChild(d)}function numberToLetterGrade(a){var b="";return a>=97?b="A+":a>=93&&96>=a?b="A":a>=90&&92>=a?b="A-":a>=87&&89>=a?b="B+":a>=83&&86>=a?b="B":a>=80&&82>=a?b="B-":a>=79&&77>=a?b="C+":a>=73&&76>=a?b="C":a>=70&&72>=a?b="C-":a>=67&&69>=a?b="D+":a>=63&&66>=a?b="D":a>=60&&62>=a?b="D-":59>=a&&(b="F"),b}if("interactive"==document.readyState&&"https://ocs-fl.client.renweb.com/pw/student/"==document.URL.replace("#","")){var colors=["#D93829","#D96C00","#FBC700","#3BC651","#3182D9","#E960BB","#5F42C0"],css="@import 'https://fonts.googleapis.com/css?family=Lato';";css+="*, body { color: #000 !important; font-family: 'Lato', sans-serif; }",css+="body { background: #ddd; margin: 0; overflow: hidden !important; padding: 0; }",css+="#charts { width: 100%; max-height: 100vh; overflow-y: scroll; text-align: center; }",css+="svg { padding: 10px; }",css+="text { font-family: 'Lato', sans-serif; -moz-user-select: none; -webkit-user-select: none; user-select: none; text-anchor: middle; }",css+="text.link:hover { cursor: pointer; text-decoration: underline; }",css+="text.grade { font-size: 20px; }",css+="text.classname { font-size: 16px; }",css+="table, tr { width: 100%; height: 100%; }",css+="td { width: 50%; height: 100%; }";var style=document.createElement("style");style.type="text/css",style.styleSheet?style.styleSheet.cssText=css:style.appendChild(document.createTextNode(css)),document.getElementsByTagName("head")[0].appendChild(style),document.getElementsByTagName("body")[0].innerHTML+="<table><tr><td><div id='charts'></div></td><td><iframe src='"+document.querySelector(".hw_frame").getAttribute("src")+"' id='hwif' width='100%' height='100%'></iframe></td></tr></table>",createHeader("1",document.querySelector(".login_box h3").innerText,"#charts"),addScript("//d3js.org/d3.v3.min.js",function(){for(var a=document.querySelectorAll("tbody .col_subject a"),b=document.querySelectorAll("tbody .col_grade a"),c=0;c<b.length;c++)createChart("#charts",colors[c],a[c].innerText,parseInt(b[c].innerText),a[c].getAttribute("href"));createHeader("6","created by Andrew M.","#charts"),displayElements(["header","article","footer"],!1),$("#hwif").load(function(){$("#hwif").contents().find("body").append("<link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet'>"),$("#hwif").contents().find("html").css({background:"#ddd",fontFamily:"'Lato', sans-serif"}),$("#hwif").contents().find("body").css({padding:0,margin:0}),$("#hwif").contents().find("body").prepend("<div style='text-align:center'><h1 style='font-weight: normal'>Homework</h1></div>");var a=new Date,b=a.getMonth()+1,c=a.getDate(),d=a.getFullYear(),e=b+"/"+c+"/"+d;$("#hwif").contents().find("body").find(".hw").each(function(){$(this).find("div").first().text().indexOf(e)>-1&&($(this).css("background","#ff0"),$(this).attr("id","current-day"),$("#hwif").contents().find("body").animate({scrollTop:$("#hwif").contents().find("#current-day").offset().top},0))});var f=document.getElementById("hwif").contentWindow;$(f).on("resize",function(){$("#hwif").contents().find("body").animate({scrollTop:$("#hwif").contents().find("#current-day").offset().top},0)})})})} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment