Skip to content

Instantly share code, notes, and snippets.

@harryward
Created September 24, 2013 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harryward/6689521 to your computer and use it in GitHub Desktop.
Save harryward/6689521 to your computer and use it in GitHub Desktop.
Freelancer Dash Code
<link rel="stylesheet" type="text/css" href="https://tsm-lab.s3.amazonaws.com/js/jquery.dataTables.css" media="screen" />
<script type="text/javascript" src="https://tsm-lab.s3.amazonaws.com/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="https://tsm-lab.s3.amazonaws.com/js/jquery.dataTables.js"></script>
<link rel="stylesheet" type="text/css" href="https://tsm-lab.s3.amazonaws.com/js/jquery.dataTables_themeroller.css" media="screen" />
<script src="https://tsm-lab.s3.amazonaws.com/js/jquery-ui-1.10.3.custom.min.js"></script>
<link href="https://code.jquery.com/ui/1.10.3/themes/black-tie/jquery-ui.css" rel="stylesheet" type="text/css">
<script src="https://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="https://townsquarelab.com/code/FeedEk.js"></script>
<div id="metadetails">
<div id="gravityformsparams">
<strong>gravity forms paramaters</strong>
<br>
invoice_url
<br>ticket_number
<br>month_name
<br>freelancer_name
<br>action_is
<hr>
<strong>Editor IDs</strong><br>
TasteOfCountry 315
<br>PopCrush 314
<br>Loudwire 316
<br>UltimateClassicRock 317
<br>ScreenCrush 318
<br>GuySpeed 319
<br>TheFW 320
DiffuserFM 321<br>
ArcadeSushi 322<br>
StarCrush 324<br>
TheDropFM 325<br>
CommicsAlliance 326<br>
TheBoot 327<br>
Noisecreep 328<br>
TheBoombox 329<br>
TSMInteractive 330<br>
<br>
</div>
<style>
#gravityformsparams{
padding:10px;
background:black;
color:white;
}
</style>
</div>
<style>
#metadetails{
display:none;
}
</style>
<script>
$(document).ready(function() {
// url for the ajax request must be changed to correct url
$.ajax({
type: 'GET',
url: 'https://ads.townsquaredigital.com/users.json?key=b0a4591ad5ccef4fb4cceed89161cacac268f450&status=1&limit=100&sort=id%3Adesc&name=harryward@townsquaremedia.com', // query id from chili project determines results
success: function(wpData) {
for (var i = wpData["users"].length - 1; i>= 0; i--) {
var userID = wpData["users"][i]["id"]; //grabs the user card json to grab user id
}
$('#divRss').FeedEk({
FeedUrl : "https://ads.townsquaredigital.com/projects/national-freelance-invoice/issues.atom?key=b0a4591ad5ccef4fb4cceed89161cacac268f450a&query={user:Site}",
ShowDesc : true,
ShowPubDate:true,
DescCharacterLimit:0,
MaxCount : 50,
TitleLinkTarget:'_blank'
});
$.ajax({
type: 'GET',
url: 'https://ads.townsquaredigital.com/projects/nat-invoice/issues.json?key=b0a4591ad5ccef4fb4cceed89161cacac268f450&query_id={user:Site}',
success: function(data) {
var tableData = [];
var tableDataHeaders = {
//"id" : "Invoice Number",
//"assignedTo" : "Assigned To",
"clientAdviser" : "Month",
//"subject" : "Subject",
//"clientAdviser" : "Month",
"tradeExpense" : "Total",
//"tradeRevenue" : "Sites",
"tradeName" : "Freelancer",
"market" : "File",
"tradeRatio" : "Action"
};
for(var i=0; i<data['issues'].length; i++) {
tableData.push({
"id":"<a href='https://ads.townsquaredigital.com/issues/'+data['issues'][i]['id']"+".atom?key=b815f9e67b757b706c222d6994a372a654ec85ba'><h2>"+data['issues'][i]['id']+"</h2></a>",
//"assignedTo":data['issues'][i]['assigned_to']['name'],
//"subject":data['issues'][i]['subject'],
"market":"<a href='"+data['issues'][i]['custom_fields'][1]['value']+"'>download invoice</a>",
"clientAdviser":data['issues'][i]['custom_fields'][2]['value'],
"tradeExpense":data['issues'][i]['custom_fields'][3]['value'],
//"tradeRevenue":data['issues'][i]['custom_fields'][5]['value'],
"tradeName":data['issues'][i]['custom_fields'][4]['value'],
"tradeRatio":"<a rel='external' href='https://townsquarelab.com/freelancer-approval/?ticket_number="+data['issues'][i]['id']+ "&invoice_url="+ data['issues'][i]['custom_fields'][1]['value']+ "&freelancer_name="+data['issues'][i]['custom_fields'][4]['value']+"&month_name="+data['issues'][i]['custom_fields'][2]['value']+"&action_is=Approve'>Approve</a> or "+"<a rel='external' href='https://townsquarelab.com/freelancer-approval/?ticket_number="+data['issues'][i]['id']+ "&invoice_url="+ data['issues'][i]['custom_fields'][1]['value']+ "&freelancer_name="+data['issues'][i]['custom_fields'][4]['value']+"&month_name="+data['issues'][i]['custom_fields'][2]['value']+"&action_is=Reject'>Reject</a>",
});
}
var tableHTML = '<table class="chiliproject"><thead><tr>';
for(var key in tableDataHeaders) tableHTML += '<th>' + tableDataHeaders[key] + '</th>';
tableHTML += '</tr></thead><tbody>';
for(var i=0; i<tableData.length; i++) {
tableHTML += '<tr>';
for(var key in tableDataHeaders) tableHTML += '<td><br>' + tableData[i][key] + '<br><br></td>';
tableHTML += '</tr>';
}
tableHTML += '</body></table>';
$('#chilitable').html(tableHTML);
//$('#chilitable').dataTable();
//$('table,h1').menu();
$('button').button();
//$('.dataTables_info, .dataTables_paginate,.dataTables_length, .dataTables_filter').hide();
}
});
}
});
});
</script>
<style>
#approveit{
display:none;
}
.ui-dialog{
width:80%!important;
}
</style>
<body>
<script>
$('#viewdetails').click(function(){
$('#approveit').dialog();
});
$('#approvebutton').click(function(){
$('#approveit').dialog();
});
$('h1').menu();
</script>
<div id="divRss" class=""></div>
<div id="chilitable"></div>
<hr>
Need Help? Contact Harry Ward - harry@townsquaredigital.com
<br>
<a href="#" id="metadatafree">About This Tool</a><br>
<script>
$('#metadatafree').click(function(){
$('#metadetails').show('fade').dialog();
});</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment