您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Useful hacks to the already excellent Class Dojo
当前为
// ==UserScript== // @name Class Dojo Plus // @namespace https://greasyfork.org/en/scripts/7873-class-dojo-plus // @version 0.19 // @description Useful hacks to the already excellent Class Dojo // @author Ryan Meyers // @match http://teach.classdojo.com/* // @match https://teach.classdojo.com/* // @grant none // ==/UserScript== /*! * Class Dojo Plus * https://github.com/ * * Allows for class arrangements (saved per computer), hotkeys for students/behaviors, * quick points via mouse wheel, and more! * * * Copyright 2015, Ryan Meyers * Dual licensed under the MIT or GPL Version 2 licenses. * */ // XHook - v1.3.0 - https://github.com/jpillora/xhook // Jaime Pillora <[email protected]> - MIT Copyright 2014 (function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};r=a.document,d="before",c="after",l="readyState",k="addEventListener",j="removeEventListener",g="dispatchEvent",o="XMLHttpRequest",h="FormData",m=["load","loadend","loadstart"],e=["progress","abort","error","timeout"],u=parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase())||[])[1]),isNaN(u)&&(u=parseInt((/trident\/.*; rv:(\d+)/.exec(navigator.userAgent.toLowerCase())||[])[1])),(y=Array.prototype).indexOf||(y.indexOf=function(a){var b,c,d,e;for(b=d=0,e=this.length;e>d;b=++d)if(c=this[b],c===a)return b;return-1}),w=function(a,b){return Array.prototype.slice.call(a,b)},q=function(a){return"returnValue"===a||"totalSize"===a||"position"===a},t=function(a,b){var c,d;for(c in a)if(d=a[c],!q(c))try{b[c]=a[c]}catch(e){}return b},v=function(a,b,c){var d,e,f,h;for(e=function(a){return function(d){var e,f,h;e={};for(f in d)q(f)||(h=d[f],e[f]=h===b?c:h);return c[g](a,e)}},f=0,h=a.length;h>f;f++)d=a[f],b["on"+d]=e(d)},s=function(a){var b;if(null!=r.createEventObject)return b=r.createEventObject(),b.type=a,b;try{return new Event(a)}catch(c){return{type:a}}},f=function(a){var c,d,e;return d={},e=function(a){return d[a]||[]},c={},c[k]=function(a,c,f){d[a]=e(a),d[a].indexOf(c)>=0||(f=f===b?d[a].length:f,d[a].splice(f,0,c))},c[j]=function(a,c){var f;return a===b?void(d={}):(c===b&&(d[a]=[]),f=e(a).indexOf(c),void(-1!==f&&e(a).splice(f,1)))},c[g]=function(){var d,f,g,h,i,j,k,l;for(d=w(arguments),f=d.shift(),a||(d[0]=t(d[0],s(f))),h=c["on"+f],h&&h.apply(b,d),l=e(f).concat(e("*")),g=j=0,k=l.length;k>j;g=++j)i=l[g],i.apply(b,d)},a&&(c.listeners=function(a){return w(e(a))},c.on=c[k],c.off=c[j],c.fire=c[g],c.once=function(a,b){var d;return d=function(){return c.off(a,d),b.apply(null,arguments)},c.on(a,d)},c.destroy=function(){return d={}}),c},x=f(!0),x.EventEmitter=f,x[d]=function(a,b){if(a.length<1||a.length>2)throw"invalid hook";return x[k](d,a,b)},x[c]=function(a,b){if(a.length<2||a.length>3)throw"invalid hook";return x[k](c,a,b)},x.enable=function(){a[o]=n},x.disable=function(){a[o]=x[o]},p=x.headers=function(a,b){var c,d,e,f,g,h,i,j,k;switch(null==b&&(b={}),typeof a){case"object":d=[];for(e in a)g=a[e],f=e.toLowerCase(),d.push(""+f+": "+g);return d.join("\n");case"string":for(d=a.split("\n"),i=0,j=d.length;j>i;i++)c=d[i],/([^:]+):\s*(.+)/.test(c)&&(f=null!=(k=RegExp.$1)?k.toLowerCase():void 0,h=RegExp.$2,null==b[f]&&(b[f]=h));return b}},i=a[h],i&&(x[h]=i,a[h]=function(a){var b;this.fd=a?new i(a):new i,this.form=a,b=[],Object.defineProperty(this,"entries",{get:function(){var c;return c=a?w(a.querySelectorAll("input,select")).filter(function(a){var b;return"checkbox"!==(b=a.type)&&"radio"!==b||a.checked}).map(function(a){return[a.name,"file"===a.type?a.files:a.value]}):[],c.concat(b)}}),this.append=function(a){return function(){var c;return c=w(arguments),b.push(c),a.fd.append.apply(a.fd,c)}}(this)}),x[o]=a[o],n=a[o]=function(){var b,i,j,n,q,r,s,w,y,A,B,C,D,E,F,G,H;return b=-1,H=new x[o],A={},D=null,r=void 0,E=void 0,B=void 0,y=function(){var a,c,d,e;if(B.status=D||H.status,D===b&&10>u||(B.statusText=H.statusText),D!==b){e=p(H.getAllResponseHeaders());for(a in e)d=e[a],B.headers[a]||(c=a.toLowerCase(),B.headers[c]=d)}},w=function(){"responseText"in H&&(B.text=H.responseText),"responseXML"in H&&(B.xml=H.responseXML),"response"in H&&(B.data=H.response)},G=function(){q.status=B.status,q.statusText=B.statusText},F=function(){"text"in B&&(q.responseText=B.text),"xml"in B&&(q.responseXML=B.xml),"data"in B&&(q.response=B.data)},n=function(a){for(;a>i&&4>i;)q[l]=++i,1===i&&q[g]("loadstart",{}),2===i&&G(),4===i&&(G(),F()),q[g]("readystatechange",{}),4===i&&setTimeout(j,0)},j=function(){r||q[g]("load",{}),q[g]("loadend",{}),r&&(q[l]=0)},i=0,C=function(a){var b,d;return 4!==a?void n(a):(b=x.listeners(c),d=function(){var a;return b.length?(a=b.shift(),2===a.length?(a(A,B),d()):3===a.length&&A.async?a(A,B,d):d()):n(4)},void d())},q=A.xhr=f(),H.onreadystatechange=function(){try{2===H[l]&&y()}catch(a){}4===H[l]&&(E=!1,y(),w()),C(H[l])},s=function(){r=!0},q[k]("error",s),q[k]("timeout",s),q[k]("abort",s),q[k]("progress",function(){3>i?C(3):q[g]("readystatechange",{})}),v(e,H,q),("withCredentials"in H||x.addWithCredentials)&&(q.withCredentials=!1),q.status=0,q.open=function(a,b,c,d,e){i=0,r=!1,E=!1,A.headers={},A.headerNames={},A.status=0,B={},B.headers={},A.method=a,A.url=b,A.async=c!==!1,A.user=d,A.pass=e,C(1)},q.send=function(b){var c,e,f,g,i,j,k,l;for(l=["type","timeout","withCredentials"],j=0,k=l.length;k>j;j++)e=l[j],f="type"===e?"responseType":e,f in q&&(A[e]=q[f]);A.body=b,i=function(){var b,c,d,g,i,j;for(E=!0,H.open(A.method,A.url,A.async,A.user,A.pass),i=["type","timeout","withCredentials"],d=0,g=i.length;g>d;d++)e=i[d],f="type"===e?"responseType":e,e in A&&(H[f]=A[e]);j=A.headers;for(b in j)c=j[b],H.setRequestHeader(b,c);a[h]&&A.body instanceof a[h]&&(A.body=A.body.fd),H.send(A.body)},c=x.listeners(d),(g=function(){var a,b;return c.length?(a=function(a){return"object"!=typeof a||"number"!=typeof a.status&&"number"!=typeof B.status?void g():(t(a,B),z.call(a,"data")<0&&(a.data=a.response||a.text),void C(4))},a.head=function(a){return t(a,B),C(2)},a.progress=function(a){return t(a,B),C(3)},b=c.shift(),1===b.length?a(b(A)):2===b.length&&A.async?b(A,a):a()):i()})()},q.abort=function(){D=b,E?H.abort():q[g]("abort",{})},q.setRequestHeader=function(a,b){var c,d;c=null!=a?a.toLowerCase():void 0,d=A.headerNames[c]=A.headerNames[c]||a,A.headers[d]&&(b=A.headers[d]+", "+b),A.headers[d]=b},q.getResponseHeader=function(a){var b;return b=null!=a?a.toLowerCase():void 0,B.headers[b]},q.getAllResponseHeaders=function(){return p(B.headers)},H.overrideMimeType&&(q.overrideMimeType=function(){return H.overrideMimeType.apply(H,arguments)}),H.upload&&(q.upload=A.upload=f(),v(e.concat(m),H.upload,q.upload)),q},"function"==typeof this.define&&this.define.amd?define("xhook",[],function(){return x}):(this.exports||this).xhook=x}).call(this,window); var names = []; var draggables = []; var draggablesSelected = []; var dragging = false; var behaviors_visible = false; var clickPositive = false; var clickNegative = false; var numStudents = 12999; var navShowing = true; var checkForBehaviors; var checkForSelected; var numSelected = 0; var checkForPopup; var oldZ = 0; var entry; var options = []; var isPositive = false; var isNegative = false; function dojoStudent(first, last, id) { this.firstName = first; this.lastName = last; this._id = id; this.name = function() {return this.firstName + " " + this.lastName;}; } function dojoClass(id, title, studentCount) { this._id = id; this.name = title; this.studentCount = studentCount; } function coord(x,y){ this.x = x; this.y = y; this.left = function() {return this.x;}; this.top = function() {return this.y;}; } function RGBcolor(r,g,b){ this.r = r; this.g = g; this.b = b; this.rgb = function(){return "rgb("+this.r+","+this.g+","+this.b+")";} this.rgba = function(a){return "rgba("+this.r+","+this.g+","+this.b+","+a+")";} } function option(c, s, k, v) { this._class = c; this._student = s; this.k = k; this.v = v; } /* * API calls: * * Get all students' information for a given class (using class-id) * [GET] https://teach.classdojo.com/api/dojoClass/{class-id}/student * * Get individual student's information for a given class (using class-id & student-id) * [GET] https://teach.classdojo.com/api/dojoClass/{class-id}/student/{student-id} * * Get class information (using class-id) * [GET] https://teach.classdojo.com/api/dojoClass/{class-id} * * Get all classes' information * [GET] https://teach.classdojo.com/api/dojoClass * * Get all awards given * [GET] https://teach.classdojo.com/api/award?classId={class-id} * * Get all awards given within a date range * Add 6 to hours * dateObj = new Date(year, month[, day[, hour[, minutes[, seconds[, milliseconds]]]]]); * dateObj.toJSON() * * [GET] https://teach.classdojo.com/api/award/?from={json-start-date}&to={json-end-date}&classId={class-id} * * Get all students in school * [GET] https://teach.classdojo.com/api/dojoStudent/ * * Get behaviors for a class (using class-id) * [GET] https://teach.classdojo.com/api/dojoClass/{class-id}/behavior * * */ xhook.before(function(request) { // if(request.url.match(/^https:\/\/teach\.classdojo\.com\/api\/dojoClass\/.+\/behavior.+$/) && request.method === "PUT") if(request.url.match(/^.*api\/award.*$/)) console.trace(); true;// request.body = request.body.replace(/-2/g,'0'); // if(request.body) request.body = request.body.replace(/poitns/g,'points'); }); xhook.after(function(request, response) { if(request.url.match(/^https:\/\/teach\.classdojo\.com\/api\/dojoClass\/.+\/student\?.+$/)) { var jsonData = JSON.parse(response.text); // console.info(jsonData['_items'].length); numStudents = jsonData['_items'].length } else if(request.url.match(/^https:\/\/teach\.classdojo\.com\/api\/dojoClass\?withPending.+$/)) { var jsonData = JSON.parse(response.text); // console.info(jsonData['_items'].length); numClasses = jsonData['_items'].length; for(i = 0; i<numClasses; i++) { } } else if(request.url.match(/^https:\/\/teach\.classdojo\.com\/api\/dojoClass\/.+\/behavior\?.+$/)) { // var jsonData = JSON.parse(response.text); //jsonData._items[0].points = -20; // response.text = JSON.stringify(jsonData); // console.info(jsonData['_items'].length); //numStudents = jsonData['_items'].length true; } else if(request.url.match(/^https:\/\/classdojo\.pubnub\.com\/subscribe\/.+$/)) { var jsonData = JSON.parse(response.text); if(jsonData[0].length > 0) { console.log("Greater than Zero!"); } //jsonData._items[0].points = -20; // response.text = JSON.stringify(jsonData); // console.info(jsonData['_items'].length); //numStudents = jsonData['_items'].length true; } if(!request.url.match(/^.*(time|api\/clientLog).*$/)) { console.group("AJAX Event: %s",decodeURIComponent(request.url)); console.log(request); console.log(request.method === "POST" || request.method === "PUT" ? response.text : response.text !== "" ? JSON.parse(response.text) : "No response"); console.groupEnd(); } // response.text = response.text.replace(/Cassidy/g,'Kid'); }); keyCodeToChar = {8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause/Break",20:"Caps Lock",27:"Esc",32:"Space",33:"Page Up",34:"Page Down",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",45:"Insert",46:"Delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",91:"Windows",93:"Right Click",96:"Numpad 0",97:"Numpad 1",98:"Numpad 2",99:"Numpad 3",100:"Numpad 4",101:"Numpad 5",102:"Numpad 6",103:"Numpad 7",104:"Numpad 8",105:"Numpad 9",106:"Numpad *",107:"Numpad +",109:"Numpad -",110:"Numpad .",111:"Numpad /",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"Num Lock",145:"Scroll Lock",182:"My Computer",183:"My Calculator",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"}; function addGlobalStyle(css) { var head, style; head = document.getElementsByTagName('head')[0]; if (!head) { return; } style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = css; head.appendChild(style); } var text = document.getElementsByClassName("t"); var toV = ''; var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { entry = { // mutation: mutation, el: mutation.target.parentElement, value: mutation.target.textContent, oldValue: mutation.oldValue, type: mutation.type }; // console.log("Recording mutation:", entry); }); console.log(toV); console.log(parseInt(entry.value)); if(parseInt(entry.value) !== toV) { var thisBubble = entry.el; toV = isNaN(parseInt(entry.value)) ? 0 : parseInt(entry.value) * 1; if(toV>=10) { oldZ = thisBubble.parentNode.parentNode.parentNode.style.zIndex; thisBubble.parentNode.parentNode.parentNode.style.zIndex = "999999"; TweenMax.to(thisBubble,1,{scale:8, yoyo:true, repeat:1, rotationX:"+=720deg", onComplete: function(){ thisBubble.parentNode.parentNode.parentNode.style.zIndex = oldZ; } }); TweenMax.to(thisBubble,1,{ backgroundColor:"rgb(170,0,255)"}); // thisBubble.style.backgroundColor = "rgb(170,0,255)"; thisBubble.style.color = "white"; thisBubble.parentNode.parentNode.style.border="rgba(170,0,255,0.5) solid 4px"; } else if(toV>=5) { thisBubble.style.backgroundColor = "rgb(0,170,255)"; thisBubble.style.color = "white"; thisBubble.parentNode.parentNode.style.border="rgba(0,170,255,0.5) solid 4px";} else if(toV>=0) { thisBubble.style.backgroundColor = "rgb(0,218,60)"; thisBubble.style.color = "white"; thisBubble.parentNode.parentNode.style.border="rgba(0,218,60,0.5) solid 4px";} else if(toV>-5) { thisBubble.style.backgroundColor = "rgb(244,243,40)"; thisBubble.style.color = "black"; thisBubble.parentNode.parentNode.style.border="rgba(244,243,40,0.5) solid 4px";} else if(toV>-10) { thisBubble.style.backgroundColor = "rgb(253,134,3)"; thisBubble.style.color = "black"; thisBubble.parentNode.parentNode.style.border="rgba(253,134,3,0.5) solid 4px";} else { thisBubble.style.backgroundColor = "rgb(223,21,26)"; thisBubble.style.color = "black"; thisBubble.parentNode.parentNode.style.border="rgba(223,21,26,0.5) solid 4px";} // entry.el.innerHTML = toV; console.log( toV); } }); function mouseWheelHandler(e){ var e = window.event || e; // old IE support e.preventDefault(); e.stopPropagation; var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))); if(delta>0) { clickPositive = true; } else { clickNegative = true; } this.click(); } addGlobalStyle(' .hotKey {opacity: 0.05;} .hotKey:hover {opacity: 1.0;} .positive-behaviors-list, .negative-behaviors-list { display: visible; } .leaderboardStudentTile:hover {background-color: rgba(20,210,40,0.2);} .leaderboard-student-tile .bubble .student-number.zero {display:block; top:-16px; right:-16px;} span.student-number.negative::first-letter {font-size:0px;}'); /* (function() { var XHR = XMLHttpRequest.prototype; // Remember references to original methods var open = XHR.open; var send = XHR.send; // Overwrite native methods // Collect data: XHR.open = function(method, url) { this._method = method; this._url = url; return open.apply(this, arguments); }; // Implement "ajaxSuccess" functionality XHR.send = function(postData) { this.addEventListener('load', function() { // Method //console.log(this._method); // URL console.group("AJAX Request"); console.info("%o",this); console.info("URL: %s",this._url); // Response body //console.log(this.responseText); //https://teach.classdojo.com/api/dojoClass/53ffe4bd2b100d272c668de3/student?_u=54c7aa2e1445f26b5a2e6264 if(this._url.match(/^https:\/\/teach\.classdojo\.com\/api\/dojoClass\/.+\/student\?.+$/)) { var jsonData = JSON.parse(this.responseText); // console.info(jsonData['_items'].length); numStudents = jsonData['_items'].length } // Request body console.log(postData); if(this._method != 'POST') console.log(JSON.parse(this.responseText)); else console.log(this.responseText); console.groupEnd(); }); return send.apply(this, arguments); }; })(); */ var script = document.createElement("script"); script.setAttribute("src", "https://cdnjs.cloudflare.com/ajax/libs/gsap/1.15.0/TweenMax.min.js"); script.addEventListener('load',function() { var script2 = document.createElement("script"); script2.setAttribute("src", "https://cdnjs.cloudflare.com/ajax/libs/gsap/1.15.0/utils/Draggable.min.js"); script2.addEventListener('load',function() { var checkExist = setInterval(function() { if ($('.leaderboard-student-tile').length === numStudents) { clearInterval(checkExist); var li = document.createElement("a"); li.className = 'help-tab'; li.id = 'hide_stuff'; li.innerHTML = '<span class="glyphicon glyphicon-eye-close"></span>Hide Extras'; var t = document.getElementsByClassName("help-container").item(0); t.appendChild(li); li.addEventListener('click',function() { $('div.navbar.navbar-static-top.mojette-navbar').toggle(); $('.help-tab[target=_blank]').toggle(); // $('div.help-container').toggle(); if(navShowing === true){ document.getElementById('hide_stuff').innerHTML = '<span class="glyphicon glyphicon-eye-open"></span>'; navShowing = false; } else { document.getElementById('hide_stuff').innerHTML = '<span class="glyphicon glyphicon-eye-close"></span>Hide Extras'; navShowing = true; } }); $( ".leaderboard-student-tile" ).wrap('<div class="leaderboardStudentTile" style="display:inline-block; position:absolute; border-radius:5px;"></div>'); // $('.first').hisResText(); // $('.last').hisResText(); var tiles = document.getElementsByClassName("leaderboard-student-tile"); // var tiles = document.getElementsByClassName("leaderboardStudentTile"); for(i=0; i<tiles.length; i++) { names[i] = tiles[i].children[1].textContent; var thisBubble = tiles[i].children[3].children[0]; toVv = isNaN(parseInt(thisBubble.textContent)) ? 0 : parseInt(thisBubble.textContent) * 1; if(toVv>=10) { thisBubble.style.backgroundColor = "rgb(170,0,255)"; thisBubble.style.color = "white"; thisBubble.parentNode.parentNode.style.border="rgba(170,0,255,0.5) solid 4px"; } else if(toVv>=5) { thisBubble.style.backgroundColor = "rgb(0,170,255)"; thisBubble.style.color = "white"; thisBubble.parentNode.parentNode.style.border="rgba(0,170,255,0.5) solid 4px";} else if(toVv>=0) { thisBubble.style.backgroundColor = "rgb(0,218,60)"; thisBubble.style.color = "white"; thisBubble.parentNode.parentNode.style.border="rgba(0,218,60,0.5) solid 4px";} else if(toVv>-5) { thisBubble.style.backgroundColor = "rgb(244,243,40)"; thisBubble.style.color = "black"; thisBubble.parentNode.parentNode.style.border="rgba(244,243,40,0.5) solid 4px";} else if(toVv>-10) { thisBubble.style.backgroundColor = "rgb(253,134,3)"; thisBubble.style.color = "black"; thisBubble.parentNode.parentNode.style.border="rgba(253,134,3,0.5) solid 4px";} else { thisBubble.style.backgroundColor = "rgb(223,21,26)"; thisBubble.style.color = "black"; thisBubble.parentNode.parentNode.style.border="rgba(223,21,26,0.5) solid 4px";} observer.observe(thisBubble, {characterData: true, characterDataOldValue: true, subtree:true}); // names[i] = tiles[i].children[0][1].textContent; } for(i=0; i<tiles.length; i++) { var span = document.createElement("div"); if(i<=11){ span.innerHTML="F"+(i+1)+""; } else if(i===12) { span.innerHTML="PS"; } else if(i===13) { span.innerHTML="SL"; } else if(i===14) { span.innerHTML="PB"; } span.style.bottom="15px"; span.style.right="15px"; span.style.position="absolute"; span.style.border="2px solid #333"; span.style.borderRadius="5px"; span.style.background="#ffe"; span.style.fontFamily="monospace"; span.style.textAlign="center"; span.style.lineHeight="2.5"; span.style.height="30px"; span.style.width="30px"; span.style.fontSize="80%"; span.className="hotKey"; span.addEventListener('load',function() { }); tiles[i].parentNode.appendChild(span); // tiles[i].style.position="absolute"; // draggables[i] = Draggable.create(tiles[i], {type:"top,left", force3D:false, trigger:tiles[i].children[4], draggables[i] = Draggable.create(tiles[i].parentNode, {type:"top,left", force3D:false, //trigger:tiles[i].parentNode.children[1], onDragEnd:function(e) { e.preventDefault(); e.stopPropagation(); $('body').css('background-image',''); var name = this.target.children[0].children[1].textContent; var vX = name+"X"; var vY = name+"Y"; // var rect = getOffsetRect(this.target); // var rect2 = document.getBoundingClientRect(); localStorage.setItem(vX, this.endX); // localStorage.setItem(vX, this.target.style.left); localStorage.setItem(vY, this.endY); // localStorage.setItem(vY, this.target.style.top); }, onClick:function(e) { e.preventDefault(); e.stopPropagation; // this.target.children[0].click(); return false; }, onDragStart:function(e){ $('body').css('background-image','url(//upload.wikimedia.org/wikipedia/commons/7/7c/Lightblue_empty_grid.svg)'); } }); } // console.log(tiles); for(i=0; i<tiles.length; i++) { tiles[i].addEventListener("mousewheel", mouseWheelHandler, false); } for(i=0; i<names.length; i++) { var vX = names[i]+"X"; var vY = names[i]+"Y"; if(localStorage.getItem(vX) !== null && localStorage.getItem(vY) !== null){ // TweenMax.to(tiles[i],5,{left:localStorage.getItem(vX), top:localStorage.getItem(vY)}); TweenMax.to(tiles[i].parentNode,5,{left:localStorage.getItem(vX), top:localStorage.getItem(vY)}); // console.log("values"); } else { TweenMax.to(tiles[i].parentNode,5,{left:i*20, top:i*20}); } } /* $('.leaderboard-student-tile').bind('contextmenu', function (e) { e.preventDefault(); });*/ $(document).keyup(function (e) { if(!$('input[type=text]').length) { if($('.behavior-tile').length){ var tiles = document.getElementsByClassName("behavior-tile"); if(e.which >= 49 && e.which <=57){ tiles.item(e.which-49).click(); e.preventDefault(); } else if(e.which === 48){ tiles.item(9).click(); e.preventDefault(); } } else if($('.leaderboard-student-tile').length){ var tiles = document.getElementsByClassName("leaderboard-student-tile"); if(e.which >= 112 && e.which <=123){ tiles.item(e.which-112).click(); e.preventDefault(); } else if(e.which === 44) { tiles.item(12).click(); e.preventDefault(); } else if(e.which === 145) { tiles.item(13).click(); e.preventDefault(); } else if(e.which === 19) { tiles.item(14).click(); e.preventDefault(); } else if(e.which === 65) { document.getElementById('award_multiple_trigger').click(); var checkExist2 = setInterval(function() { if ($('#select_all').length) { clearInterval(checkExist2); document.getElementById('select_all').click(); var checkExist3 = setInterval(function() { if ($('#give-multiple-awards-button').is(":disabled")) { return false; } else { clearInterval(checkExist3); document.getElementById('give-multiple-awards-button').click(); } }, 200); } }, 200); } } } }); $(document).keydown(function (e) { if(!$('input[type=text]').length) e.preventDefault(); }); checkForBehaviors = setInterval(function() { if ($('.behavior-tile').length) { if(!behaviorsVisible) { if(clickPositive) { document.getElementsByClassName('positive-behaviors-list').item(0).getElementsByClassName('behavior-tile').item(1).click(); clickPositive = false; } else if(clickNegative) { document.getElementsByClassName('negative-behaviors-list').item(0).getElementsByClassName('behavior-tile').item(4).click(); clickNegative = false; } else { $('.behavior-tile').css('width', '10%'); $('.behavior-tile h4').css('font-size','80%'); $('.positive-behaviors-list').show(); $('.positive-behaviors-list').prev().hide(); $('.negative-behaviors-list').show(); } } behaviorsVisible = true; //clearInterval(checkforBehaviors); } else { behaviorsVisible = false; } }, 200); checkForPopup = setInterval(function() { if ($('.award-notification-view').length) { if(!behaviorsVisible) { if(isPositive) { document.getElementsByClassName('positive-behaviors-list').item(0).getElementsByClassName('behavior-tile').item(1).click(); clickPositive = false; } else if(isNegative) { document.getElementsByClassName('negative-behaviors-list').item(0).getElementsByClassName('behavior-tile').item(4).click(); clickNegative = false; } else { $('.behavior-tile').css('width', '10%'); $('.behavior-tile h4').css('font-size','80%'); $('.positive-behaviors-list').show(); $('.positive-behaviors-list').prev().hide(); $('.negative-behaviors-list').show(); } } behaviorsVisible = true; //clearInterval(checkforBehaviors); } else { behaviorsVisible = false; } }, 200); checkForSelected = setInterval(function() { if ($('.leaderboard-student-tile.selected').length) { if ($('.leaderboard-student-tile.selected').length !== numSelected) { if(numSelected === 0) { for (i=0; i<draggables.length; i++) { draggables[i][0].disable(); } } numSelected = $('.leaderboard-student-tile.selected').length; var selectedTiles = document.getElementsByClassName('selected'); for (i=0; i<draggablesSelected.length; i++) { draggablesSelected[i][0].kill(); } for(i=0; i<numSelected; i++) { draggablesSelected[i] = Draggable.create(selectedTiles[i].parentNode, {type:"top,left", force3D:false, trigger:$('.leaderboardStudentTile').has('.leaderboard-student-tile.selected'), onDragEnd:function(e) { e.preventDefault(); e.stopPropagation(); $('body').css('background-image',''); var name = this.target.children[0].children[1].textContent; var vX = name+"X"; var vY = name+"Y"; // var rect = getOffsetRect(this.target); // var rect2 = document.getBoundingClientRect(); localStorage.setItem(vX, this.endX); // localStorage.setItem(vX, this.target.style.left); localStorage.setItem(vY, this.endY); // localStorage.setItem(vY, this.target.style.top); }, onClick:function(e) { e.preventDefault(); e.stopPropagation; // this.target.children[0].click(); return false; }, onDragStart:function(e){ $('body').css('background-image','url(http://upload.wikimedia.org/wikipedia/commons/7/7c/Lightblue_empty_grid.svg)'); } }); } } else { return false; } } else { if(numSelected !== 0) { for (i=0; i<draggables.length; i++) { draggables[i][0].enable(); } for (i=0; i<draggablesSelected.length; i++) { draggablesSelected[i][0].kill(); } } numSelected = 0; } }, 200); } }, 1000); }, false); document.body.appendChild(script2); }, false); document.body.appendChild(script);