<Module>
  <ModulePrefs
	title="Indexing Status"
	title_url="http://ntvmr.uni-muenster.de"
	author_email="scribe777@gmail.com"
	author="Institut für neutestamentliche Textforschung"
	description="Show Potential Indexing Candidate Document and Status"
	screenshot="http://ntvmr.uni-muenster.de/community/images/listescreenshot.png"
	thumbnail="http://ntvmr.uni-muenster.de/community/images/pageicon.gif"
	scrolling="true"
   >
  <Optional feature="pubsub-2">
  <Param name="topics">
    <![CDATA[ 
    <Topic title="Manuscript Selection" name="interedition.manuscript.selected"
            description="Select a Manuscript" type="string" subscribe="true"/>
    <Topic title="Manuscript Selection" name="interedition.image.selected"
            description="Select a Manuscript" type="string" subscribe="true"/>
    <Topic title="Manuscript Selection" name="interedition.transcription.selected"
            description="Select a Manuscript" type="string" subscribe="true"/>
    <Topic title="Manuscript Selection" name="interedition.page.selected"
            description="Select a Manuscript" type="string" subscribe="true"/>
	
    ]]>
  </Param>
</Optional>
  <Optional feature="dynamic-height"/>
  <Optional feature="views"/>
  <Optional feature="opensocial-0.8"/>
</ModulePrefs>

<UserPref name="height" datatype="enum" display_name="Gadget Height" default_value="600">
	<EnumValue value="200" display_value="Short"/>
	<EnumValue value="400" display_value="Medium"/>
	<EnumValue value="600" display_value="Tall"/>
</UserPref>

<Content type="html">
<![CDATA[
<head>

	<link rel="stylesheet" type="text/css" href="/community/js/jquery-ui/jquery-ui.css"/>

	<script type="text/javascript" src="/community/js/jquery/jquery.min.js"></script>
	<script type="text/javascript" src="/community/js/jquery-ui/jquery-ui.min.js"></script>
	<script type="text/javascript" src="/community/js/URI.min.js"></script>
	<script type="text/javascript" src="/community/js/jquery/jquery.cookie.js"></script>

<script type="text/javascript">


	var viewer = null;
        $(document).ready(function() {

        });
</script>
<style type="text/css">
<!--
table {
	border-collapse: collapse;
}

table#smallsize {
	border-collapse: collapse;
	width: 100%;
}

td, th {
	padding: 5px 4px;
	border: 1px solid #CCC;
	/*white-space: nowrap;
	overflow: hidden;*/
}


thead, tfoot {
	background-color: #CCC;
}

tr.rowodd {
	background-color: #FFF;
}

tr.roweven {
	background-color: #F2F2F2;
}

.sortcol {
	cursor: pointer;
	padding-right: 20px;
	background-repeat: no-repeat;
	background-position: right center;
}
.sortasc {
	background-color: #DDFFAC;
	background-image: url(../images/up.gif);
}
.sortdesc {
	background-color: #B9DDFF;
	background-image: url(../images/down.gif);
}
.nosort {
	cursor: default;
}

.urg1, .urg2, .urg3, .urg4, .urg5 {
	padding: 3px;
	text-align: center;
	border: 1px solid #333;
	width: 3em;
}

.urg1 {
	background-color: #FFFACD;
}
.urg2 {
	background-color: #FFD700;
}
.urg3 {
	background-color: #FFA500;
}
.urg4 {
	background-color: #E13E00;
}
.urg5 {
	background-color: Red;
}

th.resize-handle-active {
	cursor: e-resize;
}

.ui-tabs-nav {
	font-size: 85%;
}

.ui-tabs .ui-tabs-panel {
	padding: .5em .5em;
}

div.resize-handle { cursor: e-resize; width: 2px; border-right: 1px dashed #1E90FF; position:absolute; top:0; left:0; } 
	body {
		font-family: arial, sans-serif;
		font-size: 14px;
	}

span.lock-icon {
  position:absolute;
  left:80%;
  top:0%;
}

div.thumbnail {
  position:relative;
  display:block;
  float:left;
}

a img {
	text-decoration: none;
	border: 0 none;
	}
	
-->
</style>
</head>

<body style="background-color: #EEE;">
<div>
<b><i>Pending Work</i></b>
<p style="font-size:small;background-color: #EEE;margin-after:0px;">
The INTF NTVMR has complete Biblical Content index information for hundreds of New Testament manuscripts.  Below you will see a list of manuscripts which have not yet been fully indexed but have images available.  You can help.  Become an active member of the NTVMR community and help us build a more complete manuscript repository for NT studies.
</p>
</div>
<div style="background-color: white;">
	<table class="" style="width:100%;">
		<thead>
			<tr><th>Status</th><th>Indexer</th><th id="docIDCol">INTF Id</th><th id="ga_numbercol">GA</th><th id="centurycol">Date</th><th id="Leavescol">Pgs</th></tr>
		</thead>
		<tfoot>
			<tr><th>Status</th><th>Indexer</th><th>INTF Id</th><th>GA</th><th>Date</th><th>Pgs</th></tr>
		</tfoot>
		<tbody id="statusTable">
		</tbody>
	</table>
</div>
<script>

var servicesURL = '';
var imagesURL = '';


function loadStatus() {
	$('#statusTable').html('<tr><td colspan="6"><center><image src="'+imagesURL+'/loading.gif"/></center><br/><center><h1>Computing Index Status.  Please wait...</h1></center></td></tr>');
	var postData = {
		sessionHash : $.cookie('ntvmrSession')
	};
	var params = {};
	params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
	params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(postData);
	var url = URI('indexstatustable.jsp').absoluteTo(gadgets.util.getUrlParameters()['url']);
	gadgets.io.makeRequest(url, function(o) {
		$('#statusTable').html(o.text);

	}, params);
}

function claimResponsibility(docID) {
	if (confirm('Are you sure you want to claim responsibility for indexing document ' +docID + '?')) {
	
		var params = {};
	
		var postData = {
			sessionHash   : $.cookie('ntvmrSession'),
			objectID      : docID,
			taskTypeID    : 2,
		};
	
		params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
		params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(postData);
		var assignTaskURL = servicesURL + '/projectmanagement/task/assign/';
		gadgets.io.makeRequest(assignTaskURL, function(o) {
			var xml = $.parseXML(o.text);
			var error = $(xml).find('error');
			if (error && error.length) {
				alert($(error).attr('message'));
			}
			else {
				alert($(xml).find('success').attr('message'));
				$('#doc'+docID+'indexer').html(
					'<a href="/web/'+viewer.getDisplayName()+'" target="_blank">'+viewer.getDisplayName()+'</a>'
				 );

				// announce activity
				var params = {};  
				params[opensocial.Activity.Field.TITLE] = 'Assignment made for Indexing Manuscript: '+docID+' to '+viewer.getDisplayName();
				var activity = opensocial.newActivity(params); 
				opensocial.requestCreateActivity(activity, opensocial.CreateActivityPriority.HIGH);
			}
		}, params);
	}
}

function mss_selected(docID, focusPageId) {

	$('.docrow').css('background-color', '#FFFFFF');
	$('#doc'+docID).css('background-color', '#E2E2E2');

	if (gadgets.util.hasFeature('pubsub-2')) gadgets.Hub.publish("interedition.manuscript.selected", docID);
//	loadManuscripts(true, 'docID', docID, docID, focusPageId);
}


function loaded() {
	servicesURL = URI('../../vmr/api').absoluteTo(gadgets.util.getUrlParameters()['url']);
	imagesURL = URI('../../images').absoluteTo(gadgets.util.getUrlParameters()['url']);

        var prefs = new gadgets.Prefs();
        var preferredHeight = parseInt(prefs.getString('height'));
	if (gadgets.util.hasFeature('dynamic-height')) gadgets.window.adjustHeight(preferredHeight);

	var req = opensocial.newDataRequest(); 
	var p = {}; 

	p[opensocial.IdSpec.Field.USER_ID] = "VIEWER"; 
	var idSpec = opensocial.newIdSpec(p); 
	req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), "viewer"); 
	req.send(function(data) {
		viewer = data.get("viewer").getData();
		loadStatus();
	});
}


if (gadgets.util.hasFeature('pubsub-2')) {
	gadgets.HubSettings.onConnect = function(hum, suc, err) { loaded(); };
}
else gadgets.util.registerOnLoadHandler(loaded);

</script>
</body>

]]>
</Content>
</Module>

