Last active
December 23, 2015 14:59
-
-
Save populov/6652916 to your computer and use it in GitHub Desktop.
Gadget for integrating Uservoice into your site, based on Google Sites.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Module> | |
<!-- See http://uservoice.com for Uservoice service description --> | |
<ModulePrefs | |
title="Uservoice for Google Sites" | |
title_url="https://code.google.com/p/google-sites-uservoice/" | |
description="Add support and feedback features provided by Uservoice service to your Google Site" | |
directory_title="Uservoice for Google Sites" | |
thumbnail="https://google-sites-uservoice.googlecode.com/git/gsuv-logo.png" | |
screenshot="https://google-sites-uservoice.googlecode.com/git/screen.png" | |
author="Serge Populov" | |
author_aboutme="Software Developer" | |
author_link="http://serge.populov.com/" | |
author_quote="Simple. Fucking Good." | |
author_photo="https://sites.google.com/a/populov.com/serge/home/photo.jpg" | |
author_location="Russia" | |
author_affiliation="Haunted Soft" | |
height="550" | |
width="100%" | |
scaling="false" | |
scrolling="false" | |
> | |
</ModulePrefs> | |
<UserPref | |
name="uv_id" | |
datatype="string" | |
display_name="Uservoice script ID" | |
default_value="pJSyCeGizQrpajcmlQ8ug" | |
required="true"/> | |
<UserPref | |
name="uv_forum_id" | |
datatype="string" | |
display_name="Forum ID (optional)" | |
default_value="" /> | |
<UserPref | |
name="uv_mode" | |
datatype="enum" | |
display_name="Widget mode" | |
default_value="full"> | |
<EnumValue value="full" display_value="Give feedback & Contact support"/> | |
<EnumValue value="feedback" display_value="Give feedback only"/> | |
<EnumValue value="support" display_value="Contact support only"/> | |
</UserPref> | |
<UserPref | |
name="uv_default_tab" | |
datatype="enum" | |
display_name="Default tab selection" | |
default_value="support"> | |
<EnumValue value="support" display_value="Contact support"/> | |
<EnumValue value="feedback" display_value="Give feedback"/> | |
</UserPref> | |
<UserPref | |
name="uv_primary_color" | |
datatype="string" | |
display_name="Primary color" | |
default_value="#cc6d00"/> | |
<UserPref | |
name="uv_link_color" | |
datatype="string" | |
display_name="Link color" | |
default_value="#007dbf"/> | |
<UserPref | |
name="uv_support_tab_name" | |
datatype="string" | |
display_name="Custom support tab name (optional)" | |
default_value=""/> | |
<UserPref | |
name="uv_feedback_tab_name" | |
datatype="string" | |
display_name="Custom feedback tab name (optional)" | |
default_value=""/> | |
<Content type="html" > | |
<![CDATA[ | |
<div id="uv_gadget">Loading. Please, wait a bit...</div> | |
<script> | |
(function () { | |
var prefs = new gadgets.Prefs(); | |
var uv_id = prefs.getString("uv_id"); | |
var hexColorPattern = /^\s*([abcdef\d]{6})\s*$/i; | |
function initPlaceholder() { | |
var forum_id = prefs.getString("uv_forum_id"); | |
var mode = prefs.getString("uv_mode"); | |
var default_mode = prefs.getString("uv_default_tab"); | |
var primary_color = getColor("uv_primary_color"); | |
var link_color = getColor("uv_link_color"); | |
var support_tab_name = prefs.getString("uv_support_tab_name"); | |
var feedback_tab_name = prefs.getString("uv_feedback_tab_name"); | |
ug = document.getElementById("uv_gadget"); | |
ug.setAttribute("data-uv-inline", "classic_widget"); | |
if (forum_id) | |
ug.setAttribute("data-uv-forum-id", forum_id); | |
ug.setAttribute("data-uv-mode", mode); | |
if (mode == "full") | |
ug.setAttribute("data-uv-default-mode", default_mode); | |
if (support_tab_name) | |
ug.setAttribute("data-uv-support-tab_name", support_tab_name); | |
if (feedback_tab_name) | |
ug.setAttribute("data-uv-feedback-tab_name", feedback_tab_name); | |
ug.setAttribute("data-uv-primary-color", primary_color); | |
ug.setAttribute("data-uv-link-color", link_color); | |
ug.setAttribute("data-uv-width", "100%"); | |
ug.setAttribute("data-uv-height", "100%"); | |
} | |
// UserVoice JavaScript SDK (only needed once on a page) | |
function injectUservoiceScript() { | |
var uv = document.createElement('script'); | |
uv.type = 'text/javascript'; | |
uv.async = true; | |
uv.src = (document.location.protocol.substring(0, 5) == "https" ? 'https' : 'http') + '://widget.uservoice.com/' + uv_id + '.js'; | |
var s = document.getElementsByTagName('script')[0]; | |
s.parentNode.insertBefore(uv, s); | |
} | |
function getColor(color_target) { | |
var value = prefs.getString(color_target); | |
if (value == null || value == "") | |
return null; | |
var matches = hexColorPattern.exec(value); | |
if (matches != null && matches.length > 0) | |
return "#" + matches[1]; | |
else | |
return value; | |
} | |
initPlaceholder(); | |
injectUservoiceScript(); | |
})(); | |
</script> | |
]]> | |
</Content> | |
</Module> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment