Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/Code)
 PM add-on (PM alert)
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 3

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 10 March 2003 :  13:43:11  Show Profile
Requires Private Messages Mod

Seen this done a few times before so thought i'd share my version of it. Basically, if you have 1 message you will be promted (OK/Cancel) to view the message instantly or if you have more than 1 it will take you to your inbox.

Create a new ASP file calles inc_pm_alert.asp, add the following
<%
if strDBNTUserName <> "" Then 
	if pmcount = 1 then 

		strSql = "SELECT " & strMemberTablePrefix & "MEMBERS.MEMBER_ID, " & strMemberTablePrefix & "MEMBERS.M_NAME, " & strTablePrefix & "PM.M_ID, " & strTablePrefix & "PM.M_TO, " & strTablePrefix & "PM.M_SUBJECT, " & strTablePrefix & "PM.M_SENT, " & strTablePrefix & "PM.M_FROM, " & strTablePrefix & "PM.M_READ "
		strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS , " & strTablePrefix & "PM "
		strSql = strSql & " WHERE " & strMemberTablePrefix & "MEMBERS.M_NAME = '" & strDBNTUserName & "'"
		strSql = strSql & " AND " & strMemberTablePrefix & "MEMBERS.MEMBER_ID = " & strTablePrefix & "PM.M_TO "
		strSql = strSql & " ORDER BY " & strTablePrefix & "PM.M_SENT DESC" 

		Set rsMessage = my_Conn.Execute(strSql)
		%>		
		<script language=javascript>
		if (window.print) {
			if (getCookie('ShowMsgBox') != 'false'){
				agree = confirm('You have a new Private Message!\nWould you like to view it now ?');
				if (agree) {window.open('pm_pop_read.asp?id=<% =rsMessage("M_ID") %>','_blank','width=490,height=340,top=75,left=220,scrollbars=yes')}
				else {setCookie('ShowMsgBox', 'false','','','','')}
			}
		}
		</script>
		<%
		Set rsMessage = Nothing
	elseif pmcount > 1 then 
		%>		
		<script language=javascript>
		if (window.print) {
			if (getCookie('ShowMsgBox') != 'false'){
				agree = confirm('You have <%=pmcount%> new Private Messages!\nWould you like to go to your inbox now ?');
				if (agree) {window.location.href = 'pm_view.asp?view=inbox'; setCookie('ShowMsgBox', 'false','','','','')}
				else {setCookie('ShowMsgBox', 'false','','','','')}
			}
		}
		</script>
		<%
	end if
end if
%>


add this to inc_footer.asp above my_Conn.close
%>
<!--#INCLUDE FILE="inc_pm_alert.asp" -->
<%


add these JavaScript functions between the HEAD tags of inc_header.asp, sorry I can't be more exact with line numbers but i've extracted my js to a .js file.

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


cookies are required in the event that you click cancel on the popup, the cookie prevents the popup occuring on subsequent pages


The UK MkIVs Forum

PeeWee.Inc
Senior Member

United Kingdom
1893 Posts

Posted - 10 March 2003 :  13:59:16  Show Profile  Visit PeeWee.Inc's Homepage

<%
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}
%>


how long is the cookie stored for?

De Priofundus Calmo Ad Te Damine
Go to Top of Page

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 10 March 2003 :  14:57:36  Show Profile
Just the browser session

The UK MkIVs Forum
Go to Top of Page

Jag24
Junior Member

182 Posts

Posted - 18 March 2003 :  20:47:05  Show Profile  Visit Jag24's Homepage  Send Jag24 an ICQ Message
Looks like a great idea,
I was looking for something along this line.
HeaderFile

Any ideas where I should place the code in this header file?
Go to Top of Page

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 19 March 2003 :  05:54:32  Show Profile
Best to put it in the footer as if you have a message a javascript pop-up appears, this will stop the rest of the HTML rendering until you click 'OK'.

The UK MkIVs Forum
Go to Top of Page

forumnewbee
Starting Member

Netherlands
42 Posts

Posted - 19 March 2003 :  10:56:02  Show Profile  Visit forumnewbee's Homepage
quote:
add these JavaScript functions between the HEAD tags of inc_header.asp


where exactly is that ? sorry asp newbee here.

Greetz

Body & Fitness Forum
Go to Top of Page

forumnewbee
Starting Member

Netherlands
42 Posts

Posted - 19 March 2003 :  18:42:14  Show Profile  Visit forumnewbee's Homepage
nobody ?


Body & Fitness Forum
Go to Top of Page

forumnewbee
Starting Member

Netherlands
42 Posts

Posted - 20 March 2003 :  22:03:03  Show Profile  Visit forumnewbee's Homepage
bump

Body & Fitness Forum
Go to Top of Page

Ez4arab
Junior Member

479 Posts

Posted - 21 March 2003 :  03:52:17  Show Profile  Visit Ez4arab's Homepage
after this
function openMiniPoll(url) {
popupWin = window.open(url,'new_page','width=200,height=400,top=75,left=220')
}

Ez4arab web site Ez4arab |
Go to Top of Page

RodVera
Starting Member

Chile
2 Posts

Posted - 21 March 2003 :  18:34:24  Show Profile  Visit RodVera's Homepage  Send RodVera an ICQ Message
Hey, nice work on this one. I have a question, how do i set the cookie to expire, lets say in 5 minutes. I tried

setCookie('ShowMsgBox', 'false','300','','','')

but got javascript errors. Pls help.
Go to Top of Page

forumnewbee
Starting Member

Netherlands
42 Posts

Posted - 26 March 2003 :  20:17:17  Show Profile  Visit forumnewbee's Homepage
quote:
Originally posted by Ez4arab

after this
function openMiniPoll(url) {
popupWin = window.open(url,'new_page','width=200,height=400,top=75,left=220')
}




Can not find that part in inc_header.asp :(

Body & Fitness Forum
Go to Top of Page

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 27 March 2003 :  11:31:25  Show Profile
quote:
Originally posted by RodVera

Hey, nice work on this one. I have a question, how do i set the cookie to expire, lets say in 5 minutes. I tried

setCookie('ShowMsgBox', 'false','300','','','')

but got javascript errors. Pls help.



you need to use a valid date, i don't think seconds will work

The UK MkIVs Forum
Go to Top of Page

forumnewbee
Starting Member

Netherlands
42 Posts

Posted - 28 March 2003 :  12:11:56  Show Profile  Visit forumnewbee's Homepage
can someone plz post a link where this mod is working ?
I wanna test it :D

Greetz

Body & Fitness Forum
Go to Top of Page

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 28 March 2003 :  12:21:36  Show Profile
It's on my site, link is below

The UK MkIVs Forum
Go to Top of Page

forumnewbee
Starting Member

Netherlands
42 Posts

Posted - 29 March 2003 :  06:43:52  Show Profile  Visit forumnewbee's Homepage
quote:
Originally posted by DavidRhodes

It's on my site, link is below



I register there bro member name 'Smalluser' and tested the PM alert it looks great really !!!!!!!!!!!!

I can not get it running on mu forum :( can you plz mail the neccesary asp's so I can look into them ? so I can edit mine asp's.

admin@body-fitness.nl

Greetz

Body & Fitness Forum
Go to Top of Page

LeeC
Starting Member

36 Posts

Posted - 31 March 2003 :  17:44:47  Show Profile  Visit LeeC's Homepage
Went ahead and converted the javascript inc_header.asp portion to response.writes (Hope you don't mind David)

Find the section:

Response.Write	"<script language=""JavaScript"" type=""text/javascript"">" & vbNewLine & _
		"<!-- hide from JavaScript-challenged browsers" & vbNewLine & _


And above:

		"// done hiding -->" & vbNewLine & _
		"</script>" & vbNewLine & _


Insert the following:

		"// ################## PM Alert ##################" & vbNewLine & _
		"function setCookie(name, value, expires, path, domain, secure) {" & vbNewLine & _
		"  var curCookie = name + ""="" + escape(value) +" & vbNewLine & _
		"      ((expires) ? ""; expires="" + expires.toGMTString() : """") +" & vbNewLine & _
		"      ((path) ? ""; path="" + path : """") +" & vbNewLine & _
		"      ((domain) ? ""; domain="" + domain : """") +" & vbNewLine & _
		"      ((secure) ? ""; secure"" : """");" & vbNewLine & _
		"  document.cookie = curCookie;" & vbNewLine & _
		"}" & vbNewLine & _

		"function getCookie(name) {" & vbNewLine & _
		"  var dc = document.cookie;" & vbNewLine & _
		"  var prefix = name + ""="";" & vbNewLine & _
		"  var begin = dc.indexOf(""; "" + prefix);" & vbNewLine & _
		"  if (begin == -1) {" & vbNewLine & _
		"    begin = dc.indexOf(prefix);" & vbNewLine & _
		"    if (begin != 0) return null;" & vbNewLine & _
		"  } else" & vbNewLine & _
		"    begin += 2;" & vbNewLine & _
		"  var end = document.cookie.indexOf("";"", begin);" & vbNewLine & _
		"  if (end == -1)" & vbNewLine & _
		"    end = dc.length;" & vbNewLine & _
		"  return unescape(dc.substring(begin + prefix.length, end));" & vbNewLine & _
		"}" & vbNewLine & _
		"// #############################################" & vbNewLine & _




Oh WTF!com
Convergence - an MMORPG guild
.rdw. a CS clan
GotFrag? - Your online eSports resource

urK?!?

Edited by - LeeC on 31 March 2003 17:45:53
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.34 seconds. Powered By: Snitz Forums 2000 Version 3.4.07