hello
Server : Apache/2.4.52 (Ubuntu) System : Linux HAN2 5.15.0-185-generic #195-Ubuntu SMP Fri Jun 19 17:11:50 UTC 2026 x86_64 User : servadmin ( 1000) PHP Version : 8.1.2-1ubuntu2.25 Disable Function : NONE Directory : /www/docs/video.obu.edu/Archives/scripts/ |
<?php
//check to see if we are on the main page
$pos = strpos($_SERVER['SCRIPT_FILENAME'],'index');
if($pos===false)
{ //if we are not on the main page then set emptyFolder to delete the items in the result list as well
$clickFunction = 'emptyFolder(2)';
//same idea here. allows using the same method in a different way based on which page we are on.
$type = 2;
}
else
{ //if we are on the main page then set the emptyFolder method to not delete items in the result list
$clickFunction = 'emptyFolder(1)';
$type = 1;
}
?>
<h1>Folder<a class="folderLinks" href="folderView.php?display=0">View all</a><br /><a href class="folderLinks" onclick="<?php echo $clickFunction; ?>">Empty Folder</a></h1> <br />
<div id="folderSection">
<ul id="folder">
</ul>
</div>
<script type="text/javascript">
/*
changePage - changes the page of the folder and repopulates the items
parameters:
pageNum - the page number that is being switched to
returns:
none
*/
function changePage(pageNum)
{ var num = parseInt($.Storage.get("number"));
while((pageNum*10)>num)
{
pageNum-=1;
}
//save the page number in the storage
$.Storage.set('folderPageNum',String(pageNum));
//remove all the elements of the previous folder
$('#folder li').remove();
$('#folder a').remove();
$('#numPage').remove();
//call the populate method with the new page number
populateFolder(pageNum);
}
/*
populateFolder - loops through all the elements saved in the folder and adds them to the folder list.
parameters:
none
returns:
none
*/
function populateFolder(page)
{
//get the number of items in the folder
var num = parseInt($.Storage.get("number"));
//create the max number to loop too
var loopNum = (page*10)+10;
//assure we don't get a loopNum larger than how many elements are in the storage
loopNum = loopNum>num?num:loopNum;
//if there are more than 10 elements in the storage then create the page switcher
if(num>10)
{
addPageDisplay(1);
}
//add folder items to the list based on which page we are on
for(var i=10*page;i<loopNum;i++)
{ //parse the json of the item returned from the storage
var result = $.evalJSON($.Storage.get('item'+i));
if(result!=null)
{
var place = 0;
//get the type. indicates which page we are on. if type=1 we are on the main page
var type = <?php echo $type; ?>;
if(type==1)
{
//this allows succesful deletion and button swapping when deleting items after a page refresh
//without this items would be indexed linearly instead of according to which item they corresponded to
//for each result in the search results
$('.result').each(function()
{ //if the given results name is the same as the resource id for the result
if($(this).attr('name') == result.resourceId)
{ //get the itemNum from the list
place = parseInt($(this).attr('id').substring(6));
}
});
}
else
{ //set the item num to be the current iteration
place = i;
}
//add a <li> with the information about the item
$('#folder').append('<li id="folderItem'+ i + '" class="folderItem"><a tooltip=\"' + result.noteContent + '\" href="result.php?id=' + result.resourceId + '">' + $.quoteString(result.title).substring(1,result.title.length+1) + '</a></li>');
//add the remove button
$('#folder').append('<a href style=\"color:red;\" href id=\"remover'+ i +'\" class=\"remover\" onclick=\" removeFromFolder('+result.resourceId+', <?php echo $type; ?> ,' + place + ')\">X</a>');
}
}
}
//once the document has loaded
$(document).ready(function()
{
<?php
if(!isset($_SESSION['num']))
{
$num=10;
}
else
{ //if the user has changed the value of the number to be displayed get it from the session
$num=$_SESSION['num'];
}
?>
$('select').val('<?php echo $num; ?>');
var pageNum = parseInt($.Storage.get('folderPageNum'));
if(pageNum==null)
{
$.Storage.set('folderPageNum','0');
pageNum = 0;
}
populateFolder(pageNum);
// Notice the use of the each() method to acquire access to each elements attributes
$('#folder a[tooltip]').each(function()
{
$(this).qtip({
content: $(this).attr('tooltip'), // Use the tooltip attribute of the element for the content
style: 'light' , // Give it a crea mstyle to make it stand out
position: {
corner: {
target: 'bottomLeft',
tooltip: 'topLeft'
}
},
hide: { when: 'mouseout', fixed: true }
});
});
});
</script>