PDA

View Full Version : [MOD] Staff Panel Refresh with Countdown


webPragmatist
08-12-2008, 12:48 PM
Below is code to allow a small countdown text below the "Refresh" button and also refresh the page in /scp/tickets.php. It's tested in IE7 & FF3 but I'm sure it works in others.

/scp/js/refresh.js (Created)
var refreshTime=30;

function refreshCountDown()
{
refreshTime--;
if (refreshTime <=0)
{
clearTimeout(counter)
window.location.reload()
return
}
document.getElementById("refreshText").innerHTML=refreshTime+" secs"
counter=setTimeout("refreshCountDown()", 1000);
}

function refreshInit()
{
document.getElementById("refreshText").innerHTML=refreshTime+" secs"
refreshCountDown()
}

window.onload=refreshInit

/include/staff/tickets.inc.php (Modified)
~ Line 310
<a href="tickets.php"> <img src="images/refresh.gif" alt="Refresh" border=0></a>
<!-- Refresh Countdown addition by webPragmatist -->
<p id="refreshText" style="height: 10px; margin-left: 220px;"></p>
<!-- End Refresh Countdown addition by webPragmatist -->

/include/staff/header.inc.php (Modified)
~ Line 18
<script type="text/javascript" src="js/autolock.js" charset="utf-8"></script>
<?}?>
<!-- Refresh Countdown addition by webPragmatist -->
<?
if (empty($_GET) || array_key_exists('sort', $_GET) && array_key_exists('order', $_GET))
{?>
<script type="text/javascript" src="js/refresh.js" charset="utf-8"></script>
<? } ?>
<!-- End Refresh Countdown addition by webPragmatist -->

It seems this might break aprovals?
Check out http://osticket.com/forums/showthread.php?p=13674#post13674

SLMHC
08-19-2008, 04:28 PM
Any chance we can get approximate line #s to add/replace these with?
________
teen videos (http://teenvid.org)

webPragmatist
08-19-2008, 04:57 PM
I actually have the wrong file listed to edit. I fixed it in the original post.

Enjoy!

SLMHC
08-19-2008, 05:24 PM
Can you add a screen cap of what is actually supposed to look like? I made the changes above and nothing is happening. All that I see is an extra line break below the refresh button, no actual text.

My screencap (http://www.davehildebrand.com/explorer/viewing/refreshmod.JPG/)

edit: the page does not refresh either.
________
Yamaha VMX1200 (http://www.cyclechaos.com/wiki/Yamaha_VMX1200)

SLMHC
08-19-2008, 05:47 PM
Got it working. I removed this line:
<? if(($_SERVER['REQUEST_URI'] == '/scp/tickets.php') || ($_SERVER['REQUEST_URI'] == '/scp/index.php')){ ?>

and the page refreshes.
________
jugallette (http://juggalos.org)

webPragmatist
08-19-2008, 06:42 PM
Got it working. I removed this line:
<? if(($_SERVER['REQUEST_URI'] == '/scp/tickets.php') || ($_SERVER['REQUEST_URI'] == '/scp/index.php')){ ?>

and the page refreshes.
Well the reason that line is there is so the rest of the ticket pages don't refresh. I'll attach my include tomorrow morning for you.

SLMHC
08-20-2008, 10:57 AM
hmmm...well that would be good to have, but for some reason it didnt work for me. i'll try to wait patiently for your reply ;)
________
sc2 replay (http://screplays.com)

webPragmatist
08-20-2008, 12:56 PM
hmmm...well that would be good to have, but for some reason it didnt work for me. i'll try to wait patiently for your reply ;)

I made some updates to all three files. You may have had an open comment code in tickets.inc.php which was my fault.

Also, I added another line to header.inc.php for you to search for and find where you need to add my code.

If you are still having trouble PM me your code.

SLMHC
08-20-2008, 01:23 PM
you code still doesn't work for me so I took some time to snoop at it some more.

I changed the header.inc.php to:

<!-- Refresh Countdown addition by webPragmatist -->
<? if (($_SERVER['REQUEST_URI'] == '/scp/tickets.php') || ($_SERVER['REQUEST_URI'] == '/scp/index.php')) ?>
<? { ?>
<script type="text/javascript" src="js/refresh.js" charset="utf-8"></script>
<? } ?>
<!-- End Refresh Countdown addition by webPragmatist -->
________
full melt hash (http://trichomes.org/hashish/full-melt-hash)

webPragmatist
08-20-2008, 02:40 PM
you code still doesn't work for me so I took some time to snoop at it some more.

I changed the header.inc.php to:

<!-- Refresh Countdown addition by webPragmatist -->
<? if (($_SERVER['REQUEST_URI'] == '/scp/tickets.php') || ($_SERVER['REQUEST_URI'] == '/scp/index.php')) ?>
<? { ?>
<script type="text/javascript" src="js/refresh.js" charset="utf-8"></script>
<? } ?>
<!-- End Refresh Countdown addition by webPragmatist -->
And removing the "if" like:

<script type="text/javascript" src="js/refresh.js" charset="utf-8"></script>

Works?

SLMHC
08-21-2008, 10:53 AM
Yeah removing the if statement makes it work.
________
herbalire vaporizer review (http://herbalairevaporizer.com)

webPragmatist
08-21-2008, 12:42 PM
Yeah removing the if statement makes it work.

Is your scp in a "/scp/" directory. Like tickets.mysite.com/scp/?

Please replace header.inc.php I have changed one portion of the if statement to allow /scp/.

Basically what the if statement is doing is checking to make sure that the refresh.js is only loaded if
a) Your browser is pointed at /scp/tickets.php
b) Your browser is pointed at /scp/index.php
c) Your browser is pointed at /scp/

Granted it also ignores addresses like /scp/tickets.php?id=168.

One thing you can do is try to echo the variable $_SERVER['REQUEST_URI'] in tickets.php and figure out what you need to do from there to make the if statement work.

SLMHC
08-21-2008, 04:55 PM
I access it via http://webaddress/servicedesk/scp.

The echo outputs "/servicedesk/scp/tickets.php"
________
starcraft II replay (http://screplays.com)

webPragmatist
08-21-2008, 05:34 PM
I access it via http://webaddress/servicedesk/scp.

The echo outputs "/servicedesk/scp/tickets.php"

Ahah,

Well simply replace:
<?if (($_SERVER['REQUEST_URI'] == '/scp/tickets.php') || ($_SERVER['REQUEST_URI'] == '/scp/index.php') || ($_SERVER['REQUEST_URI'] == '/scp/')){?>

with

<?if (($_SERVER['REQUEST_URI'] == '/servicedesk/scp/tickets.php') || ($_SERVER['REQUEST_URI'] == '/servicedesk/scp/index.php') || ($_SERVER['REQUEST_URI'] == '/servicedesk/scp/')){?>

I'll figure out a better way to dynamically add the refresh.js and post it when I have some time.

saaiber
08-22-2008, 03:36 AM
Can you add a screen cap of what is actually supposed to look like? I made the changes above and nothing is happening. All that I see is an extra line break below the refresh button, no actual text.

My screencap (http://www.davehildebrand.com/explorer/viewing/refreshmod.JPG/)

edit: the page does not refresh either.

I see in your screenshot that you have added last updated by.....

Did you find this mod here? Or can you give me the mod instructions to do this? I'd really like this one and would install this on my helpdesk too. :)

@webPragmatist

Thank you for this great mod, it works like a charm on my helpdesk.

Grtz,

Nic

SLMHC
08-22-2008, 10:08 AM
Ahah,

Well simply replace:
<?if (($_SERVER['REQUEST_URI'] == '/scp/tickets.php') || ($_SERVER['REQUEST_URI'] == '/scp/index.php') || ($_SERVER['REQUEST_URI'] == '/scp/')){?>

with

<?if (($_SERVER['REQUEST_URI'] == '/servicedesk/scp/tickets.php') || ($_SERVER['REQUEST_URI'] == '/servicedesk/scp/index.php') || ($_SERVER['REQUEST_URI'] == '/servicedesk/scp/')){?>

I'll figure out a better way to dynamically add the refresh.js and post it when I have some time.

Arg. I should have figured that one out myself. Lazy sod!

Great mod, I vote for it to be included into the next release.
________
smoke kills (http://smokekills.net)

SLMHC
08-22-2008, 10:11 AM
I see in your screenshot that you have added last updated by.....

Did you find this mod here? Or can you give me the mod instructions to do this? I'd really like this one and would install this on my helpdesk too. :)


Yeah there is. You can find it here (http://www.osticket.com/forums/showthread.php?t=1068). @webPragmatist wrote that one as well. These two mods should be included into the next release.
________
Kawasaki A1 (http://www.cyclechaos.com/wiki/Kawasaki_A1)

SLMHC
08-22-2008, 10:26 AM
I should add that this MOD is great for us M$ folx who use autocron to fetch email into the system. I have autocron set to fetch every 1 min and the page refreshes every 2 min.
________
Suzuki RG500 (http://www.cyclechaos.com/wiki/Suzuki_RG500)

jpowers40828
08-24-2008, 08:06 PM
My problem is that the osticket install is in a folder on the server, so the $_SERVER['REQUEST_URI'] has the folder in first. In order to figure out what exactly it needed to be, I just added <? echo $_SERVER['REQUEST_URI']; ?> right after <BODY> in the header file to find out exactly what it was looking for. Then changed the if statement to match that. Then it works!

webPragmatist
08-24-2008, 10:37 PM
Glad to hear the mod is working well for you two.

jpowers40828
09-10-2008, 04:04 AM
I was working on writing an install guide for myself for all the mods i've done, i plan on moving osticket from godaddy to an in house server. I came across this, and I think I figured out a check at the top that should work for everyone.

<? $refresh_check = explode("/",$_SERVER['REQUEST_URI']);
$last = array_pop($refresh_check);
if (($last == 'index.php') || ($last == '') || ($last == 'tickets.php') || ($last == 'tickets.php?status=open'))
{ ?>
<script type="text/javascript" src="js/refresh.js" charset="utf-8"></script>
<? } ?>

webPragmatist
09-10-2008, 06:13 PM
I was working on writing an install guide for myself for all the mods i've done, i plan on moving osticket from godaddy to an in house server. I came across this, and I think I figured out a check at the top that should work for everyone.

<? $refresh_check = explode("/",$_SERVER['REQUEST_URI']);
$last = array_pop($refresh_check);
if (($last == 'index.php') || ($last == '') || ($last == 'tickets.php') || ($last == 'tickets.php?status=open'))
{ ?>
<script type="text/javascript" src="js/refresh.js" charset="utf-8"></script>
<? } ?>
Cool, I don't have time to test it so i'll assume it works and stick it in the first thread. ;)

ivanof
09-22-2008, 12:58 PM
Thanks for the code, it works great!

Any chance of maintaining through the refresh process the chosen Sort of columns?

I mean: I decide to order by Ticket number by clicking on Ticket number column... But when it refreshes, it comes back to original sorting of column...

Thanks in advance,

Ivanof.

webPragmatist
09-22-2008, 07:03 PM
Thanks for the code, it works great!

Any chance of maintaining through the refresh process the chosen Sort of columns?

I mean: I decide to order by Ticket number by clicking on Ticket number column... But when it refreshes, it comes back to original sorting of column...

Thanks in advance,

Ivanof.

Yep,

No clue why I didn't think of this before :confused:
<?
if (empty($_GET) || array_key_exists('sort', $_GET) && array_key_exists('order', $_GET))
{?>

Also be sure to change your refresh.js back to using:
window.location.reload()
I've updated the original post. Sorry jpowers, your mod mod has been removed :)

mazost
03-04-2010, 08:37 PM
This mod causes a problem, which I had

see
http://osticket.com/forums/showthread.php?t=3651

I had debugged it and found a solution. When a moderator approves my post, you can all see how to correct the code above and where to input the line in header.inc.php
Basically you DON'T even put in that code there, but under the refresh button code, so it does not interfere with your staff reply panel by breaking out the tabs.

Please see link for full details and the image.

webPragmatist
03-06-2010, 03:09 PM
This mod causes a problem, which I had

see
http://osticket.com/forums/showthread.php?t=3651

I had debugged it and found a solution. When a moderator approves my post, you can all see how to correct the code above and where to input the line in header.inc.php
Basically you DON'T even put in that code there, but under the refresh button code, so it does not interfere with your staff reply panel by breaking out the tabs.

Please see link for full details and the image.

Thanks mazost. I haven't used this mod since I upgraded to the new OST, now I just tell my users to download tab mix (or use Opera) to refresh the page.

I can't test this to change it but I will link to your thread on the first post.

mazost
03-06-2010, 03:47 PM
No problem. I find this a great addon and I don't have to keep refreshing myself =)