Skip to content

Commit

Permalink
removed the stupid javascript from index.php and put it at the bottom…
Browse files Browse the repository at this point in the history
… of papergraph.js
  • Loading branch information
cegme committed Sep 5, 2012
1 parent 5c15771 commit 62eadf1
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 178 deletions.
178 changes: 0 additions & 178 deletions web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,185 +154,7 @@
</div>

<script type="text/javascript">
$(document).ready(function() {
//$('#topic-btn').click(function() { doTopicChange(); });
$('#maintab a').click(function (e) {
e.preventDefault();
$(this).tab('show');
});
//$("#firsttabclick").tab('show');
$('#maintab a:last').tab('show');
$('#t_paper_pane').hide();
//$('a[data-toggle="tab"]').on('shown', function (e) {
// initializeGraphExplorer();
//});
});
function showError(msg) {
// Show the error text
$("#gresham-msg").empty();
//$("#gresham-msg").hide();
$("#gresham-msg").append("<span class=\"label label-error\">"+msg+"</span>");
$("#gresham-msg").slideDown('fast').delay(2000).slideUp(800);
}
function showInfo(msg) {
// Show the info text
$("#gresham-msg").empty();
$("#gresham-msg").append("<span class=\"label label-info\">"+msg+"</span>");
$("#gresham-msg").slideDown('fast').delay(2000).slideUp(800);
}
function toggleLoading(show) {
if(show) {
$("#gresham-loading").append("<img src='img/loader1.gif'></img>");
$("#gresham-loading").show();
}
else{
$("#gresham-loading").hide();
$("#gresham-loading").empty();
}
}
function makePaperDiv(paper) {
var mydiv = "<div><ul>";
mydiv += "<li>Paper : "; mydiv += paper["papertitle"]; mydiv += "</li>";
mydiv += "<li>Author : "; mydiv += paper["author"]; mydiv += "</li>";
mydiv += "<li>Conference : "; mydiv += paper["venue"]; mydiv += " Year : "; mydiv += paper["pubyear"];mydiv += "</li>";
mydiv += "</ul></div>";

return mydiv;
}
function hidePaper() {
$('#t_paper_pane').hide('slow');
$('#t_pane').show('slow');
}
function showPaper(tid) {
toggleLoading(true);

$.ajax({
type: 'GET',
url: '/grisham/web/query.php',
//url: 'http://neo.cise.ufl.edu/grisham/paper/web/query.php',
dataType: 'json',
data: {q: tid,
type: 'rank',
limit: 50,
offset: 0},
success: function(res) {
$('#t_pane').hide('slow');

$('#t_paper_pane').empty();
$('#t_paper_pane').append("<i class='icon-remove' onclick='hidePaper(); event.returnValue=false;'></i>");
$('#t_paper_pane').append("<h4>Topic " + tid + "<h4>");
for(var i = 0; i != res["rowcount"] && i < 10; ++i) {
//$('#t_paper_pane').append("<div>"+res[i]["papertitle"]+"</div>"); // TODO fix the show
$('#t_paper_pane').append(makePaperDiv(res[i])); // TODO fix the show
}
$('#t_paper_pane').show('slow');
toggleLoading(false);
},
error: function(xhr, statusText, errorThrown) {
// TODO Add an Error message
//$('k_msg').append('<span class=\'label label-error\'>'+statusText+'</span>');
toggleLoading(false);
}
});
}
function kwQuery(offsetval, limitval) {
var offsetval = offsetval || 0;
var limitval = limitval || 50;

// TODO Show the pane as loading
$("#k_msg").empty();

toggleLoading(true);
$.ajax({
type: "GET",
url: '/grisham/web/query.php',
//url: 'http://neo.cise.ufl.edu/grisham/paper/web/query.php',
dataType: "json",
data: {q: escape($("#kwrd").val()),
type: "keyword_realtime",
limit: limitval,
offset: offsetval},
success: function(res) {

var answertable = [];

answertable.push("<table class=\"table table-striped\">\n");

// Add a table header
answertable.push("<thead><tr>");
for(var i=0;i < 2 && res["headers"] != undefined && i < res["headers"].length; ++i) {
answertable.push("<th><h4>"+res["headers"][i]+"</h4></th>");
}
answertable.push("</tr></thead>");

answertable.push("<tbody>");
for (var i=0; i < res["rowcount"]; ++i){
answertable.push("<tr>");
answertable.push("<td>" + res[i]["person"] + "</td>");
answertable.push("<td>" + res[i]["papertitle"] + "</td>");
answertable.push("</tr>");
}
answertable.push("</tbody>");
answertable.push("</table>\n");

// Remove loading message
$("k_pane").empty();
$("k_msg").empty();

// Append to k_pane
$("#k_pane").append(answertable.join(""));

$("#k_msg").append("<span class=\"label label-info\">" + "Time: " + res["querytime"] + " seconds</span>");
toggleLoading(false);
},
error: function(xhr, statusText, errorThrown) {
$("k_pane").empty();
// Add an Error message
showError(statusText);
toggleLoading(false);
}
});
}
function doTopicChange() {

// Get all the topic values in an array
var totalval = 0.0;
var topicSize = $("#topic-table tr").length;
var tscores = [];
for (var i = 0; i != topicSize; ++i) {
var t = i+1;
tscores.push(100 * parseInt($("#slider-topic-"+t+" div").css('width')) / parseInt($("#slider-topic-"+t+" div").parent().css('width')));
totalval += 100 * parseInt($("#slider-topic-"+t+" div").css('width')) / parseInt($("#slider-topic-"+t+" div").parent().css('width'));
}

// Get the min and max values
var max = -1; var min = 1000;
for (var i = 0; i != topicSize; ++i) {
if(max < tscores[i]) max = tscores[i];
if(min >= tscores[i]) min = tscores[i];
}
var ratio = 255.0/(max-min);
//var ratio = (max-min)/255.0;

// Iterate over all the weights and change the intensities
for (var i = 0; i != topicSize; ++i) {
var t = i+1;
var red = parseInt(ratio*(100-tscores[i]));
var green = parseInt(ratio*(100-tscores[i]));
var blue = parseInt(ratio*(100-tscores[i]));
//var colorval = parseInt(tscores[i] /*/ totalval*/ * 255);
$("#divrow-"+t).css('backgroundColor', "rgb(255, "+green+","+blue+")"); // Make the color
//$("#divrow-"+t).css('backgroundColor', "rgb("+red+", 255, 255)"); // Make the color
}

}
function setMainPaper() {
var paperid = $("#graphpaperid").val();

// Defined in papergraph.js
updatePaperGraph(paperid);
return false;
}

// Code for the sliders
<?php
Expand Down
179 changes: 179 additions & 0 deletions web/papergraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,182 @@ function updatePaperGraph(paperid) {
});
return false;
}
$(document).ready(function() {
//$('#topic-btn').click(function() { doTopicChange(); });
$('#maintab a').click(function (e) {
e.preventDefault();
$(this).tab('show');
});
//$("#firsttabclick").tab('show');
$('#maintab a:last').tab('show');
$('#t_paper_pane').hide();
//$('a[data-toggle="tab"]').on('shown', function (e) {
// initializeGraphExplorer();
//});
});
function showError(msg) {
// Show the error text
$("#gresham-msg").empty();
//$("#gresham-msg").hide();
$("#gresham-msg").append("<span class=\"label label-error\">"+msg+"</span>");
$("#gresham-msg").slideDown('fast').delay(2000).slideUp(800);
}
function showInfo(msg) {
// Show the info text
$("#gresham-msg").empty();
$("#gresham-msg").append("<span class=\"label label-info\">"+msg+"</span>");
$("#gresham-msg").slideDown('fast').delay(2000).slideUp(800);
}
function toggleLoading(show) {
if(show) {
$("#gresham-loading").append("<img src='img/loader1.gif'></img>");
$("#gresham-loading").show();
}
else{
$("#gresham-loading").hide();
$("#gresham-loading").empty();
}
}
function makePaperDiv(paper) {
var mydiv = "<div><ul>";
mydiv += "<li>Paper : "; mydiv += paper["papertitle"]; mydiv += "</li>";
mydiv += "<li>Author : "; mydiv += paper["author"]; mydiv += "</li>";
mydiv += "<li>Conference : "; mydiv += paper["venue"]; mydiv += " Year : "; mydiv += paper["pubyear"];mydiv += "</li>";
mydiv += "</ul></div>";

return mydiv;
}
function hidePaper() {
$('#t_paper_pane').hide('slow');
$('#t_pane').show('slow');
}
function showPaper(tid) {
toggleLoading(true);

$.ajax({
type: 'GET',
url: '/grisham/web/query.php',
//url: 'http://neo.cise.ufl.edu/grisham/paper/web/query.php',
dataType: 'json',
data: {q: tid,
type: 'rank',
limit: 50,
offset: 0},
success: function(res) {
$('#t_pane').hide('slow');

$('#t_paper_pane').empty();
$('#t_paper_pane').append("<i class='icon-remove' onclick='hidePaper(); event.returnValue=false;'></i>");
$('#t_paper_pane').append("<h4>Topic " + tid + "<h4>");
for(var i = 0; i != res["rowcount"] && i < 10; ++i) {
//$('#t_paper_pane').append("<div>"+res[i]["papertitle"]+"</div>"); // TODO fix the show
$('#t_paper_pane').append(makePaperDiv(res[i])); // TODO fix the show
}
$('#t_paper_pane').show('slow');
toggleLoading(false);
},
error: function(xhr, statusText, errorThrown) {
// TODO Add an Error message
//$('k_msg').append('<span class=\'label label-error\'>'+statusText+'</span>');
toggleLoading(false);
}
});
}
function kwQuery(offsetval, limitval) {
var offsetval = offsetval || 0;
var limitval = limitval || 50;

// TODO Show the pane as loading
$("#k_msg").empty();

toggleLoading(true);
$.ajax({
type: "GET",
url: '/grisham/web/query.php',
//url: 'http://neo.cise.ufl.edu/grisham/paper/web/query.php',
dataType: "json",
data: {q: escape($("#kwrd").val()),
type: "keyword_realtime",
limit: limitval,
offset: offsetval},
success: function(res) {

var answertable = [];

answertable.push("<table class=\"table table-striped\">\n");

// Add a table header
answertable.push("<thead><tr>");
for(var i=0;i < 2 && res["headers"] != undefined && i < res["headers"].length; ++i) {
answertable.push("<th><h4>"+res["headers"][i]+"</h4></th>");
}
answertable.push("</tr></thead>");

answertable.push("<tbody>");
for (var i=0; i < res["rowcount"]; ++i){
answertable.push("<tr>");
answertable.push("<td>" + res[i]["person"] + "</td>");
answertable.push("<td>" + res[i]["papertitle"] + "</td>");
answertable.push("</tr>");
}
answertable.push("</tbody>");
answertable.push("</table>\n");

// Remove loading message
$("k_pane").empty();
$("k_msg").empty();

// Append to k_pane
$("#k_pane").append(answertable.join(""));

$("#k_msg").append("<span class=\"label label-info\">" + "Time: " + res["querytime"] + " seconds</span>");
toggleLoading(false);
},
error: function(xhr, statusText, errorThrown) {
$("k_pane").empty();
// Add an Error message
showError(statusText);
toggleLoading(false);
}
});
}
function doTopicChange() {

// Get all the topic values in an array
var totalval = 0.0;
var topicSize = $("#topic-table tr").length;
var tscores = [];
for (var i = 0; i != topicSize; ++i) {
var t = i+1;
tscores.push(100 * parseInt($("#slider-topic-"+t+" div").css('width')) / parseInt($("#slider-topic-"+t+" div").parent().css('width')));
totalval += 100 * parseInt($("#slider-topic-"+t+" div").css('width')) / parseInt($("#slider-topic-"+t+" div").parent().css('width'));
}

// Get the min and max values
var max = -1; var min = 1000;
for (var i = 0; i != topicSize; ++i) {
if(max < tscores[i]) max = tscores[i];
if(min >= tscores[i]) min = tscores[i];
}
var ratio = 255.0/(max-min);
//var ratio = (max-min)/255.0;

// Iterate over all the weights and change the intensities
for (var i = 0; i != topicSize; ++i) {
var t = i+1;
var red = parseInt(ratio*(100-tscores[i]));
var green = parseInt(ratio*(100-tscores[i]));
var blue = parseInt(ratio*(100-tscores[i]));
//var colorval = parseInt(tscores[i] /*/ totalval*/ * 255);
$("#divrow-"+t).css('backgroundColor', "rgb(255, "+green+","+blue+")"); // Make the color
//$("#divrow-"+t).css('backgroundColor', "rgb("+red+", 255, 255)"); // Make the color
}

}
function setMainPaper() {
var paperid = $("#graphpaperid").val();

// Defined in papergraph.js
updatePaperGraph(paperid);
return false;
}

0 comments on commit 62eadf1

Please sign in to comment.