Last active
December 15, 2016 03:06
-
-
Save gelicia/44c526900907ebf44cdae4cf7c6d985c to your computer and use it in GitHub Desktop.
Northstar MLS comment box and cost per sq ft additions. Only works on page load, gotta go in through main page for diff searches. EMOJIS WORK!!
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
// ==UserScript== | |
// @name mls additions | |
// @namespace nsmls | |
// @include http://matrix.northstarmls.com/* | |
// @version 1 | |
// @grant none | |
// @require https://code.jquery.com/jquery-2.1.4.min.js | |
// @require https://cdn.firebase.com/js/client/2.2.3/firebase.js | |
// ==/UserScript== | |
var rows = $('.singleLineDisplay'); | |
//draw the textboxes | |
for (var i = 0; i < rows.length; i++) { | |
var row = $(rows[i]); | |
var textbox = document.createElement('input'); | |
textbox.type = "text"; | |
var mlsID = $(".d1839m8", row)[0].innerText; | |
textbox.setAttribute("id", "m_" + mlsID); | |
textbox.setAttribute("class", "commentText"); | |
textbox.setAttribute("style", "width:600px; margin-left: 20px; margin-bottom: 10px;"); | |
row[0].append(textbox); | |
var costTxt = document.createElement('p'); | |
costTxt.setAttribute("id", "m_txt_" + mlsID); | |
costTxt.setAttribute("class", "costText"); | |
costTxt.setAttribute("style", "display:inline; margin-left: 5px;"); | |
var cost = parseInt(($(".d1839m17", row)[0].innerText).replace(/[^0-9]/g,'')); | |
var sqft = parseInt(($(".d1839m22", row)[0].innerText).replace(/[^0-9]/g,'')); | |
var costPerSqFt = (cost / sqft).toFixed(2); | |
costTxt.innerHTML = "$" + costPerSqFt + " / sqft"; | |
row[0].append(costTxt); | |
} | |
//add values | |
var mlsEntry = new Firebase('https://fake-database-name.firebaseio.com/'); | |
mlsEntry.on("child_added", function(snap) { | |
$("#m_" + snap.key()).val(snap.val().comments); | |
}); | |
$(".commentText").keyup(function(e) { | |
if(e.keyCode == 13){ | |
var mlsID = e.currentTarget.id.substring(2); | |
mlsEntry.child(mlsID).set({ | |
"comments" : e.currentTarget.value | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment