2015-04-21 16:18:15 -04:00
<?xml version="1.0" encoding="UTF-8"?>
<Module >
<ModulePrefs title= "Create a Group" author= "Eric Meeks" >
<Require feature= "opensocial-0.9" />
<Require feature= "pubsub" />
<Require feature= "views" />
<Require feature= "osapi" />
<Require feature= "rdf" />
</ModulePrefs>
<Content type= "html" view= "canvas, small" > <![CDATA[<!--HTML-->
<!DOCTYPE html>
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
<!-- #includes -->
<link rel= "stylesheet" href= "css/gadget.css" type= "text/css" media= "screen, projection" >
<script type= "text/javascript" src= "js/os.js" > </script>
<script type= "text/javascript" src= "js/jquery-1.4.4.js" > </script>
<script type= "text/javascript" src= "js/environment.js" > </script>
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
<style >
.tool_title {font-family:Arial,Helvetica; font-size:14px;}
.tool_title_orange {font-weight:bold; font-family:Arial,Helvetica; font-size:14px; color:#CA7C29;margin-top:-1px;}
.tool_body {font-family:Arial; font-size:12px;}
.tool_credit {font-family:Arial; font-size:10px;}
.tool_table_cell {font-family:Arial,Helvetica; font-size:12px; padding:0 20px 0 0;}
.tool_table_cell_small {font-family:Arial,Helvetica;font-size:11px;}
.tool_table_cell_small span a {font-size:11px;}
.tool_table_cell_small span {font-size:11px;display:inline-block;margin-right: -15px; }
2019-04-25 14:51:38 -07:00
.tool_toggle_button {font-size: 13px;padding:0 5px;}
2015-04-21 16:18:15 -04:00
a, a:visited { color: #0088CC; text-decoration: none; }
a:hover { color: #005580; text-decoration: underline; }
</style>
<script type= "text/javascript" >
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
// ==============================================================
function gadgetEventTrack(action, label, value) {
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
var message = {'action' : action};
if (label) {message.label = label;}
if (value) {message.value = value;}
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
gadgets.pubsub.publish("analytics", message);
2019-04-25 14:51:38 -07:00
}
2015-04-21 16:18:15 -04:00
// ==============================================================
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
function showHelp() {
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
var pop = window.open('Create a Group Help','','top=200,left=200,width=450,height=340,scrollbars=0,status=0,menubar=0,location=0,resizable=0');
pop.document.title = "Create a Group Help";
2019-04-25 14:51:38 -07:00
pop.document.write("<html > <head > </head> <body > <div style= 'margin:10px; font-family:Arial; font-size:12px;' > ");
2015-04-21 16:18:15 -04:00
pop.document.write("Create a list of profiles and start a UCSF Chatter group or email list from here. "
+ "Here's how:<br > <ol > "
+ "<li > Click the 'Create Now!' button</li> "
+ "<li > Start compiling a list of profiles for your group. "
+ "You can add one profile at a time, add a set of search results, "
+ "or add a set of co-authors.</li> "
+ "<li > Review your list and create your group</li> "
+ "<li > Name your group and add a description</li> </ol> "
+ "<strong > Tips:</strong> <br > <br > "
+ "You are automatically added to the UCSF Chatter group if you create it. "
+ "You don't need to add yourself to the list of group members. "
+ "This works best if your group is 25 people or less. "
+ "If you want to add or remove members after the group is created, "
+ "go to UCSF Chatter directly.<br > <br > "
+ "To learn more about UCSF Chatter, go to "
+ "<a href= 'http://it.ucsf.edu/services/chatter' target= '_blank' > "
+ "http://it.ucsf.edu/services/chatter</a> ");
2019-04-25 14:51:38 -07:00
pop.document.write("<br > <br > <center > "
+ "<input type = 'button' value = 'Close' onclick = 'window.close();' > "
2015-04-21 16:18:15 -04:00
+ "</center> ");
pop.document.write("</body> </html> ");
}
// ==============================================================
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
function getNewProfilesStats(sender, message) {
var stats = gadgets.json.parse(message);
// display the action item table and update it
$("#actions").show();
if (message === 0) {
2019-04-25 14:51:38 -07:00
document.getElementById("add_profiles").innerHTML = "No Profiles found";
2015-04-21 16:18:15 -04:00
}
else {
document.getElementById("add_profiles").innerHTML = "<a style= 'font-size:11px;' href= 'javascript:addNewProfiles();' > Add " + message + " to list</a> ";
}
}
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
function addNewProfiles() {
2019-04-25 14:51:38 -07:00
document.getElementById("add_profiles").innerHTML = "Adding profiles...";
document.getElementById("list_profiles").innerHTML = "Merging into list...";
2015-04-21 16:18:15 -04:00
readIdsFromDB(function(existingIds) {
gadgets.pubsub.subscribe("JSONPersonIds", getNewIdsCallback(existingIds));
});
}
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
function getNewIdsCallback(existingIds) {
return function(sender, message) {
// extract the array of incoming person IDs
var newIds = gadgets.json.parse(message).personIds;
var addedListSize = getListSize(newIds);
var priorListSize = getListSize(existingIds);
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
// merge the incoming and existing person ID arrays
// existing array already populated
for (var baseURI in newIds) {
if (!existingIds.hasOwnProperty(baseURI)) {
existingIds[baseURI] = [];
}
existingIds[baseURI] = dedupeArray(existingIds[baseURI].concat(newIds[baseURI]));
}
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
var newListSize = getListSize(existingIds);
showCurrentListSize(newListSize);
if (newListSize > priorListSize) {
saveData(existingIds, function() {
document.getElementById("add_profiles").innerHTML = ((newListSize - priorListSize) === 1 ? "1 new Profile added" : "" + (newListSize - priorListSize) + " new Profiles added");
showCurrentListSize(newListSize);
});
}
else {
document.getElementById("add_profiles").innerHTML = (addedListSize == 1 ? "Profile already in list" : "Profiles already in list");
2019-04-25 14:51:38 -07:00
}
2015-04-21 16:18:15 -04:00
};
}
// ==============================================================
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
function getListSize(ids) {
var cnt = 0;
for (var baseURI in ids) {
cnt += ids[baseURI].length;
}
return cnt;
2019-04-25 14:51:38 -07:00
}
2015-04-21 16:18:15 -04:00
// ==============================================================
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
function showCurrentListSize(count) {
if (count > 0) {
document.getElementById("list_profiles").innerHTML = "<a href= 'javascript:gadgets.views.requestNavigateTo(\"canvas\");' > " + count + " Profiles in list</a> ";
}
else {
document.getElementById("list_profiles").innerHTML = "List is currently empty";
2019-04-25 14:51:38 -07:00
}
2015-04-21 16:18:15 -04:00
}
function showToolVersion(canvasMode) {
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
// fetch the extended state
osapi.appdata.get({'userId':'@viewer', 'appId':'@app', 'fields':['extended']} )
2019-04-25 14:51:38 -07:00
.execute(function(result) {
2015-04-21 16:18:15 -04:00
if (os.osapi.getViewerFromResult(result).extended == "True") {
if (canvasMode) {
document.getElementById("extended_functions").style.display = "inline-block";
document.getElementById("extended_functions").style.padding = "0 0 0 20px";
2019-04-25 14:51:38 -07:00
document.getElementById("canvas_help").innerHTML =
2015-04-21 16:18:15 -04:00
'Create a UCSF Chatter group or email list that includes the people below. '
2019-04-25 14:51:38 -07:00
+ 'To manage your UCSF Chatter group after you create it, such as adding or '
2015-04-21 16:18:15 -04:00
+ 'removing members, go to UCSF Chatter directly.' ;
2019-04-25 14:51:38 -07:00
}
2015-04-21 16:18:15 -04:00
}
else {
// this is what people who have limited functionality (only chatter group) see
if (canvasMode) {
document.getElementById("basic_functions").style.display = "inline-block";
document.getElementById("basic_functions").style.padding = "0 0 0 20px";
2019-04-25 14:51:38 -07:00
document.getElementById("canvas_help").innerHTML =
2015-04-21 16:18:15 -04:00
'Create a UCSF Chatter group that includes the people below. '
2019-04-25 14:51:38 -07:00
+ 'To manage your group after you create it, such as adding or '
2015-04-21 16:18:15 -04:00
+ 'removing members, go to UCSF Chatter directly.' ;
2019-04-25 14:51:38 -07:00
}
2015-04-21 16:18:15 -04:00
}
// if we are not in canvas mode, show the On/Off state correctly
2019-04-25 14:51:38 -07:00
if (!canvasMode) {
2015-04-21 16:18:15 -04:00
readCountFromDB( function(count) {
showCurrentListSize(count);
2019-04-25 14:51:38 -07:00
});
2015-04-21 16:18:15 -04:00
gadgets.pubsub.subscribe("PersonResultCount", getNewProfilesStats);
2019-04-25 14:51:38 -07:00
}
2015-04-21 16:18:15 -04:00
});
}
// ==============================================================
function toURIList(existingIds) {
var uriList = [];
for (var baseURI in existingIds) {
for (var i = 0; i < existingIds [ b a s e U R I ] . l e n g t h ; i + + ) {
uriList.push(baseURI + existingIds[baseURI][i]);
}
}
return uriList;
}
2019-04-25 14:51:38 -07:00
// first argument is an map of data,
// second argument is the callback function to execute after updating the data
function saveData(ids, callback) {
2015-04-21 16:18:15 -04:00
osapi.appdata.update({'userId': '@viewer', 'appId':'@app', 'data': {'count' : '' + getListSize(ids), 'ids' : gadgets.json.stringify(ids)}}).execute(callback);
}
// ==============================================================
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
function readCountFromDB(callback) {
2019-04-25 14:51:38 -07:00
osapi.appdata.get({'userId':'@viewer', 'appId':'@app', 'fields':'count'}).execute(function(result) {
2015-04-21 16:18:15 -04:00
// a map of {baseURI1 : ["string", "string"], baseURI2 : ["string", "string"]}
var count = os.osapi.getViewerFromResult(result).count || 0;
callback(count);
});
}
function readIdsFromDB(callback) {
2019-04-25 14:51:38 -07:00
osapi.appdata.get({'userId':'@viewer', 'appId':'@app', 'fields':'ids'}).execute(function(result) {
2015-04-21 16:18:15 -04:00
// a map of {baseURI1 : ["string", "string"], baseURI2 : ["string", "string"]}
var existingIds = os.osapi.getViewerFromResult(result).ids || "{}";
callback(gadgets.json.parse(existingIds));
});
}
2019-04-25 14:51:38 -07:00
// ==============================================================
2015-04-21 16:18:15 -04:00
function deleteList() {
osapi.appdata['delete']({'userId':'@viewer', 'appId':'@app', 'fields': ['ids', 'count']} )
.execute(function(result){
2019-04-25 14:51:38 -07:00
if (result.error) {
2015-04-21 16:18:15 -04:00
alert("Error " + result.error.code + " deleting application data: " + result.error.message);
} else {
document.getElementById("canvas_email_list_textarea").value = "";
document.getElementById("canvas_full_list_textarea").value = "";
document.getElementById("canvas_profile_list").innerHTML = "";
document.getElementById("number_selected").innerHTML = "Select Profiles";
2019-04-25 14:51:38 -07:00
}
2015-04-21 16:18:15 -04:00
}); /* end osapi.appdata.delete */
2019-04-25 14:51:38 -07:00
}
// ==============================================================
2015-04-21 16:18:15 -04:00
function dedupeArray(arrHasDupes) {
var deduped = [];
$.each(arrHasDupes, function(i, el){
if($.inArray(el, deduped) === -1) deduped.push(el);
});
2019-04-25 14:51:38 -07:00
return deduped;
2015-04-21 16:18:15 -04:00
}
2019-04-25 14:51:38 -07:00
// ==============================================================
2015-04-21 16:18:15 -04:00
2019-04-25 14:51:38 -07:00
function displayProfileList(existingIds) {
2015-04-21 16:18:15 -04:00
var uris = toURIList(existingIds);
// put these as individual fields in an ontology.js file
2019-04-25 14:51:38 -07:00
// pass in as options to getRdf call
2015-04-21 16:18:15 -04:00
var fullName = 'http://profiles.catalyst.harvard.edu/ontology/prns#fullName';
var preferredTitle = 'http://vivoweb.org/ontology/core#preferredTitle';
2019-04-25 14:51:38 -07:00
var email = 'http://vivoweb.org/ontology/core#email';
2015-04-21 16:18:15 -04:00
var strTable="<table cellspacing= '0' cellpadding= '0' width= '640' > <tr > ";
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
// build the table header row
strTable += "<td align= 'left' valign= 'top' class= 'tool_table_cell' > " + "<u > <b > Name</b> </u> </td> ";
strTable += "<td align= 'left' valign= 'top' class= 'tool_table_cell' > " + "<u > <b > Title</b> </u> </td> ";
strTable += "<td align= 'left' valign= 'top' class= 'tool_table_cell' > " + "<u > <b > Email Address</b> </u> </td> ";
strTable += "</tr> ";
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
for (i in uris) {
//strTable += "<tr id= '" + uris[i] + "' > <div id= 'displayPerson_" + i + "' > </div> </tr> ";
strTable += "<tr id= '" + uris[i] + "' > </tr> ";
2019-04-25 14:51:38 -07:00
}
2015-04-21 16:18:15 -04:00
strTable += "</table> ";
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
// dispay the empty table in canvas view
document.getElementById("canvas_profile_list").innerHTML = strTable;
document.getElementById("number_selected").innerHTML = "Your list includes (" + uris.length + ")" + " selected profiles";
// initialize the export divs
document.getElementById("canvas_email_list_textarea").value = "";
document.getElementById("canvas_full_list_textarea").value = "";
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
// load in groups of ten
var batchSize = 10;
var batchCount = Math.floor(uris.length/batchSize) + (uris.length % batchSize == 0 ? 0 : 1);
for (i = 0; i < uris.length ; i + = b a t c h S i z e ) {
var ids = '';
for (j = 0; j < batchSize & & i + j < u r i s . l e n g t h ; j + + ) {
2019-04-25 14:51:38 -07:00
ids += (j > 0 ? ',' : '') + uris[i + j];
2015-04-21 16:18:15 -04:00
}
osapi.rdf.getRDF(ids).execute(function(data) {
var people = data.list;
if(!people) {
people = [data];
}
for (var j = 0; j < people.length ; j + + ) {
var base = people[j].base;
people[j] = jsonldHelper.getItem(people[j]);
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
// put in div now so people can see progress
var table_row = "<td align= 'left' valign= 'top' class= 'tool_table_cell' > " + people[j][fullName] + "</td> ";
table_row += "<td align= 'left' valign= 'top' class= 'tool_table_cell' > " + people[j][preferredTitle] + "</td> ";
table_row += "<td align= 'left' valign= 'top' class= 'tool_table_cell email' > " + (people[j][email] ? people[j][email] : "") + "</td> ";
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
document.getElementById(base + people[j]['@id']).innerHTML = table_row;
}
// see if we are done and if so turn off progress bar and
2019-04-25 14:51:38 -07:00
// add to export lists
2015-04-21 16:18:15 -04:00
if (--batchCount == 0) {
var full_list = "";
var email_list = "";
$("#canvas_profile_list tr").each(function(index, tr){
if(!$(tr).attr("id")) {
return true;
}
var row = "";
$("td", tr).each(function(fld_index, td){
2019-04-25 14:51:38 -07:00
var txt = $(td).text();
2015-04-21 16:18:15 -04:00
row += txt + ";";
if(fld_index == 2 & & txt != "") {
email_list += txt + "\n";
}
});
full_list += row + "\n";
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
});
document.getElementById("canvas_full_list_textarea").value = full_list;
document.getElementById("canvas_email_list_textarea").value = email_list;
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
document.getElementById("progress").style.display="none";
}
});
}
} /* end displayProfileList */
2019-04-25 14:51:38 -07:00
// ==============================================================
2015-04-21 16:18:15 -04:00
function copyEmailDivToClipboard() {
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
$("#canvas_email_list").show();
$("#canvas_email_list_text").show();
$("#canvas_full_list").hide();
$("#canvas_full_list_text").hide();
2019-04-25 14:51:38 -07:00
$("#canvas_profile_list").hide();
2015-04-21 16:18:15 -04:00
}
2019-04-25 14:51:38 -07:00
// ==============================================================
2015-04-21 16:18:15 -04:00
function copyFullDivToClipboard() {
$("#canvas_full_list").show();
$("#canvas_full_list_text").show();
$("#canvas_email_list").hide();
$("#canvas_email_list_text").hide();
$("#canvas_profile_list").hide();
2019-04-25 14:51:38 -07:00
}
// ==============================================================
2015-04-21 16:18:15 -04:00
var root = (typeof ENV_LOCAL_URL === 'undefined')? "": ENV_LOCAL_URL;
2019-04-25 14:51:38 -07:00
var chatterProxyURL = root + "/chatter/ChatterProxyService.svc";
2015-04-21 16:18:15 -04:00
function getNodeIdFromURI(uri) {
2019-04-25 14:51:38 -07:00
if (typeof uri === 'string') {
2015-04-21 16:18:15 -04:00
var c = uri.split('/');
return c[c.length-1];
}
else {
var retval = [];
for ( i = 0; i < uri.length ; i + + ) {
retval[i] = getNodeIdFromURI(uri[i]);
2019-04-25 14:51:38 -07:00
}
2015-04-21 16:18:15 -04:00
return retval;
}
}
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
function createGroup(name, description, ownerId, users) {
document.getElementById("progress").style.display="block";
var params = {
"name": name,
"description": description,
"ownerId": ownerId,
"users": users};
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
sendRequest(false, false, chatterProxyURL + "/group/new", params, function(data) {
document.getElementById("progress").style.display="none";
if(data.Success) {
2019-04-25 14:51:38 -07:00
showMessage("<strong > Success! Your UCSF Chatter group '" + name + "' has been created.</strong> <br > "
2015-04-21 16:18:15 -04:00
+ "<a target= '_blank' href= '" + data.URL + "' > Go to UCSF Chatter to start working with your group.</a> ");
$("input#goup_name").val("");
}
else {
showMessage("Cannot create a group. " + data.ErrorMessage, true);
}
},
function(obj) {
showMessage("Server error " + obj.rc + " : " + obj.errors, true);
});
}
2019-04-25 14:51:38 -07:00
// ==============================================================
2015-04-21 16:18:15 -04:00
function sendRequest(cache, signed, url, post_params, success, error) {
2019-04-25 14:51:38 -07:00
var params = {};
2015-04-21 16:18:15 -04:00
if (signed) {
params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
}
params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(post_params);
params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
if(cache == false) {
params[gadgets.io.RequestParameters.REFRESH_INTERVAL] = 0;
}
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
gadgets.io.makeRequest(url, function(obj) {
if(obj.data != null) {
success(obj.data);
}
2019-04-25 14:51:38 -07:00
else if(obj.errors != null) {
2015-04-21 16:18:15 -04:00
if(error) {
error(obj);
}
}
2019-04-25 14:51:38 -07:00
}
2015-04-21 16:18:15 -04:00
, params);
}
2019-04-25 14:51:38 -07:00
// ==============================================================
2015-04-21 16:18:15 -04:00
function showMessage(msg, isError) {
$("div.message").html(msg);
if(isError == true) {
2019-04-25 14:51:38 -07:00
$("div.message").removeClass("info");
2015-04-21 16:18:15 -04:00
$("div.message").addClass("error");
}
else {
2019-04-25 14:51:38 -07:00
$("div.message").removeClass("error");
2015-04-21 16:18:15 -04:00
$("div.message").addClass("info");
}
2019-04-25 14:51:38 -07:00
$("div.message").removeClass("hidden");
2015-04-21 16:18:15 -04:00
}
2019-04-25 14:51:38 -07:00
// ==============================================================
2015-04-21 16:18:15 -04:00
function getUserList() {
var items = [];
$("div#canvas_profile_list tr").each( function(index, elem) {
var id = $(elem).attr("id");
if(id != null & & id != "") {
items.push(getNodeIdFromURI(id));
}
2019-04-25 14:51:38 -07:00
});
2015-04-21 16:18:15 -04:00
return items.join(',');
}
2019-04-25 14:51:38 -07:00
// ==============================================================
2015-04-21 16:18:15 -04:00
</script> ]]></Content>
<Content type= "html" view= "small" preferred_height= "75" preferred_width= "190" > <![CDATA[<!--HTML-->
<!DOCTYPE html>
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
<table id= "button_and_help" cellspacing= "6" cellpadding= "5" style= "display:block;" >
<tr >
<td class= "tool_table_cell_small" style= "width:145px" > Add profiles to your list</td>
<td > <img src= "images/hovertiptarget.png" border= "0" onClick= "gadgetEventTrack('help');showHelp()" > </td>
</tr>
</table>
<table id= "actions" style= "display:none;clear:right;" cellspacing= "2" cellpadding= "0" >
<tr >
<td class= "tool_table_cell_small" > 1. </td>
<td class= "tool_table_cell_small" > <span id= "add_profiles" onClick= "gadgetEventTrack('add_profiles')" > </span> </td>
</tr>
<tr >
<td class= "tool_table_cell_small" valign= "top" style= "padding-top:4px" > 2. </td>
<td class= "tool_table_cell_small" valign= "top" style= "padding-top:4px" > <span id= "list_profiles" onClick= "gadgetEventTrack('list_profiles')" > Loading...</span> </td>
</tr>
</table>
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
<script type= "text/javascript" >
function init() {
showToolVersion(false);
2019-04-25 14:51:38 -07:00
}
2015-04-21 16:18:15 -04:00
gadgets.util.registerOnLoadHandler(init);
</script> ]]></Content>
<Content type= "html" view= "canvas" preferred_height= "600" preferred_width= "700" > <![CDATA[<!--HTML-->
<!DOCTYPE html>
<style type= "text/css" >
div#create_group {
margin-left: 20px;
margin-top:10px;
margin-bottom:10px;
padding-top:10px;
padding-bottom:10px;
padding-left:10px;
padding-right:10px;
border:solid gray 1px;
width:470px;
border-radius: 0;
}
input#close {
margin-left:10px;
}
div.message {
margin-bottom:10px;
}
div.info {
color:green;
}
div.error {
color:red;
}
.hidden {
display:none;
}
a, a:visited { color: #0088CC; text-decoration: none; }
a:hover { color: #005580; text-decoration: underline; }
p { width: 640px; }
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
</style>
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
<!-- top menu links -->
<div style= "width:640px;" >
<p id= "number_selected" class= "tool_title_orange" style= "margin-left:20px;margin-top:20px\9;" >
Selected Profiles<p >
<p id= "canvas_help" style= "padding-left:20px" > </p>
<p class= "tool_body" style= "margin-left:20px; margin-bottom:10px;" >
<div id= "extended_functions" style= "display:none;" >
<a href= "" id= "create_group" > Create UCSF Chatter Group</a> |
2019-04-25 14:51:38 -07:00
<a href= "javascript:gadgetEventTrack('export_email');copyEmailDivToClipboard();" > Export email addresses only</a> |
2015-04-21 16:18:15 -04:00
<a href= "javascript:gadgetEventTrack('export_all_data');copyFullDivToClipboard();" > Export all data</a> |
<a href= "" id= "compose-email" > Compose email to list</a> <p >
</div>
<div id= "basic_functions" style= "display:none;" >
<a href= "" id= "create_group" > Create UCSF Chatter Group</a> |
</div>
<a href= "javascript:gadgetEventTrack('delete_list');deleteList();" style= "margin-left:20px;" > Delete list</a>
</p>
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
<p id= "progress" style= "margin-left:20px;" >
<br > <br >
<img src= "images/waiting.gif" >
<br > <br >
<b > This may take a minute or two, based on the size of your selected Profiles list.</b> </p>
</div>
<div id= "create_group" class= "hidden" >
2019-04-25 14:51:38 -07:00
<div class= "message hidden" > <strong > Success! Your UCSF Chatter group has been created.</strong> <br >
2015-04-21 16:18:15 -04:00
Go to UCSF Chatter to start working with your group.</div>
2019-04-25 14:51:38 -07:00
<table > <tr >
2015-04-21 16:18:15 -04:00
<td n o w r a p valign= "top" > UCSF Chatter Group Name:</td>
<td > <input id= "group_name" type= "text" style= "width:218px" > </input> <br > <br > </td> </tr> <tr >
<td n o w r a p valign= "top" align= "right" > Group Description:</td>
<td > <textarea id= "group_description" rows= "4" cols= "25" > </textarea> <br > <br > </td> </tr> <tr > <td > </td>
<td > <input id= "create" type= "button" value= "Create" > </input>
2019-04-25 14:51:38 -07:00
<input id= "close" type= "button" value= "Cancel/Close" > </input> </td> </tr> </table>
2015-04-21 16:18:15 -04:00
</div>
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
<div id= "canvas_email_list" style= "display:none; background:#FFF; width:670px; height:50px; margin-left:20px;" >
Copy and paste the email addresses below into an Excel spreadsheet or email client "To" field.
<input type= "button" style= "height:22px; font-size:10; margin-left:40px; margin-top: 6px;" value= "Close" onClick= "document.getElementById('canvas_email_list').style.display='none';document.getElementById('canvas_email_list_text').style.display='none';document.getElementById('canvas_profile_list').style.display='block';" > </button>
</div>
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
<!-- holds the email address list to be copied to the clipboard -->
<div id= "canvas_email_list_text" style= "display:none; width:658px; height:450px; color:#000; margin:0px 5px 0px 5px;" >
<textarea id= "canvas_email_list_textarea" rows= "27" cols= "78" style= "border:1px solid #000; margin: 0px 8px 0px 8px;" >
</textarea>
</div>
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
<div id= "canvas_full_list" style= "display:none; background:#FFF; width:640px; height:50px; margin-left: 20px;" >
Copy and paste the profile data below into an Excel spreadsheet or external text editor.
<input type= "button" style= "height:22px; font-size:10; margin-left:40px; margin-top: 6px;" value= "Close" onClick= "document.getElementById('canvas_full_list').style.display='none';document.getElementById('canvas_full_list_text').style.display='none';document.getElementById('canvas_profile_list').style.display='block';" > </button>
</div>
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
<!-- holds the full profile list to be copied to the clipboard -->
<div id= "canvas_full_list_text" style= "display:none; width:640px; height:450px; color:#000; margin:0px 5px 0px 5px;" >
<textarea id= "canvas_full_list_textarea" rows= "27" cols= "78" style= "border:1px solid #000; margin: 0px 8px 0px 8px;" >
</textarea>
2019-04-25 14:51:38 -07:00
</div>
2015-04-21 16:18:15 -04:00
<!-- holds the visible profile details list -->
<div id= "canvas_profile_list" style= "display:none; margin-left:20px; height:463px; height:443px\9; width: 660px; overflow:auto;" > </div>
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
<script type= "text/javascript" >
function init() {
// update UI
showToolVersion(true);
2019-04-25 14:51:38 -07:00
readIdsFromDB(displayProfileList);
2015-04-21 16:18:15 -04:00
document.getElementById("canvas_profile_list").style.display="block";
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
$("a#create_group").click(function(event){
event.preventDefault();
2019-04-25 14:51:38 -07:00
$("div.message").addClass("hidden");
2015-04-21 16:18:15 -04:00
$("div#create_group").removeClass("hidden");
2019-04-25 14:51:38 -07:00
});
2015-04-21 16:18:15 -04:00
$("input#close").click(function(event){
$("div#create_group").addClass("hidden");
});
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
$("input#create").click(function(event){
2019-04-25 14:51:38 -07:00
$("div.message").addClass("hidden");
2015-04-21 16:18:15 -04:00
var name = $("div#create_group input#group_name").val();
var description = $("div#create_group #group_description").val();
if(name == null || name == '') {
showMessage("Please enter a group name.", true);
}
2019-04-25 14:51:38 -07:00
else {
2015-04-21 16:18:15 -04:00
osapi.people.getViewer({ fields: ['id'] }).execute(function(result) {
var users = getUserList();
createGroup(name, description, getNodeIdFromURI(result.id), users);
2019-04-25 14:51:38 -07:00
});
2015-04-21 16:18:15 -04:00
}
});
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
$("#compose-email").click(function(event){
var emails = [];
var emailElem = $("td.email");
if(emailElem.size() > 50) {
if(!confirm("Only the first 50 email addresses can be used. If your list has more, please use the Export function and paste them into email. Do you want to proceed?")) {
event.preventDefault();
return false;
}
2019-04-25 14:51:38 -07:00
}
2015-04-21 16:18:15 -04:00
emailElem.each(function(index, elem) {
var email = $.trim($(elem).text());
if(email != '') {
emails.push(email);
}
if(emails.length >= 50) {
return false;
}
});
if(emails.length > 0) {
$(this).attr("href", "mailto:" + emails.join(';'));
}
});
}
2019-04-25 14:51:38 -07:00
2015-04-21 16:18:15 -04:00
gadgets.util.registerOnLoadHandler(init);
</script> ]]></Content>
2019-04-25 14:51:38 -07:00
</Module>