Grab cell values from a table using Jquery? - javascript

I'm trying to grab the cell values from an HTML table generated from another PHP code. That I can use the result to send a rendezvous at final user.
My current JSFiddle can grab some values but not like I want. I need to retrieve the attrib title & value from the button in the TD, my problem is currently the code return data from morning day and jump to the next morning day.
How I can return entire day value & title data's for each available days in the table ?
Code :
$(document).ready(function(){
eachCell();
function eachCell(){
var cellInnerText = [];
var cellValue = [];
var out = document.getElementById("out");
var out2 = document.getElementById("out2");
$('#ft_agenda tbody tr').each(function(index) {
// console.log("index ", index, " this: " , this, "this.attr(rel)", $(this).attr('rel'), "$(this).text()", $(this).text());
console.log($(":first-child", $(this))[0]);
cellInnerText.push($("td button", $(this)).attr('value'));
cellValue.push($("td button", $(this)).attr('title'));
});
out.innerHTML = cellInnerText.join(" | ");
out2.innerHTML = cellValue.join(" | ");
}
});

// Try this code on your jsfiddle
// https://jsfiddle.net/g60ogt8c/1/
$(function() {
function findColumnByDate(date) {
var col;
$('#ft_agenda thead th').each(function(idx) {
if ($(this).text().trim() == date.trim()) col = idx;
});
return col;
}
function showAvailableTimes(date) {
var times = [],
column = findColumnByDate(date);
if (column) {
var $rows = $('#ft_agenda tbody td:nth-of-type('+column+')');
if ($rows.length) {
times[0] = '';
$rows.find('button').each(function() {
times[times.length] = $(this).attr('value')+' - '+$(this).attr('title');
});
times[0] = 'For date '+date+' found '+(times.length-1)+' free terms';
} else {
times[0] = ['No free terms for date: '+date];
}
} else {
times[0] = ['Invalid date '+date+' or date not found'];
}
return times;
}
// Function showAvailableTimes() now returns array.
// In index 0 is status message and if available times found,
// these lies on indexes 1 and more.
// Use it this way:
$('#out').html('');
showAvailableTimes('15-09-2016').forEach(function(item) {
$('#out').append(item + '<br>');
});
// Or this way:
// Jsonify returned array and send it toSome.php.
var json = JSON.stringify(showAvailableTimes('09-09-2016'));
$.post('toSome.php', {times: json});
// Or if there are free terms, filter status message
// and send just free terms - without status message.
var times = showAvailableTimes('09-09-2016');
if (times.length > 1) {
var json = JSON.stringify(times.filter(function(itm,idx){return idx>0}));
$.post('toSome.php', {times: json});
// Here you can see that status message was skipped
$('#out2').text(json);
}
});

Related

Create calendar event from Gmail?

I found the following code online but can't remember where I got it from. The script will search for any emails with a specific label (in this case "GReminder") and add those emails into your calendar. I tried to set this up but I'm getting the error message:
TypeError: label.getThreads is not a function
I'm not familiar with Javascript and I'm not a software developer by any means. I've tried to modify it but couldn't get it to work. Hoping someone can help me here. Here is the code below:
function gMailReminder() {
var reminderLabel = "GReminder", //Substitute your label here
calendarName = "Mobile Calendar", ////Substitute your Calendar name here
reminderDuration = 2, //duration in hours
label = GmailApp.getUserLabelByName(reminderLabel),
threads = label.getThreads();
if (threads.length > 0) {
//get calendar by name
var cals = CalendarApp.getCalendarsByName(calendarName);
var now = new Date().getTime();
for (i in threads) {
cals[0].createEvent(reminderLabel + '- '+threads[0].getFirstMessageSubject(),
new Date(now+(60000*60*reminderDuration)),
new Date(now+(60000*60*reminderDuration)), {description: threads[i].getPermalink()});
}
//Remove the label from the mails to avoid duplicate event creation on next run
label.removeFromThreads(threads);
}
}
Furthermore, the code searches for the label "GReminder" and then removes that label at the end of the script. I'd like to modify this so that the script searches for GReminder in Gmail, then adds a new GReminder-Processed label to it (to show that those emails have been "processed") and then the next time it runs again, it will skip emails with GReminder-Processed. I've only gotten the part of creating the labels sorted (I think), but can't figure out the rest...
function getOrCreateLabel(labelName) {
var label = GmailApp.getUserLabelByName(labelName);
if (label == null) {
label = GmailApp.createLabel(labelName);
}
return label;
}
var label = getOrCreateLabel("Bill Reminder - processed");
thread.addLabel(label);
function gMailReminder() {
const rlbl = "GReminder";
const rdur = 2;
const label = GmailApp.getUserLabelByName(rlbl);
const threads = label.getThreads();
const cal = CalendarApp.getCalendarsByName("Mobile Calendar")[0];
if (threads.length > 0) {
threads.forEach(t => {
let now = new Date().getTime();
cal.createEvent(rlbl + '- ' + t.getFirstMessageSubject(), new Date(now), new Date(now + (60000 * 60 * rdur)), { description: t.getPermalink() });
});
label.removeFromThreads(threads);
}
}
I think probably your label name is wrong:
Here's a function to get your label names:
function getUserLabels() {
const labels = GmailApp.getUserLabels();
let html = '';
labels.forEach(l => {
html += `<br>Name: ${l.getName()}`
});
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(html),'Label Names');
}
I modified your code to test the label names:
function gMailReminder() {
const rlbl = "Qs/Services/Google";
const label = GmailApp.getUserLabelByName(rlbl);
const threads = label.getThreads();
let html ='';
if (threads.length > 0) {
threads.forEach(t => {
html += `<br>${t.getFirstMessageSubject()}`;
});
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(html),'Subjects');
}
}
And this now works
Came up with the solution myself.
As you can see, my label has Chinese characters and GmailApp.Search has no problem with this.
However, LABEL_DONE requires you to put in I guess the unicode (or whatever it's called) of the Chinese characters. Again, I don't know anything about Javascript and so a lot of my code is just copying and pasting code from somewhere else and modifying them to the best of my extent. I had to do a bit of debugging to find out what my Chinese label looks like in the Logger. The result provided by the Logger is the unicode that you see for LABEL_DONE. If you also use non-English characters for your labels, you'll need to test it yourself and find what the corresponding unicode string is.
Anyway, the code below will use GmailApp.Search to search for specific labels (you can mix and match search conditions in there and can test this easily in Gmail search itself). It will then add the emails for those specific labels into Google Calendar, then apply a "Bill Reminder - Processed" label. The next time the Google App Script trigger runs, it will skip these emails, because of the Processed label.
// https://stackoverflow.com/questions/12377640/printing-to-the-console-in-google-apps-script
function testLog(){
Logger.log("Logger.log");
console.log("console.log")
}
function BillReminder_Rates() {
if (!GmailApp) return; // Skip script execution if GMail is currently not available (yes this happens from time to time and triggers spam emails!)
var reminderLabel = "電費,-水費,-垃圾袋,-網路-bill-reminder---processed", //Substitute your label here
calendarName = "Reminders", ////Substitute your Calendar name here
reminderDuration27Days = 648; //duration in hours;
var threads = GmailApp.search('(label:電費,-水費,-垃圾袋,-網路-council-rates---me) AND (-label:電費,-水費,-垃圾袋,-網路-bill-reminder---processed)');
if (threads.length > 0) {
//get calendar by name
var cals = CalendarApp.getCalendarsByName(calendarName);
var now = new Date().getTime();
for (i in threads) {
//cals[0].createEvent(reminderLabel + ' - '+threads[i].getFirstMessageSubject(),
cals[0].createEvent(threads[i].getFirstMessageSubject(),
new Date(now+(60000*60*reminderDuration27Days)),
new Date(now+(60000*60*reminderDuration27Days)), {description: threads[i].getPermalink()});
}
LABEL_DONE = "\u96fb\u8cbb, \u6c34\u8cbb, \u5783\u573e\u888b, \u7db2\u8def/Bill Reminder - Processed";
var label_done = GmailApp.getUserLabelByName(LABEL_DONE);
for (var t in threads) {
var threadblah = threads[t];
// Grab the task data
var taskTitle = threadblah.getFirstMessageSubject();
// Insert the task
//addTask_(taskTitle, TASKLIST);
// Set to 'done' by exchanging labels
//threadblah.removeLabel(label_pending);
threadblah.addLabel(label_done);
}
}
}
function BillReminder_Power_Gas() {
if (!GmailApp) return; // Skip script execution if GMail is currently not available (yes this happens from time to time and triggers spam emails!)
var reminderLabel = "電費,-水費,-垃圾袋,-網路-bill-reminder---processed", //Substitute your label here
calendarName = "Reminders", ////Substitute your Calendar name here
reminderDuration12Days = 288; //duration in hours;
var threads = GmailApp.search('(label:電費,-水費,-垃圾袋,-網路-power -OR label:電費,-水費,-垃圾袋,-網路-gas) AND (-label:電費,-水費,-垃圾袋,-網路-bill-reminder---processed)');
if (threads.length > 0) {
//get calendar by name
var cals = CalendarApp.getCalendarsByName(calendarName);
var now = new Date().getTime();
for (i in threads) {
//cals[0].createEvent(reminderLabel + ' - '+threads[i].getFirstMessageSubject(),
cals[0].createEvent(threads[i].getFirstMessageSubject(),
new Date(now+(60000*60*reminderDuration12Days)),
new Date(now+(60000*60*reminderDuration12Days)), {description: threads[i].getPermalink()});
}
LABEL_DONE = "\u96fb\u8cbb, \u6c34\u8cbb, \u5783\u573e\u888b, \u7db2\u8def/Bill Reminder - Processed";
var label_done = GmailApp.getUserLabelByName(LABEL_DONE);
for (var t in threads) {
var threadblah = threads[t];
// Grab the task data
var taskTitle = threadblah.getFirstMessageSubject();
// Insert the task
//addTask_(taskTitle, TASKLIST);
// Set to 'done' by exchanging labels
//threadblah.removeLabel(label_pending);
threadblah.addLabel(label_done);
}
}
}
function BillReminder_Water() {
if (!GmailApp) return; // Skip script execution if GMail is currently not available (yes this happens from time to time and triggers spam emails!)
var reminderLabel = "電費,-水費,-垃圾袋,-網路-bill-reminder---processed", //Substitute your label here
calendarName = "Reminders", ////Substitute your Calendar name here
reminderDuration15Days = 360; //duration in hours;
var threads = GmailApp.search('(label:電費,-水費,-垃圾袋,-網路-watercare---me) AND (-label:電費,-水費,-垃圾袋,-網路-bill-reminder---processed)');
if (threads.length > 0) {
//get calendar by name
var cals = CalendarApp.getCalendarsByName(calendarName);
var now = new Date().getTime();
for (i in threads) {
//cals[0].createEvent(reminderLabel + ' - '+threads[i].getFirstMessageSubject(),
cals[0].createEvent(threads[i].getFirstMessageSubject(),
new Date(now+(60000*60*reminderDuration15Days)),
new Date(now+(60000*60*reminderDuration15Days)), {description: threads[i].getPermalink()});
}
LABEL_DONE = "\u96fb\u8cbb, \u6c34\u8cbb, \u5783\u573e\u888b, \u7db2\u8def/Bill Reminder - Processed";
var label_done = GmailApp.getUserLabelByName(LABEL_DONE);
for (var t in threads) {
var threadblah = threads[t];
// Grab the task data
var taskTitle = threadblah.getFirstMessageSubject();
// Insert the task
//addTask_(taskTitle, TASKLIST);
// Set to 'done' by exchanging labels
//threadblah.removeLabel(label_pending);
threadblah.addLabel(label_done);
}
}
}
function delete_events()
{
//take care: Date function starts at 0 for the month (January=0)
//{search: 'cycle'+"*"+'Checkpoint'} hier zijn de search terms
var fromDate = new Date(2021,6,1,0,0,0); //This is July 1, 2021
var toDate = new Date(2021,11,1,0,0,0); //This is September 1, 2021 at 00h00'00"
var calendarName = 'Reminders';
var toRemove = 'title_of_the_events';
var calendar = CalendarApp.getCalendarsByName(calendarName)[0];
var events = calendar.getEvents(fromDate, toDate,{search: toRemove});
for(var i=0; i<events.length;i++)
{
var ev = events[i];
if(ev.getTitle()==toRemove) //check if the title matches
{
Logger.log('Item '+ev.getTitle()+' found on '+ev.getStartTime()); // show event name and date in log
ev.deleteEvent(); //uncomment this line to actually do the delete !
}
}
}
function delete_events2()
{
var fromDate = new Date(2021,8,1,0,0,0);
var toDate = new Date(2021,11,27,0,0,0);
var calendarName = 'Reminders';
// delete from Jan 1 to end of Jan 4, 2013 (for month 0 = Jan, 1 = Feb...)
var calendar = CalendarApp.getCalendarsByName(calendarName)[0];
var events = calendar.getEvents(fromDate, toDate);
for(var i=0; i<events.length;i++){
var ev = events[i];
Logger.log(ev.getTitle()); // show event name in log
ev.deleteEvent();
}
}

Create an HTML table using Javascript Array

parse the given array (using JavaScript) and create an HTML table
Gmail - containing all email ids with domain gmail.com.
Yahoo - containing all email ids with domain yahoo.com.
Others - containing all email ids with domains not in a,b, and c, i.e., NOT gmail, hotmail and yahoo.
I want to segregate the array of emailids based on domain and show them in html table. I have tried the following code , but it doesnt work at if condition. Please help me solve this problem or alternate solution
----------
<script>
// var email ="test#gmail.com"
// var domain = email.replace(/.*#/," ");
// alert(domain);
var d1 = "gmail.com"
var d2 = "hotmail.com"
var d3 = "yahoo.com"
var email =[" test#gmail.com", "test#hotmail.com" , "test#yahoo.com"];
var i;
// var domain = email.replace(/.*#/," ");
var text = "";
for(i=0;i<email.length;i++){
var dom = email[i].replace(/.*#/," ");
if(dom[i]==d1){
// text += email[i] + "<br>";
// document.getElementById("demo").innerHTML = text;
document.write("hii hello");
}
// else if(dom == "hotmail.com"){
// // text += email[i] + "<br>";
// // document.getElementById("demo").innerHTML = text;
// document.write("hii");
// }
// else if(dom == "yahoo.com"){
// // text += email[i] + "<br>";
// // document.getElementById("demo").innerHTML = text;
// document.write("swax");
// }
else{
document.write(dom); }
}
// document.getElementById("demo").innerHTML = text;
</script>
.replace(/.*#/," ");
You should replace with an empty string
.replace(/.*#/,"");
By the way, it's not really recommended to use document.write().
To help you I wrote quickly this snippet as starting point for you (no judgement, I barely tested it):
function createTable(rows) {
const table = document.createElement('table');
for (row of rows) {
const tr = document.createElement('tr');
for (column of row) {
const td = document.createElement('td');
td.appendChild(document.createTextNode(column));
tr.appendChild(td);
}
table.appendChild(tr);
}
document.body.appendChild(table);
}
const emails = [
'test0#gmail.com', 'test0#hotmail.com', 'test0#test.com',
'test1#gmail.com', 'test1#hotmail.com', 'test1#test.com',
];
const split = [[], [], []];
emails.forEach(email => {
switch (email.split('#')[1]) {
case 'gmail.com': split[0].push(email); break;
case 'hotmail.com': split[1].push(email); break;
default: split[2].push(email)
}
});
createTable(split);
Regards,
Vincent

Speeding up UrlFetch Google App Scripts?

The goal is to run through about 10,000 lines of links. Determine which have page numbers > 3 and highlight the first column. I have all of this done, but the problem is that it takes Url Fetch too long, I run into a maximum run time error. Is there anyway I can speed up this code so I can run through the 10,000 lines?
function readColumns() {
//program is going to run through column 3 by going through the amount of rows, truncating last three characters to see if pdf, then highlighting first column
var sheet = SpreadsheetApp.getActiveSheet();
var columns = sheet.getDataRange();
var rowNum = columns.getNumRows();
var values = columns.getValues();
var html;
var htmlString;
for(var i = 1; i <= rowNum; i++){
var columnLogger = values[i][2];
try{
html = UrlFetchApp.fetch(values[i][2],
{
muteHttpExceptions: true,
}
);
}catch(e){
Logger.log("Error at line " + i);
var error = true;
}
htmlString = html.getContentText();
var index = htmlString.indexOf("Pages") + 6;
var pageNumber = parseInt(htmlString.charAt(index),10);
var lastChars = "" + columnLogger.charAt(columnLogger.length-3) + columnLogger.charAt(columnLogger.length-2) + columnLogger.charAt(columnLogger.length-1);
if((error) || (!lastChars.equals("pdf") && values[i][6].equals("") && !pageNumber >= 3)){
//goes back to first column and highlights yellow
var cellRange = sheet.getRange(1, 1, rowNum, 3)
var cell = cellRange.getCell(i+1, 1)
cell.setBackground("yellow");
}
}
}
Edit - short scripts:
function foreverCall(){
var start = 1480;
for(;;){
readColumns(start);
start = start + 100;
}
}
function readColumns(start) {
//program is going to run through column 3 by going through the amount of rows, truncating last three characters to see if pdf, then highlighting first column
var sheet = SpreadsheetApp.getActiveSheet();
var columns = sheet.getDataRange();
var rowNum = columns.getNumRows();
var values = columns.getValues();
var html;
var htmlString;
var error;
for(var i = start; i < start+100; i++){
if(loop(values, error, html, htmlString, rowNum, sheet, columns, i)){
var cellRange = sheet.getRange(1, 1, rowNum, 3)
var cell = cellRange.getCell(i, 1)
cell.setBackground("yellow");
}
}
}
function loop(values, error, html, htmlString, rowNum, sheet, columns, i){
var columnLogger = values[i][2];
var lastChars = columnLogger.slice(-4);
if(!lastChars.equals(".pdf") && values[i][6].equals("")){
return true;
}else{
try{
error = false
html = UrlFetchApp.fetch(values[i][2].toString());
if(html == null){
error = true;
}
}catch(e){
Logger.log("Error at line " + i);
error = true;
}
if(!error){
htmlString = html.getContentText();
var index = htmlString.indexOf("Pages") + 6;
var pageNumber = parseInt(htmlString.charAt(index),10);
}
//goes back to first column and highlights yellow
if(error || !pageNumber >= 3){
return true;
}
}
return false;
}
You can replace this:
var lastChars = "" + columnLogger.charAt(columnLogger.length-3) + columnLogger.charAt(columnLogger.length-2) + columnLogger.charAt(columnLogger.length-1);
With this:
var lastChars = columnLogger.slice(-3);
You could also initiate the fetch script from an html sidebar or dialog to run short batches and then return back to the success handler which could then initiate another batch depending upon the return value. The return value could also be used to start the next batch at the next row. It would actually take longer to run but you could probably stay well under the script limit by keeping your batches small.
You can replace with the line with
var lastChars = columnLogger.slice(-3);

How can I show only the row of a table that has the same value that was entered in a textbox with jquery

I have a table of rank where I type the ID of the rank and it shows me only the column line that has this line as my code:
$('button').click(function () {
var data = $("textarea").val();
var rank = $("#rank").val();
if(rank == ""){
alert("digit rank number");
}
else{
data = data.replace(/\s/, " #");
data = data.replace(/([0-9]\s)/g, "$1#");
var lines = data.split("#"),
output = [],
i;
for (i = 0; i < lines.length; i++)
output.push("<tr><td>" + lines[i].slice(0,-1).split(",").join("</td><td>") + "</td></tr>");
output = "<table>" + output.join("") + "</table>";
var valuefinal = $(output).find('tr').filter(function(){
return $(this).children('td').eq(1).text() == rank;
});
$('#fileDisplayArea').html(valuefinal);
}
});
I'm doing this filter in that part of the code
var valuefinal = $(output).find('tr').filter(function(){
return $(this).children('td').eq(1).text() == rank;
});
$('#fileDisplayArea').html(valuefinal);
DEMO CODE
(Forgive me if you did not understand something, my english sucks. I hope it is clear what I need.)
You need to change this -
return $(this).children('td').eq(1).text() == rank;
to this -
return $(this).children('td').eq(0).text() == rank;
.eq() is a zero-based array method.
http://jsfiddle.net/jayblanchard/qM6Fj/19/
http://api.jquery.com/eq/
You need to have a search feature for the contents you have displayed in the table is what i got.....
You can use jQuery DataTable for this purpose which does this job link .. scroll down to see the table show with sort, search etc features

How to Increase the numurical value of 3rd column in a particular row when some one click on the link which is in the 2nd column of same row

How to increase the numerical value of 3rd column in a particular row when some one click on the link which is in the 2nd column of same row? Data loads from firebase in tabular form.
Fiddle here, so you can understand it much better.
The script which loads (callback) data from firebase is given bellow
var LEADERBOARD_SIZE = 10;
var get_title = $('title').html();
var get_id = $('id').find('textarea').html();
// Create our Firebase reference
var scoreListRef = new Firebase('https://androidappania.firebaseio.com//AlternateLinksDirectory//' + get_id);
// Keep a mapping of firebase locations to HTML elements, so we can move / remove elements as necessary.
var htmlForPath = {};
// Helper function that takes a new score snapshot and adds an appropriate row to our leaderboard table.
function handleScoreAdded(scoreSnapshot, prevScoreName) {
var newScoreRow = $("");
newScoreRow.append($("").append($("").text(scoreSnapshot.val().name)));
newScoreRow.append($("").text(scoreSnapshot.val().url));
newScoreRow.append($("").text(scoreSnapshot.val().score));
// Store a reference to the table row so we can get it again later.
htmlForPath[scoreSnapshot.name()] = newScoreRow;
// Insert the new score in the appropriate place in the table.
if (prevScoreName === null) {
$("#leaderboardTable").append(newScoreRow);
} else {
var lowerScoreRow = htmlForPath[prevScoreName];
lowerScoreRow.before(newScoreRow);
}
}
// Helper function to handle a score object being removed; just removes the corresponding table row.
function handleScoreRemoved(scoreSnapshot) {
var removedScoreRow = htmlForPath[scoreSnapshot.name()];
removedScoreRow.remove();
delete htmlForPath[scoreSnapshot.name()];
}
// Create a view to only receive callbacks for the last LEADERBOARD_SIZE scores
var scoreListView = scoreListRef.limit(LEADERBOARD_SIZE);
// Add a callback to handle when a new score is added.
scoreListView.on('child_added', function (newScoreSnapshot, prevScoreName) {
handleScoreAdded(newScoreSnapshot, prevScoreName);
});
// Add a callback to handle when a score is removed
scoreListView.on('child_removed', function (oldScoreSnapshot) {
handleScoreRemoved(oldScoreSnapshot);
});
// Add a callback to handle when a score changes or moves positions.
var changedCallback = function (scoreSnapshot, prevScoreName) {
handleScoreRemoved(scoreSnapshot);
handleScoreAdded(scoreSnapshot, prevScoreName);
};
scoreListView.on('child_moved', changedCallback);
scoreListView.on('child_changed', changedCallback);
// When the user presses enter on scoreInput, add the score, and update the highest score.
$("#scoreInput").keypress(function (e) {
if (e.keyCode == 13) {
var newScore = ($("#scoreInput").val());
var url1 = $("#urlInput").val();
var name = $("#nameInput").val();
$("#scoreInput").val("");
if (url1.length === 0)
if (name.length === 0) return;
var userScoreRef = scoreListRef.child(name);
// Use setWithPriority to put the name / score in Firebase, and set the priority to be the score.
userScoreRef.setWithPriority({
name: name,
url: url1,
score: newScore
}, newScore);
alert('Alternate Link for this App has been Succesfully submitted by you. By using this service you agree that you will Not Spam or Submit Links which refers to illegal or Copyrighted content.');
}
});
// delay function to make link clickable after 4 sec and also add onclick='HitCounter()' into links
var delay = 4000 //4 seconds
setTimeout(function () {
function replaceURLWithHTMLLinks(text) {
var re = /(\(.*?)?\b((?:https?|ftp|file):\/\/[-a-z0-9+&##\/%?=~_()|!:,.;]*[-a-z0-9+&##\/%=~_()|])/ig;
return text.replace(re, function (match, lParens, url) {
var rParens = '';
lParens = lParens || '';
var lParenCounter = /\(/g;
while (lParenCounter.exec(lParens)) {
var m;
if (m = /(.*)(\.\).*)/.exec(url) || /(.*)(\).*)/.exec(url)) {
url = m[1];
rParens = m[2] + rParens;
}
}
return lParens + "" + url + "" + rParens;
});
}
var elm = document.getElementById('leaderboardTable');
elm.innerHTML = replaceURLWithHTMLLinks(elm.innerHTML);
$(document).ready(function () {
$("a[href^='http://']").filter(function () {
return this.hostname && this.hostname !== location.hostname;
}).attr('target', '_blank');
});
}, delay)
and the script which take care of URL Hit Counts is given bellow
function HitCounter() {
var get_id = $('id').find('textarea').html();
var HitCounterRef = new Firebase('https://androidappania.firebaseio.com//AlternateLinksDirectory//' + get_id);
var hits = $(tbody).find('tr').children('td').html();
if (hits == null) {
hits = 1;
} else {
hits++;
}
HitCounterRef.setWithPriority({
score: hits
}, hits);
};
I need some modification or improvement in this code so that when some one click on a link then correct corresponding 3rd column of same row should get a increment/increase in it's numerical value.
I also need something which could create connection b/w HitCounter and urls given in 2nd column of every row or initiate the HitCounter function when some one click on any of the link given in 2nd column of every row.

Categories

Resources