Sei sulla pagina 1di 5

<table id="tblResourceAndStartBtn" style="display:none;width:100%;" cellspacing="

10px" cellpadding="10px">
<tr>
<td>
<h1 id="headingListTitle"></h1><hr />
</td>
</tr>
<tr id="trFeedback" style="display:none">
<td>
<div>Thank you for responding to this Awareness Program.
We will get back to you soon.</div>
</td>
</tr>
<tr id="trAlreadyRespond" style="display:none">
<td>
<div>You have already responded to this Awareness Progra
m.</div>
</td>
</tr>
<tr id="trNoFurtherResponses" style="display:none">
<td>
<div><strong class="spnListTitle"></strong> ended on <st
rong class="spnEndDate"></strong>. No further responses will be processed.</div>
</td>
</tr>
<tr id="trIframe" style="display:none">
<td align="center">
<IFRAME id="iframePdf" style="width:745px; height: 500px
;" src="" frameBorder=0 align="center"></IFRAME>
</td>
</tr>
<tr id="trFullScrPdf" style="display:none">
<!--<td align="center">Click <a href="#" target="_blank" id="Fu
llScrPdf" style="text-decoration:underline">here</a> to view in full screen </td
>!-->
</tr>
<tr id="trVideoPlayer" style="display:none">
<td align="center">
<object id="videoObj" classid="clsid:D27CDB6E-AE6D-11cf96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/f
lash/swflash.cab#version=6,0,40,0" width="600" height="200">
<param name="allowfullscreen" value="true" />
<param name="movie" value="http://portal.pic.com
.kw:7777/PIC/player.swf" />
<param name="flashvars" value="" />
<param name="wmode" value="transparent"/>
<embed id="videoEmbed" width="500" heigh
t="311" allowfullscreen="true" type="application/x-shockwave-flash" src="http://
portal.pic.com.kw:7777/PIC/player.swf" pluginspage="http://www.macromedia.com/go
/getflashplayer" flashvars="" />
</object>
</td>
</tr>
<tr id="trLink" style="display:none">
<td align="center">
<a href="#" id="anchorDocLink" target="_blank">Click her
e to download the document.</a>
</td>
</tr>
<tr id="trStart" style="display:none">

<td align="center">
Read the above <strong class="spnListTitle"></strong> an
d Click the button to start the Assessment <input type="button" value="Start Ass
essment" onclick="OpenAwarenessPopUp()"/>
</td>
</tr>
</table>
<script src="/SiteAssets/jquery.js"></script>
<script type="text/javascript">
var ConfId = "";
var File="";
var FileExt="";
var FileUrl="";
var ListName="";
var StartDate="";
var EndDate="";
var AwarenessTitle="";
var licAwarenessConfig="";
var isAlreadyRespond = false;
var userid="";
var isSurvey=false;
var surveyLink="";
LoadSodByKey("sp.js", function () {});
//var SiteUrlDV="http://picspdv01:701";
ConfId = GetQueryStringValue('ConfId');
function init()
{
if(ConfId!="")
ExecuteOrDelayUntilScriptLoaded(GetDataFromAwarenessConf
igList, "sp.js");
}
function GetDataFromAwarenessConfigList()
{
var clientContext = new SP.ClientContext(SiteUrl);
var listAwarenessConfig = clientContext.get_web().get_lists().getBy
Title("Awareness Config");
var queryAwarenessConfig = new SP.CamlQuery();
queryAwarenessConfig.set_viewXml('<View><Query><Where><Eq><Field
Ref Name="ID" /><Value Type="Counter">'+ConfId+'</Value></Eq></Where></Query></V
iew>');
licAwarenessConfig = listAwarenessConfig.getItems(queryAwareness
Config);
clientContext.load(licAwarenessConfig);
clientContext.executeQueryAsync(Function.createDelegate(this, th
is.onLoadAwarenessConfigSuccess), Function.createDelegate(this, this.onFailureMe
thod));
}
function onLoadAwarenessConfigSuccess()
{
if(licAwarenessConfig.get_count()>0)

{
var vListEnumerator = licAwarenessConfig.getEnumerator()
;
while (vListEnumerator.moveNext()) {
var vCurrentItem = vListEnumerator.get_current();
File = vCurrentItem.get_item('FileLeafRef');
FileUrl = vCurrentItem.get_item('FileRef');
ListName = vCurrentItem.get_item('AwarenessListName');
StartDate = new Date(vCurrentItem.get_item('StartDate'))
;
EndDate = new Date(vCurrentItem.get_item('EndDate'));
AwarenessTitle = vCurrentItem.get_item('AssessmentTitle'
);
FileExt = vCurrentItem.get_item("File_x0020_Type");
surveyLink=vCurrentItem.get_item("SurveyLink");
//FileExt = File.split('.').pop();
}
if(surveyLink!=null)
if(surveyLink!="" && surveyLink!="#")
isSurvey=true;
if(FileExt=="pdf")
{
var urlForIframePdf=FileUrl+"#toolbar=0&amp;navpanes=0&a
mp;scrollbar=0";
$("#iframePdf").attr('src', urlForIframePdf);
$("#FullScrPdf").attr('href', FileUrl);
$("#trIframe").show();
$("#trFullScrPdf").show();
}
else if((FileExt=="mp4")||(FileExt=="wmv")||(FileExt=="flv"))
{
var FileFullPathForVideo = "file="+window.location.proto
col+"//"+window.location.host+FileUrl;
$("#videoObj param[name=flashvars]").attr('value', FileF
ullPathForVideo);
$("#videoEmbed").attr('flashvars', FileFullPathForVideo)
;
$("#trVideoPlayer").show();
}
else
{
$("#anchorDocLink").attr('href', FileUrl);
$("#trLink").show();
}
var Today = new Date();
if(Today<EndDate)
{
userid= _spPageContextInfo.userId;
if(ListName!=null)
IsAlreadyRespond();
else
$("#trStart").show();
}
else
{

$(".spnEndDate").text(EndDate.localeFormat("MM/dd/yyyy")
);
$("#trNoFurtherResponses").show();
}
$(".spnListTitle").html(AwarenessTitle);
$("#headingListTitle").html(AwarenessTitle);
$("#tblResourceAndStartBtn").show();
}
}
function onFailureMethod()
{
//alert("Error");
}
function IsAlreadyRespond() {
var CurrentUserRespondUri = "/_api/lists/getbytitle('"+ListName+"')/
items?$filter=Author eq "+userid;
($).ajax({
url: CurrentUserRespondUri,
type: "GET",
async: false,
headers: { "ACCEPT": "application/json;odata=verbose" },
success: onCurrentUserRespondQuerySuccess,
error: onCurrentUserRespondQueryError
});
}
function onCurrentUserRespondQuerySuccess(data)
{
if (data.d.results.length > 0)
{
$("#trAlreadyRespond").show();
$("#trStart").hide();
}
else
{
$("#trStart").show();
}
}
function onCurrentUserRespondQueryError()
{
//alert("Error");
}
function OpenAwarenessPopUp()
{
var awarenessUrl = "";
if(isSurvey)
awarenessUrl=surveyLink;
else
awarenessUrl="AwarenessProgram.aspx?ListName="+ListName;
var options = {
url: awarenessUrl,
args: null,
title: AwarenessTitle,
allowMaximize: false,

showClose: true,
width: 850,
dialogReturnValueCallback: dialogCallbackAwarene
ssProgramPopUp,
};
SP.UI.ModalDialog.showModalDialog(options);
window.scroll(0,0);
}
function dialogCallbackAwarenessProgramPopUp(dialogResult, returnValue)
{
if(dialogResult==1)
{
$("#trStart").hide();
$("#trFeedback").show();
}
}
function GetQueryStringValue(pVariable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0].toLowerCase() == pVariable.toLowerCase()) {
return pair[1];
}
}
}
init();
</script>

Potrebbero piacerti anche