Skip to content

Instantly share code, notes, and snippets.

@rashivkp
Created January 19, 2016 05:49
Show Gist options
  • Save rashivkp/88fd112dfd10fd2d335c to your computer and use it in GitHub Desktop.
Save rashivkp/88fd112dfd10fd2d335c to your computer and use it in GitHub Desktop.
sanchai mapping - userscript to ease the data entry
// ==UserScript==
// @name so
// @namespace ALL
// @version 1
// @grant none
// @include http://sanchaya.lsgkerala.gov.in/assessment/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @require https://greasyfork.org/scripts/1003-wait-for-key-elements/code/Wait%20for%20key%20elements.js?version=49342
// ==/UserScript==
// ==UserScript==
// @name _Adding a live button
// @description Adds live example button, with styling.
// @include http://sanchaya.lsgkerala.gov.in/assessment/*
// @grant GM_addStyle
// ==/UserScript==
/*--- Create a button in a container div. It will be styled and
positioned with CSS.
*/
var zNode = document.createElement ('div');
zNode.innerHTML = '<button id="selectMappedBtn" type="button">Select Mapped</button>' +
'<button id="selectVerifiedBtn" type="button">Select Verified</button>' +
'<button id="countAllBtn" type="button">Show Counts</button>' +
'<button id="year2013Btn" type="button">Year to 2013</button>' +
'<button id="closeFrame" type="button">close frame</button>' +
'<input placeholder="new ward" id="newmyWard" type="text" />' +
'<input placeholder="new door" id="newmyDoor" type="text" />' +
'<input placeholder="new sub" id="newmyDoorSub" type="text" />' +
'<button id="setMyValues">Set values<button/>';
zNode.setAttribute ('id', 'myContainer');
zNode.style.position = 'fixed'
zNode.style.top = '0';
zNode.style.right = '0';
zNode.style.zIndex = '100005';
document.body.appendChild (zNode);
//--- Activate the newly added button.
document.getElementById ("selectMappedBtn").addEventListener (
"click", SelectMapped, false
);
document.getElementById ("selectVerifiedBtn").addEventListener (
"click", SelectVerified, false
);
document.getElementById ("countAllBtn").addEventListener (
"click", CountRows, false
);
document.getElementById ("year2013Btn").addEventListener (
"click", changeYear, false
);
document.getElementById ("closeFrame").addEventListener (
"click", closeFrame, false
);
document.getElementById ("setMyValues").addEventListener (
"click", setValuesFromInputs, false
);
function SelectMapped(zEvent) {
$('td').filter( function (index) { return $(this).text() == "Mapped"; } ).parent().find('td:eq(11) input').prop('checked', true);
}
function SelectVerified(zEvent) {
$('td').filter( function (index) { return $(this).text() == "verified"; } ).parent().find('td:eq(11) input').prop('checked', true);
}
function CountRows(zevent) {
console.log('Not verified: '+$('td').filter( function (index) { return $(this).text() == "Not verified"; } ).parent().find('td:eq(11)').length);
console.log('Mapped: '+$('td').filter( function (index) { return $(this).text() == "Mapped"; } ).parent().find('td:eq(11)').length);
console.log('verified: '+$('td').filter( function (index) { return $(this).text() == "verified"; } ).parent().find('td:eq(11)').length);
}
waitforkeyelements ("#ctl00_contentplaceholder1_pnldoor", changeyear);
function changeYear(zevent) {
if($("#ctl00_ContentPlaceHolder1_pnlDoor").css('display') != "none" && $('#ctl00_ContentPlaceHolder1_ddwardyearnew').val() != '2013') {
$('#ctl00_ContentPlaceHolder1_ddwardyearnew').val('2013');
$('#ctl00_ContentPlaceHolder1_btnSearchnew').trigger('change');
}
}
function closeFrame(zevent) {
$('#ctl00_ContentPlaceHolder1_btnDoorClose').click();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment