Version Notes
- optionally remove trailing slash from embed URL
Download this release
Release Info
Developer | Magento Core Team |
Extension | Fanplayr |
Version | 1.0.48 |
Comparing to | |
See all releases |
Version 1.0.48
- app/code/community/Fanplayr/Socialcoupons/Block/Adminhtml/System/Config/Form/Field/Installhelper.php +441 -0
- app/code/community/Fanplayr/Socialcoupons/Model/CartObserver.php +89 -0
- app/code/community/Fanplayr/Socialcoupons/Model/EmbedObserver.php +637 -0
- app/code/community/Fanplayr/Socialcoupons/Model/OrderObserver.php +349 -0
- app/code/community/Fanplayr/Socialcoupons/controllers/AjaxController.php +116 -0
- app/code/community/Fanplayr/Socialcoupons/controllers/CompyController.php +750 -0
- app/code/community/Fanplayr/Socialcoupons/controllers/CouponController.php +191 -0
- app/code/community/Fanplayr/Socialcoupons/controllers/IndexController.php +24 -0
- app/code/community/Fanplayr/Socialcoupons/etc/config.xml +178 -0
- app/code/community/Fanplayr/Socialcoupons/etc/system.xml +67 -0
- app/design/frontend/base/default/template/fanplayr/embed.phtml +122 -0
- app/design/frontend/base/default/template/fanplayr/embed_ajax.phtml +32 -0
- app/design/frontend/base/default/template/fanplayr/success.phtml +157 -0
- app/design/frontend/default/default/template/fanplayr/embed.phtml +122 -0
- app/design/frontend/default/default/template/fanplayr/embed_ajax.phtml +32 -0
- app/design/frontend/default/default/template/fanplayr/success.phtml +157 -0
- app/etc/modules/Fanplayr_Socialcoupons.xml +10 -0
- package.xml +18 -0
- skin/frontend/socialcoupons/fanplayr_join.html +42 -0
- skin/frontend/socialcoupons/fanplayr_socialcoupons.css +298 -0
- skin/frontend/socialcoupons/fanplayr_socialcoupons.js +591 -0
- skin/frontend/socialcoupons/fanplayr_socialcoupons.min.css +39 -0
- skin/frontend/socialcoupons/images/.picasa.ini +2 -0
- skin/frontend/socialcoupons/images/accept.png +0 -0
- skin/frontend/socialcoupons/images/activity.gif +0 -0
- skin/frontend/socialcoupons/images/disable.png +0 -0
- skin/frontend/socialcoupons/images/fanplayr_logo.png +0 -0
- skin/frontend/socialcoupons/images/genius_16.png +0 -0
- skin/frontend/socialcoupons/images/pencil.png +0 -0
- skin/frontend/socialcoupons/images/progress-loader.gif +0 -0
- skin/frontend/socialcoupons/images/sales_16.png +0 -0
- skin/frontend/socialcoupons/images/star_gold.png +0 -0
- skin/frontend/socialcoupons/images/warning.png +0 -0
- skin/frontend/socialcoupons/jquery-1.7.2.min.js +4 -0
app/code/community/Fanplayr/Socialcoupons/Block/Adminhtml/System/Config/Form/Field/Installhelper.php
ADDED
@@ -0,0 +1,441 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Fanplayr_Socialcoupons_Block_Adminhtml_System_Config_Form_Field_Installhelper extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
+
{
|
5 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
6 |
+
{
|
7 |
+
|
8 |
+
// ------------------------------------------------------------------------
|
9 |
+
// get local details
|
10 |
+
$secret = Mage::getStoreConfig('fanplayrsocialcoupons/config/secret');
|
11 |
+
$secretInner = Mage::getStoreConfig('fanplayrsocialcoupons/config/secret_inner');
|
12 |
+
$accKey = Mage::getStoreConfig('fanplayrsocialcoupons/config/acc_key');
|
13 |
+
$shopId = Mage::getStoreConfig('fanplayrsocialcoupons/config/shop_id');
|
14 |
+
|
15 |
+
if (empty($secret)) {
|
16 |
+
$secret = md5(uniqid("Things are fine, seriously. I love this!", true));
|
17 |
+
$this->updateConfig('fanplayrsocialcoupons/config/secret', $secret);
|
18 |
+
}
|
19 |
+
if (empty($secretInner)) {
|
20 |
+
$secretInner = md5(uniqid("And other things are great ...", true));
|
21 |
+
$this->updateConfig('fanplayrsocialcoupons/config/secret_inner', $secretInner);
|
22 |
+
}
|
23 |
+
|
24 |
+
// default some others
|
25 |
+
$prefix = Mage::getStoreConfig('fanplayrsocialcoupons/config/dep_prefix');
|
26 |
+
if (empty($prefix)) {
|
27 |
+
$this->updateConfig('fanplayrsocialcoupons/config/dep_prefix', 'F2P9P31R_');
|
28 |
+
}
|
29 |
+
|
30 |
+
// setup vars in case we need 'em
|
31 |
+
// ------------------------------------------------------------------------
|
32 |
+
// get current admin user info
|
33 |
+
$userId = Mage::getSingleton('admin/session')->getUser()->getId();
|
34 |
+
$user = Mage::getModel('admin/user')->load($userId);
|
35 |
+
$userData = $user->getData();
|
36 |
+
|
37 |
+
// get details to send along ...
|
38 |
+
$firstname = array_key_exists('firstname', $userData) ? $userData['firstname'] : '';
|
39 |
+
$lastname = array_key_exists('lastname', $userData) ? $userData['lastname'] : '';
|
40 |
+
$email = array_key_exists('email', $userData) ? $userData['email'] : '';
|
41 |
+
$shopUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
42 |
+
|
43 |
+
$customShopUrl = Mage::getStoreConfig('fanplayrsocialcoupons/config/custom_url');
|
44 |
+
$customShopUrlUsed = true;
|
45 |
+
if (empty($customShopUrl)) {
|
46 |
+
$customShopUrlUsed = false;
|
47 |
+
$customShopUrl = $shopUrl;
|
48 |
+
}
|
49 |
+
$shopUrl = $customShopUrl;
|
50 |
+
|
51 |
+
$customEmbedUrl = Mage::getStoreConfig('fanplayrsocialcoupons/config/custom_embed_url');
|
52 |
+
|
53 |
+
$shopName = Mage::getStoreConfig('general/store_information/name');
|
54 |
+
$shopPhone = Mage::getStoreConfig('general/store_information/phone');
|
55 |
+
$shopAddress = Mage::getStoreConfig('general/store_information/address');
|
56 |
+
$shopCountry = Mage::getStoreConfig('general/country/default');
|
57 |
+
$shopTz = Mage::getStoreConfig('general/locale/timezone');
|
58 |
+
|
59 |
+
$adminUrlFull = Mage::helper('adminhtml')->getUrl('/');
|
60 |
+
$adminUrl = substr($adminUrlFull, 0, strpos($adminUrlFull, 'index/index'));
|
61 |
+
|
62 |
+
// add index.php to shop URL, just in case they don't have URL rewriting ong
|
63 |
+
if (!$customShopUrlUsed){
|
64 |
+
if (!strpos($shopUrl, 'index.php/'))
|
65 |
+
$shopUrl .= 'index.php/';
|
66 |
+
}
|
67 |
+
|
68 |
+
$logoSrc = 'http://localhost/magento/skin/frontend/default/default/' . Mage::getStoreConfig('design/header/logo_src');
|
69 |
+
$skinDir = Mage::getBaseUrl('skin').'frontend/socialcoupons';
|
70 |
+
|
71 |
+
$queryString = 'secret=' . urlencode($secret);
|
72 |
+
$queryString .= '&email=' . urlencode($email);
|
73 |
+
$queryString .= '&name=' . urlencode($firstname . ' ' . $lastname);
|
74 |
+
$queryString .= '&shopUrl=' . urlencode($shopUrl);
|
75 |
+
$queryString .= '&shopName=' . urlencode($shopName);
|
76 |
+
$queryString .= '&adminUrl=' . urlencode($adminUrl);
|
77 |
+
|
78 |
+
$queryString .= '&phone=' . urlencode($shopPhone);
|
79 |
+
//$queryString .= '&address=' . urlencode($shopAddress);
|
80 |
+
$queryString .= '&address=';
|
81 |
+
$queryString .= '&country=' . urlencode($shopCountry);
|
82 |
+
$queryString .= '&tz=' . urlencode($shopTz);
|
83 |
+
|
84 |
+
$queryString .= '&authUser=' . urlencode(array_key_exists('PHP_AUTH_USER', $_SERVER) ? $_SERVER['PHP_AUTH_USER'] : '');
|
85 |
+
$queryString .= '&authPass=' . urlencode(array_key_exists('PHP_AUTH_PW', $_SERVER) ? $_SERVER['PHP_AUTH_PW'] : '');
|
86 |
+
|
87 |
+
// setup our general always needed HTML
|
88 |
+
// ------------------------------------------------------------------------
|
89 |
+
$mageVersion = Mage::getVersion();
|
90 |
+
|
91 |
+
$gamafiedKeys = htmlspecialchars(Mage::getStoreConfig('fanplayrsocialcoupons/config/widget_keys'));
|
92 |
+
$sntKeys = htmlspecialchars(Mage::getStoreConfig('fanplayrsocialcoupons/config/widget_keys_genius'));
|
93 |
+
$disableOnUrls = htmlspecialchars(Mage::getStoreConfig('fanplayrsocialcoupons/config/disable_on_urls'));
|
94 |
+
|
95 |
+
$depPrefix = htmlspecialchars(Mage::getStoreConfig('fanplayrsocialcoupons/config/dep_prefix'));
|
96 |
+
$depRoutes = htmlspecialchars(Mage::getStoreConfig('fanplayrsocialcoupons/config/dep_extra_rewrite_routes'));
|
97 |
+
$gtmContainerId = htmlspecialchars(Mage::getStoreConfig('fanplayrsocialcoupons/config/gtm_container_id'));
|
98 |
+
$trailingSlash = htmlspecialchars(Mage::getStoreConfig('fanplayrsocialcoupons/config/trailing_slash'));
|
99 |
+
|
100 |
+
// have to use this variable for backwards compatability ...
|
101 |
+
$currentEmbedType = htmlspecialchars(Mage::getStoreConfig('fanplayrsocialcoupons/config/wait_for_onload'));
|
102 |
+
if (!$currentEmbedType) $currentEmbedType = '0';
|
103 |
+
$embedOptions = '';
|
104 |
+
$embedOptions .= '<option value="0"'.($currentEmbedType=='0'||!$currentEmbedType?' selected':'').'>Defered Script: Normal</option>';
|
105 |
+
$embedOptions .= '<option value="1"'.($currentEmbedType=='1'?' selected':'').'>Defered Script: Lazy Loading</option>';
|
106 |
+
$embedOptions .= '<option value="2"'.($currentEmbedType=='2'?' selected':'').'>Tag Management System (User Only)</option>';
|
107 |
+
$embedOptions .= '<option value="3"'.($currentEmbedType=='3'?' selected':'').'>Tag Management System (User & Order)</option>';
|
108 |
+
$embedOptions .= '<option value="4"'.($currentEmbedType=='4'?' selected':'').'>Direct Embed</option>';
|
109 |
+
$embedOptions .= '<option value="5"'.($currentEmbedType=='5'?' selected':'').'>Direct Embed: Lazy Loading</option>';
|
110 |
+
$embedOptions .= '<option value="6"'.($currentEmbedType=='6'?' selected':'').'>Google Tag Manager</option>';
|
111 |
+
$embedOptions .= '<option value="6"'.($currentEmbedType=='7'?' selected':'').'>Google Tag Manager (Universal Analytics Enhanced Ecommerce)</option>';
|
112 |
+
|
113 |
+
$currentLayoutHookHome = Mage::getStoreConfig('fanplayrsocialcoupons/config/layout_hook_home');
|
114 |
+
if (!$currentLayoutHookHome) $currentLayoutHookHome = 'content';
|
115 |
+
$layoutHooksHome = '';
|
116 |
+
$layoutHooksHome .= '<option value="content"'.($currentLayoutHookHome=='content'?' selected':'').'>content</option>';
|
117 |
+
$layoutHooksHome .= '<option value="footer.before"'.($currentLayoutHookHome=='footer.before'?' selected':'').'>footer.before</option>';
|
118 |
+
$layoutHooksHome .= '<option value="before_body_end"'.($currentLayoutHookHome=='before_body_end'?' selected':'').'>before_body_end</option>';
|
119 |
+
|
120 |
+
$currentLayoutHook = Mage::getStoreConfig('fanplayrsocialcoupons/config/layout_hook');
|
121 |
+
if (!$currentLayoutHook) $currentLayoutHook = 'content';
|
122 |
+
$layoutHooks = '';
|
123 |
+
$layoutHooks .= '<option value="content"'.($currentLayoutHook=='content'?' selected':'').'>content</option>';
|
124 |
+
$layoutHooks .= '<option value="footer.before"'.($currentLayoutHook=='footer.before'?' selected':'').'>footer.before</option>';
|
125 |
+
$layoutHooks .= '<option value="before_body_end"'.($currentLayoutHook=='before_body_end'?' selected':'').'>before_body_end</option>';
|
126 |
+
|
127 |
+
$currentLayoutHookOrder = Mage::getStoreConfig('fanplayrsocialcoupons/config/layout_hook_order');
|
128 |
+
if (!$currentLayoutHookOrder) $currentLayoutHookOrder = 'content';
|
129 |
+
$layoutHooksOrder = '';
|
130 |
+
$layoutHooksOrder .= '<option value="content"'.($currentLayoutHookOrder=='content'?' selected':'').'>content</option>';
|
131 |
+
$layoutHooksOrder .= '<option value="footer.before"'.($currentLayoutHookOrder=='footer.before'?' selected':'').'>footer.before</option>';
|
132 |
+
$layoutHooksOrder .= '<option value="before_body_end"'.($currentLayoutHookOrder=='before_body_end'?' selected':'').'>before_body_end</option>';
|
133 |
+
|
134 |
+
$customShopUrlEdit = (empty($accKey) && empty($customShopUrl)) ? $shopUrl : $customShopUrl;
|
135 |
+
|
136 |
+
// ------------------------------------------------------------------------
|
137 |
+
// check that all themes have FP templates!
|
138 |
+
|
139 |
+
// we may need to add Fanplayr templates to other directories
|
140 |
+
// is this just for default though?
|
141 |
+
$templatesWithNoFanplayr = array();
|
142 |
+
|
143 |
+
foreach(array(getcwd().'/app/design/frontend/default/', getcwd().'/app/design/frontend/enterprise/') as $path) {
|
144 |
+
$dir = opendir($path);
|
145 |
+
while($d = readdir($dir)){
|
146 |
+
if (is_dir($path . $d) && $d != '.' && $d != '..') {
|
147 |
+
if (is_dir($path . $d . '/template') && !is_dir($path . $d . '/template/fanplayr')){
|
148 |
+
array_push($templatesWithNoFanplayr, $d);
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
// ------------------------------------------------------------------------
|
155 |
+
|
156 |
+
$generalHtml = <<<EOT
|
157 |
+
<script>
|
158 |
+
var c = document.createElement("link");
|
159 |
+
c.setAttribute("rel", "stylesheet");
|
160 |
+
c.setAttribute("type", "text/css");
|
161 |
+
c.setAttribute("href", '{$skinDir}/fanplayr_socialcoupons.css');
|
162 |
+
document.getElementsByTagName("head")[0].appendChild(c);
|
163 |
+
</script>
|
164 |
+
<script type="text/javascript" src="{$skinDir}/jquery-1.7.2.min.js"></script>
|
165 |
+
<script type="text/javascript" src="{$skinDir}/fanplayr_socialcoupons.js"></script>
|
166 |
+
<script>
|
167 |
+
$.noConflict()(function($) {
|
168 |
+
// remove unneeded TDs, we want all the space!
|
169 |
+
// hope this is OK with the "Magento Way"?
|
170 |
+
// v1.4.1 and above
|
171 |
+
|
172 |
+
$('#row_fanplayrsocialcoupons_config_installed td:eq(0)').remove();
|
173 |
+
$('#row_fanplayrsocialcoupons_config_installed td.scope-label').remove();
|
174 |
+
//$('#row_fanplayrsocialcoupons_config_installed td:eq(2)').remove();
|
175 |
+
//$('#row_fanplayrsocialcoupons_config_installed td').css('width', 'auto');
|
176 |
+
|
177 |
+
if ("{$mageVersion}" == "1.4.0"){
|
178 |
+
// for v1.4.0
|
179 |
+
$('#fanplayrsocialcoupons_config td:eq(0)').remove();
|
180 |
+
$('#fanplayrsocialcoupons_config td:eq(1)').remove();
|
181 |
+
$('#fanplayrsocialcoupons_config td:eq(1)').remove();
|
182 |
+
$('#fanplayrsocialcoupons_config td').css('width', 'auto');
|
183 |
+
}
|
184 |
+
|
185 |
+
var fieldSet = fanplayrJQuery('#fanplayrsocialcoupons_config-head');
|
186 |
+
if (!fieldSet.hasClass('open')) {
|
187 |
+
// open it automatically !
|
188 |
+
try {
|
189 |
+
var a = fieldSet.attr('onclick');
|
190 |
+
eval(a.substr(0, a.indexOf('return')));
|
191 |
+
}catch(e){}
|
192 |
+
}
|
193 |
+
|
194 |
+
// set up some vars we need
|
195 |
+
Fanplayr.configAccKey = "{$accKey}";
|
196 |
+
Fanplayr.configSecret = "{$secret}";
|
197 |
+
Fanplayr.configSecretInner = "{$secretInner}";
|
198 |
+
Fanplayr.configShopId = "{$shopId}";
|
199 |
+
Fanplayr.configShopUrl = "{$shopUrl}";
|
200 |
+
});
|
201 |
+
</script>
|
202 |
+
<div id="fanplayrsocialcoupons-console" style="display:none;">
|
203 |
+
<div>
|
204 |
+
<p>Please be very careful when editing these values manually. Not for the faint of heart.</p>
|
205 |
+
<p>Disable on URLs: please provide a comma separated list of URLs on which to disable Fanplayr. By default Fanplayr is disabled for URLs containing "/checkout/onepage/" and "/checkout/multishipping/".</p>
|
206 |
+
<p>Embed Type: Do not use "Direct Embed" if you are using a Full Page Cache.</p>
|
207 |
+
</div>
|
208 |
+
<table>
|
209 |
+
<tr><td><label></label></td><td></td></tr>
|
210 |
+
<tr><td><label>Custom URL</label></td><td><input type="text" id="fanplayrsocialcoupons-console-url" name="fanplayrsocialcoupons-console-url" value="{$customShopUrlEdit}" /></td></tr>
|
211 |
+
<tr><td><label>Account Key</label></td><td><input type="text" id="fanplayrsocialcoupons-console-acckey" name="fanplayrsocialcoupons-console-acckey" value="{$accKey}" /></td></tr>
|
212 |
+
<tr><td><label>Secret</label></td><td><input type="text" id="fanplayrsocialcoupons-console-secret" name="fanplayrsocialcoupons-console-secret" value="{$secret}" /></td></tr>
|
213 |
+
<tr><td><label>Shop ID</label></td><td><input type="text" id="fanplayrsocialcoupons-console-shopid" name="fanplayrsocialcoupons-console-shopid" value="{$shopId}" /></td></tr>
|
214 |
+
<tr><td><label>Gamafied</label></td><td><input type="text" id="fanplayrsocialcoupons-console-gamafied" name="fanplayrsocialcoupons-console-gamafied" value="{$gamafiedKeys}" /></td></tr>
|
215 |
+
<tr><td><label>S & T</label></td><td><input type="text" id="fanplayrsocialcoupons-console-snt" name="fanplayrsocialcoupons-console-snt" value="{$sntKeys}" /></td></tr>
|
216 |
+
<tr><td><label>Disable on URLs</label></td><td><input type="text" id="fanplayrsocialcoupons-console-disableonurls" name="fanplayrsocialcoupons-console-disableonurls" value="{$disableOnUrls}" /></td></tr>
|
217 |
+
<tr><td><label>Embed Type</label></td><td><select size="1" id="fanplayrsocialcoupons-console-embedtype" name="fanplayrsocialcoupons-console-embedtype">{$embedOptions}</select></td></tr>
|
218 |
+
<tr><td><label>Layout Hook (User: Home)</label></td><td><select size="1" id="fanplayrsocialcoupons-console-layouthookhome" name="fanplayrsocialcoupons-console-layouthookhome">{$layoutHooksHome}</select></td></tr>
|
219 |
+
<tr><td><label>Layout Hook (User: Other)</label></td><td><select size="1" id="fanplayrsocialcoupons-console-layouthook" name="fanplayrsocialcoupons-console-layouthook">{$layoutHooks}</select></td></tr>
|
220 |
+
<tr><td><label>Layout Hook (Order)</label></td><td><select size="1" id="fanplayrsocialcoupons-console-layouthookorder" name="fanplayrsocialcoupons-console-layouthookorder">{$layoutHooksOrder}</select></td></tr>
|
221 |
+
<tr><td colspan="2"><small>Please note this may cause problems on multi-site if you use different "websites".</small></td></tr>
|
222 |
+
<tr><td><label>Custom Embed URL</label></td><td><input type="text" id="fanplayrsocialcoupons-console-customembedurl" name="fanplayrsocialcoupons-console-customembedurl" value="{$customEmbedUrl}" /></td></tr>
|
223 |
+
|
224 |
+
<tr><td colspan="2"><b>Deputization</b></td></tr>
|
225 |
+
<tr><td><label>Prefix</label></td><td><input type="text" id="fanplayrsocialcoupons-console-depprefix" name="fanplayrsocialcoupons-console-depprefix" value="{$depPrefix}" /></td></tr>
|
226 |
+
<tr><td><label>Extra Routes</label></td><td><input type="text" id="fanplayrsocialcoupons-console-deproutes" name="fanplayrsocialcoupons-console-deproutes" value="{$depRoutes}" /></td></tr>
|
227 |
+
<tr><td><label>GTM Container Public ID</label></td><td><input type="text" id="fanplayrsocialcoupons-console-gtmcontainerid" name="fanplayrsocialcoupons-console-gtmcontainerid" value="{$gtmContainerId}" /></td></tr>
|
228 |
+
<tr><td><label>Trailing Slash (0 == no)</label></td><td><input type="text" id="fanplayrsocialcoupons-console-trailingslash" name="fanplayrsocialcoupons-console-trailingslash" value="{$trailingSlash}" /></td></tr>
|
229 |
+
|
230 |
+
<tr><td colspan="2"><a href="#" id="fanplayrsocialcoupons-console-save" onclick="Fanplayr.console.save(); return false;">Save</a> <a href="#" id="fanplayrsocialcoupons-console-hide" onclick="Fanplayr.console.hide(); return false;">Hide</a></td></tr>
|
231 |
+
</table>
|
232 |
+
<div id="fanplayrsocialcoupons-console-saving" style="display: none;"><b>Please be patient, saving ...</b></div>
|
233 |
+
</div>
|
234 |
+
EOT;
|
235 |
+
if (array_key_exists('fanplayrsocialcoupons-console-display', $_COOKIE) && $_COOKIE['fanplayrsocialcoupons-console-display'] == 'show') {
|
236 |
+
$generalHtml .= <<< EOT
|
237 |
+
<script>
|
238 |
+
document.getElementById('fanplayrsocialcoupons-console').style.display = 'block';
|
239 |
+
</script>
|
240 |
+
EOT;
|
241 |
+
}
|
242 |
+
|
243 |
+
// actual logic time !
|
244 |
+
// ------------------------------------------------------------------------
|
245 |
+
|
246 |
+
// the HTML to output to the admin control
|
247 |
+
$ouputHtml = '';
|
248 |
+
|
249 |
+
if (empty($secret) || empty($accKey) || empty($shopId)) {
|
250 |
+
|
251 |
+
// our install HTML
|
252 |
+
$installHtml = <<<EOT
|
253 |
+
<script>
|
254 |
+
fanplayrJQuery().ready(function() {
|
255 |
+
var $ = fanplayrJQuery;
|
256 |
+
var fanplayrInstallModal = new FanplayrModal('fanplayr_install_modal');
|
257 |
+
$('#fanplayr-install-button').on('click', function(e) {
|
258 |
+
e.preventDefault();
|
259 |
+
fanplayrInstallModal.load('{$skinDir}/fanplayr_join.html?{$queryString}');
|
260 |
+
});
|
261 |
+
});
|
262 |
+
</script>
|
263 |
+
<div id="fanplayr-install-wrapper">
|
264 |
+
<p>
|
265 |
+
<img src="{$skinDir}/images/fanplayr_logo.png" width="200" height="65" alt="Fanplayr Logo" title="Fanplayr" />
|
266 |
+
</p>
|
267 |
+
<div id="fanplayr-install-description">
|
268 |
+
<p>Welcome to Fanplayr, the leader in targeted conversions.</p>
|
269 |
+
<p>Click on the button below to get started by linking your Fanplayr account to your Magento Store. If you don't have an account yet you will have a chance to create one. Easy!</p>
|
270 |
+
</div>
|
271 |
+
<a href="#" id="fanplayr-install-button"><div class="fanplayr-icon fanplayr-add"></div>Link to Fanplayr</a>
|
272 |
+
</div>
|
273 |
+
EOT;
|
274 |
+
$outputHtml = $installHtml;
|
275 |
+
} else {
|
276 |
+
$errorGettingInstallData = false;
|
277 |
+
try {
|
278 |
+
$m = json_decode($this->httpGetContent('http://my.fanplayr.com/api.magentoCheckInstall/', array(
|
279 |
+
'acc_key' => $accKey,
|
280 |
+
'shop_id' => $shopId,
|
281 |
+
'secret' => $secret,
|
282 |
+
'version' => $this->getExtensionVersion()
|
283 |
+
)));
|
284 |
+
}catch (Exception $e) {
|
285 |
+
$errorGettingInstallData = true;
|
286 |
+
}
|
287 |
+
if (!$m) $errorGettingInstallData = true;
|
288 |
+
|
289 |
+
// just give 'em an error
|
290 |
+
if ($errorGettingInstallData) {
|
291 |
+
$outputHtml = 'Sorry, there was an error getting information about your installation. Please refresh to try again.';
|
292 |
+
}else{
|
293 |
+
// the server said there was an error
|
294 |
+
if ($m->error) {
|
295 |
+
$outputHtml = 'ERROR: ' . $m->message . ' - This may be due to a wrongly linked account. To unlink your account and try again <a href="#" onclick="Fanplayr.unlink();">click here</a>.';
|
296 |
+
// all is good, let's continue!
|
297 |
+
}else{
|
298 |
+
|
299 |
+
// if it's a new version warn 'em!
|
300 |
+
$newVersionWarningHtml = '';
|
301 |
+
|
302 |
+
if ($m->newVersion) {
|
303 |
+
$newVersionWarningHtml = $m->newVersion;
|
304 |
+
}
|
305 |
+
|
306 |
+
try {
|
307 |
+
$campData = addslashes($this->httpGetContent('http://my.fanplayr.com/api.magentoGetCampaigns/all/1/', array(
|
308 |
+
'acc_key' => $accKey,
|
309 |
+
'shop_id' => $shopId,
|
310 |
+
'secret' => $secret,
|
311 |
+
'version' => $this->getExtensionVersion()
|
312 |
+
)));
|
313 |
+
} catch (Exception $e) {
|
314 |
+
$campData = '';
|
315 |
+
}
|
316 |
+
|
317 |
+
$outputHtml = '';
|
318 |
+
|
319 |
+
if ($newVersionWarningHtml){
|
320 |
+
$outputHtml .= '<div id="fanplayr-new-version">' . $newVersionWarningHtml . '</div>';
|
321 |
+
}else {
|
322 |
+
$outputHtml .= '';
|
323 |
+
}
|
324 |
+
|
325 |
+
$outputHtml .= "<script> fanplayrCampData = null; try { fanplayrCampData = ";
|
326 |
+
$outputHtml .= $campData == '' ? 'null;' : 'fanplayrJQuery.parseJSON("'.$campData.'");';
|
327 |
+
$outputHtml .= "} catch(e){} </script>";
|
328 |
+
|
329 |
+
if (count($templatesWithNoFanplayr)) {
|
330 |
+
$outputHtml .= '<div id="fanplayr-template-warning"><span>'.count($templatesWithNoFanplayr).'</span> Magento templates do not include Fanplayr templates. This could cause Fanplayr to incorrectly track visitors on some or all pages. Please click the "Add Templates" button below.<br /><br />Optionally, you can do this manually by copying the Fanplayr templates from /app/design/frontend/base/default/template/fanplayr into the Magento templates in question.';
|
331 |
+
$outputHtml .= '<br /><br /><button onclick="Fanplayr.addTemplates(); return false;" id="fanplayr-template-warning-add" title="Add Templates" type="button" class="scalable save"><span>Add Templates</span></button>';
|
332 |
+
$outputHtml .= '</div>';
|
333 |
+
}
|
334 |
+
|
335 |
+
$outputHtml .= <<<EOT
|
336 |
+
<script>
|
337 |
+
fanplayrJQuery().ready(function() {
|
338 |
+
var $ = fanplayrJQuery;
|
339 |
+
|
340 |
+
$('#fanplayr-none-wrapper, #fanplayr-draft-wrapper, #fanplayr-head-wrapper').css('display','none');
|
341 |
+
|
342 |
+
Fanplayr.fillCampaignList($('#fanplayr-campaign-list'), fanplayrCampData);
|
343 |
+
|
344 |
+
if (Fanplayr.hasDraftCampaigns || Fanplayr.hasPublishedCampaigns || Fanplayr.hasRunningCampaigns) {
|
345 |
+
if (Fanplayr.hasPublishedCampaigns || Fanplayr.hasRunningCampaigns) {
|
346 |
+
$('#fanplayr-head-wrapper').css('display', 'block');
|
347 |
+
}else {
|
348 |
+
$('#fanplayr-draft-wrapper').css('display', 'block');
|
349 |
+
}
|
350 |
+
}
|
351 |
+
});
|
352 |
+
function refreshPage() {
|
353 |
+
window.location.reload();
|
354 |
+
}
|
355 |
+
</script>
|
356 |
+
|
357 |
+
<div id="fanplayr-none-wrapper">
|
358 |
+
<p>
|
359 |
+
<img src="{$skinDir}/images/fanplayr_logo.png" width="200" height="65" alt="Fanplayr Logo" title="Fanplayr" />
|
360 |
+
</p>
|
361 |
+
<div id="fanplayr-none-description">
|
362 |
+
<p>Your Store has been linked to Fanplayr, but you still need to create a campaign. Click below to get started.</p>
|
363 |
+
<p>You will have to <a href="#" onclick="refreshPage();">refresh</a> the page to see campaigns once you have created them.</p>
|
364 |
+
</div>
|
365 |
+
<a href="http://my.fanplayr.com/login/" id="fanplayr-start-button" target="_blank"><div class="fanplayr-icon fanplayr-icon-star"></div>Create a Fanplayr Campaign</a>
|
366 |
+
</div>
|
367 |
+
<script>
|
368 |
+
fanplayrJQuery().ready(function() {
|
369 |
+
if (fanplayrCampData == null || fanplayrCampData.campaigns.length == 0)
|
370 |
+
fanplayrJQuery('#fanplayr-none-wrapper').css('display', 'block');
|
371 |
+
});
|
372 |
+
</script>
|
373 |
+
|
374 |
+
<div id="fanplayr-draft-wrapper">
|
375 |
+
<p>
|
376 |
+
<img src="{$skinDir}/images/fanplayr_logo.png" width="200" height="65" alt="Fanplayr Logo" title="Fanplayr" />
|
377 |
+
</p>
|
378 |
+
<div id="fanplayr-draft-description">
|
379 |
+
<p>You've got a campaign but it's not quite ready to show on your store. Edit a current campaign, and once it's published you can show it on your Store.</p>
|
380 |
+
</div>
|
381 |
+
</div>
|
382 |
+
|
383 |
+
<div id="fanplayr-head-wrapper">
|
384 |
+
<p>
|
385 |
+
<img src="{$skinDir}/images/fanplayr_logo.png" width="200" height="65" alt="Fanplayr Logo" title="Fanplayr" />
|
386 |
+
</p>
|
387 |
+
<div id="fanplayr-head-description">
|
388 |
+
<p>Awesome. Looks like there's campaigns that can be running on the store!</p>
|
389 |
+
</div>
|
390 |
+
</div>
|
391 |
+
|
392 |
+
<table cellspacing="0" id="fanplayr-campaign-list"></table>
|
393 |
+
EOT;
|
394 |
+
}
|
395 |
+
}
|
396 |
+
}
|
397 |
+
|
398 |
+
//
|
399 |
+
// Return
|
400 |
+
return $generalHtml . $outputHtml;
|
401 |
+
}
|
402 |
+
|
403 |
+
// -------------------------------------------------------------------------
|
404 |
+
// helpers
|
405 |
+
|
406 |
+
private function getExtensionVersion()
|
407 |
+
{
|
408 |
+
return (string) Mage::getConfig()->getNode()->modules->Fanplayr_Socialcoupons->version;
|
409 |
+
}
|
410 |
+
|
411 |
+
// postVars as k/v array OR
|
412 |
+
private function httpGetContent($url, $vars = null)
|
413 |
+
{
|
414 |
+
$ch = curl_init();
|
415 |
+
|
416 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
417 |
+
curl_setopt($ch, CURLOPT_HEADER, 0);
|
418 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ;
|
419 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
420 |
+
|
421 |
+
if ($vars != null) {
|
422 |
+
// WTF ?
|
423 |
+
if (is_array($vars)) $vars = str_replace('&', '&', http_build_query($vars));
|
424 |
+
//curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
|
425 |
+
//curl_setopt($ch, CURLOPT_POST, 1);
|
426 |
+
curl_setopt($ch, CURLOPT_URL, $url.'?'.$vars);
|
427 |
+
}
|
428 |
+
|
429 |
+
$r = curl_exec($ch);
|
430 |
+
curl_close($ch);
|
431 |
+
|
432 |
+
return $r;
|
433 |
+
}
|
434 |
+
|
435 |
+
public function updateConfig($key, $value)
|
436 |
+
{
|
437 |
+
Mage::getConfig()->saveConfig($key, $value);
|
438 |
+
Mage::getConfig()->reinit();
|
439 |
+
Mage::app()->reinitStores();
|
440 |
+
}
|
441 |
+
}
|
app/code/community/Fanplayr/Socialcoupons/Model/CartObserver.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Fanplayr_Socialcoupons_Model_CartObserver
|
3 |
+
{
|
4 |
+
public $hasSucceeded;
|
5 |
+
|
6 |
+
public function checkSavedCouponAction()
|
7 |
+
{
|
8 |
+
$couponCode = Mage::getSingleton('core/session')->getData('fanplayr_coupon');
|
9 |
+
|
10 |
+
if ($couponCode) {
|
11 |
+
$this->applyCoupon($couponCode);
|
12 |
+
if ($this->hasSucceeded) {
|
13 |
+
Mage::getSingleton('core/session')->setData('fanplayr_coupon', null);
|
14 |
+
}
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
public function applyCoupon($couponCode)
|
19 |
+
{
|
20 |
+
$itemInCart = true;
|
21 |
+
$this->hasSucceeded = true;
|
22 |
+
|
23 |
+
$quote = $this->getCurrentQuote();
|
24 |
+
|
25 |
+
if (!$quote->getItemsCount()) {
|
26 |
+
$itemInCart = false;
|
27 |
+
// store it for later use ...
|
28 |
+
$this->remember($couponCode);
|
29 |
+
$this->notice('There are currently no items in the shopping cart. We will try and apply your coupon code "' . $couponCode . '" once you have added some items to your cart.');
|
30 |
+
}
|
31 |
+
|
32 |
+
if ($itemInCart){
|
33 |
+
|
34 |
+
// ----------------------------------------
|
35 |
+
// check for deputized coupon and replace
|
36 |
+
$session = Mage::getSingleton("core/session");
|
37 |
+
$deputies = $session->getData("fanplayr_deputy_codes");
|
38 |
+
if (is_array($deputies) && array_key_exists($couponCode, $deputies)) {
|
39 |
+
// has to be done first so we get actual coupon
|
40 |
+
$session->setData('fanplayr_last_deputy_used', $couponCode);
|
41 |
+
$couponCode = array_key_exists($couponCode, $deputies) ? $deputies[$couponCode] : '';
|
42 |
+
}
|
43 |
+
try {
|
44 |
+
$quote->getShippingAddress()->setCollectShippingRates(true);
|
45 |
+
$quote->setCouponCode(strlen($couponCode) ? $couponCode : '')
|
46 |
+
->collectTotals()
|
47 |
+
->save();
|
48 |
+
} catch (Exception $e) {
|
49 |
+
$this->error('Cannot apply coupon code: ' . $e-> getMessage());
|
50 |
+
$this->hasSucceeded = false;
|
51 |
+
return;
|
52 |
+
}
|
53 |
+
|
54 |
+
if ($couponCode) {
|
55 |
+
if ($couponCode != $quote->getCouponCode()) {
|
56 |
+
$this->error('Coupon code is invalid');
|
57 |
+
$this->hasSucceeded = false;
|
58 |
+
return;
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
if ($this->hasSucceeded) {
|
63 |
+
$this->success('Your coupon has been applied.');
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
public function getCurrentQuote($quoteId)
|
69 |
+
{
|
70 |
+
return Mage::getSingleton('checkout/session')->getQuote();
|
71 |
+
}
|
72 |
+
|
73 |
+
// TODO: multilingual this
|
74 |
+
public function error($message)
|
75 |
+
{
|
76 |
+
Mage::getSingleton('core/session')->addError($message);
|
77 |
+
$this->hasSucceeded = false;
|
78 |
+
}
|
79 |
+
|
80 |
+
public function success($message)
|
81 |
+
{
|
82 |
+
Mage::getSingleton('core/session')->addSuccess($message);
|
83 |
+
}
|
84 |
+
|
85 |
+
public function notice($message)
|
86 |
+
{
|
87 |
+
Mage::getSingleton('core/session')->addNotice($message);
|
88 |
+
}
|
89 |
+
}
|
app/code/community/Fanplayr/Socialcoupons/Model/EmbedObserver.php
ADDED
@@ -0,0 +1,637 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Fanplayr_Socialcoupons_Model_EmbedObserver
|
3 |
+
{
|
4 |
+
public function getEmbedAction()
|
5 |
+
{
|
6 |
+
$r = Mage::app()->getRequest();
|
7 |
+
$pCnt = $r->getControllerName(); // onepage, multishipping, cart
|
8 |
+
$pAct = $r->getActionName(); // index
|
9 |
+
$pRte = $r->getRouteName(); // checkout
|
10 |
+
$pMod = $r->getModuleName(); // checkout
|
11 |
+
|
12 |
+
if ($pMod == 'admin')
|
13 |
+
return;
|
14 |
+
|
15 |
+
$_ac = Mage::getStoreConfig('fanplayrsocialcoupons/config/acc_key');
|
16 |
+
if (empty($_ac))
|
17 |
+
return;
|
18 |
+
|
19 |
+
$atPayment = $pMod == 'checkout' && $pCnt != 'cart';
|
20 |
+
$atCart = $pMod == 'checkout' && $pCnt == 'cart';
|
21 |
+
|
22 |
+
// AIT checkout compatability
|
23 |
+
$atCart = $pMod == 'aitcheckout'&& $pCnt == 'checkout';
|
24 |
+
|
25 |
+
// StreamCheckout
|
26 |
+
$atCart = $pRte == 'streamcheckout'&& $pMod == 'streamcheckout';
|
27 |
+
|
28 |
+
// DEPUTIES: if we have cookies set then reset it to 3 hours later
|
29 |
+
// so we don't forget
|
30 |
+
$cookie = Mage::getSingleton('core/cookie');
|
31 |
+
$d = $cookie->get('fanplayr_deputy_codes');
|
32 |
+
if ($d) $cookie->set('fanplayr_deputy_codes', $d, 10800, '/');
|
33 |
+
|
34 |
+
// v1.0.14: added this to allow disabling on specific URLs
|
35 |
+
$disableThisUrl = false;
|
36 |
+
$disabledUrlString = Mage::getStoreConfig('fanplayrsocialcoupons/config/disable_on_urls');
|
37 |
+
if (!empty($disabledUrlString)) {
|
38 |
+
$disabledUrls = explode(',', $disabledUrlString);
|
39 |
+
if (count($disabledUrls)) {
|
40 |
+
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
|
41 |
+
foreach($disabledUrls as $url) {
|
42 |
+
$url = trim($url);
|
43 |
+
if (strstr($currentUrl, $url) !== false) {
|
44 |
+
$disableThisUrl = true;
|
45 |
+
break;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
// don't show at payment, or custom disabled URLs
|
52 |
+
if (!$atPayment && !$disableThisUrl) {
|
53 |
+
|
54 |
+
$block = Mage::getSingleton('core/layout')->createBlock(
|
55 |
+
'Mage_Core_Block_Template',
|
56 |
+
'fanplayr_embed_block'
|
57 |
+
);
|
58 |
+
|
59 |
+
|
60 |
+
// this variable has changed from simply doing "wait for onload" to being for differnt types
|
61 |
+
// 0: Ajax: Normal
|
62 |
+
// 1: Ajax: Lazy load
|
63 |
+
// 2: TMS: User Only
|
64 |
+
// 3: TMS: User and Order
|
65 |
+
// 4: No Ajax: Normal
|
66 |
+
// 5: No Ajax: Lazy Load
|
67 |
+
// 6: Ajax: Normal, GTM
|
68 |
+
// 7: Ajax: Normal, GTM Extended
|
69 |
+
$embedType = intval(Mage::getStoreConfig('fanplayrsocialcoupons/config/wait_for_onload'));
|
70 |
+
|
71 |
+
$directEmbed = true;
|
72 |
+
// ajax embeds
|
73 |
+
if ($embedType >= 0 && $embedType <= 3 || $embedType == 6 || $embedType = 7) {
|
74 |
+
$directEmbed = false;
|
75 |
+
}
|
76 |
+
|
77 |
+
if ($directEmbed){
|
78 |
+
$block->setTemplate('fanplayr/embed.phtml');
|
79 |
+
}else{
|
80 |
+
$block->setTemplate('fanplayr/embed_ajax.phtml');
|
81 |
+
}
|
82 |
+
|
83 |
+
// enc data
|
84 |
+
$pageType = '';
|
85 |
+
$currentProduct = '';
|
86 |
+
$currentProductName = '';
|
87 |
+
$currentCategory = '';
|
88 |
+
$currentCategoryName = '';
|
89 |
+
|
90 |
+
$pageType = $this->getPageType();
|
91 |
+
|
92 |
+
if ($pageType == 'prod') {
|
93 |
+
// just in case we'll protect with @
|
94 |
+
@$cP = Mage::registry('current_product');
|
95 |
+
if ($cP){
|
96 |
+
$currentProduct = $cP->getId();
|
97 |
+
$currentProductName = $cP->getName();
|
98 |
+
|
99 |
+
$categories = $cP->getCategoryIds();
|
100 |
+
foreach($categories as $k => $_category_id){
|
101 |
+
$_category = Mage::getModel('catalog/category')->load($_category_id);
|
102 |
+
$currentCategory = $_category->getId();
|
103 |
+
$currentCategoryName = $_category->getName();
|
104 |
+
break;
|
105 |
+
}
|
106 |
+
}
|
107 |
+
} else if ($pageType == 'cat') {
|
108 |
+
// url for category ?
|
109 |
+
@$cC = Mage::registry('current_category');
|
110 |
+
if ($cC) {
|
111 |
+
$currentCategory = $cC->getId();
|
112 |
+
$currentCategoryName = $cC->getName();
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
// shop URL
|
117 |
+
$shopUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
118 |
+
if (!strpos($shopUrl, 'index.php/'))
|
119 |
+
$shopUrl .= 'index.php/';
|
120 |
+
$customEmbedUrl = trim(Mage::getStoreConfig('fanplayrsocialcoupons/config/custom_embed_url'));
|
121 |
+
if (!empty($customEmbedUrl)) $shopUrl = $customEmbedUrl;
|
122 |
+
|
123 |
+
$block->assign('shopUrl', $shopUrl);
|
124 |
+
|
125 |
+
if (!$directEmbed){
|
126 |
+
$block->assign('tt', $pageType);
|
127 |
+
$block->assign('tp', $currentProduct);
|
128 |
+
$block->assign('tc', $currentCategory);
|
129 |
+
|
130 |
+
$block->assign('tpn', $currentProductName);
|
131 |
+
$block->assign('tcn', $currentCategoryName);
|
132 |
+
}else {
|
133 |
+
// direct embed so we need to set some other things we'd normally set in AjaxController
|
134 |
+
// store session data in case the cookie is lost somehow
|
135 |
+
$sessionVars = $this->decodeSessionCookie('fanplayr_genius_session');
|
136 |
+
if ($sessionVars) {
|
137 |
+
$session = Mage::getModel('core/session');
|
138 |
+
if ($session){
|
139 |
+
if (array_key_exists('key', $sessionVars)) $session->setData('fanplayr_session_session_key',$sessionVars['key']);
|
140 |
+
if (array_key_exists('user', $sessionVars)) $session->setData('fanplayr_session_user_key', $sessionVars['user']);
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
$block->assign('widgetKeys', Mage::getStoreConfig('fanplayrsocialcoupons/config/widget_keys'));
|
145 |
+
$block->assign('widgetKeysGenius', Mage::getStoreConfig('fanplayrsocialcoupons/config/widget_keys_genius'));
|
146 |
+
$block->assign('accountKey', Mage::getStoreConfig('fanplayrsocialcoupons/config/acc_key'));
|
147 |
+
|
148 |
+
$block->assign('applyToCartUrl', $shopUrl . 'fanplayr/coupon/add/code/%c/');
|
149 |
+
$block->assign('depitizeUrl', $shopUrl . 'fanplayr/coupon/deputize/a/%a/d/%d/');
|
150 |
+
|
151 |
+
$block->assign('noTags', false);
|
152 |
+
|
153 |
+
$data = $this->getData(
|
154 |
+
($pageType == 'cart'),
|
155 |
+
$pageType,
|
156 |
+
$currentProduct,
|
157 |
+
$currentCategory,
|
158 |
+
$currentProductName,
|
159 |
+
$currentCategoryName
|
160 |
+
);
|
161 |
+
|
162 |
+
$block->assign('data', $data);
|
163 |
+
}
|
164 |
+
|
165 |
+
$trailingSlash = Mage::getStoreConfig('fanplayrsocialcoupons/config/trailing_slash');
|
166 |
+
var_dump('xxxxxxxxxxxxxx');
|
167 |
+
var_dump($trailingSlash);
|
168 |
+
if ($trailingSlash == '0') {
|
169 |
+
$trailingSlash = '';
|
170 |
+
}else{
|
171 |
+
$trailingSlash = '/';
|
172 |
+
}
|
173 |
+
var_dump($trailingSlash);
|
174 |
+
$block->assign('embedType', $embedType);
|
175 |
+
$block->assign('trailingSlash', $trailingSlash);
|
176 |
+
|
177 |
+
$currentLayoutHook = Mage::getStoreConfig('fanplayrsocialcoupons/config/layout_hook' . ($pageType == 'home' ? '_home' : ''));
|
178 |
+
if (!$currentLayoutHook)
|
179 |
+
$currentLayoutHook = 'content';
|
180 |
+
|
181 |
+
$contentBlock = Mage::getSingleton('core/layout')->getBlock($currentLayoutHook);
|
182 |
+
if ($contentBlock) $contentBlock->insert($block);
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
186 |
+
public static function getData($atCart = null, $pageType = null, $currentProduct = null, $currentCategory = null, $currentProductName = null, $currentCategoryName = null)
|
187 |
+
{
|
188 |
+
$itemCount = 0;
|
189 |
+
$itemQty = 0;
|
190 |
+
$subtotal = 0;
|
191 |
+
$discount = 0;
|
192 |
+
$custEmail = '';
|
193 |
+
$custId = '';
|
194 |
+
$couponCode = '';
|
195 |
+
$currencyIso = '';
|
196 |
+
$custSegment = '';
|
197 |
+
$custGroup = '';
|
198 |
+
|
199 |
+
$products = array();
|
200 |
+
$productString = '';
|
201 |
+
|
202 |
+
// get the current customer
|
203 |
+
$customer = Mage::getSingleton('customer/session');
|
204 |
+
$custGroup = $customer->getCustomerGroupId();
|
205 |
+
|
206 |
+
$customerId = $customer->getCustomerId();
|
207 |
+
if (self::isMageEnterprise()){
|
208 |
+
$websiteId = Mage::app()->getStore()->getWebsiteId();
|
209 |
+
$segments = Mage::getModel('enterprise_customersegment/customer')->getCustomerSegmentIdsForWebsite($customerId,$websiteId);
|
210 |
+
$custSegment = implode(',', $segments);
|
211 |
+
}
|
212 |
+
|
213 |
+
// get cart data
|
214 |
+
$cartData = null;
|
215 |
+
$cartMod = Mage::getSingleton('checkout/session');
|
216 |
+
|
217 |
+
$mageV = Mage::getVersion();
|
218 |
+
$mageVa = explode('.', $mageV);
|
219 |
+
|
220 |
+
if ($cartMod) {
|
221 |
+
$quote = $cartMod->getQuote();
|
222 |
+
if ($quote) {
|
223 |
+
|
224 |
+
$session = Mage::getSingleton("core/session");
|
225 |
+
|
226 |
+
$updateProductDetails = $session->getData("fanplayr_update_product_details");
|
227 |
+
if ($updateProductDetails === true || $updateProductDetails === null) {
|
228 |
+
|
229 |
+
//Mage::log('Updating product details JSON');
|
230 |
+
|
231 |
+
$products = self::getProductsFromQuote($quote);
|
232 |
+
|
233 |
+
$productString = addslashes(json_encode($products));
|
234 |
+
$session->setData("fanplayr_product_cache", $productString);
|
235 |
+
|
236 |
+
$session->setData("fanplayr_update_product_details", false);
|
237 |
+
}else{
|
238 |
+
$productCache = $session->getData("fanplayr_product_cache");
|
239 |
+
if (strlen($productCache) > 0) {
|
240 |
+
$productString = $productCache;
|
241 |
+
}else{
|
242 |
+
// empty array JSON of products
|
243 |
+
$productString = "[]";
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
$cartData = $quote->getData();
|
248 |
+
|
249 |
+
$itemCount = array_key_exists('items_count', $cartData) ? $cartData['items_count'] : 0;
|
250 |
+
$itemQty = array_key_exists('items_qty', $cartData) ? $cartData['items_qty'] : 0;
|
251 |
+
|
252 |
+
$custEmail = array_key_exists('customer_email', $cartData) ? $cartData['customer_email'] : '';
|
253 |
+
$custId = array_key_exists('customer_id', $cartData) ? $cartData['customer_id'] : '';
|
254 |
+
$couponCode = array_key_exists('coupon_code', $cartData) ? $cartData['coupon_code'] : '';
|
255 |
+
$currencyIso = array_key_exists('quote_currency_code', $cartData) ? $cartData['quote_currency_code'] : '';
|
256 |
+
|
257 |
+
// before discount
|
258 |
+
$subtotal = array_key_exists('subtotal', $cartData) ? $cartData['subtotal'] : 0;
|
259 |
+
$discount = array_key_exists('subtotal_with_discount', $cartData) ? $subtotal - $cartData['subtotal_with_discount'] : 0;
|
260 |
+
// after discount, before shipping / tax
|
261 |
+
$total = array_key_exists('subtotal_with_discount', $cartData) ? $cartData['subtotal_with_discount'] : 0;
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
$storeCode = Mage::app()->getStore()->getCode();
|
266 |
+
$gtmContainerId = Mage::getStoreConfig('fanplayrsocialcoupons/config/gtm_container_id');
|
267 |
+
|
268 |
+
$data = array(
|
269 |
+
'atCart' => $atCart,
|
270 |
+
'lineItemCount' => (int)$itemCount,
|
271 |
+
'numItems' => (int)$itemQty,
|
272 |
+
'total' => (float)$total,
|
273 |
+
'subTotal' => (float)$subtotal,
|
274 |
+
'discount' => (float)$discount,
|
275 |
+
'customerEmail' => $custEmail,
|
276 |
+
'couponCode' => $couponCode,
|
277 |
+
'currency' => $currencyIso,
|
278 |
+
'customerId' => $custId,
|
279 |
+
'customerSegment' => $custSegment,
|
280 |
+
'customerGroup' => $custGroup,
|
281 |
+
'pageType' => $pageType,
|
282 |
+
'productId' => $currentProduct,
|
283 |
+
'productName' => $currentProductName,
|
284 |
+
'categoryId' => $currentCategory,
|
285 |
+
'categoryName' => $currentCategoryName,
|
286 |
+
'version' => 3,
|
287 |
+
'shopType' => 'magento',
|
288 |
+
'products' => $productString,
|
289 |
+
'storeCode' => $storeCode,
|
290 |
+
'gtmContainerId' => $gtmContainerId
|
291 |
+
);
|
292 |
+
|
293 |
+
return $data;
|
294 |
+
}
|
295 |
+
|
296 |
+
function getPageType()
|
297 |
+
{
|
298 |
+
// pageType, currentPRoduct, currentCategory
|
299 |
+
// tt: home, cart, page, srch, cat, prod, blog
|
300 |
+
$r = Mage::app()->getRequest();
|
301 |
+
$pCnt = $r->getControllerName();
|
302 |
+
$pAct = $r->getActionName();
|
303 |
+
$pRte = $r->getRouteName();
|
304 |
+
$pMod = $r->getModuleName();
|
305 |
+
|
306 |
+
// home
|
307 |
+
// index, index, cms, cms
|
308 |
+
if ($pCnt == 'index' && $pAct == 'index' && $pRte == 'cms') {
|
309 |
+
return 'home';
|
310 |
+
}
|
311 |
+
|
312 |
+
// product
|
313 |
+
// product, view, catalog, catalog
|
314 |
+
if ($pCnt == 'product') {
|
315 |
+
return 'prod';
|
316 |
+
}
|
317 |
+
|
318 |
+
// category
|
319 |
+
// category, view, catalog, catalog
|
320 |
+
if ($pCnt == 'category') {
|
321 |
+
return 'cat';
|
322 |
+
}
|
323 |
+
|
324 |
+
// search
|
325 |
+
// result, index, catalogsearch, catalogsearch
|
326 |
+
// advanced, index, catalogsearch, catalogsearch
|
327 |
+
// term, popular, catalogsearch, catalogsearch
|
328 |
+
// seo_sitemap, category, catalog, catalog
|
329 |
+
if ($pCnt == 'result' || $pCnt == 'advanced' || $pCnt == 'term' || $pCnt == 'seo_sitemap') {
|
330 |
+
return 'srch';
|
331 |
+
}
|
332 |
+
|
333 |
+
// cart
|
334 |
+
// cart, index, checkout, checkout
|
335 |
+
if ($pCnt == 'cart') {
|
336 |
+
return 'cart';
|
337 |
+
}
|
338 |
+
|
339 |
+
// blog (nah !)
|
340 |
+
|
341 |
+
// page
|
342 |
+
// page, view, cms, cms
|
343 |
+
// index, index, contacts, contacts
|
344 |
+
// guest, form, sales, sales
|
345 |
+
return 'page';
|
346 |
+
}
|
347 |
+
|
348 |
+
public static function isMageEnterprise() {
|
349 |
+
return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
|
350 |
+
}
|
351 |
+
|
352 |
+
public static function isMageProfessional() {
|
353 |
+
return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
|
354 |
+
}
|
355 |
+
|
356 |
+
public static function isMageCommunity() {
|
357 |
+
return !self::isMageEnterprise() && !self::isMageProfessional();
|
358 |
+
}
|
359 |
+
|
360 |
+
// -------------------------------------------------------------------
|
361 |
+
// coupon deputization
|
362 |
+
|
363 |
+
// called before outpout, replaced coupons with deputized coupons
|
364 |
+
// called on http_response_send_before
|
365 |
+
//
|
366 |
+
public function deputizeReplaceAction($observer)
|
367 |
+
{
|
368 |
+
$response = $observer->getResponse();
|
369 |
+
if (!$response) return;
|
370 |
+
|
371 |
+
$session = Mage::getSingleton("core/session");
|
372 |
+
$lastDeputiesUsed = $session->getData("fanplayr_used_deputies");
|
373 |
+
|
374 |
+
// don't even bother to go further if we haven't used a deputized code
|
375 |
+
if (!is_array($lastDeputiesUsed)) {
|
376 |
+
return;
|
377 |
+
}
|
378 |
+
|
379 |
+
// ------------------------------------------------------
|
380 |
+
// only for pages we want
|
381 |
+
$r = Mage::app()->getRequest();
|
382 |
+
$pCnt = $r->getControllerName(); // onepage, multishipping, cart
|
383 |
+
$pAct = $r->getActionName(); // index
|
384 |
+
$pRte = $r->getRouteName(); // checkout
|
385 |
+
$pMod = $r->getModuleName(); // checkout
|
386 |
+
|
387 |
+
// full route
|
388 |
+
$route = $pCnt.'/'.$pAct.'/'.$pRte.'/'.$pMod;
|
389 |
+
|
390 |
+
$extraAllowedRoutes = array();
|
391 |
+
$depRoutes = Mage::getStoreConfig('fanplayrsocialcoupons/config/dep_extra_rewrite_routes');
|
392 |
+
// just in case we have problems here we don't want it to freak out
|
393 |
+
try {
|
394 |
+
$extraAllowedRoutes = array_merge($extraAllowedRoutes, explode(',', $depRoutes));
|
395 |
+
}catch (Exception $e) {
|
396 |
+
$extraAllowedRoutes = array();
|
397 |
+
}
|
398 |
+
|
399 |
+
// checkout pages, order view pages
|
400 |
+
if (
|
401 |
+
($pMod == 'checkout' && $pAct != 'success')
|
402 |
+
|| $route == 'order/view/sales/sales'
|
403 |
+
|| $route == 'index/index/onestepcheckout/onestepcheckout' // osc
|
404 |
+
|| $route == 'ajax/add_coupon/onestepcheckout/onestepcheckout' // osc
|
405 |
+
|| $route == 'ajax/set_methods_separate/onestepcheckout/onestepcheckout' // osc
|
406 |
+
|| $route == 'checkout/updateSteps/aitcheckout/aitcheckout' //AIT checkout
|
407 |
+
|| $route == 'cart/couponPost/aitcheckout/aitcheckout' //AIT checkout
|
408 |
+
|| $route == 'checkout/index/aitcheckout/aitcheckout' //AIT checkout
|
409 |
+
|| $route == 'index/index/streamcheckout/streamcheckout' // StreamCheckout by Made People
|
410 |
+
|| $route == 'index/saveAll/streamcheckout/streamcheckout' // StreamCheckout (AJAX)
|
411 |
+
|| $route == 'index/applyCoupon/streamcheckout/streamcheckout' // StreamCheckout (Coupon)
|
412 |
+
|| in_array($route, $extraAllowedRoutes)
|
413 |
+
){
|
414 |
+
// do nothing
|
415 |
+
}else {
|
416 |
+
// yes I know this is a silly way to "else return"
|
417 |
+
// but it makes the above code cleaner
|
418 |
+
return;
|
419 |
+
}
|
420 |
+
|
421 |
+
// ------------------------------------------------------
|
422 |
+
// now we should be doing the deputization
|
423 |
+
// as we are only doing a simple search/replace this is
|
424 |
+
// why we REQUIRE a "prefix" as to not destroy any
|
425 |
+
// HTML tags etc
|
426 |
+
|
427 |
+
$deputies = $session->getData("fanplayr_deputy_codes");
|
428 |
+
|
429 |
+
// cookie fallback
|
430 |
+
if (!$deputies) {
|
431 |
+
$cookie = Mage::getSingleton('core/cookie');
|
432 |
+
$d = $cookie->get('fanplayr_deputy_codes');
|
433 |
+
if ($d) $deputies = (Array)json_decode($d);
|
434 |
+
}
|
435 |
+
|
436 |
+
$html = $response->getBody();
|
437 |
+
|
438 |
+
foreach($lastDeputiesUsed as $lastDeputyUsed){
|
439 |
+
if (is_array($deputies) && array_key_exists($lastDeputyUsed, $deputies)) {
|
440 |
+
|
441 |
+
// replace deputies
|
442 |
+
if (array_key_exists($lastDeputyUsed, $deputies))
|
443 |
+
$html = str_replace($deputies[$lastDeputyUsed], $lastDeputyUsed, $html);
|
444 |
+
}
|
445 |
+
}
|
446 |
+
|
447 |
+
$response->setBody($html);
|
448 |
+
}
|
449 |
+
|
450 |
+
// used when a user inputs a coupon,
|
451 |
+
// called on controller_action_predispatch
|
452 |
+
public function deputizeInputAction($observer)
|
453 |
+
{
|
454 |
+
$r = Mage::app()->getRequest();
|
455 |
+
$pCnt = $r->getControllerName(); // onepage, multishipping, cart
|
456 |
+
$pAct = $r->getActionName(); // index
|
457 |
+
$pRte = $r->getRouteName(); // checkout
|
458 |
+
$pMod = $r->getModuleName(); // checkout
|
459 |
+
|
460 |
+
$route = $pCnt . '/' . $pAct . '/' . $pRte . '/' . $pMod;
|
461 |
+
|
462 |
+
// which input do we use?
|
463 |
+
$inpVar = 'coupon_code';
|
464 |
+
$setPost = false;
|
465 |
+
|
466 |
+
// one step checkout
|
467 |
+
if ($route == 'ajax/add_coupon/onestepcheckout/onestepcheckout') {
|
468 |
+
$inpVar = 'code';
|
469 |
+
}
|
470 |
+
|
471 |
+
// amasty cancel
|
472 |
+
if ($route == 'checkout/cancelCoupon/amcoupons/amcoupons') {
|
473 |
+
$inpVar = 'amcoupon_code_cancel';
|
474 |
+
}
|
475 |
+
|
476 |
+
// AIT Checkout
|
477 |
+
if ($route == 'cart/couponPost/aitcheckout/aitcheckout') {
|
478 |
+
// it uses 'getPost' rather than 'getParam'
|
479 |
+
$setPost = true;
|
480 |
+
}
|
481 |
+
|
482 |
+
// StreamCheckout: uses POST
|
483 |
+
if ($route == 'index/applyCoupon/streamcheckout/streamcheckout') {
|
484 |
+
$setPost = true;
|
485 |
+
}
|
486 |
+
|
487 |
+
// special for StreamCheckout SaveOrder
|
488 |
+
if ($route == 'index/saveOrder/streamcheckout/streamcheckout') {
|
489 |
+
$setPost = true;
|
490 |
+
$inpVar = 'stream_coupon_code';
|
491 |
+
}
|
492 |
+
|
493 |
+
$depCoupon = Mage::app()->getRequest()->getParam($inpVar); // normal coupon
|
494 |
+
$disallowedPrefix = Mage::getStoreConfig('fanplayrsocialcoupons/config/dep_prefix');
|
495 |
+
|
496 |
+
// remove spaces
|
497 |
+
$depCoupon = trim($depCoupon);
|
498 |
+
|
499 |
+
// if someone enters the actual code, and it is a prefix code
|
500 |
+
// then set it to prefix with "..." on the end
|
501 |
+
if (strpos($depCoupon, $disallowedPrefix) === 0) {
|
502 |
+
Mage::app()->getRequest()->setParam($inpVar, $disallowedPrefix . '...');
|
503 |
+
if ($setPost) Mage::app()->getRequest()->setPost($inpVar, $disallowedPrefix . '...');
|
504 |
+
return;
|
505 |
+
}
|
506 |
+
|
507 |
+
$session = Mage::getSingleton("core/session");
|
508 |
+
$deputies = $session->getData("fanplayr_deputy_codes");
|
509 |
+
|
510 |
+
// cookie fallback
|
511 |
+
if (!$deputies) {
|
512 |
+
$cookie = Mage::getSingleton('core/cookie');
|
513 |
+
$d = $cookie->get('fanplayr_deputy_codes');
|
514 |
+
if ($d) $deputies = (Array)json_decode($d);
|
515 |
+
}
|
516 |
+
|
517 |
+
if (is_array($deputies) && array_key_exists($depCoupon, $deputies)) {
|
518 |
+
$actualCoupon = array_key_exists($depCoupon, $deputies) ? $deputies[$depCoupon] : '';
|
519 |
+
|
520 |
+
// must be set first to get actual coupon
|
521 |
+
// need to set as array, to support those horrible multi-coupon extensions
|
522 |
+
$sessionDeps = $session->getData('fanplayr_used_deputies');
|
523 |
+
if (!is_array($sessionDeps))
|
524 |
+
$sessionDeps = array();
|
525 |
+
// and only add it if it's not there so no duplicates
|
526 |
+
if (!in_array($depCoupon, $sessionDeps))
|
527 |
+
array_push($sessionDeps, $depCoupon);
|
528 |
+
$session->setData('fanplayr_used_deputies', $sessionDeps);
|
529 |
+
|
530 |
+
Mage::app()->getRequest()->setParam($inpVar, $actualCoupon);
|
531 |
+
if ($setPost) Mage::app()->getRequest()->setPost($inpVar, $actualCoupon);
|
532 |
+
}
|
533 |
+
}
|
534 |
+
|
535 |
+
// when adding a product we should refresh product info on next call
|
536 |
+
public function checkQuoteAddAction($observer)
|
537 |
+
{
|
538 |
+
$session = Mage::getSingleton("core/session");
|
539 |
+
$session->setData("fanplayr_update_product_details", true);
|
540 |
+
}
|
541 |
+
|
542 |
+
// when removing a product we should refresh product info on next call
|
543 |
+
public function checkQuoteRemoveAction($observer)
|
544 |
+
{
|
545 |
+
$session = Mage::getSingleton("core/session");
|
546 |
+
$session->setData("fanplayr_update_product_details", true);
|
547 |
+
}
|
548 |
+
|
549 |
+
// when updating a product we should refresh product info on next call
|
550 |
+
// we only do this for checkout 'updatePost' and 'delete' actions though
|
551 |
+
// update is called many many times for simple things like cart views
|
552 |
+
public function checkQuoteUpdateQtyAction($observer)
|
553 |
+
{
|
554 |
+
$r = Mage::app()->getRequest();
|
555 |
+
$pCnt = $r->getControllerName(); // onepage, multishipping, cart
|
556 |
+
$pAct = $r->getActionName(); // index
|
557 |
+
$pRte = $r->getRouteName(); // checkout
|
558 |
+
$pMod = $r->getModuleName(); // checkout
|
559 |
+
|
560 |
+
$route = "$pMod/$pRte/$pAct/$pCnt";
|
561 |
+
if ($route == "checkout/checkout/updatePost/cart"
|
562 |
+
|| $route == "checkout/checkout/delete/cart") {
|
563 |
+
$session = Mage::getSingleton("core/session");
|
564 |
+
$session->setData("fanplayr_update_product_details", true);
|
565 |
+
}
|
566 |
+
}
|
567 |
+
|
568 |
+
// -------------------------------------------------------------------
|
569 |
+
// gets an array of all products from cart with needed details for tracking
|
570 |
+
// quite expensive so should only be called when it has changed
|
571 |
+
|
572 |
+
private static function getProductsFromQuote($quote)
|
573 |
+
{
|
574 |
+
$products = array();
|
575 |
+
|
576 |
+
foreach ($quote->getAllVisibleItems() as $item) {
|
577 |
+
|
578 |
+
if ($option = $item->getOptionByCode('simple_product')) {
|
579 |
+
$p = $option->getProduct();
|
580 |
+
} else {
|
581 |
+
$p = $item->getProduct();
|
582 |
+
}
|
583 |
+
|
584 |
+
// bug in Magento 1.5 and below?
|
585 |
+
// just make sure it doesn't break things!
|
586 |
+
$sku = '';
|
587 |
+
try { $sku = !$p ? '' : $p->getSku(); }catch(Exception $e){}
|
588 |
+
|
589 |
+
$products[] = array(
|
590 |
+
'qty' => $item->getQty(),
|
591 |
+
'price' => $item->getCalculationPrice(),
|
592 |
+
'catName' => '',
|
593 |
+
'id' => !$p ? '' : $p->getId(),
|
594 |
+
'sku' => $sku,
|
595 |
+
'name' => $item->getName(),
|
596 |
+
'catId' => !$p ? '' : implode(',', $p->getCategoryIds())
|
597 |
+
);
|
598 |
+
}
|
599 |
+
|
600 |
+
return $products;
|
601 |
+
}
|
602 |
+
|
603 |
+
// -------------------------------------------------------------------
|
604 |
+
// decode session cookie
|
605 |
+
|
606 |
+
// in case sessions aren't being sent through correctly
|
607 |
+
// we will store this each hit, and then get it back later
|
608 |
+
|
609 |
+
private function decodeSessionCookie( $cookie_name )
|
610 |
+
{
|
611 |
+
if ( array_key_exists($cookie_name, $_COOKIE) && !empty($_COOKIE[$cookie_name]) ) {
|
612 |
+
$data = array();
|
613 |
+
$params = explode(';', $_COOKIE[$cookie_name]);
|
614 |
+
|
615 |
+
foreach ( $params as $param ) {
|
616 |
+
$parts = explode('=', $param);
|
617 |
+
if (count($parts) != 2)
|
618 |
+
continue;
|
619 |
+
|
620 |
+
$type = substr($parts[1], 0, 1);
|
621 |
+
$value = substr($parts[1], 1);
|
622 |
+
|
623 |
+
if ( empty($type) ) continue;
|
624 |
+
|
625 |
+
if ( $type === 'n' || $type === 'u' ) { $value = null; }
|
626 |
+
if ( $type === 'b' ) { $value = (intval($value, 10) !== 0); }
|
627 |
+
if ( $type === 'f' ) { $value = floatval($value); }
|
628 |
+
if ( $type === 's' ) { $value = urldecode($value); }
|
629 |
+
|
630 |
+
$data[urldecode($parts[0])] = $value;
|
631 |
+
}
|
632 |
+
|
633 |
+
return $data;
|
634 |
+
}
|
635 |
+
return null;
|
636 |
+
}
|
637 |
+
}
|
app/code/community/Fanplayr/Socialcoupons/Model/OrderObserver.php
ADDED
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Fanplayr_Socialcoupons_Model_OrderObserver
|
3 |
+
{
|
4 |
+
// normal flow for single address orders
|
5 |
+
public function checkSuccessSingle($observer)
|
6 |
+
{
|
7 |
+
$this->afterSuccessfulOrder($observer->getData('order_ids'));
|
8 |
+
}
|
9 |
+
|
10 |
+
// normal flow for multi address orders
|
11 |
+
public function checkSuccessMulti($observer)
|
12 |
+
{
|
13 |
+
$this->afterSuccessfulOrder($observer->getData('order_ids'));
|
14 |
+
}
|
15 |
+
|
16 |
+
// normal flow fro multi or single address orders
|
17 |
+
// this is not the flow for external paypal payments and such
|
18 |
+
private function afterSuccessfulOrder($lastOrderId)
|
19 |
+
{
|
20 |
+
// only do embed (or even get data for it) if we have an account key - ie we are linked
|
21 |
+
$accountKey = Mage::getStoreConfig('fanplayrsocialcoupons/config/acc_key');
|
22 |
+
if (empty($accountKey))
|
23 |
+
return;
|
24 |
+
|
25 |
+
$errors = '';
|
26 |
+
|
27 |
+
$secret = Mage::getStoreConfig('fanplayrsocialcoupons/config/secret');
|
28 |
+
|
29 |
+
if (is_array($lastOrderId))
|
30 |
+
$lastOrderId = $lastOrderId[0];
|
31 |
+
|
32 |
+
// get the main order data, offloaded here as we also use this in the server-server route
|
33 |
+
$data = $this->getLastOrderInformation($lastOrderId);
|
34 |
+
|
35 |
+
// get session data if we can
|
36 |
+
$session = null;
|
37 |
+
$sessionKey = '';
|
38 |
+
$userKey = '';
|
39 |
+
try {
|
40 |
+
$session = Mage::getModel('core/session');
|
41 |
+
}catch(Exception $e){}
|
42 |
+
|
43 |
+
if ($session) {
|
44 |
+
$sessionKey = $session->getData('fanplayr_session_session_key');
|
45 |
+
$userKey = $session->getData('fanplayr_session_user_key');
|
46 |
+
}
|
47 |
+
|
48 |
+
$data = array_merge($data, array(
|
49 |
+
'accountKey' => $accountKey,
|
50 |
+
'shopType' => 'magento',
|
51 |
+
'version' => 3,
|
52 |
+
'sessionKey' => $sessionKey,
|
53 |
+
'userKey' => $userKey,
|
54 |
+
'errors' => $errors
|
55 |
+
));
|
56 |
+
|
57 |
+
// add the embed type
|
58 |
+
// this variable has changed from simply doing "wait for onload" to being for differnt types
|
59 |
+
$data['embedType'] = intval(Mage::getStoreConfig('fanplayrsocialcoupons/config/wait_for_onload'));
|
60 |
+
|
61 |
+
// ------------------------------------------------------------------
|
62 |
+
// do the embed
|
63 |
+
// normaly in the content block, but may be changed
|
64 |
+
|
65 |
+
$block = Mage::getSingleton('core/layout')->createBlock(
|
66 |
+
'Mage_Core_Block_Template',
|
67 |
+
'fanplayr_embed_block',
|
68 |
+
array('template' => 'fanplayr/success.phtml')
|
69 |
+
)->assign('data', $data);
|
70 |
+
|
71 |
+
$currentLayoutHook = Mage::getStoreConfig('fanplayrsocialcoupons/config/layout_hook_order');
|
72 |
+
if (!$currentLayoutHook)
|
73 |
+
$currentLayoutHook = 'content';
|
74 |
+
|
75 |
+
$contentBlock = Mage::getSingleton('core/layout')->getBlock($currentLayoutHook);
|
76 |
+
if ($contentBlock) $contentBlock->insert($block);
|
77 |
+
}
|
78 |
+
|
79 |
+
// sales_order_place_after
|
80 |
+
public function serverToServerTrackingBeforePayment($ob)
|
81 |
+
{
|
82 |
+
$this->serverToServerTracking($ob->order);
|
83 |
+
}
|
84 |
+
|
85 |
+
// called on "sales_order_invoice_save_commit_after", after payment
|
86 |
+
public function serverToServerTrackingAfterPayment($ob)
|
87 |
+
{
|
88 |
+
$this->serverToServerTracking($ob->getEvent()->getInvoice()->getOrder());
|
89 |
+
}
|
90 |
+
|
91 |
+
// used for tracking payments that don't go through the normal flow
|
92 |
+
private function serverToServerTracking($order)
|
93 |
+
{
|
94 |
+
try {
|
95 |
+
|
96 |
+
$accountKey = Mage::getStoreConfig('fanplayrsocialcoupons/config/acc_key');
|
97 |
+
if (!$accountKey) return;
|
98 |
+
|
99 |
+
//$order = $ob->order;
|
100 |
+
|
101 |
+
$state = $order->getState();
|
102 |
+
$method = $order->getPayment()->getMethod();
|
103 |
+
|
104 |
+
// only paypal_standard supported ATM
|
105 |
+
if ($method == 'paypal_standard'){
|
106 |
+
|
107 |
+
$url = '';
|
108 |
+
$params = array();
|
109 |
+
|
110 |
+
// order created, let's tell Fanplayr to link details at a later time
|
111 |
+
if ($state == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
|
112 |
+
|
113 |
+
$url .= 'http://my.fanplayr.com/api.track.v1.ordercreated/';
|
114 |
+
|
115 |
+
// we will only have these on the before
|
116 |
+
// get session data if we can
|
117 |
+
$session = null;
|
118 |
+
$sessionKey = '';
|
119 |
+
$userKey = '';
|
120 |
+
try {
|
121 |
+
$session = Mage::getModel('core/session');
|
122 |
+
}catch(Exception $e){}
|
123 |
+
if ($session) {
|
124 |
+
$sessionKey = $session->getData('fanplayr_session_session_key');
|
125 |
+
$userKey = $session->getData('fanplayr_session_user_key');
|
126 |
+
}
|
127 |
+
|
128 |
+
$params['id'] = $order->getId();
|
129 |
+
$params['number'] = $order->getIncrementId(); // getNumber don't work here ...
|
130 |
+
|
131 |
+
$params['accountkey'] = $accountKey;
|
132 |
+
$params['sessionkey'] = $sessionKey;
|
133 |
+
$params['userkey'] = $userKey;
|
134 |
+
|
135 |
+
// log the order with Fanplayr
|
136 |
+
} else if ($state == Mage_Sales_Model_Order::STATE_PROCESSING) {
|
137 |
+
|
138 |
+
$url .= 'http://my.fanplayr.com/api.track.v1.orderpaid/';
|
139 |
+
|
140 |
+
// get order info
|
141 |
+
$data = $this->getLastOrderInformation($order->getId());
|
142 |
+
|
143 |
+
$params['domain'] = Mage::getUrl();
|
144 |
+
$params['shoptype'] = 'magento';
|
145 |
+
|
146 |
+
$params['id'] = $data['orderId'];
|
147 |
+
$params['number'] = $data['orderNumber'];
|
148 |
+
|
149 |
+
$params['email'] = $data['orderEmail'];
|
150 |
+
$params['date'] = $data['orderDate'];
|
151 |
+
$params['total'] = $data['total'];
|
152 |
+
$params['subTotal'] = $data['subTotal'];
|
153 |
+
$params['discountamount'] = $data['discount'];
|
154 |
+
$params['discountcode'] = $data['discountCode'];
|
155 |
+
$params['firstname'] = $data['firstName'];
|
156 |
+
$params['lastname'] = $data['lastName'];
|
157 |
+
$params['customeremail'] = $data['customerEmail'];
|
158 |
+
$params['customerid'] = $data['customerId'];
|
159 |
+
$params['shipping'] = $data['shipping'];
|
160 |
+
$params['tax'] = $data['tax'];
|
161 |
+
$params['products'] = json_encode($data['products']);
|
162 |
+
|
163 |
+
$params['accountkey'] = $accountKey;
|
164 |
+
|
165 |
+
// we don't have these afterwards but we should send through anyway
|
166 |
+
$params['sessionkey'] = '';
|
167 |
+
$params['userkey'] = '';
|
168 |
+
}
|
169 |
+
|
170 |
+
// now if we set a URL call it!
|
171 |
+
if ($url) {
|
172 |
+
|
173 |
+
$params = http_build_query($params);
|
174 |
+
|
175 |
+
$ch = curl_init();
|
176 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
177 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
178 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
179 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
180 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
181 |
+
|
182 |
+
// DEBUG
|
183 |
+
//Mage::log('PayPal Return, URL: ' . $url);
|
184 |
+
//Mage::log('PayPal Return, Params: ' . $params);
|
185 |
+
//Mage::log('PayPal Return, State (' . $state . '): ' . curl_exec($ch));
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
}catch(Exception $e) {
|
190 |
+
Mage::log('Fanplayr Exception. Save order for PayPal. ' . $e->message);
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
// ------------------------------------------------------------------------------------------------------
|
195 |
+
// utils / helpers
|
196 |
+
|
197 |
+
// gets the last order information
|
198 |
+
// needs an ID for later than 1.4, otherwise automatically gets it
|
199 |
+
// returns an array of data from the order
|
200 |
+
private function getLastOrderInformation($lastOrderId)
|
201 |
+
{
|
202 |
+
$mageV = Mage::getVersion();
|
203 |
+
$mageVa = explode('.', $mageV);
|
204 |
+
|
205 |
+
// community 1.4 and below
|
206 |
+
// enterprise 1.9 and below
|
207 |
+
$useOldVersion = false;
|
208 |
+
if ($this->isMageCommunity() && $mageVa[0] == '1' && intval($mageVa[1]) <= 4
|
209 |
+
|| ($this->isMageEnterprise() || $this->isMageProfessional) && $mageVa[0] == '1' && intval($mageVa[1] <= 9)) {
|
210 |
+
$useOldVersion = true;
|
211 |
+
}
|
212 |
+
|
213 |
+
$products = array();
|
214 |
+
|
215 |
+
// have to get the last order in a stupid way for some reason for 1.4 ...
|
216 |
+
if ($useOldVersion) {
|
217 |
+
|
218 |
+
$lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
219 |
+
|
220 |
+
// seriosuly, why would THIS be the way to do it? fail!
|
221 |
+
$orderCollection = Mage::getModel('sales/order')->getCollection()
|
222 |
+
->addFilter('increment_id', $lastOrderId)
|
223 |
+
->setOrder('created_at', Varien_Data_Collection_Db::SORT_ORDER_DESC)
|
224 |
+
;
|
225 |
+
$order = $orderCollection->getFirstItem();
|
226 |
+
$order->load($lastOrderId);
|
227 |
+
|
228 |
+
$orderId = $order->getId();
|
229 |
+
$orderNumber = $order->getRealOrderId();
|
230 |
+
|
231 |
+
$data = $order->getData();
|
232 |
+
|
233 |
+
// have to be careful here because some versions miss some variables ...
|
234 |
+
$orderEmail = array_key_exists('customer_email', $data) ? $data['customer_email'] : '';
|
235 |
+
$orderDate = array_key_exists('created_at', $data) ? $data['created_at'] : '';
|
236 |
+
$currency = array_key_exists('order_currency_code', $data) ? $data['order_currency_code'] : '';
|
237 |
+
$firstName = array_key_exists('customer_firstname', $data) ? $data['customer_firstname'] : '';
|
238 |
+
$lastName = array_key_exists('customer_lastname', $data) ? $data['customer_lastname'] : '';
|
239 |
+
$customerEmail = array_key_exists('customer_email', $data) ? $data['customer_email'] : '';
|
240 |
+
$customerId = array_key_exists('customer_id', $data) ? $data['customer_id'] : '';
|
241 |
+
$discountCode = array_key_exists('coupon_code', $data) ? $data['coupon_code'] : '';
|
242 |
+
if (!$discountCode) $discountCode = '';
|
243 |
+
$discountAmount = array_key_exists('discount_amount', $data) ? round($data['discount_amount'], 2) : 0;
|
244 |
+
|
245 |
+
$orderSubTotal = array_key_exists('subtotal', $data) ? round($data['subtotal'], 2) : 0;
|
246 |
+
$orderTotal = $orderSubTotal - abs($discountAmount);
|
247 |
+
|
248 |
+
$shipping = array_key_exists('shipping_amount', $data) ? round($data['shipping_amount'], 2) : 0;
|
249 |
+
$tax = array_key_exists('tax_amount', $data) ? round($data['tax_amount'], 2) : 0;
|
250 |
+
|
251 |
+
$products = $this->getProductsFromOrder($order);
|
252 |
+
|
253 |
+
} else {
|
254 |
+
$order = Mage::getModel('sales/order')->load($lastOrderId);
|
255 |
+
|
256 |
+
$orderId = $order->getId();
|
257 |
+
$orderNumber = $order->getRealOrderId();
|
258 |
+
$orderEmail = $order->getCustomerEmail();
|
259 |
+
$orderDate = $order->getCreatedAt();
|
260 |
+
$currency = $order->getOrderCurrencyCode();
|
261 |
+
$firstName = $order->getCustomerFirstname();
|
262 |
+
$lastName = $order->getCustomerLastname();
|
263 |
+
$customerEmail = $order->getCustomerEmail();
|
264 |
+
$customerId = $order->getCustomerId();
|
265 |
+
$discountCode = $order->getCouponCode();
|
266 |
+
if (!$discountCode) $discountCode = '';
|
267 |
+
|
268 |
+
$data = $order->getData();
|
269 |
+
$discountAmount = array_key_exists('base_discount_amount', $data) ? round($data['base_discount_amount'], 2) : 0;
|
270 |
+
|
271 |
+
$orderSubTotal = round($order->getBaseSubtotal(), 2);
|
272 |
+
$orderTotal = $orderSubTotal - abs($discountAmount);
|
273 |
+
|
274 |
+
$shipping = round($order->getShippingAmount(), 2);
|
275 |
+
$tax = round($order->getTaxAmount(), 2);
|
276 |
+
|
277 |
+
$products = $this->getProductsFromOrder($order);
|
278 |
+
}
|
279 |
+
|
280 |
+
$storeCode = Mage::app()->getStore()->getCode();
|
281 |
+
$gtmContainerId = Mage::getStoreConfig('fanplayrsocialcoupons/config/gtm_container_id');
|
282 |
+
|
283 |
+
return array(
|
284 |
+
'orderId' => $orderId,
|
285 |
+
'orderNumber' => $orderNumber,
|
286 |
+
'orderDate' => $orderDate,
|
287 |
+
'total' => (float)$orderTotal,
|
288 |
+
'subTotal' => (float)$orderSubTotal,
|
289 |
+
'discount' => (float)$discountAmount,
|
290 |
+
'discountCode' => $discountCode,
|
291 |
+
'currency' => $currency,
|
292 |
+
'orderEmail' => $orderEmail,
|
293 |
+
'firstName' => $firstName,
|
294 |
+
'lastName' => $lastName,
|
295 |
+
'customerEmail' => $customerEmail,
|
296 |
+
'customerId' => $customerId,
|
297 |
+
'shipping' => (float)$shipping,
|
298 |
+
'tax' => (float)$tax,
|
299 |
+
'products' => $products,
|
300 |
+
'storeCode' => $storeCode,
|
301 |
+
'gtmContainerId' => $gtmContainerId
|
302 |
+
);
|
303 |
+
|
304 |
+
}
|
305 |
+
|
306 |
+
// used to fill out the "products" data
|
307 |
+
// this will normally be printed later as a JSON, but this simply returns an array or arrays
|
308 |
+
// it is likely we will not get all the information
|
309 |
+
private function getProductsFromOrder($order)
|
310 |
+
{
|
311 |
+
$products = array();
|
312 |
+
|
313 |
+
$items = $order->getAllItems();
|
314 |
+
|
315 |
+
foreach ($items as $itemId => $item) {
|
316 |
+
if ($item->getQtyOrdered() > 0 && !$item->getParentItemId()){
|
317 |
+
|
318 |
+
// bug in Magento 1.5 and below?
|
319 |
+
// just make sure it doesn't break things!
|
320 |
+
$sku = '';
|
321 |
+
try { $sku = $item->getSku(); }catch(Exception $e){}
|
322 |
+
|
323 |
+
$products[] = array(
|
324 |
+
'qty' => $item->getQtyOrdered(),
|
325 |
+
'id' => $item->getProductId(),
|
326 |
+
'sku' => $sku,
|
327 |
+
'name' => $item->getName(),
|
328 |
+
'price' => $item->getPrice(),
|
329 |
+
'catId' => '',
|
330 |
+
'catName' => ''
|
331 |
+
);
|
332 |
+
}
|
333 |
+
}
|
334 |
+
|
335 |
+
return $products;
|
336 |
+
}
|
337 |
+
|
338 |
+
public function isMageEnterprise() {
|
339 |
+
return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
|
340 |
+
}
|
341 |
+
|
342 |
+
public function isMageProfessional() {
|
343 |
+
return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
|
344 |
+
}
|
345 |
+
|
346 |
+
public function isMageCommunity() {
|
347 |
+
return !$this->isMageEnterprise() && !$this->isMageProfessional();
|
348 |
+
}
|
349 |
+
}
|
app/code/community/Fanplayr/Socialcoupons/controllers/AjaxController.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Fanplayr_Socialcoupons_AjaxController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
echo $this->jsonMessage(true, 'Please use a valid method.');
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getEmbedJsAction()
|
10 |
+
{
|
11 |
+
// store session data in case the cookie is lost somehow
|
12 |
+
$sessionVars = $this->decodeSessionCookie('fanplayr_genius_session');
|
13 |
+
if ($sessionVars) {
|
14 |
+
$session = Mage::getModel('core/session');
|
15 |
+
if ($session){
|
16 |
+
if (array_key_exists('key', $sessionVars)) $session->setData('fanplayr_session_session_key',$sessionVars['key']);
|
17 |
+
if (array_key_exists('user', $sessionVars)) $session->setData('fanplayr_session_user_key', $sessionVars['user']);
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
// now do the rest ...
|
22 |
+
$p = $this->getRequest()->getParams();
|
23 |
+
|
24 |
+
$block = new Mage_Core_Block_Template();
|
25 |
+
$block->setTemplate('fanplayr/embed.phtml');
|
26 |
+
|
27 |
+
// shop URL
|
28 |
+
$shopUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
29 |
+
if (!strpos($shopUrl, 'index.php/'))
|
30 |
+
$shopUrl .= 'index.php/';
|
31 |
+
$customEmbedUrl = trim(Mage::getStoreConfig('fanplayrsocialcoupons/config/custom_embed_url'));
|
32 |
+
if (!empty($customEmbedUrl)) $shopUrl = $customEmbedUrl;
|
33 |
+
|
34 |
+
$block->assign('widgetKeys', Mage::getStoreConfig('fanplayrsocialcoupons/config/widget_keys'));
|
35 |
+
$block->assign('widgetKeysGenius', Mage::getStoreConfig('fanplayrsocialcoupons/config/widget_keys_genius'));
|
36 |
+
$block->assign('accountKey', Mage::getStoreConfig('fanplayrsocialcoupons/config/acc_key'));
|
37 |
+
|
38 |
+
$block->assign('applyToCartUrl', $shopUrl . 'fanplayr/coupon/add/code/%c/');
|
39 |
+
$block->assign('depitizeUrl', $shopUrl . 'fanplayr/coupon/deputize/a/%a/d/%d/');
|
40 |
+
|
41 |
+
$block->assign('noTags', true);
|
42 |
+
|
43 |
+
// get data and add it ...
|
44 |
+
$data = Fanplayr_Socialcoupons_Model_EmbedObserver::getData(
|
45 |
+
array_key_exists('ac', $p) ? $p['ac'] == '1' : false,
|
46 |
+
array_key_exists('tt', $p) ? $p['tt'] : '',
|
47 |
+
array_key_exists('tp', $p) ? $p['tp'] : '',
|
48 |
+
array_key_exists('tc', $p) ? $p['tc'] : '',
|
49 |
+
array_key_exists('tpn', $p) ? $p['tpn'] : '',
|
50 |
+
array_key_exists('tcn', $p) ? $p['tcn'] : ''
|
51 |
+
);
|
52 |
+
|
53 |
+
$block->assign('data', $data);
|
54 |
+
|
55 |
+
$embedType = intval(Mage::getStoreConfig('fanplayrsocialcoupons/config/wait_for_onload'));
|
56 |
+
$block->assign('embedType', $embedType);
|
57 |
+
|
58 |
+
$this->getResponse()
|
59 |
+
->clearHeaders()
|
60 |
+
->setHeader('Cache-Control', 'no-cache, must-revalidate')
|
61 |
+
->setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT')
|
62 |
+
->setHeader('Content-Type', 'text/javascript')
|
63 |
+
->setBody($block->toHtml());
|
64 |
+
}
|
65 |
+
|
66 |
+
// -------------------------------------------------------------------
|
67 |
+
// decode session cookie
|
68 |
+
|
69 |
+
// in case sessions aren't being sent through correctly
|
70 |
+
// we will store this each hit, and then get it back later
|
71 |
+
|
72 |
+
private function decodeSessionCookie( $cookie_name )
|
73 |
+
{
|
74 |
+
if ( array_key_exists($cookie_name, $_COOKIE) && !empty($_COOKIE[$cookie_name]) ) {
|
75 |
+
$data = array();
|
76 |
+
$params = explode(';', $_COOKIE[$cookie_name]);
|
77 |
+
|
78 |
+
foreach ( $params as $param ) {
|
79 |
+
$parts = explode('=', $param);
|
80 |
+
if (count($parts) != 2)
|
81 |
+
continue;
|
82 |
+
|
83 |
+
$type = substr($parts[1], 0, 1);
|
84 |
+
$value = substr($parts[1], 1);
|
85 |
+
|
86 |
+
if ( empty($type) ) continue;
|
87 |
+
|
88 |
+
if ( $type === 'n' || $type === 'u' ) { $value = null; }
|
89 |
+
if ( $type === 'b' ) { $value = (intval($value, 10) !== 0); }
|
90 |
+
if ( $type === 'f' ) { $value = floatval($value); }
|
91 |
+
if ( $type === 's' ) { $value = urldecode($value); }
|
92 |
+
|
93 |
+
$data[urldecode($parts[0])] = $value;
|
94 |
+
}
|
95 |
+
|
96 |
+
return $data;
|
97 |
+
}
|
98 |
+
return null;
|
99 |
+
}
|
100 |
+
|
101 |
+
public function jsonMessage($isError, $message, $extras = array())
|
102 |
+
{
|
103 |
+
$extras['error'] = $isError;
|
104 |
+
$extras['message'] = $message;
|
105 |
+
$extras['version'] = $this->getExtensionVersion();
|
106 |
+
$extras['mage_version'] = Mage::getVersion();
|
107 |
+
|
108 |
+
return json_encode($extras);
|
109 |
+
}
|
110 |
+
|
111 |
+
private function getExtensionVersion()
|
112 |
+
{
|
113 |
+
return (string) Mage::getConfig()->getNode()->modules->Fanplayr_Socialcoupons->version;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
?>
|
app/code/community/Fanplayr/Socialcoupons/controllers/CompyController.php
ADDED
@@ -0,0 +1,750 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Fanplayr_Socialcoupons_CompyController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
private $countryLookup;
|
5 |
+
private $shippingLookup;
|
6 |
+
private $paymentLookup;
|
7 |
+
private $regionLookup;
|
8 |
+
|
9 |
+
public function indexAction()
|
10 |
+
{
|
11 |
+
echo $this->jsonMessage(true, 'Please use a valid method.');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function isPerm()
|
15 |
+
{
|
16 |
+
$p = $this->getRequest()->getParams();
|
17 |
+
|
18 |
+
// required input
|
19 |
+
$secret = array_key_exists('secret', $p) ? $p['secret'] : '';
|
20 |
+
$accKey = array_key_exists('acckey', $p) ? $p['acckey'] : '';
|
21 |
+
|
22 |
+
// error, needs more info
|
23 |
+
if (empty($secret) || empty($accKey)) {
|
24 |
+
echo $this->jsonMessage(true, "Error. Needs 'secret' and 'acckey'.");
|
25 |
+
return false;
|
26 |
+
}
|
27 |
+
|
28 |
+
$actualSecret = Mage::getStoreConfig('fanplayrsocialcoupons/config/secret');
|
29 |
+
$actualAccKey = Mage::getStoreConfig('fanplayrsocialcoupons/config/acc_key');
|
30 |
+
|
31 |
+
if ($actualSecret != $secret || $actualAccKey != $accKey) {
|
32 |
+
echo $this->jsonMessage(true, "Error. Either your 'secret' or 'acckey' are incorrect.");
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
return true;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function unlinkAction()
|
40 |
+
{
|
41 |
+
if (!$this->isPerm()) return;
|
42 |
+
|
43 |
+
$this->updateConfig('fanplayrsocialcoupons/config/secret', '', false);
|
44 |
+
$this->updateConfig('fanplayrsocialcoupons/config/secret_inner', '', false);
|
45 |
+
$this->updateConfig('fanplayrsocialcoupons/config/acc_key', '', false);
|
46 |
+
$this->updateConfig('fanplayrsocialcoupons/config/shop_id', '', false);
|
47 |
+
$this->updateConfig('fanplayrsocialcoupons/config/widget_keys', '', false);
|
48 |
+
$this->updateConfig('fanplayrsocialcoupons/config/widget_keys_genius', '', false);
|
49 |
+
$this->updateConfig('fanplayrsocialcoupons/config/disable_on_urls', '', false);
|
50 |
+
$this->updateConfig('fanplayrsocialcoupons/config/wait_for_onload', '', false);
|
51 |
+
|
52 |
+
$this->updateConfig('fanplayrsocialcoupons/config/dep_prefix', '', false);
|
53 |
+
$this->updateConfig('fanplayrsocialcoupons/config/dep_extra_rewrite_routes', '', false);
|
54 |
+
|
55 |
+
$this->updateConfig('fanplayrsocialcoupons/config/gtm_container_id', '', false);
|
56 |
+
$this->updateConfig('fanplayrsocialcoupons/config/trailing_slash', '', false);
|
57 |
+
|
58 |
+
$this->updateConfig('fanplayrsocialcoupons/config/custom_embed_url', '', true);
|
59 |
+
//$this->addNotice('Fanplayr details removed.');
|
60 |
+
echo $this->jsonMessage(false, 'Fanplayr unlink successful".');
|
61 |
+
}
|
62 |
+
|
63 |
+
public function addTemplateAction()
|
64 |
+
{
|
65 |
+
// protect
|
66 |
+
if (!$this->isPerm()) return;
|
67 |
+
|
68 |
+
$numTemplatesWithNoFanplayr = 0;
|
69 |
+
|
70 |
+
$originalPath = getcwd() . '/app/design/frontend/base/default/template/fanplayr';
|
71 |
+
|
72 |
+
foreach(array(getcwd().'/app/design/frontend/default/', getcwd().'/app/design/frontend/enterprise/') as $path) {
|
73 |
+
|
74 |
+
$dir = opendir($path);
|
75 |
+
|
76 |
+
while($d = readdir($dir)){
|
77 |
+
if (is_dir($path . $d) && $d != '.' && $d != '..') {
|
78 |
+
if (is_dir($path . $d . '/template') && !is_dir($path . $d . '/template/fanplayr')){
|
79 |
+
symlink($originalPath, $path . $d . '/template/fanplayr');
|
80 |
+
$numTemplatesWithNoFanplayr++;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
echo $this->jsonMessage(false, $numTemplatesWithNoFanplayr . ' templates added.');
|
88 |
+
}
|
89 |
+
|
90 |
+
public function consoleUpdateAction()
|
91 |
+
{
|
92 |
+
// a bit of dodgy stuff here, but should be fine
|
93 |
+
// hopefully doesn't make it less secure!
|
94 |
+
$p = $this->getRequest()->getParams();
|
95 |
+
|
96 |
+
// required input
|
97 |
+
$secretInner = array_key_exists('secretinner', $p) ? $p['secretinner'] : '';
|
98 |
+
$secret = array_key_exists('secret', $p) ? $p['secret'] : '';
|
99 |
+
|
100 |
+
$actualSecret = Mage::getStoreConfig('fanplayrsocialcoupons/config/secret');
|
101 |
+
$actualSecretInner = Mage::getStoreConfig('fanplayrsocialcoupons/config/secret_inner');
|
102 |
+
|
103 |
+
if (empty($secret) || empty($secretInner)) {
|
104 |
+
echo $this->jsonMessage(true, "Error. Needs 'secret' and 'super secret'!");
|
105 |
+
return false;
|
106 |
+
}
|
107 |
+
|
108 |
+
if ($actualSecret != $secret || $secretInner != $actualSecretInner) {
|
109 |
+
echo $this->jsonMessage(true, "Error. Either your 'secret' or 'super secret' are incorrect.");
|
110 |
+
return false;
|
111 |
+
}
|
112 |
+
|
113 |
+
// -----------------------------
|
114 |
+
|
115 |
+
$this->updateConfig('fanplayrsocialcoupons/config/secret', array_key_exists('secretnew', $p) ? $p['secretnew'] : '', false);
|
116 |
+
$this->updateConfig('fanplayrsocialcoupons/config/acc_key', array_key_exists('acckeynew', $p) ? $p['acckeynew'] : '', false);
|
117 |
+
$this->updateConfig('fanplayrsocialcoupons/config/shop_id', array_key_exists('shopid', $p) ? $p['shopid'] : '', false);
|
118 |
+
$this->updateConfig('fanplayrsocialcoupons/config/widget_keys', array_key_exists('gamafied', $p) ? $p['gamafied'] : '', false);
|
119 |
+
$this->updateConfig('fanplayrsocialcoupons/config/widget_keys_genius', array_key_exists('genius', $p) ? $p['genius'] : '', false);
|
120 |
+
$this->updateConfig('fanplayrsocialcoupons/config/custom_url', array_key_exists('url', $p) ? $p['url'] : '', false);
|
121 |
+
$this->updateConfig('fanplayrsocialcoupons/config/disable_on_urls', array_key_exists('disableonurls', $p) ? $p['disableonurls'] : '', false);
|
122 |
+
|
123 |
+
// a bit of a hack, used to be "waitforonload" but is now used for "embedtype"
|
124 |
+
$this->updateConfig('fanplayrsocialcoupons/config/wait_for_onload', (array_key_exists('embedtype', $p) ? $p['embedtype'] : '0'), false);
|
125 |
+
|
126 |
+
$this->updateConfig('fanplayrsocialcoupons/config/layout_hook', (array_key_exists('layouthook', $p) ? $p['layouthook'] : 'content'), false);
|
127 |
+
$this->updateConfig('fanplayrsocialcoupons/config/layout_hook_home', (array_key_exists('layouthookhome', $p) ? $p['layouthookhome'] : 'content'), false);
|
128 |
+
$this->updateConfig('fanplayrsocialcoupons/config/layout_hook_order', (array_key_exists('layouthookorder', $p) ? $p['layouthookorder'] : 'content'), false);
|
129 |
+
|
130 |
+
$this->updateConfig('fanplayrsocialcoupons/config/dep_prefix', array_key_exists('depprefix', $p) ? $p['depprefix'] : '', false);
|
131 |
+
$this->updateConfig('fanplayrsocialcoupons/config/dep_extra_rewrite_routes', array_key_exists('deproutes', $p) ? $p['deproutes'] : '', false);
|
132 |
+
|
133 |
+
$this->updateConfig('fanplayrsocialcoupons/config/gtm_container_id', array_key_exists('gtmcontainerid', $p) ? $p['gtmcontainerid'] : '', false);
|
134 |
+
$this->updateConfig('fanplayrsocialcoupons/config/trailing_slash', array_key_exists('trailingslash', $p) ? $p['trailingslash'] : '', false);
|
135 |
+
|
136 |
+
$this->updateConfig('fanplayrsocialcoupons/config/custom_embed_url', array_key_exists('customembedurl', $p) ? $p['customembedurl'] : '', true);
|
137 |
+
|
138 |
+
//$this->addNotice('Fanplayr details updated.');
|
139 |
+
echo $this->jsonMessage(false, 'Fanplayr details updated".');
|
140 |
+
}
|
141 |
+
|
142 |
+
public function setInstallDataAction()
|
143 |
+
{
|
144 |
+
$p = $this->getRequest()->getParams();
|
145 |
+
|
146 |
+
$secret = array_key_exists('secret', $p) ? $p['secret'] : '';
|
147 |
+
$accKey = array_key_exists('acckey', $p) ? $p['acckey'] : '';
|
148 |
+
$shopId = array_key_exists('shopid', $p) ? $p['shopid'] : '';
|
149 |
+
|
150 |
+
// error, needs more info
|
151 |
+
if (empty($secret) || empty($accKey) || empty($shopId)) {
|
152 |
+
//$this->addError("Fanplayr: Error setting install data. Please provide 'secret', 'accid' and 'shopid'.");
|
153 |
+
echo $this->jsonMessage(true, "Please provide 'secret', 'acckey' and 'shopid'.");
|
154 |
+
return;
|
155 |
+
}
|
156 |
+
|
157 |
+
// check that the secret is correct
|
158 |
+
$actualSecret = Mage::getStoreConfig('fanplayrsocialcoupons/config/secret');
|
159 |
+
if ($secret != $actualSecret){
|
160 |
+
//$this->addError('Fanplayr: Error setting install data. Secret is incorrect.');
|
161 |
+
echo $this->jsonMessage(true, 'Secret is incorrect.');
|
162 |
+
return;
|
163 |
+
}
|
164 |
+
|
165 |
+
// ok, we can set the new accId
|
166 |
+
$this->updateConfig('fanplayrsocialcoupons/config/acc_key', $accKey);
|
167 |
+
$this->updateConfig('fanplayrsocialcoupons/config/shop_id', $shopId);
|
168 |
+
|
169 |
+
//$this->addSuccess('Fanplayr: Install data set.');
|
170 |
+
|
171 |
+
// return a good response
|
172 |
+
echo $this->jsonMessage(false, 'Thanks, account ID updated to "' . $accKey . '" and shop ID to "' . $shopId . '".');
|
173 |
+
}
|
174 |
+
|
175 |
+
public function joinCompleteAction()
|
176 |
+
{
|
177 |
+
$p = $this->getRequest()->getParams();
|
178 |
+
|
179 |
+
$message = array_key_exists('message', $p) ? $p['message'] : '';
|
180 |
+
$error = array_key_exists('error', $p) ? $p['error'] : '';
|
181 |
+
|
182 |
+
//if (!empty($message)) $this->addSuccess("Fanplayr: " . $message);
|
183 |
+
//if (!empty($error)) $this->addError("Fanplayr: " . $error);
|
184 |
+
|
185 |
+
$skinDir = Mage::getBaseUrl('skin').'/frontend/socialcoupons';
|
186 |
+
|
187 |
+
$out = <<<EOT
|
188 |
+
<html>
|
189 |
+
<head>
|
190 |
+
<title></title>
|
191 |
+
<style>
|
192 |
+
#fanplayr-updating-logo {
|
193 |
+
width: 200px;
|
194 |
+
height: 65px;
|
195 |
+
margin: 30px auto;
|
196 |
+
}
|
197 |
+
#fanplayr-updating-thanks {
|
198 |
+
font-family: Helvetica, Arial, Verdana, sans-serif;
|
199 |
+
font-size: 120%;
|
200 |
+
font-weight: bold;
|
201 |
+
text-align:center;
|
202 |
+
}
|
203 |
+
#fanplayr-updating-spinner {
|
204 |
+
width: 43px;
|
205 |
+
height: 11px;
|
206 |
+
margin: 30px auto;
|
207 |
+
}
|
208 |
+
</style>
|
209 |
+
<script>
|
210 |
+
window.top.location.reload(true);
|
211 |
+
</script>
|
212 |
+
</head>
|
213 |
+
<body>
|
214 |
+
<div id="fanplayr-updating-logo"><img src="{$skinDir}/images/fanplayr_logo.png" width="200" height="65" alt="Fanplayr Logo" title="Fanplayr" /></div>
|
215 |
+
<div id="fanplayr-updating-thanks">Thanks. Updating details.</div>
|
216 |
+
<div id="fanplayr-updating-spinner"><img src="{$skinDir}/images/progress-loader.gif" width="43" height="11" alt="Loading ..." title="Loading ..." /></div>
|
217 |
+
</body>
|
218 |
+
</html>
|
219 |
+
EOT;
|
220 |
+
echo $out;
|
221 |
+
}
|
222 |
+
|
223 |
+
public function addWidgetAction()
|
224 |
+
{
|
225 |
+
$this->addRemoveWidget(false);
|
226 |
+
}
|
227 |
+
|
228 |
+
public function removeWidgetAction()
|
229 |
+
{
|
230 |
+
$this->addRemoveWidget(true);
|
231 |
+
}
|
232 |
+
|
233 |
+
private function countryNameFromCode($code)
|
234 |
+
{
|
235 |
+
if (!$this->countryLookup) $this->countryLookup = Mage::getModel('directory/country_api')->items();
|
236 |
+
|
237 |
+
foreach($this->countryLookup as $k => $v) {
|
238 |
+
if (array_key_exists('country_id', $v) && $v['country_id'] == $code)
|
239 |
+
return $v['name'];
|
240 |
+
}
|
241 |
+
return $code;
|
242 |
+
}
|
243 |
+
|
244 |
+
private function paymentNameFromCode($code)
|
245 |
+
{
|
246 |
+
if (!$this->paymentLookup) $this->paymentLookup = Mage::getSingleton('payment/config')->getActiveMethods();
|
247 |
+
|
248 |
+
foreach ($this->paymentLookup as $paymentCode => $paymentModel) {
|
249 |
+
if ($paymentCode == $code) {
|
250 |
+
return Mage::getStoreConfig('payment/'.$paymentCode.'/title');
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
return $code;
|
255 |
+
}
|
256 |
+
|
257 |
+
private function shippingNameFromCode($code)
|
258 |
+
{
|
259 |
+
if (!$this->shippingLookup) $this->shippingLookup = Mage::getSingleton('shipping/config')->getAllCarriers();
|
260 |
+
|
261 |
+
foreach ($this->shippingLookup as $carrierCode => $carrierModel) {
|
262 |
+
$carrierMethods = $carrierModel->getAllowedMethods();
|
263 |
+
if (!$carrierMethods)
|
264 |
+
return $code;
|
265 |
+
|
266 |
+
$carrierTitle = Mage::getStoreConfig('carriers/'.$carrierCode.'/title');
|
267 |
+
foreach ($carrierMethods as $methodCode => $methodTitle) {
|
268 |
+
if ($carrierCode.'_'.$methodCode == $code) {
|
269 |
+
return '['.$carrierCode.'] '.$methodTitle;
|
270 |
+
}
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
return $code;
|
275 |
+
}
|
276 |
+
|
277 |
+
private function regionNameFromCode($code)
|
278 |
+
{
|
279 |
+
$countriesArray = Mage::getResourceModel('directory/country_collection')->load()->toOptionArray(false);
|
280 |
+
$countries = array();
|
281 |
+
foreach ($countriesArray as $a) {
|
282 |
+
$countries[$a['value']] = $a['label'];
|
283 |
+
}
|
284 |
+
|
285 |
+
$countryRegions = array();
|
286 |
+
$regionsCollection = Mage::getResourceModel('directory/region_collection')->load();
|
287 |
+
foreach ($regionsCollection as $region) {
|
288 |
+
$countryRegions[$region->getCountryId()][$region->getId()] = $region->getDefaultName();
|
289 |
+
}
|
290 |
+
|
291 |
+
foreach ($countryRegions as $countryId=>$regions) {
|
292 |
+
foreach ($regions as $regionId => $regionName) {
|
293 |
+
if ($regionId == $code) {
|
294 |
+
return $regionName.', '.$countries[$countryId];
|
295 |
+
}
|
296 |
+
}
|
297 |
+
}
|
298 |
+
|
299 |
+
return $code;
|
300 |
+
}
|
301 |
+
|
302 |
+
public function getRulesAction()
|
303 |
+
{
|
304 |
+
if (!$this->isPerm()) return;
|
305 |
+
|
306 |
+
|
307 |
+
$p = $this->getRequest()->getParams();
|
308 |
+
|
309 |
+
$offset = array_key_exists('offset', $p) ? $p['offset'] : null;
|
310 |
+
if ($offset == null) $offset = 0;
|
311 |
+
$offset = (int)$offset;
|
312 |
+
$limit = array_key_exists('limit', $p) ? $p['limit'] : null;
|
313 |
+
if ($limit == null) $limit = 100;
|
314 |
+
$limit = (int)$limit;
|
315 |
+
|
316 |
+
try {
|
317 |
+
$rules = Mage::getResourceModel('salesrule/rule_collection')->load();
|
318 |
+
|
319 |
+
//$rules = Mage::getModel('salesrule/rule')->getCollection();
|
320 |
+
//$rules->getSelect()->limit($limit, $offset);
|
321 |
+
|
322 |
+
$returnData = array();
|
323 |
+
|
324 |
+
foreach ($rules as $rule)
|
325 |
+
{
|
326 |
+
if (!$rule-> getIsActive())
|
327 |
+
continue;
|
328 |
+
|
329 |
+
// don't send those that have expired over
|
330 |
+
// hopefully this will fix any problems with too many coupons being sent?
|
331 |
+
if ($rule->getToDate() && strtotime($rule->getToDate()) < time())
|
332 |
+
continue;
|
333 |
+
|
334 |
+
$rule = Mage::getModel('salesrule/rule')->load($rule->getId());
|
335 |
+
|
336 |
+
$data = $rule->getData();
|
337 |
+
if (array_key_exists('conditions_serialized', $data)) unset($data['conditions_serialized']);
|
338 |
+
if (array_key_exists('actions_serialized', $data)) unset($data['actions_serialized']);
|
339 |
+
|
340 |
+
$data['conditions'] = $rule->getConditions()->asArray();
|
341 |
+
|
342 |
+
if ($data['conditions']['conditions']){
|
343 |
+
foreach($data['conditions']['conditions'] as $k => $v) {
|
344 |
+
if ($v['type'] == 'salesrule/rule_condition_address') {
|
345 |
+
|
346 |
+
// if it's a country, replace the country data
|
347 |
+
if ($v['attribute'] == 'country_id') {
|
348 |
+
$countryName = $this->countryNameFromCode($v['value']);
|
349 |
+
|
350 |
+
if ($countryName) {
|
351 |
+
$data['conditions']['conditions'][$k]['value'] = $countryName;
|
352 |
+
}
|
353 |
+
}
|
354 |
+
|
355 |
+
// region
|
356 |
+
if ($v['attribute'] == 'region_id') {
|
357 |
+
$regionName = $this->regionNameFromCode($v['value']);
|
358 |
+
|
359 |
+
if ($regionName) {
|
360 |
+
$data['conditions']['conditions'][$k]['value'] = $regionName;
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
// payment method
|
365 |
+
if ($v['attribute'] == 'payment_method') {
|
366 |
+
$paymentName = $this->paymentNameFromCode($v['value']);
|
367 |
+
|
368 |
+
if ($paymentName) {
|
369 |
+
$data['conditions']['conditions'][$k]['value'] = $paymentName;
|
370 |
+
}
|
371 |
+
}
|
372 |
+
|
373 |
+
// shipping method
|
374 |
+
if ($v['attribute'] == 'shipping_method') {
|
375 |
+
$shippingName = $this->shippingNameFromCode($v['value']);
|
376 |
+
|
377 |
+
if ($countryName) {
|
378 |
+
$data['conditions']['conditions'][$k]['value'] = $shippingName;
|
379 |
+
}
|
380 |
+
}
|
381 |
+
}
|
382 |
+
}
|
383 |
+
}
|
384 |
+
|
385 |
+
array_push($returnData, $data);
|
386 |
+
}
|
387 |
+
|
388 |
+
$returnData = array_reverse($returnData);
|
389 |
+
|
390 |
+
echo $this->jsonMessage(false, 'Rewards gathered.', array('rules' => $returnData));
|
391 |
+
}catch (Exception $e) {
|
392 |
+
echo $this->jsonMessage(true, 'Sorry, there was a problem getting Rules data.');
|
393 |
+
}
|
394 |
+
}
|
395 |
+
|
396 |
+
// addev in v1.0.18
|
397 |
+
public function getPrefixAction()
|
398 |
+
{
|
399 |
+
if (!$this->isPerm()) return;
|
400 |
+
|
401 |
+
echo $this->jsonMessage(false, 'Deputization Prefix.', array('prefix' => Mage::getStoreConfig('fanplayrsocialcoupons/config/dep_prefix')));
|
402 |
+
}
|
403 |
+
|
404 |
+
// addev in v1.0.18
|
405 |
+
public function setPrefixAction()
|
406 |
+
{
|
407 |
+
if (!$this->isPerm()) return;
|
408 |
+
|
409 |
+
$p = $this->getRequest()->getParams();
|
410 |
+
$prefix = array_key_exists('prefix', $p) ? $p['prefix'] : '';
|
411 |
+
|
412 |
+
if (empty($prefix)) {
|
413 |
+
echo $this->jsonMessage(true, "'prefix' required.");
|
414 |
+
return;
|
415 |
+
}
|
416 |
+
|
417 |
+
$oldPrefix = Mage::getStoreConfig('fanplayrsocialcoupons/config/dep_prefix');
|
418 |
+
$this->updateConfig('fanplayrsocialcoupons/config/dep_prefix', $prefix);
|
419 |
+
|
420 |
+
echo $this->jsonMessage(false, 'Deputization Prefix.', array('oldPrefix' => $oldPrefix, 'newPrefix' => Mage::getStoreConfig('fanplayrsocialcoupons/config/dep_prefix')));
|
421 |
+
}
|
422 |
+
|
423 |
+
// added in v1.0.18
|
424 |
+
public function getOrdersAction()
|
425 |
+
{
|
426 |
+
if (!$this->isPerm()) return;
|
427 |
+
|
428 |
+
$p = $this->getRequest()->getParams();
|
429 |
+
|
430 |
+
$orderId = array_key_exists('id', $p) ? $p['id'] : null;
|
431 |
+
$orderNumber = array_key_exists('num', $p) ? @$p['num'] : null;
|
432 |
+
|
433 |
+
// id, num, date, updated, null
|
434 |
+
$filter = array_key_exists('filter', $p) ? $p['filter'] : null;
|
435 |
+
|
436 |
+
$to = array_key_exists('to', $p) ? $p['to'] : null;
|
437 |
+
$from = array_key_exists('from', $p) ? $p['from'] : null;
|
438 |
+
|
439 |
+
$offset = array_key_exists('offset', $p) ? $p['offset'] : null;
|
440 |
+
if ($offset == null) $offset = 0;
|
441 |
+
$offset = (int)$offset;
|
442 |
+
$limit = array_key_exists('limit', $p) ? $p['limit'] : null;
|
443 |
+
if ($limit == null) $limit = 10;
|
444 |
+
$limit = (int)$limit;
|
445 |
+
|
446 |
+
// single
|
447 |
+
if (!empty($orderId) || !empty($orderNumber)) {
|
448 |
+
if ($orderId){
|
449 |
+
$orders = array(Mage::getModel('sales/order')->load($orderId));
|
450 |
+
}else {
|
451 |
+
$orders = array(Mage::getModel('sales/order')->loadByIncrementId($orderNumber));
|
452 |
+
}
|
453 |
+
|
454 |
+
if (is_array($orders) && $orders[0]->getRealOrderId() == null) {
|
455 |
+
echo $this->jsonMessage(true, 'Error getting order.', array('orders' => null, 'count' => 0));
|
456 |
+
return;
|
457 |
+
}
|
458 |
+
// multi
|
459 |
+
} else {
|
460 |
+
|
461 |
+
if ($filter == 'id') $filterBy = 'entity_id';
|
462 |
+
if ($filter == 'num') $filterBy = 'increment_id';
|
463 |
+
if ($filter == 'date') $filterBy = 'created_at';
|
464 |
+
if ($filter == 'updated') $filterBy = 'updated_at';
|
465 |
+
|
466 |
+
$orders = Mage::getModel('sales/order')->getCollection();
|
467 |
+
|
468 |
+
if ($filter) {
|
469 |
+
if ($from && $to) {
|
470 |
+
$orders = $orders->addAttributeToFilter($filterBy, array('from' => $from, 'to' => $to));
|
471 |
+
} else {
|
472 |
+
echo $this->jsonMessage(false, 'Orders returned.', array('orders' => $orderReturn, 'count' => 0));
|
473 |
+
return;
|
474 |
+
}
|
475 |
+
}
|
476 |
+
|
477 |
+
$orders->getSelect()->limit($limit, $offset);
|
478 |
+
}
|
479 |
+
|
480 |
+
$count = 0;
|
481 |
+
$count = $orders->count();
|
482 |
+
|
483 |
+
// will fill this ..
|
484 |
+
$orderReturn = array();
|
485 |
+
|
486 |
+
// ---------------------------------------------------
|
487 |
+
// yep, gotta support 1.4
|
488 |
+
|
489 |
+
$mageV = Mage::getVersion();
|
490 |
+
$mageVa = explode('.', $mageV);
|
491 |
+
|
492 |
+
// community 1.4 and below
|
493 |
+
// enterprise?
|
494 |
+
$useOldVersion = false;
|
495 |
+
if ($this->isMageCommunity() && $mageVa[0] == '1' && intval($mageVa[1]) <= 4) {
|
496 |
+
$useOldVersion = true;
|
497 |
+
}
|
498 |
+
|
499 |
+
// have to get the last order in a stupid way for some reason for 1.4 ...
|
500 |
+
if ($useOldVersion) {
|
501 |
+
|
502 |
+
foreach($orders as $order) {
|
503 |
+
|
504 |
+
$data = $order->getData();
|
505 |
+
|
506 |
+
$orderReturn[] = array(
|
507 |
+
'orderId' => array_key_exists('id', $data) ? $data['id'] : '',
|
508 |
+
'orderNumber' => $order->getRealOrderId(),
|
509 |
+
'orderEmail' => array_key_exists('customer_email', $data) ? $data['customer_email'] : '',
|
510 |
+
'orderDate' => array_key_exists('created_at', $data) ? $data['created_at'] : '',
|
511 |
+
'updatedDate' => array_key_exists('updated_at', $data) ? $data['updated_at'] : '',
|
512 |
+
'currency' => array_key_exists('order_currency_code', $data) ? $data['order_currency_code'] : '',
|
513 |
+
'orderTotal' => array_key_exists('subtotal', $data) ? round($data['subtotal'], 2) : 0,
|
514 |
+
'firstName' => array_key_exists('customer_firstname', $data) ? $data['customer_firstname'] : '',
|
515 |
+
'lastName' => array_key_exists('customer_lastname', $data) ? $data['customer_lastname'] : '',
|
516 |
+
'customerEmail' => array_key_exists('customer_email', $data) ? $data['customer_email'] : '',
|
517 |
+
'customerId' => array_key_exists('customer_id', $data) ? $data['customer_id'] : '',
|
518 |
+
'discountCode' => array_key_exists('coupon_code', $data) ? $data['coupon_code'] : '',
|
519 |
+
'discountAmount' => array_key_exists('discount_amount', $data) ? round($data['discount_amount'], 2) : 0,
|
520 |
+
'state' => array_key_exists('state', $data) ? $data['state'] : '',
|
521 |
+
'status' => array_key_exists('status', $data) ? $data['status'] : ''
|
522 |
+
);
|
523 |
+
}
|
524 |
+
|
525 |
+
}else {
|
526 |
+
|
527 |
+
foreach($orders as $order) {
|
528 |
+
|
529 |
+
$data = $order->getData();
|
530 |
+
|
531 |
+
$orderReturn[] = array(
|
532 |
+
'orderId' => $order->getId(),
|
533 |
+
'orderNumber' => $order->getRealOrderId(),
|
534 |
+
'orderEmail' => $order->getCustomerEmail(),
|
535 |
+
'orderDate' => $order->getCreatedAt(),
|
536 |
+
'updatedDate' => $order->getUpdatedAt(),
|
537 |
+
'currency' => $order->getOrderCurrencyCode(),
|
538 |
+
'orderTotal' => round($order->getBaseSubtotal(), 2),
|
539 |
+
'firstName' => $order->getCustomerFirstname(),
|
540 |
+
'lastName' => $order->getCustomerLastname(),
|
541 |
+
'customerEmail' => $order->getCustomerEmail(),
|
542 |
+
'customerId' => $order->getCustomerId(),
|
543 |
+
'discountCode' => $order->getCouponCode(),
|
544 |
+
'discountAmount' => array_key_exists('base_discount_amount', $data) ? round($data['base_discount_amount'], 2) : 0,
|
545 |
+
'state' => $order->getState(),
|
546 |
+
'status' => $order->getStatus()
|
547 |
+
);
|
548 |
+
}
|
549 |
+
|
550 |
+
}
|
551 |
+
// ---------------------------------------------------
|
552 |
+
|
553 |
+
echo $this->jsonMessage(false, 'Orders returned.', array('orders' => $orderReturn, 'count' => $count));
|
554 |
+
}
|
555 |
+
|
556 |
+
// ------------------------------------------------------------------
|
557 |
+
// testing only
|
558 |
+
public function clearCartAction()
|
559 |
+
{
|
560 |
+
if (strpos($_SERVER['HTTP_HOST'], 'fanplayr.com') > 0){
|
561 |
+
$cartHelper = Mage::helper('checkout/cart');
|
562 |
+
$items = $cartHelper->getCart()->getItems();
|
563 |
+
foreach ($items as $item) {
|
564 |
+
$itemId = $item->getItemId();
|
565 |
+
$cartHelper->getCart()->removeItem($itemId)->save();
|
566 |
+
}
|
567 |
+
}
|
568 |
+
}
|
569 |
+
|
570 |
+
// -------------------------------------------------------------------
|
571 |
+
// used by both add / remove
|
572 |
+
private function addRemoveWidget($remove = false)
|
573 |
+
{
|
574 |
+
if (!$this->isPerm()) return;
|
575 |
+
|
576 |
+
$p = $this->getRequest()->getParams();
|
577 |
+
|
578 |
+
// required input
|
579 |
+
$secret = array_key_exists('secret', $p) ? $p['secret'] : null;
|
580 |
+
$accKey = array_key_exists('acckey', $p) ? $p['acckey'] : null;
|
581 |
+
$campKey = array_key_exists('campkey', $p) ? $p['campkey'] : null;
|
582 |
+
|
583 |
+
// could be null for "social-sales" or "genius"
|
584 |
+
$type = array_key_exists('type', $p) ? $p['type'] : null;
|
585 |
+
|
586 |
+
$inform = array_key_exists('inform', $p) ? $p['inform'] == '1' : false;
|
587 |
+
$shopId = Mage::getStoreConfig('fanplayrsocialcoupons/config/shop_id');
|
588 |
+
|
589 |
+
// tell fanplayr about it
|
590 |
+
if ($inform) {
|
591 |
+
$m = null;
|
592 |
+
try {
|
593 |
+
$m = json_decode($this->httpGetContent('http://my.fanplayr.com/api.magentoInformWidget/', array(
|
594 |
+
'acc_key' => $accKey,
|
595 |
+
'shop_id' => $shopId,
|
596 |
+
'secret' => $secret,
|
597 |
+
'version' => $this->getExtensionVersion(),
|
598 |
+
'camp_key' => $campKey,
|
599 |
+
'remove' => ($remove ? '1' : '0'),
|
600 |
+
'type' => $type
|
601 |
+
)));
|
602 |
+
}catch (Exception $e) {
|
603 |
+
echo $this->jsonMessage(true, "Error. Could not inform Fanplayr.");
|
604 |
+
return;
|
605 |
+
}
|
606 |
+
if ($m) {
|
607 |
+
if ($m->error) {
|
608 |
+
echo $this->jsonMessage(true, $m->message);
|
609 |
+
return;
|
610 |
+
}
|
611 |
+
}
|
612 |
+
}
|
613 |
+
|
614 |
+
// if that worked (or we skipped) now add to local config to actually show it
|
615 |
+
$widgetConf = 'fanplayrsocialcoupons/config/widget_keys';
|
616 |
+
if (!empty($type)) {
|
617 |
+
// genius, social-sales
|
618 |
+
if ($type == 'genius')
|
619 |
+
$widgetConf = 'fanplayrsocialcoupons/config/widget_keys_genius';
|
620 |
+
}
|
621 |
+
|
622 |
+
$widgetKeys = array();
|
623 |
+
try {
|
624 |
+
$widgetKeys = json_decode(Mage::getStoreConfig($widgetConf));
|
625 |
+
}catch(Exception $e) {
|
626 |
+
}
|
627 |
+
|
628 |
+
if (!is_array($widgetKeys))
|
629 |
+
$widgetKeys = array();
|
630 |
+
|
631 |
+
if ($remove){
|
632 |
+
$this->array_remove_all($widgetKeys, $campKey);
|
633 |
+
}else {
|
634 |
+
array_push($widgetKeys, $campKey);
|
635 |
+
}
|
636 |
+
|
637 |
+
$this->updateConfig($widgetConf, json_encode($widgetKeys));
|
638 |
+
|
639 |
+
echo $this->jsonMessage(false, "Widget set.");
|
640 |
+
return;
|
641 |
+
}
|
642 |
+
|
643 |
+
// added in 1.0.18
|
644 |
+
public function getWidgetAction()
|
645 |
+
{
|
646 |
+
if (!$this->isPerm()) return;
|
647 |
+
|
648 |
+
$p = $this->getRequest()->getParams();
|
649 |
+
$type = array_key_exists('type', $p) ? $p['type'] : null;
|
650 |
+
if (empty($type))
|
651 |
+
$type = 'social-sales';
|
652 |
+
|
653 |
+
$widgetConf = 'fanplayrsocialcoupons/config/widget_keys';
|
654 |
+
if ($type == 'genius')
|
655 |
+
$widgetConf = 'fanplayrsocialcoupons/config/widget_keys_genius';
|
656 |
+
|
657 |
+
$widgetKeys = array();
|
658 |
+
try {
|
659 |
+
$widgetKeys = json_decode(Mage::getStoreConfig($widgetConf));
|
660 |
+
}catch(Exception $e) {
|
661 |
+
}
|
662 |
+
|
663 |
+
echo $this->jsonMessage(false, "Widget keys: " . $type, array('keys'=>$widgetKeys));
|
664 |
+
}
|
665 |
+
|
666 |
+
// -------------------------------------------------------------------------------
|
667 |
+
// helpers
|
668 |
+
|
669 |
+
function array_remove( &$array, $val ) {
|
670 |
+
foreach ( $array as $i => $v ) {
|
671 |
+
if ( $v == $val ) {
|
672 |
+
array_splice( $array, $i, 1 );
|
673 |
+
return $array;
|
674 |
+
}
|
675 |
+
}
|
676 |
+
return $array;
|
677 |
+
}
|
678 |
+
|
679 |
+
function array_remove_all( &$array, $val ) {
|
680 |
+
$n = array();
|
681 |
+
foreach ( $array as $i => $v ) {
|
682 |
+
if ( $v != $val ) {
|
683 |
+
array_push($n, $v);
|
684 |
+
}
|
685 |
+
}
|
686 |
+
$array = $n;
|
687 |
+
return $array;
|
688 |
+
}
|
689 |
+
|
690 |
+
public function jsonMessage($isError, $message, $extras = array())
|
691 |
+
{
|
692 |
+
$extras['error'] = $isError;
|
693 |
+
$extras['message'] = $message;
|
694 |
+
$extras['version'] = $this->getExtensionVersion();
|
695 |
+
$extras['mage_version'] = Mage::getVersion();
|
696 |
+
|
697 |
+
return json_encode($extras);
|
698 |
+
}
|
699 |
+
|
700 |
+
private function getExtensionVersion()
|
701 |
+
{
|
702 |
+
return (string) Mage::getConfig()->getNode()->modules->Fanplayr_Socialcoupons->version;
|
703 |
+
}
|
704 |
+
|
705 |
+
// postVars as k/v array OR
|
706 |
+
private function httpGetContent($url, $vars = null)
|
707 |
+
{
|
708 |
+
$ch = curl_init();
|
709 |
+
|
710 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
711 |
+
curl_setopt($ch, CURLOPT_HEADER, 0);
|
712 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ;
|
713 |
+
|
714 |
+
if ($vars != null) {
|
715 |
+
// WTF ?
|
716 |
+
if (is_array($vars)) $vars = str_replace('&', '&', http_build_query($vars));
|
717 |
+
//curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
|
718 |
+
//curl_setopt($ch, CURLOPT_POST, 1);
|
719 |
+
curl_setopt($ch, CURLOPT_URL, $url.'?'.$vars);
|
720 |
+
}
|
721 |
+
|
722 |
+
$r = curl_exec($ch);
|
723 |
+
curl_close($ch);
|
724 |
+
|
725 |
+
return $r;
|
726 |
+
}
|
727 |
+
|
728 |
+
public function updateConfig($key, $value, $refresh = true)
|
729 |
+
{
|
730 |
+
Mage::getConfig()->saveConfig($key, $value);
|
731 |
+
if ($refresh){
|
732 |
+
Mage::getConfig()->reinit();
|
733 |
+
Mage::app()->reinitStores();
|
734 |
+
}
|
735 |
+
}
|
736 |
+
|
737 |
+
public function isMageEnterprise() {
|
738 |
+
return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
|
739 |
+
}
|
740 |
+
|
741 |
+
public function isMageProfessional() {
|
742 |
+
return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
|
743 |
+
}
|
744 |
+
|
745 |
+
public function isMageCommunity() {
|
746 |
+
return !$this->isMageEnterprise() && !$this->isMageProfessional();
|
747 |
+
}
|
748 |
+
|
749 |
+
}
|
750 |
+
?>
|
app/code/community/Fanplayr/Socialcoupons/controllers/CouponController.php
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Fanplayr_Socialcoupons_CouponController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public $hasSucceeded;
|
5 |
+
|
6 |
+
public function indexAction()
|
7 |
+
{
|
8 |
+
echo $this->jsonMessage(true, 'Please use a valid method.');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function addAction()
|
12 |
+
{
|
13 |
+
$p = $this->getRequest()->getParams();
|
14 |
+
$code = array_key_exists('code', $p) ? $p['code'] : '';
|
15 |
+
|
16 |
+
// ----------------------------------------
|
17 |
+
// if we have a code then apply, otherwise error
|
18 |
+
if (!empty($code)) {
|
19 |
+
$this->applyCoupon($code);
|
20 |
+
$this->redirect();
|
21 |
+
}else {
|
22 |
+
$message = $this->__('No coupon code supplied.');
|
23 |
+
$this->error($message);
|
24 |
+
$this->redirect();
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
public function deputizeAction()
|
29 |
+
{
|
30 |
+
$p = $this->getRequest()->getParams();
|
31 |
+
|
32 |
+
$actualCode = array_key_exists('a', $p) ? $p['a'] : null;
|
33 |
+
$deputyCode = array_key_exists('d', $p) ? $p['d'] : null;
|
34 |
+
|
35 |
+
if ($actualCode && $deputyCode)
|
36 |
+
{
|
37 |
+
$session = Mage::getSingleton("core/session");
|
38 |
+
|
39 |
+
$deputies = $session->getData("fanplayr_deputy_codes");
|
40 |
+
|
41 |
+
// cookie fallback
|
42 |
+
if (!$deputies) {
|
43 |
+
$cookie = Mage::getSingleton('core/cookie');
|
44 |
+
$d = $cookie->get('fanplayr_deputy_codes');
|
45 |
+
if ($d) $deputies = (Array)json_decode($d);
|
46 |
+
}
|
47 |
+
|
48 |
+
if (!is_array($deputies))
|
49 |
+
$deputies = array();
|
50 |
+
|
51 |
+
$deputies[$deputyCode] = $actualCode;
|
52 |
+
|
53 |
+
$session->setData("fanplayr_deputy_codes", $deputies);
|
54 |
+
|
55 |
+
$cookie = Mage::getSingleton('core/cookie');
|
56 |
+
$cookie->set('fanplayr_deputy_codes', json_encode($deputies), 10800, '/');
|
57 |
+
}
|
58 |
+
|
59 |
+
//echo json_encode($deputies);
|
60 |
+
}
|
61 |
+
|
62 |
+
public function applyCoupon($couponCode)
|
63 |
+
{
|
64 |
+
$itemInCart = true;
|
65 |
+
$this->hasSucceeded = true;
|
66 |
+
|
67 |
+
$quote = $this->getCurrentQuote();
|
68 |
+
|
69 |
+
if (!$quote->getItemsCount()) {
|
70 |
+
$itemInCart = false;
|
71 |
+
// store it for later use ...
|
72 |
+
$this->remember($couponCode);
|
73 |
+
$message = $this->__('There are currently no items in the shopping cart. We will try and apply your coupon code "%s" once you have added some items to your cart.', Mage::helper('core')->htmlEscape($couponCode));
|
74 |
+
$this->notice($message);
|
75 |
+
}
|
76 |
+
|
77 |
+
if ($itemInCart){
|
78 |
+
|
79 |
+
$oldCouponCode = $quote->getCouponCode();
|
80 |
+
if (!strlen($couponCode) && !strlen($oldCouponCode)) {
|
81 |
+
$this->redirect();
|
82 |
+
}
|
83 |
+
|
84 |
+
// ----------------------------------------
|
85 |
+
// check for deputized coupon and replace
|
86 |
+
$session = Mage::getSingleton("core/session");
|
87 |
+
$deputies = $session->getData("fanplayr_deputy_codes");
|
88 |
+
|
89 |
+
// cookie fallback
|
90 |
+
if (!$deputies) {
|
91 |
+
$cookie = Mage::getSingleton('core/cookie');
|
92 |
+
$d = $cookie->get('fanplayr_deputy_codes');
|
93 |
+
if ($d) $deputies = (Array)json_decode($d);
|
94 |
+
}
|
95 |
+
|
96 |
+
if (is_array($deputies) && array_key_exists($couponCode, $deputies)) {
|
97 |
+
// must be set first to get actual coupon
|
98 |
+
// need to set as array, to support those horrible multi-coupon extensions
|
99 |
+
$sessionDeps = $session->getData('fanplayr_used_deputies');
|
100 |
+
if (!is_array($sessionDeps))
|
101 |
+
$sessionDeps = array();
|
102 |
+
// and only add it if it's not there so no duplicates
|
103 |
+
if (!in_array($couponCode, $sessionDeps))
|
104 |
+
array_push($sessionDeps, $couponCode);
|
105 |
+
$session->setData('fanplayr_used_deputies', $sessionDeps);
|
106 |
+
|
107 |
+
//
|
108 |
+
$couponCode = array_key_exists($couponCode, $deputies) ? $deputies[$couponCode] : '';
|
109 |
+
}
|
110 |
+
|
111 |
+
try {
|
112 |
+
$quote->getShippingAddress()->setCollectShippingRates(true);
|
113 |
+
$quote->setCouponCode(strlen($couponCode) ? $couponCode : '')
|
114 |
+
->collectTotals()
|
115 |
+
->save();
|
116 |
+
} catch (Exception $e) {
|
117 |
+
//$this->error('Cannot apply coupon code: ' . $e->getMessage());
|
118 |
+
$this->error($this->__('Cannot apply the coupon code'));
|
119 |
+
}
|
120 |
+
|
121 |
+
if ($couponCode) {
|
122 |
+
if ($couponCode != $quote-> getCouponCode()) {
|
123 |
+
$this->error($this->__('Coupon code "%s" is not valid.', Mage::helper('core')->htmlEscape($couponCode)));
|
124 |
+
//$this->error('Coupon code is invalid.');
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
if ($this->hasSucceeded) {
|
129 |
+
$this->success($this->__('Coupon code "%s" was applied.', Mage::helper('core')->htmlEscape($couponCode)));
|
130 |
+
//$this->success('Your coupon has been applied.');
|
131 |
+
}
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
public function redirect()
|
136 |
+
{
|
137 |
+
// now go to cart and add thanks message
|
138 |
+
$shopUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
139 |
+
if (!strpos($shopUrl, 'index.php/'))
|
140 |
+
$shopUrl .= 'index.php/';
|
141 |
+
$customEmbedUrl = trim(Mage::getStoreConfig('fanplayrsocialcoupons/config/custom_embed_url'));
|
142 |
+
if (!empty($customEmbedUrl)) $shopUrl = $customEmbedUrl;
|
143 |
+
|
144 |
+
header('Location: ' . $shopUrl . 'checkout/cart/');
|
145 |
+
exit(1);
|
146 |
+
}
|
147 |
+
|
148 |
+
public function getCurrentQuote()
|
149 |
+
{
|
150 |
+
return Mage::getSingleton('checkout/session')->getQuote();
|
151 |
+
}
|
152 |
+
|
153 |
+
// TODO: multilingual this
|
154 |
+
public function error($message)
|
155 |
+
{
|
156 |
+
Mage::getSingleton('checkout/session')->addError($message);
|
157 |
+
$this->hasSucceeded = false;
|
158 |
+
}
|
159 |
+
|
160 |
+
public function success($message)
|
161 |
+
{
|
162 |
+
Mage::getSingleton('checkout/session')->addSuccess($message);
|
163 |
+
}
|
164 |
+
|
165 |
+
public function notice($message)
|
166 |
+
{
|
167 |
+
Mage::getSingleton('checkout/session')->addNotice($message);
|
168 |
+
}
|
169 |
+
|
170 |
+
public function remember($couponCode)
|
171 |
+
{
|
172 |
+
Mage::getSingleton('core/session')->setData('fanplayr_coupon', $couponCode);
|
173 |
+
}
|
174 |
+
|
175 |
+
public function jsonMessage($isError, $message, $extras = array())
|
176 |
+
{
|
177 |
+
$extras['error'] = $isError;
|
178 |
+
$extras['message'] = $message;
|
179 |
+
$extras['version'] = $this->getExtensionVersion();
|
180 |
+
$extras['mage_version'] = Mage::getVersion();
|
181 |
+
|
182 |
+
return json_encode($extras);
|
183 |
+
}
|
184 |
+
|
185 |
+
private function getExtensionVersion()
|
186 |
+
{
|
187 |
+
return (string) Mage::getConfig()->getNode()->modules->Fanplayr_Socialcoupons->version;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
?>
|
app/code/community/Fanplayr/Socialcoupons/controllers/IndexController.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Fanplayr_Socialcoupons_IndexController extends Mage_Core_Controller_Front_Action {
|
3 |
+
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
echo $this->jsonMessage(true, 'Please call use a valid controller.');
|
7 |
+
}
|
8 |
+
|
9 |
+
public function jsonMessage($isError, $message, $extras = array())
|
10 |
+
{
|
11 |
+
$extras['error'] = $isError;
|
12 |
+
$extras['message'] = $message;
|
13 |
+
$extras['version'] = $this->getExtensionVersion();
|
14 |
+
$extras['mage_version'] = Mage::getVersion();
|
15 |
+
|
16 |
+
return json_encode($extras);
|
17 |
+
}
|
18 |
+
|
19 |
+
private function getExtensionVersion()
|
20 |
+
{
|
21 |
+
return (string) Mage::getConfig()->getNode()->modules->Fanplayr_Socialcoupons->version;
|
22 |
+
}
|
23 |
+
}
|
24 |
+
?>
|
app/code/community/Fanplayr/Socialcoupons/etc/config.xml
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
|
4 |
+
<frontend>
|
5 |
+
|
6 |
+
<routers>
|
7 |
+
<fanplayrsocialcoupons>
|
8 |
+
<use>standard</use>
|
9 |
+
<args>
|
10 |
+
<module>Fanplayr_Socialcoupons</module>
|
11 |
+
<frontName>fanplayr</frontName>
|
12 |
+
</args>
|
13 |
+
</fanplayrsocialcoupons>
|
14 |
+
</routers>
|
15 |
+
|
16 |
+
<translate>
|
17 |
+
<modules>
|
18 |
+
<Fanplayr_Socialcoupons>
|
19 |
+
<files>
|
20 |
+
<default>Fanplayr_Socialcoupons.csv</default>
|
21 |
+
</files>
|
22 |
+
</Fanplayr_Socialcoupons>
|
23 |
+
</modules>
|
24 |
+
</translate>
|
25 |
+
|
26 |
+
<events>
|
27 |
+
|
28 |
+
<!-- general embed -->
|
29 |
+
<controller_action_layout_generate_blocks_after>
|
30 |
+
<observers>
|
31 |
+
<fanplayr_socialcoupons_model_embedobserver>
|
32 |
+
<type>singleton</type>
|
33 |
+
<class>Fanplayr_Socialcoupons_Model_EmbedObserver</class>
|
34 |
+
<method>getEmbedAction</method>
|
35 |
+
</fanplayr_socialcoupons_model_embedobserver>
|
36 |
+
</observers>
|
37 |
+
</controller_action_layout_generate_blocks_after>
|
38 |
+
|
39 |
+
<!-- replaces deputized coupons -->
|
40 |
+
<http_response_send_before>
|
41 |
+
<observers>
|
42 |
+
<fanplayr_socialcoupons_model_embedobserver_dep>
|
43 |
+
<type>singleton</type>
|
44 |
+
<class>Fanplayr_Socialcoupons_Model_EmbedObserver</class>
|
45 |
+
<method>deputizeReplaceAction</method>
|
46 |
+
</fanplayr_socialcoupons_model_embedobserver_dep>
|
47 |
+
</observers>
|
48 |
+
</http_response_send_before>
|
49 |
+
|
50 |
+
<!-- catches deputized coupon in input before it is sent to backend -->
|
51 |
+
<controller_action_predispatch>
|
52 |
+
<observers>
|
53 |
+
<fanplayr_socialcoupons_model_embedobserver_depint>
|
54 |
+
<type>singleton</type>
|
55 |
+
<class>Fanplayr_Socialcoupons_Model_EmbedObserver</class>
|
56 |
+
<method>deputizeInputAction</method>
|
57 |
+
</fanplayr_socialcoupons_model_embedobserver_depint>
|
58 |
+
</observers>
|
59 |
+
</controller_action_predispatch>
|
60 |
+
|
61 |
+
<!-- catches adding of a product to the cart so we can add a coupon that we earlier tried to apply when there was no products -->
|
62 |
+
<checkout_cart_add_product_complete>
|
63 |
+
<observers>
|
64 |
+
<fanplayr_socialcoupons_model_cartobserver>
|
65 |
+
<type>singleton</type>
|
66 |
+
<class>Fanplayr_Socialcoupons_Model_CartObserver</class>
|
67 |
+
<method>checkSavedCouponAction</method>
|
68 |
+
</fanplayr_socialcoupons_model_cartobserver>
|
69 |
+
</observers>
|
70 |
+
</checkout_cart_add_product_complete>
|
71 |
+
|
72 |
+
<!-- catch adding to quote: save cart details for quick lookup -->
|
73 |
+
<checkout_cart_add_product_complete>
|
74 |
+
<observers>
|
75 |
+
<fanplayr_socialcoupons_model_additemobserver>
|
76 |
+
<type>singleton</type>
|
77 |
+
<class>Fanplayr_Socialcoupons_Model_EmbedObserver</class>
|
78 |
+
<method>checkQuoteAddAction</method>
|
79 |
+
</fanplayr_socialcoupons_model_additemobserver>
|
80 |
+
</observers>
|
81 |
+
</checkout_cart_add_product_complete>
|
82 |
+
|
83 |
+
<!-- catch removing from quote: save cart details for quick lookup -->
|
84 |
+
<sales_quote_remove_item>
|
85 |
+
<observers>
|
86 |
+
<fanplayr_socialcoupons_model_removeitemobserver>
|
87 |
+
<type>singleton</type>
|
88 |
+
<class>Fanplayr_Socialcoupons_Model_EmbedObserver</class>
|
89 |
+
<method>checkQuoteRemoveAction</method>
|
90 |
+
</fanplayr_socialcoupons_model_removeitemobserver>
|
91 |
+
</observers>
|
92 |
+
</sales_quote_remove_item>
|
93 |
+
|
94 |
+
<!-- catch updating cart qty: save cart details for quick lookup -->
|
95 |
+
<sales_quote_item_qty_set_after>
|
96 |
+
<observers>
|
97 |
+
<fanplayr_socialcoupons_model_updateqtyobserver>
|
98 |
+
<type>singleton</type>
|
99 |
+
<class>Fanplayr_Socialcoupons_Model_EmbedObserver</class>
|
100 |
+
<method>checkQuoteUpdateQtyAction</method>
|
101 |
+
</fanplayr_socialcoupons_model_updateqtyobserver>
|
102 |
+
</observers>
|
103 |
+
</sales_quote_item_qty_set_after>
|
104 |
+
|
105 |
+
<!-- checkout success -->
|
106 |
+
<checkout_onepage_controller_success_action>
|
107 |
+
<observers>
|
108 |
+
<fanplayr_socialcoupons_model_orderobserver>
|
109 |
+
<type>singleton</type>
|
110 |
+
<class>Fanplayr_Socialcoupons_Model_OrderObserver</class>
|
111 |
+
<method>checkSuccessSingle</method>
|
112 |
+
</fanplayr_socialcoupons_model_orderobserver>
|
113 |
+
</observers>
|
114 |
+
</checkout_onepage_controller_success_action>
|
115 |
+
|
116 |
+
<!-- checkout (multi shipping) success -->
|
117 |
+
<checkout_multishipping_controller_success_action>
|
118 |
+
<observers>
|
119 |
+
<fanplayr_socialcoupons_model_orderobserver_multi>
|
120 |
+
<type>singleton</type>
|
121 |
+
<class>Fanplayr_Socialcoupons_Model_OrderObserver</class>
|
122 |
+
<method>checkSuccessMulti</method>
|
123 |
+
</fanplayr_socialcoupons_model_orderobserver_multi>
|
124 |
+
</observers>
|
125 |
+
</checkout_multishipping_controller_success_action>
|
126 |
+
|
127 |
+
<!--Order: after create, before payment -->
|
128 |
+
<sales_order_place_after>
|
129 |
+
<observers>
|
130 |
+
<fanplayr_socialcoupons_model_orderobserver_beforepay>
|
131 |
+
<type>singleton</type>
|
132 |
+
<class>Fanplayr_Socialcoupons_Model_OrderObserver</class>
|
133 |
+
<method>serverToServerTrackingBeforePayment</method>
|
134 |
+
</fanplayr_socialcoupons_model_orderobserver_beforepay>
|
135 |
+
</observers>
|
136 |
+
</sales_order_place_after>
|
137 |
+
|
138 |
+
<!--Order: after payment -->
|
139 |
+
<sales_order_invoice_save_commit_after>
|
140 |
+
<observers>
|
141 |
+
<fanplayr_socialcoupons_model_orderobserver_afterepay>
|
142 |
+
<type>singleton</type>
|
143 |
+
<class>Fanplayr_Socialcoupons_Model_OrderObserver</class>
|
144 |
+
<method>serverToServerTrackingAfterPayment</method>
|
145 |
+
</fanplayr_socialcoupons_model_orderobserver_afterepay>
|
146 |
+
</observers>
|
147 |
+
</sales_order_invoice_save_commit_after>
|
148 |
+
|
149 |
+
</events>
|
150 |
+
|
151 |
+
</frontend>
|
152 |
+
|
153 |
+
<adminhtml>
|
154 |
+
<acl>
|
155 |
+
<resources>
|
156 |
+
<all>
|
157 |
+
<title>Allow Everything</title>
|
158 |
+
</all>
|
159 |
+
<admin>
|
160 |
+
<children>
|
161 |
+
<system>
|
162 |
+
<children>
|
163 |
+
<config>
|
164 |
+
<children>
|
165 |
+
<fanplayrsocialcoupons>
|
166 |
+
<title>Fanplayr</title>
|
167 |
+
</fanplayrsocialcoupons>
|
168 |
+
</children>
|
169 |
+
</config>
|
170 |
+
</children>
|
171 |
+
</system>
|
172 |
+
</children>
|
173 |
+
</admin>
|
174 |
+
</resources>
|
175 |
+
</acl>
|
176 |
+
</adminhtml>
|
177 |
+
|
178 |
+
</config>
|
app/code/community/Fanplayr/Socialcoupons/etc/system.xml
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
|
4 |
+
<tabs>
|
5 |
+
<fanplayrsocialcoupons translate="label">
|
6 |
+
<label>Fanplayr</label>
|
7 |
+
<sort_order>99999</sort_order>
|
8 |
+
</fanplayrsocialcoupons>
|
9 |
+
</tabs>
|
10 |
+
|
11 |
+
<sections>
|
12 |
+
<fanplayrsocialcoupons translate="label">
|
13 |
+
<label><![CDATA[<span id="fanplayr-social-coupons-menu-item" style="padding-left: 0px;"><div style="border-radius: 1px 1px 1px 1px; display: block; float: left; width: 16px; height: 16px; background-color: #f47721; margin-right: 5px;"><div style="color: rgb(255, 255, 255); font-weight: bold; font-family: Arial,Helvetica,sans-serif; margin-left: 5px; font-size: 12px;">F</div></div>Fanplayr Conversions</span>]]></label>
|
14 |
+
<tab>fanplayrsocialcoupons</tab>
|
15 |
+
<frontend_type>text</frontend_type>
|
16 |
+
<sort_order>1000</sort_order>
|
17 |
+
<show_in_default>1</show_in_default>
|
18 |
+
<show_in_website>0</show_in_website>
|
19 |
+
<show_in_store>0</show_in_store>
|
20 |
+
|
21 |
+
<groups>
|
22 |
+
<config translate="label">
|
23 |
+
<label>Fanplayr Account Information</label>
|
24 |
+
<frontend_type>text</frontend_type>
|
25 |
+
<sort_order>10</sort_order>
|
26 |
+
<show_in_default>1</show_in_default>
|
27 |
+
<show_in_website>0</show_in_website>
|
28 |
+
<show_in_store>0</show_in_store>
|
29 |
+
<fields>
|
30 |
+
|
31 |
+
<secret>
|
32 |
+
<label>Secret</label>
|
33 |
+
<frontend_type>hidden</frontend_type>
|
34 |
+
<sort_order>1</sort_order>
|
35 |
+
<show_in_default>0</show_in_default>
|
36 |
+
<show_in_website>0</show_in_website>
|
37 |
+
<show_in_store>0</show_in_store>
|
38 |
+
</secret>
|
39 |
+
|
40 |
+
<acc_key>
|
41 |
+
<label>Acc Key</label>
|
42 |
+
<frontend_type>hidden</frontend_type>
|
43 |
+
<sort_order>1</sort_order>
|
44 |
+
<show_in_default>0</show_in_default>
|
45 |
+
<show_in_website>0</show_in_website>
|
46 |
+
<show_in_store>0</show_in_store>
|
47 |
+
</acc_key>
|
48 |
+
|
49 |
+
<installed>
|
50 |
+
<label>Fanplayr Install</label>
|
51 |
+
<frontend_type>button</frontend_type>
|
52 |
+
<frontend_model>Fanplayr_Socialcoupons_Block_Adminhtml_System_Config_Form_Field_Installhelper</frontend_model>
|
53 |
+
<sort_order>3</sort_order>
|
54 |
+
<show_in_default>1</show_in_default>
|
55 |
+
<show_in_website>0</show_in_website>
|
56 |
+
<show_in_store>0</show_in_store>
|
57 |
+
</installed>
|
58 |
+
|
59 |
+
</fields>
|
60 |
+
</config>
|
61 |
+
|
62 |
+
</groups>
|
63 |
+
|
64 |
+
</fanplayrsocialcoupons>
|
65 |
+
</sections>
|
66 |
+
|
67 |
+
</config>
|
app/design/frontend/base/default/template/fanplayr/embed.phtml
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
try {
|
3 |
+
$widgetKeys = json_decode($widgetKeys);
|
4 |
+
}catch(Exception $e) {
|
5 |
+
}
|
6 |
+
|
7 |
+
try {
|
8 |
+
$widgetKeysGenius = json_decode($widgetKeysGenius);
|
9 |
+
}catch(Exception $e) {
|
10 |
+
}
|
11 |
+
|
12 |
+
if (!is_array($widgetKeys))
|
13 |
+
$widgetKeys = array();
|
14 |
+
|
15 |
+
if (!is_array($widgetKeysGenius))
|
16 |
+
$widgetKeysGenius = array();
|
17 |
+
|
18 |
+
foreach($widgetKeys as $k){ ?>
|
19 |
+
<?php if(!$noTags){ ?><script><?php } ?>
|
20 |
+
window.fplr = (function(d, s, key) {
|
21 |
+
var f, js = d.createElement(s), fjs = d.getElementsByTagName(s)[0]; js.async = true;
|
22 |
+
js.src = '//my.fanplayr.com/website/<?=$k?>/?v=3'; fjs.parentNode.insertBefore(js, fjs);
|
23 |
+
return window.fplr || (f = { _r: [], ready: function(a){ f._r.push(a) }, setSessionId: function(a, b){ f._s = a; f._l = b; if (b && a) setSessionCookie('fplr_magento_sess', a, 0); else if (b && !a) setSessionCookie('fplr_magento_sess', '', -1); } });
|
24 |
+
})(document, 'script');
|
25 |
+
|
26 |
+
fplr.ready(function(){});
|
27 |
+
|
28 |
+
function setSessionCookie(cookieName,cookieValue, expires) {
|
29 |
+
document.cookie = cookieName+"="+escape(cookieValue)+ ";expires=" + expires + ";path=/";
|
30 |
+
}
|
31 |
+
<?php if(!$noTags){ ?></script><?php } ?>
|
32 |
+
|
33 |
+
<?php } ?>
|
34 |
+
|
35 |
+
<?php if(!$noTags){ ?><script><?php }
|
36 |
+
if ( !function_exists('fanplayr_qr') ){
|
37 |
+
function fanplayr_qr($s){
|
38 |
+
$s = str_replace("'", "\'", $s);
|
39 |
+
return $s;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
?>
|
43 |
+
<?php if ($embedType != 6){ ?>
|
44 |
+
(function(d, w, s){
|
45 |
+
var l = function(){
|
46 |
+
var f = w.fanplayr = w.fanplayr || { _i:[] };
|
47 |
+
f.custom = f.custom || {};
|
48 |
+
var _ = f.custom;
|
49 |
+
|
50 |
+
f._i.push({
|
51 |
+
type: 'st',
|
52 |
+
accountKey: _.accountKey || '<?php echo $accountKey; ?>',
|
53 |
+
applyToCartUrl: encodeURIComponent('<?php echo $applyToCartUrl; ?>'),
|
54 |
+
depitizeUrl: encodeURIComponent('<?php echo $depitizeUrl; ?>'),
|
55 |
+
data: {
|
56 |
+
lineItemCount: <?php echo $data['lineItemCount']; ?>,
|
57 |
+
numItems: <?php echo $data['numItems']; ?>,
|
58 |
+
couponCode: '<?php echo fanplayr_qr($data['couponCode']); ?>',
|
59 |
+
total: <?php echo $data['total']; ?>,
|
60 |
+
subTotal: <?php echo $data['subTotal']; ?>,
|
61 |
+
discount: <?php echo $data['discount']; ?>,
|
62 |
+
pageType: '<?php echo fanplayr_qr($data['pageType']); ?>',
|
63 |
+
categoryId: '<?php echo fanplayr_qr($data['categoryId']); ?>',
|
64 |
+
categoryName: encodeURIComponent('<?php echo fanplayr_qr($data['categoryName']); ?>'),
|
65 |
+
productId: '<?php echo fanplayr_qr($data['productId']); ?>',
|
66 |
+
productName: encodeURIComponent('<?php echo fanplayr_qr($data['productName']); ?>'),
|
67 |
+
currency: '<?php echo $data['currency']; ?>',
|
68 |
+
customerEmail: '<?php echo fanplayr_qr($data['customerEmail']); ?>',
|
69 |
+
customerId: '<?php echo fanplayr_qr($data['customerId']); ?>',
|
70 |
+
customerGroup: '<?php echo fanplayr_qr($data['customerGroup']); ?>',
|
71 |
+
customerSegment: '<?php echo fanplayr_qr($data['customerSegment']); ?>',
|
72 |
+
shopType: '<?php echo $data['shopType']; ?>',
|
73 |
+
version: <?php echo $data['version']; ?>,
|
74 |
+
products: '<?php echo $data['products']; ?>',
|
75 |
+
storeDomain: _.storeDomain || ''
|
76 |
+
},
|
77 |
+
custom_data: w.fanplayrCustomData || {}
|
78 |
+
});
|
79 |
+
var js = d.createElement(s);
|
80 |
+
var fjs = d.getElementsByTagName(s)[0];
|
81 |
+
js.async = true;
|
82 |
+
js.src = 'https://d1q7pknmpq2wkm.cloudfront.net/js/my.fanplayr.com/fp_smart.js?' +
|
83 |
+
(new Date().getTime()); fjs.parentNode.insertBefore(js, fjs);
|
84 |
+
};
|
85 |
+
<?php if ($embedType == 5){ /* direct lazy loading */ ?>
|
86 |
+
if (window.addEventListener){ window.addEventListener('load', l, false); }
|
87 |
+
else if (window.attachEvent){ window.attachEvent('onload', l); }
|
88 |
+
<?php }else{ ?>
|
89 |
+
l();
|
90 |
+
<?php } ?>
|
91 |
+
})(document, window, 'script');
|
92 |
+
<?php }else if($embedType == 6 || $embedType == 7){ ?>
|
93 |
+
window.dataLayer = window.dataLayer || [];
|
94 |
+
var dl = window.dataLayer;
|
95 |
+
|
96 |
+
dl.push({
|
97 |
+
'event': 'fanplayr.ready',
|
98 |
+
'pageType': '<?php echo fanplayr_qr($data['pageType']); ?>',
|
99 |
+
'fanplayr': {
|
100 |
+
'accountKey': '<?php echo $accountKey; ?>',
|
101 |
+
'applyToCartUrl': encodeURIComponent('<?php echo $applyToCartUrl; ?>'),
|
102 |
+
'depitizeUrl': encodeURIComponent('<?php echo $depitizeUrl; ?>'),
|
103 |
+
|
104 |
+
'couponCode': '<?php echo fanplayr_qr($data['couponCode']); ?>',
|
105 |
+
'total': <?php echo $data['total']; ?>,
|
106 |
+
'subTotal': <?php echo $data['subTotal']; ?>,
|
107 |
+
'discount': <?php echo $data['discount']; ?>,
|
108 |
+
'categoryId': '<?php echo fanplayr_qr($data['categoryId']); ?>',
|
109 |
+
'categoryName': encodeURIComponent('<?php echo fanplayr_qr($data['categoryName']); ?>'),
|
110 |
+
'productId': '<?php echo fanplayr_qr($data['productId']); ?>',
|
111 |
+
'productName': encodeURIComponent('<?php echo fanplayr_qr($data['productName']); ?>'),
|
112 |
+
'currency': '<?php echo $data['currency']; ?>',
|
113 |
+
'customerEmail': '<?php echo fanplayr_qr($data['customerEmail']); ?>',
|
114 |
+
'customerId': '<?php echo fanplayr_qr($data['customerId']); ?>',
|
115 |
+
'customerGroup': '<?php echo fanplayr_qr($data['customerGroup']); ?>',
|
116 |
+
'customerSegment': '<?php echo fanplayr_qr($data['customerSegment']); ?>',
|
117 |
+
|
118 |
+
'products': '<?php echo $data['products']; ?>'
|
119 |
+
}
|
120 |
+
});
|
121 |
+
<?php } ?>
|
122 |
+
<?php if(!$noTags){ ?></script><?php } ?>
|
app/design/frontend/base/default/template/fanplayr/embed_ajax.phtml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script>
|
2 |
+
<?php if($embedType != 2 || $embedType != 3){ ?>
|
3 |
+
(function(d, w, s) {
|
4 |
+
var f = function(){
|
5 |
+
|
6 |
+
w.fanplayr = w.fanplayr || {};
|
7 |
+
w.fanplayr.custom = w.fanplayr.custom || {};
|
8 |
+
var _ = w.fanplayr.custom;
|
9 |
+
|
10 |
+
var js = d.createElement(s),
|
11 |
+
fjs = d.getElementsByTagName(s)[0];
|
12 |
+
|
13 |
+
js.async = true;
|
14 |
+
js.src = (_.embedUrl || '<?php echo $shopUrl; ?>') + 'fanplayr/ajax/getEmbedJs<?php echo $trailingSlash; ?>?tt=<?php echo urlencode($tt); ?>&tp=<?php echo urlencode($tp); ?>&tc=<?php echo urlencode($tc); ?>&tpn=<?php echo urlencode($tpn); ?>&tcn=<?php echo urlencode($tcn); ?>&' + (new Date().getTime());
|
15 |
+
fjs.parentNode.insertBefore(js, fjs);
|
16 |
+
};
|
17 |
+
<?php if ($embedType == 1){ ?>
|
18 |
+
if (window.addEventListener){ window.addEventListener('load', f, false); }
|
19 |
+
else if (window.attachEvent){ window.attachEvent('onload', f); }
|
20 |
+
<?php }else{ ?>
|
21 |
+
f();
|
22 |
+
<?php } ?>
|
23 |
+
})(document, window, 'script');
|
24 |
+
<?php }else if($embedType == 2 || $embedType == 3){ // master TMS ?>
|
25 |
+
window.fanplayrTms = {};
|
26 |
+
window.fanplayrTms.pageType = '<?php echo urlencode($tt); ?>';
|
27 |
+
window.fanplayrTms.productId = '<?php echo urlencode($tp); ?>';
|
28 |
+
window.fanplayrTms.categoryId = '<?php echo urlencode($tc); ?>';
|
29 |
+
window.fanplayrTms.productName = '<?php echo urlencode($tpn)?>';
|
30 |
+
window.fanplayrTms.categoryName = '<?php echo urlencode($tcn)?>';
|
31 |
+
<?php } ?>
|
32 |
+
</script>
|
app/design/frontend/base/default/template/fanplayr/success.phtml
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( !function_exists('fanplayr_qr') ){
|
3 |
+
function fanplayr_qr($s){
|
4 |
+
return str_replace("'", "\'", $s);
|
5 |
+
}
|
6 |
+
}
|
7 |
+
|
8 |
+
if ($data && $data['embedType'] != 6 && $data['embedType'] != 7){
|
9 |
+
?><script>
|
10 |
+
(function(d, w, s) {
|
11 |
+
if ( !w.fp_sales_orders ) {
|
12 |
+
w.fanplayr = w.fanplayr || {};
|
13 |
+
w.fanplayr.custom = w.fanplayr.custom || {};
|
14 |
+
var _ = w.fanplayr.custom;
|
15 |
+
w.fp_sales_orders = {
|
16 |
+
accountKey: _.accountKey || '<?php echo $data['accountKey']; ?>',
|
17 |
+
sessionKey: '<?php echo $data['sessionKey']; ?>',
|
18 |
+
userKey: '<?php echo $data['userKey']; ?>',
|
19 |
+
data: {
|
20 |
+
orderId: '<?php echo fanplayr_qr($data['orderId']); ?>',
|
21 |
+
orderNumber: '<?php echo fanplayr_qr($data['orderNumber']); ?>',
|
22 |
+
orderDate: '<?php echo $data['orderDate']; ?>',
|
23 |
+
total: <?php echo $data['total']; ?>,
|
24 |
+
subTotal: <?php echo $data['subTotal']; ?>,
|
25 |
+
discount: <?php echo $data['discount']; ?>,
|
26 |
+
discountCode: '<?php echo fanplayr_qr($data['discountCode']); ?>',
|
27 |
+
currency: '<?php echo $data['currency']; ?>',
|
28 |
+
orderEmail: '<?php echo fanplayr_qr($data['orderEmail']); ?>',
|
29 |
+
firstName: '<?php echo fanplayr_qr($data['firstName']); ?>',
|
30 |
+
lastName: '<?php echo fanplayr_qr($data['lastName']); ?>',
|
31 |
+
customerEmail: '<?php echo fanplayr_qr($data['customerEmail']); ?>',
|
32 |
+
customerId: '<?php echo fanplayr_qr($data['customerId']); ?>',
|
33 |
+
shipping: <?php echo $data['shipping']; ?>,
|
34 |
+
tax: <?php echo $data['tax']; ?>,
|
35 |
+
shopType: '<?php echo $data['shopType']; ?>',
|
36 |
+
version: '<?php echo $data['version']; ?>',
|
37 |
+
products: '<?php echo addslashes(json_encode($data['products'])); ?>',
|
38 |
+
storeDomain: _.storeDomain || ''
|
39 |
+
},
|
40 |
+
errors: '<?php echo addslashes($data['errors']); ?>'
|
41 |
+
};
|
42 |
+
<?php if($data['embedType'] != 3){ // normal, wait for onload or MasterTMS (user only) ?>
|
43 |
+
var js = d.createElement(s);
|
44 |
+
var fjs = d.getElementsByTagName(s)[0];
|
45 |
+
js.async = true;
|
46 |
+
js.src = 'https://d1q7pknmpq2wkm.cloudfront.net/js/my.fanplayr.com/fp_custom_orders.js?' + (new Date().getTime());
|
47 |
+
fjs.parentNode.insertBefore(js, fjs);
|
48 |
+
<?php }else if($data['embedType'] == 3){ ?>
|
49 |
+
// fanplayr sales order waiting for MasterTMS
|
50 |
+
<?php } ?>
|
51 |
+
}
|
52 |
+
})(document, window, 'script')
|
53 |
+
</script><?php
|
54 |
+
}else if($data && $data['embedType'] == 6){
|
55 |
+
?><script>
|
56 |
+
window.dataLayer = window.dataLayer || [];
|
57 |
+
var dl = window.dataLayer;
|
58 |
+
dl.push({
|
59 |
+
'transactionId': '<?php echo fanplayr_qr($data['orderId']); ?>',
|
60 |
+
'transactionAffiliation': '', // ?
|
61 |
+
'transactionTotal': <?php echo $data['total']; ?>,
|
62 |
+
'transactionTax': <?php echo $data['tax']; ?>,
|
63 |
+
'transactionShipping': <?php echo $data['shipping']; ?>,
|
64 |
+
'transactionPromoCode': '<?php echo fanplayr_qr($data['discountCode']); ?>',
|
65 |
+
'transactionProducts': [<?php
|
66 |
+
$c = 0;
|
67 |
+
foreach($data['products'] as $k => $v){
|
68 |
+
echo "{";
|
69 |
+
echo "'sku': '".fanplayr_qr($v['sku'])."',\n";
|
70 |
+
echo "'id': '".fanplayr_qr($v['id'])."', // FP \n";
|
71 |
+
echo "'name': '".fanplayr_qr($v['name'])."',\n";
|
72 |
+
echo "'category': '".fanplayr_qr($v['catName'])."',\n";
|
73 |
+
//echo "'categoryId': '".fanplayr_qr($v['catId'])."' // FP ,\n";
|
74 |
+
echo "'price': ".$v['price'].",\n";
|
75 |
+
echo "'quantity': ".$v['qty']."\n";
|
76 |
+
echo "}";
|
77 |
+
if ($c < count($data['products']) - 1){
|
78 |
+
echo ",";
|
79 |
+
}
|
80 |
+
$c++;
|
81 |
+
}
|
82 |
+
?>],
|
83 |
+
'fanplayr': {
|
84 |
+
'accountKey': '<?php echo $data['accountKey']; ?>',
|
85 |
+
'sessionKey': '<?php echo $data['sessionKey']; ?>',
|
86 |
+
'userKey': '<?php echo $data['userKey']; ?>',
|
87 |
+
'order': {
|
88 |
+
'number': '<?php echo fanplayr_qr($data['orderNumber']); ?>',
|
89 |
+
'discount': '<?php echo $data['discount']; ?>',
|
90 |
+
'date': '<?php echo $data['orderDate']; ?>',
|
91 |
+
'currency': '<?php echo $data['currency']; ?>'
|
92 |
+
}
|
93 |
+
}
|
94 |
+
});
|
95 |
+
</script><?php
|
96 |
+
}else if($data && $data['embedType'] == 7){
|
97 |
+
?><script>
|
98 |
+
window.dataLayer = window.dataLayer || [];
|
99 |
+
var dl = window.dataLayer;
|
100 |
+
dl.push({
|
101 |
+
'ecommerce': {
|
102 |
+
'currencyCode': '<?php echo $data['currency']; ?>',
|
103 |
+
'purchase': {
|
104 |
+
'actionField': {
|
105 |
+
'id': '<?php echo fanplayr_qr($data['orderId']); ?>',
|
106 |
+
'affiliation': '<?php echo fanplayr_qr($data['storeCode']); ?>',
|
107 |
+
'revenue': '<?php echo $data['total']; ?>', // inc tax, shipping, disc
|
108 |
+
'tax':'<?php echo $data['tax']; ?>',
|
109 |
+
'shipping': '<?php echo $data['shipping']; ?>',
|
110 |
+
'coupon': '<?php echo fanplayr_qr($data['discountCode']); ?>'
|
111 |
+
},
|
112 |
+
'products': [<?php
|
113 |
+
$c = 0;
|
114 |
+
foreach($data['products'] as $k => $v){
|
115 |
+
echo "{";
|
116 |
+
echo "'sku': '".fanplayr_qr($v['sku'])."',\n"; // FP
|
117 |
+
echo "'id': '".fanplayr_qr($v['id'])."',\n"; // likely to contain SKU not id
|
118 |
+
echo "'name': '".fanplayr_qr($v['name'])."',\n";
|
119 |
+
echo "'category': '".fanplayr_qr($v['catName'])."',\n";
|
120 |
+
echo "'categoryId': '".fanplayr_qr($v['catId'])."',\n"; // FP
|
121 |
+
echo "'price': '".$v['price']."',\n";
|
122 |
+
echo "'quantity': ".$v['qty'].",\n";
|
123 |
+
echo "'coupon': ''\n";
|
124 |
+
echo "}";
|
125 |
+
if ($c < count($data['products']) - 1){
|
126 |
+
echo ",";
|
127 |
+
}
|
128 |
+
$c++;
|
129 |
+
}
|
130 |
+
?>]
|
131 |
+
}
|
132 |
+
},
|
133 |
+
'fanplayr': {
|
134 |
+
'accountKey': '<?php echo $data['accountKey']; ?>',
|
135 |
+
'sessionKey': '<?php echo $data['sessionKey']; ?>',
|
136 |
+
'userKey': '<?php echo $data['userKey']; ?>',
|
137 |
+
'order': {
|
138 |
+
'number': '<?php echo fanplayr_qr($data['orderNumber']); ?>',
|
139 |
+
'discount': '<?php echo $data['discount']; ?>',
|
140 |
+
'date': '<?php echo $data['orderDate']; ?>'
|
141 |
+
}
|
142 |
+
}
|
143 |
+
});
|
144 |
+
</script><?php
|
145 |
+
}
|
146 |
+
?>
|
147 |
+
<?php if ($data['gtmContainerId']){ ?>
|
148 |
+
<!-- Google Tag Manager -->
|
149 |
+
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=<?php echo $data['gtmContainerId']; ?>"
|
150 |
+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
151 |
+
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
152 |
+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
153 |
+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
154 |
+
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
155 |
+
})(window,document,'script','dataLayer','<?php echo $data['gtmContainerId']; ?>');</script>
|
156 |
+
<!-- End Google Tag Manager -->
|
157 |
+
<?php } ?>
|
app/design/frontend/default/default/template/fanplayr/embed.phtml
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
try {
|
3 |
+
$widgetKeys = json_decode($widgetKeys);
|
4 |
+
}catch(Exception $e) {
|
5 |
+
}
|
6 |
+
|
7 |
+
try {
|
8 |
+
$widgetKeysGenius = json_decode($widgetKeysGenius);
|
9 |
+
}catch(Exception $e) {
|
10 |
+
}
|
11 |
+
|
12 |
+
if (!is_array($widgetKeys))
|
13 |
+
$widgetKeys = array();
|
14 |
+
|
15 |
+
if (!is_array($widgetKeysGenius))
|
16 |
+
$widgetKeysGenius = array();
|
17 |
+
|
18 |
+
foreach($widgetKeys as $k){ ?>
|
19 |
+
<?php if(!$noTags){ ?><script><?php } ?>
|
20 |
+
window.fplr = (function(d, s, key) {
|
21 |
+
var f, js = d.createElement(s), fjs = d.getElementsByTagName(s)[0]; js.async = true;
|
22 |
+
js.src = '//my.fanplayr.com/website/<?=$k?>/?v=3'; fjs.parentNode.insertBefore(js, fjs);
|
23 |
+
return window.fplr || (f = { _r: [], ready: function(a){ f._r.push(a) }, setSessionId: function(a, b){ f._s = a; f._l = b; if (b && a) setSessionCookie('fplr_magento_sess', a, 0); else if (b && !a) setSessionCookie('fplr_magento_sess', '', -1); } });
|
24 |
+
})(document, 'script');
|
25 |
+
|
26 |
+
fplr.ready(function(){});
|
27 |
+
|
28 |
+
function setSessionCookie(cookieName,cookieValue, expires) {
|
29 |
+
document.cookie = cookieName+"="+escape(cookieValue)+ ";expires=" + expires + ";path=/";
|
30 |
+
}
|
31 |
+
<?php if(!$noTags){ ?></script><?php } ?>
|
32 |
+
|
33 |
+
<?php } ?>
|
34 |
+
|
35 |
+
<?php if(!$noTags){ ?><script><?php }
|
36 |
+
if ( !function_exists('fanplayr_qr') ){
|
37 |
+
function fanplayr_qr($s){
|
38 |
+
$s = str_replace("'", "\'", $s);
|
39 |
+
return $s;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
?>
|
43 |
+
<?php if ($embedType != 6){ ?>
|
44 |
+
(function(d, w, s){
|
45 |
+
var l = function(){
|
46 |
+
var f = w.fanplayr = w.fanplayr || { _i:[] };
|
47 |
+
f.custom = f.custom || {};
|
48 |
+
var _ = f.custom;
|
49 |
+
|
50 |
+
f._i.push({
|
51 |
+
type: 'st',
|
52 |
+
accountKey: _.accountKey || '<?php echo $accountKey; ?>',
|
53 |
+
applyToCartUrl: encodeURIComponent('<?php echo $applyToCartUrl; ?>'),
|
54 |
+
depitizeUrl: encodeURIComponent('<?php echo $depitizeUrl; ?>'),
|
55 |
+
data: {
|
56 |
+
lineItemCount: <?php echo $data['lineItemCount']; ?>,
|
57 |
+
numItems: <?php echo $data['numItems']; ?>,
|
58 |
+
couponCode: '<?php echo fanplayr_qr($data['couponCode']); ?>',
|
59 |
+
total: <?php echo $data['total']; ?>,
|
60 |
+
subTotal: <?php echo $data['subTotal']; ?>,
|
61 |
+
discount: <?php echo $data['discount']; ?>,
|
62 |
+
pageType: '<?php echo fanplayr_qr($data['pageType']); ?>',
|
63 |
+
categoryId: '<?php echo fanplayr_qr($data['categoryId']); ?>',
|
64 |
+
categoryName: encodeURIComponent('<?php echo fanplayr_qr($data['categoryName']); ?>'),
|
65 |
+
productId: '<?php echo fanplayr_qr($data['productId']); ?>',
|
66 |
+
productName: encodeURIComponent('<?php echo fanplayr_qr($data['productName']); ?>'),
|
67 |
+
currency: '<?php echo $data['currency']; ?>',
|
68 |
+
customerEmail: '<?php echo fanplayr_qr($data['customerEmail']); ?>',
|
69 |
+
customerId: '<?php echo fanplayr_qr($data['customerId']); ?>',
|
70 |
+
customerGroup: '<?php echo fanplayr_qr($data['customerGroup']); ?>',
|
71 |
+
customerSegment: '<?php echo fanplayr_qr($data['customerSegment']); ?>',
|
72 |
+
shopType: '<?php echo $data['shopType']; ?>',
|
73 |
+
version: <?php echo $data['version']; ?>,
|
74 |
+
products: '<?php echo $data['products']; ?>',
|
75 |
+
storeDomain: _.storeDomain || ''
|
76 |
+
},
|
77 |
+
custom_data: w.fanplayrCustomData || {}
|
78 |
+
});
|
79 |
+
var js = d.createElement(s);
|
80 |
+
var fjs = d.getElementsByTagName(s)[0];
|
81 |
+
js.async = true;
|
82 |
+
js.src = 'https://d1q7pknmpq2wkm.cloudfront.net/js/my.fanplayr.com/fp_smart.js?' +
|
83 |
+
(new Date().getTime()); fjs.parentNode.insertBefore(js, fjs);
|
84 |
+
};
|
85 |
+
<?php if ($embedType == 5){ /* direct lazy loading */ ?>
|
86 |
+
if (window.addEventListener){ window.addEventListener('load', l, false); }
|
87 |
+
else if (window.attachEvent){ window.attachEvent('onload', l); }
|
88 |
+
<?php }else{ ?>
|
89 |
+
l();
|
90 |
+
<?php } ?>
|
91 |
+
})(document, window, 'script');
|
92 |
+
<?php }else if($embedType == 6 || $embedType == 7){ ?>
|
93 |
+
window.dataLayer = window.dataLayer || [];
|
94 |
+
var dl = window.dataLayer;
|
95 |
+
|
96 |
+
dl.push({
|
97 |
+
'event': 'fanplayr.ready',
|
98 |
+
'pageType': '<?php echo fanplayr_qr($data['pageType']); ?>',
|
99 |
+
'fanplayr': {
|
100 |
+
'accountKey': '<?php echo $accountKey; ?>',
|
101 |
+
'applyToCartUrl': encodeURIComponent('<?php echo $applyToCartUrl; ?>'),
|
102 |
+
'depitizeUrl': encodeURIComponent('<?php echo $depitizeUrl; ?>'),
|
103 |
+
|
104 |
+
'couponCode': '<?php echo fanplayr_qr($data['couponCode']); ?>',
|
105 |
+
'total': <?php echo $data['total']; ?>,
|
106 |
+
'subTotal': <?php echo $data['subTotal']; ?>,
|
107 |
+
'discount': <?php echo $data['discount']; ?>,
|
108 |
+
'categoryId': '<?php echo fanplayr_qr($data['categoryId']); ?>',
|
109 |
+
'categoryName': encodeURIComponent('<?php echo fanplayr_qr($data['categoryName']); ?>'),
|
110 |
+
'productId': '<?php echo fanplayr_qr($data['productId']); ?>',
|
111 |
+
'productName': encodeURIComponent('<?php echo fanplayr_qr($data['productName']); ?>'),
|
112 |
+
'currency': '<?php echo $data['currency']; ?>',
|
113 |
+
'customerEmail': '<?php echo fanplayr_qr($data['customerEmail']); ?>',
|
114 |
+
'customerId': '<?php echo fanplayr_qr($data['customerId']); ?>',
|
115 |
+
'customerGroup': '<?php echo fanplayr_qr($data['customerGroup']); ?>',
|
116 |
+
'customerSegment': '<?php echo fanplayr_qr($data['customerSegment']); ?>',
|
117 |
+
|
118 |
+
'products': '<?php echo $data['products']; ?>'
|
119 |
+
}
|
120 |
+
});
|
121 |
+
<?php } ?>
|
122 |
+
<?php if(!$noTags){ ?></script><?php } ?>
|
app/design/frontend/default/default/template/fanplayr/embed_ajax.phtml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script>
|
2 |
+
<?php if($embedType != 2 || $embedType != 3){ ?>
|
3 |
+
(function(d, w, s) {
|
4 |
+
var f = function(){
|
5 |
+
|
6 |
+
w.fanplayr = w.fanplayr || {};
|
7 |
+
w.fanplayr.custom = w.fanplayr.custom || {};
|
8 |
+
var _ = w.fanplayr.custom;
|
9 |
+
|
10 |
+
var js = d.createElement(s),
|
11 |
+
fjs = d.getElementsByTagName(s)[0];
|
12 |
+
|
13 |
+
js.async = true;
|
14 |
+
js.src = (_.embedUrl || '<?php echo $shopUrl; ?>') + 'fanplayr/ajax/getEmbedJs<?php echo $trailingSlash; ?>?tt=<?php echo urlencode($tt); ?>&tp=<?php echo urlencode($tp); ?>&tc=<?php echo urlencode($tc); ?>&tpn=<?php echo urlencode($tpn); ?>&tcn=<?php echo urlencode($tcn); ?>&' + (new Date().getTime());
|
15 |
+
fjs.parentNode.insertBefore(js, fjs);
|
16 |
+
};
|
17 |
+
<?php if ($embedType == 1){ ?>
|
18 |
+
if (window.addEventListener){ window.addEventListener('load', f, false); }
|
19 |
+
else if (window.attachEvent){ window.attachEvent('onload', f); }
|
20 |
+
<?php }else{ ?>
|
21 |
+
f();
|
22 |
+
<?php } ?>
|
23 |
+
})(document, window, 'script');
|
24 |
+
<?php }else if($embedType == 2 || $embedType == 3){ // master TMS ?>
|
25 |
+
window.fanplayrTms = {};
|
26 |
+
window.fanplayrTms.pageType = '<?php echo urlencode($tt); ?>';
|
27 |
+
window.fanplayrTms.productId = '<?php echo urlencode($tp); ?>';
|
28 |
+
window.fanplayrTms.categoryId = '<?php echo urlencode($tc); ?>';
|
29 |
+
window.fanplayrTms.productName = '<?php echo urlencode($tpn)?>';
|
30 |
+
window.fanplayrTms.categoryName = '<?php echo urlencode($tcn)?>';
|
31 |
+
<?php } ?>
|
32 |
+
</script>
|
app/design/frontend/default/default/template/fanplayr/success.phtml
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( !function_exists('fanplayr_qr') ){
|
3 |
+
function fanplayr_qr($s){
|
4 |
+
return str_replace("'", "\'", $s);
|
5 |
+
}
|
6 |
+
}
|
7 |
+
|
8 |
+
if ($data && $data['embedType'] != 6 && $data['embedType'] != 7){
|
9 |
+
?><script>
|
10 |
+
(function(d, w, s) {
|
11 |
+
if ( !w.fp_sales_orders ) {
|
12 |
+
w.fanplayr = w.fanplayr || {};
|
13 |
+
w.fanplayr.custom = w.fanplayr.custom || {};
|
14 |
+
var _ = w.fanplayr.custom;
|
15 |
+
w.fp_sales_orders = {
|
16 |
+
accountKey: _.accountKey || '<?php echo $data['accountKey']; ?>',
|
17 |
+
sessionKey: '<?php echo $data['sessionKey']; ?>',
|
18 |
+
userKey: '<?php echo $data['userKey']; ?>',
|
19 |
+
data: {
|
20 |
+
orderId: '<?php echo fanplayr_qr($data['orderId']); ?>',
|
21 |
+
orderNumber: '<?php echo fanplayr_qr($data['orderNumber']); ?>',
|
22 |
+
orderDate: '<?php echo $data['orderDate']; ?>',
|
23 |
+
total: <?php echo $data['total']; ?>,
|
24 |
+
subTotal: <?php echo $data['subTotal']; ?>,
|
25 |
+
discount: <?php echo $data['discount']; ?>,
|
26 |
+
discountCode: '<?php echo fanplayr_qr($data['discountCode']); ?>',
|
27 |
+
currency: '<?php echo $data['currency']; ?>',
|
28 |
+
orderEmail: '<?php echo fanplayr_qr($data['orderEmail']); ?>',
|
29 |
+
firstName: '<?php echo fanplayr_qr($data['firstName']); ?>',
|
30 |
+
lastName: '<?php echo fanplayr_qr($data['lastName']); ?>',
|
31 |
+
customerEmail: '<?php echo fanplayr_qr($data['customerEmail']); ?>',
|
32 |
+
customerId: '<?php echo fanplayr_qr($data['customerId']); ?>',
|
33 |
+
shipping: <?php echo $data['shipping']; ?>,
|
34 |
+
tax: <?php echo $data['tax']; ?>,
|
35 |
+
shopType: '<?php echo $data['shopType']; ?>',
|
36 |
+
version: '<?php echo $data['version']; ?>',
|
37 |
+
products: '<?php echo addslashes(json_encode($data['products'])); ?>',
|
38 |
+
storeDomain: _.storeDomain || ''
|
39 |
+
},
|
40 |
+
errors: '<?php echo addslashes($data['errors']); ?>'
|
41 |
+
};
|
42 |
+
<?php if($data['embedType'] != 3){ // normal, wait for onload or MasterTMS (user only) ?>
|
43 |
+
var js = d.createElement(s);
|
44 |
+
var fjs = d.getElementsByTagName(s)[0];
|
45 |
+
js.async = true;
|
46 |
+
js.src = 'https://d1q7pknmpq2wkm.cloudfront.net/js/my.fanplayr.com/fp_custom_orders.js?' + (new Date().getTime());
|
47 |
+
fjs.parentNode.insertBefore(js, fjs);
|
48 |
+
<?php }else if($data['embedType'] == 3){ ?>
|
49 |
+
// fanplayr sales order waiting for MasterTMS
|
50 |
+
<?php } ?>
|
51 |
+
}
|
52 |
+
})(document, window, 'script')
|
53 |
+
</script><?php
|
54 |
+
}else if($data && $data['embedType'] == 6){
|
55 |
+
?><script>
|
56 |
+
window.dataLayer = window.dataLayer || [];
|
57 |
+
var dl = window.dataLayer;
|
58 |
+
dl.push({
|
59 |
+
'transactionId': '<?php echo fanplayr_qr($data['orderId']); ?>',
|
60 |
+
'transactionAffiliation': '', // ?
|
61 |
+
'transactionTotal': <?php echo $data['total']; ?>,
|
62 |
+
'transactionTax': <?php echo $data['tax']; ?>,
|
63 |
+
'transactionShipping': <?php echo $data['shipping']; ?>,
|
64 |
+
'transactionPromoCode': '<?php echo fanplayr_qr($data['discountCode']); ?>',
|
65 |
+
'transactionProducts': [<?php
|
66 |
+
$c = 0;
|
67 |
+
foreach($data['products'] as $k => $v){
|
68 |
+
echo "{";
|
69 |
+
echo "'sku': '".fanplayr_qr($v['sku'])."',\n";
|
70 |
+
echo "'id': '".fanplayr_qr($v['id'])."', // FP \n";
|
71 |
+
echo "'name': '".fanplayr_qr($v['name'])."',\n";
|
72 |
+
echo "'category': '".fanplayr_qr($v['catName'])."',\n";
|
73 |
+
//echo "'categoryId': '".fanplayr_qr($v['catId'])."' // FP ,\n";
|
74 |
+
echo "'price': ".$v['price'].",\n";
|
75 |
+
echo "'quantity': ".$v['qty']."\n";
|
76 |
+
echo "}";
|
77 |
+
if ($c < count($data['products']) - 1){
|
78 |
+
echo ",";
|
79 |
+
}
|
80 |
+
$c++;
|
81 |
+
}
|
82 |
+
?>],
|
83 |
+
'fanplayr': {
|
84 |
+
'accountKey': '<?php echo $data['accountKey']; ?>',
|
85 |
+
'sessionKey': '<?php echo $data['sessionKey']; ?>',
|
86 |
+
'userKey': '<?php echo $data['userKey']; ?>',
|
87 |
+
'order': {
|
88 |
+
'number': '<?php echo fanplayr_qr($data['orderNumber']); ?>',
|
89 |
+
'discount': '<?php echo $data['discount']; ?>',
|
90 |
+
'date': '<?php echo $data['orderDate']; ?>',
|
91 |
+
'currency': '<?php echo $data['currency']; ?>'
|
92 |
+
}
|
93 |
+
}
|
94 |
+
});
|
95 |
+
</script><?php
|
96 |
+
}else if($data && $data['embedType'] == 7){
|
97 |
+
?><script>
|
98 |
+
window.dataLayer = window.dataLayer || [];
|
99 |
+
var dl = window.dataLayer;
|
100 |
+
dl.push({
|
101 |
+
'ecommerce': {
|
102 |
+
'currencyCode': '<?php echo $data['currency']; ?>',
|
103 |
+
'purchase': {
|
104 |
+
'actionField': {
|
105 |
+
'id': '<?php echo fanplayr_qr($data['orderId']); ?>',
|
106 |
+
'affiliation': '<?php echo fanplayr_qr($data['storeCode']); ?>',
|
107 |
+
'revenue': '<?php echo $data['total']; ?>', // inc tax, shipping, disc
|
108 |
+
'tax':'<?php echo $data['tax']; ?>',
|
109 |
+
'shipping': '<?php echo $data['shipping']; ?>',
|
110 |
+
'coupon': '<?php echo fanplayr_qr($data['discountCode']); ?>'
|
111 |
+
},
|
112 |
+
'products': [<?php
|
113 |
+
$c = 0;
|
114 |
+
foreach($data['products'] as $k => $v){
|
115 |
+
echo "{";
|
116 |
+
echo "'sku': '".fanplayr_qr($v['sku'])."',\n"; // FP
|
117 |
+
echo "'id': '".fanplayr_qr($v['id'])."',\n"; // likely to contain SKU not id
|
118 |
+
echo "'name': '".fanplayr_qr($v['name'])."',\n";
|
119 |
+
echo "'category': '".fanplayr_qr($v['catName'])."',\n";
|
120 |
+
echo "'categoryId': '".fanplayr_qr($v['catId'])."',\n"; // FP
|
121 |
+
echo "'price': '".$v['price']."',\n";
|
122 |
+
echo "'quantity': ".$v['qty'].",\n";
|
123 |
+
echo "'coupon': ''\n";
|
124 |
+
echo "}";
|
125 |
+
if ($c < count($data['products']) - 1){
|
126 |
+
echo ",";
|
127 |
+
}
|
128 |
+
$c++;
|
129 |
+
}
|
130 |
+
?>]
|
131 |
+
}
|
132 |
+
},
|
133 |
+
'fanplayr': {
|
134 |
+
'accountKey': '<?php echo $data['accountKey']; ?>',
|
135 |
+
'sessionKey': '<?php echo $data['sessionKey']; ?>',
|
136 |
+
'userKey': '<?php echo $data['userKey']; ?>',
|
137 |
+
'order': {
|
138 |
+
'number': '<?php echo fanplayr_qr($data['orderNumber']); ?>',
|
139 |
+
'discount': '<?php echo $data['discount']; ?>',
|
140 |
+
'date': '<?php echo $data['orderDate']; ?>'
|
141 |
+
}
|
142 |
+
}
|
143 |
+
});
|
144 |
+
</script><?php
|
145 |
+
}
|
146 |
+
?>
|
147 |
+
<?php if ($data['gtmContainerId']){ ?>
|
148 |
+
<!-- Google Tag Manager -->
|
149 |
+
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=<?php echo $data['gtmContainerId']; ?>"
|
150 |
+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
151 |
+
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
152 |
+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
153 |
+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
154 |
+
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
155 |
+
})(window,document,'script','dataLayer','<?php echo $data['gtmContainerId']; ?>');</script>
|
156 |
+
<!-- End Google Tag Manager -->
|
157 |
+
<?php } ?>
|
app/etc/modules/Fanplayr_Socialcoupons.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Fanplayr_Socialcoupons>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<version>1.0.48</version>
|
8 |
+
</Fanplayr_Socialcoupons>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Fanplayr</name>
|
4 |
+
<version>1.0.48</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.fanplayr.com/Fanplayr_terms_and_conditions.pdf">Fanplayr License</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Fanplayr Conversions enables Magento merchants to harness an automated solution to track, analyze and intelligently target your visitors</summary>
|
10 |
+
<description>Fanplayr Conversion enables Magento merchants to harness an automated solution to track, analyze and intelligently target your visitors</description>
|
11 |
+
<notes>- optionally remove trailing slash from embed URL</notes>
|
12 |
+
<authors><author><name>Tarwin Stroh-Spijer</name><user>auto-converted</user><email>tarwin@fanplayr.com</email></author></authors>
|
13 |
+
<date>2014-10-10</date>
|
14 |
+
<time>22:17:41</time>
|
15 |
+
<contents><target name="mageskin"><dir name="frontend"><dir name="socialcoupons"><dir name="images"><file name="accept.png" hash="8bfed48756f192ed7afe6eaa4799aae4"/><file name="activity.gif" hash="fc4ac1c258ac6d13be5afe5ecc5f10e6"/><file name="disable.png" hash="bb2fc85482c3e9c9a9ab4bc3e8e4ebe6"/><file name="fanplayr_logo.png" hash="3d8827fedc2ff79d3041a64265a2f7e0"/><file name="genius_16.png" hash="895bf92ff7689c8116bf1a6f7583c3ab"/><file name="pencil.png" hash="a34e71ab08a6d1162b948d26321dea50"/><file name="progress-loader.gif" hash="5243dea18965998ada5477a2117e2ead"/><file name="sales_16.png" hash="e7b77f97a81b4339c9c6b94e1077a675"/><file name="star_gold.png" hash="73541d75f70cbda977a8b04bf87ddc39"/><file name="warning.png" hash="c847e1076da70df83ef5284622b82a74"/><file name=".picasa.ini" hash="98908647c7af9a7c540c9d711b911d0c"/></dir><file name="fanplayr_join.html" hash="72f2ba80caf3b3f790a3eed928c79626"/><file name="fanplayr_socialcoupons.css" hash="ef40e0653303cbe861ac2141fce32222"/><file name="fanplayr_socialcoupons.js" hash="86238397d54e3b4abcb639fc0147bed3"/><file name="fanplayr_socialcoupons.min.css" hash="c6d326ff4161a090b77a0b00e2f7d81d"/><file name="jquery-1.7.2.min.js" hash="8d1a6f9c08b59506c56b18e2b2695fc8"/></dir></dir></target><target name="magecommunity"><dir name="Fanplayr"><dir name="Socialcoupons"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Installhelper.php" hash="c373a94b044c91aaa185aeeedf632c7f"/></dir></dir></dir></dir></dir></dir><dir name="Model"><file name="CartObserver.php" hash="baca491c222a4dd401e779a7c60d98bc"/><file name="EmbedObserver.php" hash="cd322c93c44aa45cae3e7d0a541b7079"/><file name="OrderObserver.php" hash="ca94b4bdcc08c4a7c1c4a1be9064e639"/></dir><dir name="controllers"><file name="AjaxController.php" hash="6f75c084b1d11d34ccacc66248166d2c"/><file name="CompyController.php" hash="0c20f6948005ea778f1527498696c6c4"/><file name="CouponController.php" hash="7a76962c34af6e4943a881acdcca3b32"/><file name="IndexController.php" hash="8b18f83d9592433bfd4f196cf574fec3"/></dir><dir name="etc"><file name="config.xml" hash="df1c1ebc423b6e0dc0c71b6ba87e80b4"/><file name="system.xml" hash="a32e53b5dd521ca60be8b61bc49c886b"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Fanplayr_Socialcoupons.xml" hash="784d2de205d06d07493af7e39a339c17"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="fanplayr"><file name="embed.phtml" hash="dc88c2ef482872d0360023d55fe49d31"/><file name="success.phtml" hash="244d6a0380af72e13ec1fc3ce0596b90"/><file name="embed_ajax.phtml" hash="4047fd3fd7d11745da7f4763cb013917"/></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="template"><dir name="fanplayr"><file name="embed.phtml" hash="dc88c2ef482872d0360023d55fe49d31"/><file name="success.phtml" hash="244d6a0380af72e13ec1fc3ce0596b90"/><file name="embed_ajax.phtml" hash="4047fd3fd7d11745da7f4763cb013917"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies/>
|
18 |
+
</package>
|
skin/frontend/socialcoupons/fanplayr_join.html
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="utf-8">
|
5 |
+
<title>Fanplayr: Link to Magento</title>
|
6 |
+
<script>
|
7 |
+
var urlParams = {};
|
8 |
+
(function () {
|
9 |
+
var e,
|
10 |
+
a = /\+/g, // Regex for replacing addition symbol with a space
|
11 |
+
r = /([^&=]+)=?([^&]*)/g,
|
12 |
+
//d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
|
13 |
+
d = function (s) { return s.replace(a, " "); },
|
14 |
+
q = window.location.search.substring(1);
|
15 |
+
|
16 |
+
while (e = r.exec(q))
|
17 |
+
urlParams[d(e[1])] = d(e[2]);
|
18 |
+
})();
|
19 |
+
|
20 |
+
var queryString = 'secret=' + urlParams['secret'];
|
21 |
+
queryString += '&email=' + urlParams['email'];
|
22 |
+
queryString += '&name=' + urlParams['name'];
|
23 |
+
queryString += '&shopUrl=' + urlParams['shopUrl'];
|
24 |
+
queryString += '&shopName=' + urlParams['shopName'];
|
25 |
+
queryString += '&adminUrl=' + urlParams['adminUrl'];
|
26 |
+
|
27 |
+
queryString += '&phone=' + urlParams['phone'];
|
28 |
+
queryString += '&address=' + urlParams['address'];
|
29 |
+
queryString += '&country=' + urlParams['country'];
|
30 |
+
queryString += '&tz=' + urlParams['tz'];
|
31 |
+
|
32 |
+
queryString += '&authUser=' + urlParams['authUser'];
|
33 |
+
queryString += '&authPass=' + urlParams['authPass'];
|
34 |
+
|
35 |
+
</script>
|
36 |
+
</head>
|
37 |
+
<body>
|
38 |
+
<script>
|
39 |
+
document.write('<iframe style="" width="700" height="510" frameborder="0" src="//my.fanplayr.com/join/with/magento/chrome/0/?' + queryString + '"></iframe>');
|
40 |
+
</script>
|
41 |
+
</body>
|
42 |
+
</html>
|
skin/frontend/socialcoupons/fanplayr_socialcoupons.css
ADDED
@@ -0,0 +1,298 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#fanplayr-campaign-list {
|
2 |
+
width: 100%;
|
3 |
+
border: 1px solid #ccc;
|
4 |
+
}
|
5 |
+
|
6 |
+
#fanplayr-campaign-list td {
|
7 |
+
vertical-align: middle;
|
8 |
+
}
|
9 |
+
|
10 |
+
.fanplayr-camplist-header {
|
11 |
+
background: none repeat scroll 0 0 #6F8992;
|
12 |
+
color: #fff;
|
13 |
+
}
|
14 |
+
|
15 |
+
.fanplayr-camplist-header td {
|
16 |
+
padding: 2px 10px;
|
17 |
+
}
|
18 |
+
|
19 |
+
.fanplayr-camplist-row td {
|
20 |
+
padding: 2px 10px;
|
21 |
+
}
|
22 |
+
|
23 |
+
#fanplayr-install-button {
|
24 |
+
background-color: #46A546;
|
25 |
+
background-image: -moz-linear-gradient(center top , #50B550, #46A546);
|
26 |
+
background-repeat: repeat-x;
|
27 |
+
border-color: #3E933E;
|
28 |
+
color: #fff;
|
29 |
+
display: inline-block;
|
30 |
+
font-size: 15px;
|
31 |
+
line-height: 27px;
|
32 |
+
padding: 8px 12px;
|
33 |
+
text-decoration: none;
|
34 |
+
border-radius: 2px 2px 2px 2px;
|
35 |
+
-moz-user-select: none;
|
36 |
+
}
|
37 |
+
|
38 |
+
#fanplayr-install-button:hover {
|
39 |
+
background-color: #50B550;
|
40 |
+
background-image: -moz-linear-gradient(center top , #62BC62, #50B550);
|
41 |
+
border-color: #378137;
|
42 |
+
}
|
43 |
+
|
44 |
+
.fanplayr-list-button {
|
45 |
+
-moz-user-select: none;
|
46 |
+
background-color: #EDEDED;
|
47 |
+
background-image: -moz-linear-gradient(center top , #F7F7F7, #EDEDED);
|
48 |
+
background-repeat: repeat-x;
|
49 |
+
border: 1px solid #E6E6E6;
|
50 |
+
border-radius: 2px 2px 2px 2px;
|
51 |
+
color: #000000;
|
52 |
+
cursor: pointer;
|
53 |
+
display: inline-block;
|
54 |
+
line-height: 27px;
|
55 |
+
text-decoration: none;
|
56 |
+
margin: 4px;
|
57 |
+
padding: 0px 12px;
|
58 |
+
}
|
59 |
+
.fanplayr-list-button:hover {
|
60 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) inset;
|
61 |
+
}
|
62 |
+
|
63 |
+
#fanplayr-start-button {
|
64 |
+
background-color: #46A546;
|
65 |
+
background-image: -moz-linear-gradient(center top , #50B550, #46A546);
|
66 |
+
background-repeat: repeat-x;
|
67 |
+
border-color: #3E933E;
|
68 |
+
color: #fff;
|
69 |
+
display: inline-block;
|
70 |
+
font-size: 15px;
|
71 |
+
line-height: 27px;
|
72 |
+
padding: 8px 12px;
|
73 |
+
text-decoration: none;
|
74 |
+
border-radius: 2px 2px 2px 2px;
|
75 |
+
-moz-user-select: none;
|
76 |
+
}
|
77 |
+
#fanplayr-start-button:hover {
|
78 |
+
background-color: #50B550;
|
79 |
+
background-image: -moz-linear-gradient(center top , #62BC62, #50B550);
|
80 |
+
border-color: #378137;
|
81 |
+
}
|
82 |
+
|
83 |
+
.fanplayr-icon {
|
84 |
+
width: 16px;
|
85 |
+
height: 16px;
|
86 |
+
display: inline-block;
|
87 |
+
margin-right: 10px;
|
88 |
+
padding-top: 3px;
|
89 |
+
}
|
90 |
+
|
91 |
+
.fanplayr-icon-star {
|
92 |
+
background: url(./images/star_gold.png) 0px 3px no-repeat;
|
93 |
+
}
|
94 |
+
|
95 |
+
.fanplayr-edit {
|
96 |
+
background: url(./images/pencil.png) 0px 3px no-repeat;
|
97 |
+
position: relative;
|
98 |
+
top: 3px;
|
99 |
+
}
|
100 |
+
|
101 |
+
.fanplayr-add-remove, .fanplayr-add {
|
102 |
+
background: url(./images/accept.png) 0px 3px no-repeat;
|
103 |
+
position: relative;
|
104 |
+
top: 3px;
|
105 |
+
}
|
106 |
+
|
107 |
+
.fanplayr-is-added .fanplayr-add-remove {
|
108 |
+
background-image: url(./images/disable.png);
|
109 |
+
}
|
110 |
+
|
111 |
+
.fanplayr-activity .fanplayr-icon {
|
112 |
+
background-image: url(./images/activity.gif) !important;
|
113 |
+
position: relative;
|
114 |
+
top: 3px;
|
115 |
+
}
|
116 |
+
|
117 |
+
/* campaign type icons */
|
118 |
+
.fanplayr-type-sales {
|
119 |
+
background-image: url(./images/sales_16.png);
|
120 |
+
background-repeat: no-repeat;
|
121 |
+
padding-left: 30px !important;
|
122 |
+
background-position: 7px 12px;
|
123 |
+
}
|
124 |
+
.fanplayr-type-genius {
|
125 |
+
background-image: url(./images/genius_16.png);
|
126 |
+
background-repeat: no-repeat;
|
127 |
+
padding-left: 30px !important;
|
128 |
+
background-position: 7px 12px;
|
129 |
+
}
|
130 |
+
|
131 |
+
/* ---------------------------------------------------------------------- */
|
132 |
+
|
133 |
+
.fanplayr-modal-frame
|
134 |
+
{
|
135 |
+
width:76px;
|
136 |
+
height:76px;
|
137 |
+
margin-left:-38px;
|
138 |
+
margin-top:-38px;
|
139 |
+
overflow:hidden;
|
140 |
+
z-index: 10001;
|
141 |
+
}
|
142 |
+
.fanplayr-modal-inner
|
143 |
+
{
|
144 |
+
position: relative;
|
145 |
+
z-index: 10002;
|
146 |
+
|
147 |
+
background-color: #FFFFFF;
|
148 |
+
border: 1px solid rgba(0, 0, 0, 0.3);
|
149 |
+
-webkit-border-radius:6px;
|
150 |
+
-moz-border-radius:6px;
|
151 |
+
border-radius:6px;
|
152 |
+
box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
|
153 |
+
left: 50%;
|
154 |
+
margin: -250px 0 0 -250px;
|
155 |
+
position: fixed;
|
156 |
+
top: 50%;
|
157 |
+
z-index: 11000;
|
158 |
+
}
|
159 |
+
.fanplayr-modal-frame.loading
|
160 |
+
{
|
161 |
+
background:rgba(255, 255, 255, 0.050000000000000044);
|
162 |
+
-webkit-box-shadow:none;
|
163 |
+
-moz-box-shadow:none;
|
164 |
+
box-shadow:none;
|
165 |
+
-webkit-box-shadow:none;
|
166 |
+
-moz-box-shadow:none;
|
167 |
+
box-shadow:none;
|
168 |
+
border:1px solid rgba(255, 255, 255, 0.020000000000000018);
|
169 |
+
}
|
170 |
+
.fanplayr-modal-frame.loading .icon-load
|
171 |
+
{
|
172 |
+
display:block;
|
173 |
+
position:absolute;
|
174 |
+
top:50%;
|
175 |
+
left:50%;
|
176 |
+
width:43px;
|
177 |
+
height:11px;
|
178 |
+
margin:-6px 0 0 -21px;
|
179 |
+
background:url("./images/progress-loader.gif") no-repeat;
|
180 |
+
}
|
181 |
+
.fanplayr-modal-frame .icon-load
|
182 |
+
{
|
183 |
+
display:none;
|
184 |
+
}
|
185 |
+
.fanplayr-modal-frame iframe
|
186 |
+
{
|
187 |
+
visibility:hidden;
|
188 |
+
overflow:hidden;
|
189 |
+
-webkit-border-radius:6px;
|
190 |
+
-moz-border-radius:6px;
|
191 |
+
border-radius:6px;
|
192 |
+
border:none;
|
193 |
+
}
|
194 |
+
|
195 |
+
.fanplayr-modal-backdrop
|
196 |
+
{
|
197 |
+
background-color:#000000;
|
198 |
+
position:fixed;
|
199 |
+
top:0;
|
200 |
+
left:0;
|
201 |
+
right:0;
|
202 |
+
bottom:0;
|
203 |
+
z-index:10000;
|
204 |
+
}
|
205 |
+
.fanplayr-modal-backdrop.fade
|
206 |
+
{
|
207 |
+
opacity:0;
|
208 |
+
}
|
209 |
+
.fanplayr-modal-backdrop,.modal-backdrop.fade.in
|
210 |
+
{
|
211 |
+
filter:alpha(opacity=30);
|
212 |
+
-khtml-opacity:0.3;
|
213 |
+
-moz-opacity:0.3;
|
214 |
+
opacity:0.3;
|
215 |
+
}
|
216 |
+
|
217 |
+
#fanplayr-install-wrapper {
|
218 |
+
|
219 |
+
}
|
220 |
+
|
221 |
+
#fanplayr-install-description {
|
222 |
+
margin-top: 30px;
|
223 |
+
margin-bottom: 30px;
|
224 |
+
width: 480px;
|
225 |
+
}
|
226 |
+
|
227 |
+
#fanplayr-none-wrapper, #fanplayr-draft-wrapper, #fanplayr-head-wrapper {
|
228 |
+
}
|
229 |
+
|
230 |
+
#fanplayr-none-description, #fanplayr-draft-description, #fanplayr-head-description {
|
231 |
+
margin-top: 30px;
|
232 |
+
margin-bottom: 30px;
|
233 |
+
width: 480px;
|
234 |
+
}
|
235 |
+
|
236 |
+
#fanplayr-new-version {
|
237 |
+
width: 100%;
|
238 |
+
margin-bottom: 25px;
|
239 |
+
background: #FAFAEC url("./images/warning.png") 4px 4px no-repeat;
|
240 |
+
border: 1px solid #FCD344;
|
241 |
+
color: #3D6611;
|
242 |
+
padding: 5px;
|
243 |
+
padding-left: 30px;
|
244 |
+
}
|
245 |
+
|
246 |
+
#fanplayrsocialcoupons-console {
|
247 |
+
background: #eee;
|
248 |
+
border: 1px solid #ddd;
|
249 |
+
padding: 15px;
|
250 |
+
margin: 15px;
|
251 |
+
margin-bottom: 30px;
|
252 |
+
width: 500px;
|
253 |
+
}
|
254 |
+
#fanplayrsocialcoupons-console label {
|
255 |
+
font-weight: bold;
|
256 |
+
display: block;
|
257 |
+
float: right;
|
258 |
+
margin-right: 10px;
|
259 |
+
}
|
260 |
+
#fanplayrsocialcoupons-console input {
|
261 |
+
width: 300px;
|
262 |
+
margin-bottom: 12px;
|
263 |
+
}
|
264 |
+
#fanplayrsocialcoupons-console a {
|
265 |
+
margin-top: 15px;
|
266 |
+
|
267 |
+
display: block;
|
268 |
+
text-decoration: none;
|
269 |
+
|
270 |
+
border-width: 1px;
|
271 |
+
border-style: solid;
|
272 |
+
border-color: #ED6502 #A04300 #A04300 #ED6502;
|
273 |
+
padding: 1px 7px 2px 7px;
|
274 |
+
background-color: #ee8b36;
|
275 |
+
color: white;
|
276 |
+
font: bold 12px arial, helvetica, sans-serif;
|
277 |
+
cursor: pointer;
|
278 |
+
text-align: center !important;
|
279 |
+
white-space: nowrap;
|
280 |
+
}
|
281 |
+
#fanplayrsocialcoupons-console-save {
|
282 |
+
float: left;
|
283 |
+
}
|
284 |
+
#fanplayrsocialcoupons-console-hide {
|
285 |
+
float: right;
|
286 |
+
}
|
287 |
+
|
288 |
+
#fanplayr-template-warning {
|
289 |
+
border: 1px solid #ccc;
|
290 |
+
padding: 5px;
|
291 |
+
margin-bottom: 15px;
|
292 |
+
}
|
293 |
+
|
294 |
+
#fanplayr-template-warning-add {
|
295 |
+
margin-top: 15px;
|
296 |
+
margin-bottom: 15px;
|
297 |
+
display: inline-block;
|
298 |
+
}
|
skin/frontend/socialcoupons/fanplayr_socialcoupons.js
ADDED
@@ -0,0 +1,591 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* ...
|
3 |
+
* @author Tarwin
|
4 |
+
*/
|
5 |
+
|
6 |
+
fanplayrJQuery.postJSON = function(url, data, callback) {
|
7 |
+
return fanplayrJQuery.ajax({
|
8 |
+
'type': 'POST',
|
9 |
+
'url': url,
|
10 |
+
'data': data,
|
11 |
+
'dataType': 'json',
|
12 |
+
'success': callback
|
13 |
+
});
|
14 |
+
};
|
15 |
+
|
16 |
+
// we need this crap for cookies - at least to be lazy
|
17 |
+
if (typeof String.prototype.trimLeft !== "function") {
|
18 |
+
String.prototype.trimLeft = function() {
|
19 |
+
return this.replace(/^\s+/, "");
|
20 |
+
};
|
21 |
+
}
|
22 |
+
if (typeof String.prototype.trimRight !== "function") {
|
23 |
+
String.prototype.trimRight = function() {
|
24 |
+
return this.replace(/\s+$/, "");
|
25 |
+
};
|
26 |
+
}
|
27 |
+
if (typeof Array.prototype.map !== "function") {
|
28 |
+
Array.prototype.map = function(callback, thisArg) {
|
29 |
+
for (var i=0, n=this.length, a=[]; i<n; i++) {
|
30 |
+
if (i in this) a[i] = callback.call(thisArg, this[i]);
|
31 |
+
}
|
32 |
+
return a;
|
33 |
+
};
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( ! window.Fanplayr ) {
|
37 |
+
window.Fanplayr = {
|
38 |
+
isWorking: false,
|
39 |
+
proxy : function (fn, obj) {
|
40 |
+
return function() { fn.apply(obj, arguments); };
|
41 |
+
},
|
42 |
+
|
43 |
+
getParams : function() {
|
44 |
+
var a = window.location.search.substr(1).split("&");
|
45 |
+
if (a == "") return {};
|
46 |
+
var b = {};
|
47 |
+
for (var i = 0; i < a.length; ++i) {
|
48 |
+
var p = a[i].split("=");
|
49 |
+
if (p.length != 2) continue;
|
50 |
+
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
|
51 |
+
}
|
52 |
+
return b;
|
53 |
+
},
|
54 |
+
|
55 |
+
getParam : function( name, defValue ) {
|
56 |
+
var params = this.getParams();
|
57 |
+
if (params.hasOwnProperty(name)) {
|
58 |
+
return params[name];
|
59 |
+
}
|
60 |
+
return defValue;
|
61 |
+
},
|
62 |
+
|
63 |
+
disableLogs : function() {
|
64 |
+
var empty = function() {};
|
65 |
+
Fanplayr.log = Fanplayr.debug = Fanplayr.info = Fanplayr.warn = Fanplayr.error = empty;
|
66 |
+
},
|
67 |
+
|
68 |
+
unlink: function(){
|
69 |
+
var url = Fanplayr.configShopUrl + 'fanplayr/compy/unlink/';
|
70 |
+
fanplayrJQuery.postJSON(url, {
|
71 |
+
acckey: Fanplayr.configAccKey,
|
72 |
+
secret: Fanplayr.configSecret
|
73 |
+
})
|
74 |
+
.success(function(result) {
|
75 |
+
if (!result.error){
|
76 |
+
alert('Account unlinked. Refreshing page.');
|
77 |
+
window.top.location.reload();
|
78 |
+
}else{
|
79 |
+
alert(result.message);
|
80 |
+
}
|
81 |
+
})
|
82 |
+
.error(function() {
|
83 |
+
alert('Sorry, there was a communications error. Refreshing page.');
|
84 |
+
window.top.location.reload();
|
85 |
+
});
|
86 |
+
},
|
87 |
+
|
88 |
+
fillCampaignList : function($cnt, data) {
|
89 |
+
|
90 |
+
if (!data) return;
|
91 |
+
|
92 |
+
var $ = fanplayrJQuery;
|
93 |
+
|
94 |
+
if (data.error){
|
95 |
+
$cnt.html("Sorry there was an error getting your campaign data. " + data.message);
|
96 |
+
}else{
|
97 |
+
function CampList() {
|
98 |
+
var obj = {
|
99 |
+
init : function() {
|
100 |
+
this.$cnt = $cnt;
|
101 |
+
var out = '';
|
102 |
+
var outD = '';
|
103 |
+
var outP = '';
|
104 |
+
var outR = '';
|
105 |
+
|
106 |
+
Fanplayr.numGenius = 0;
|
107 |
+
|
108 |
+
for (i=0; i<data.campaigns.length; i++){
|
109 |
+
camp = data.campaigns[i];
|
110 |
+
var sId = camp.shopIntegrationId;
|
111 |
+
var isIntegrated = sId != '' && sId != 'null' && sId != null;
|
112 |
+
var id = 'fanplayr-int-' + camp.key;
|
113 |
+
var cStatus = camp.status;
|
114 |
+
var tOut = '<tr class="fanplayr-camplist-row fanplayr-status-' + cStatus;
|
115 |
+
tOut += (isIntegrated ? ' fanplayr-is-added ' : ' fanplayr-not-added ');
|
116 |
+
|
117 |
+
if (camp.type == 'genius'){
|
118 |
+
tOut += '" id="' + id + '" data-key="' + camp.key + '" data-type="' + camp.type + '"><td class="fanplayr-type-genius">' + camp.name + '</td><td align="right"><a class="fanplayr-list-button" href="http://my.fanplayr.com/dashboard.genius.site/campaignId/' + camp.id + '/" target="_blank"><div class="fanplayr-icon fanplayr-edit"></div><span>View / Edit</span></a></td></tr>';
|
119 |
+
}else{
|
120 |
+
tOut += '" id="' + id + '" data-key="' + camp.key + '" data-type="' + camp.type + '"><td class="fanplayr-type-sales">' + camp.name + '</td><td align="right"><a class="fanplayr-list-button fanplayr-add-remove-button" href="#"><div class="fanplayr-add-remove fanplayr-icon"></div><span>Activate</span></a><a class="fanplayr-list-button" href="http://my.fanplayr.com/dashboard.campaign.overview/campaignId/' + camp.id + '/" target="_blank"><div class="fanplayr-icon fanplayr-edit"></div><span>Edit</span></a></td></tr>';
|
121 |
+
}
|
122 |
+
|
123 |
+
if (cStatus == 'draft') outD += tOut;
|
124 |
+
if (cStatus == 'published') outP += tOut;
|
125 |
+
if (cStatus == 'running') outR += tOut;
|
126 |
+
|
127 |
+
if ((cStatus == 'published' || cStatus == 'running') && camp.type == 'genius' && isIntegrated)
|
128 |
+
Fanplayr.numGenius++;
|
129 |
+
}
|
130 |
+
|
131 |
+
// only add headings if some exist
|
132 |
+
if (outD.length)
|
133 |
+
out += '<tr class="fanplayr-camplist-header"><td colspan="2">Drafts (you have to publish these before you can add them)</td></tr>' + outD;
|
134 |
+
if (outP.length)
|
135 |
+
out += '<tr class="fanplayr-camplist-header"><td colspan="2">Scheduled</td></tr>' + outP;
|
136 |
+
if (outR.length)
|
137 |
+
out += '<tr class="fanplayr-camplist-header"><td colspan="2">Currently Running</td></tr>' + outR;
|
138 |
+
|
139 |
+
Fanplayr.hasDraftCampaigns = outD.length > 0;
|
140 |
+
Fanplayr.hasPublishedCampaigns = outP.length > 0;
|
141 |
+
Fanplayr.hasRunningCampaigns = outR.length > 0;
|
142 |
+
|
143 |
+
this.$cnt.html(out);
|
144 |
+
|
145 |
+
this.$cnt.find('.fanplayr-status-draft .fanplayr-add-remove-button').hide();
|
146 |
+
this.$cnt.find('.fanplayr-is-added a.fanplayr-add-remove-button span').text('Deactivate');
|
147 |
+
|
148 |
+
this.$cnt.on("click", "a.fanplayr-add-remove-button", $.proxy(this.onAddRemove, this));
|
149 |
+
|
150 |
+
return this;
|
151 |
+
},
|
152 |
+
|
153 |
+
onAddRemove: function(e) {
|
154 |
+
e.preventDefault();
|
155 |
+
|
156 |
+
if (Fanplayr.isWorking){
|
157 |
+
alert('Please wait until the current task is complete.');
|
158 |
+
return;
|
159 |
+
}
|
160 |
+
|
161 |
+
var $t = $(e.currentTarget);
|
162 |
+
var $row = $t.closest('tr');
|
163 |
+
var key = $row.data('key');
|
164 |
+
var type = $row.data('type');
|
165 |
+
|
166 |
+
// not already pressed
|
167 |
+
if (!$t.hasClass('fanplayr-activity')){
|
168 |
+
$t.addClass('fanplayr-activity');
|
169 |
+
$t.find('span').text('Working ...');
|
170 |
+
var added = $t.closest('tr').hasClass('fanplayr-is-added');
|
171 |
+
|
172 |
+
if (!added){
|
173 |
+
if (type == 'genius' && Fanplayr.numGenius > 0){
|
174 |
+
$t.removeClass('fanplayr-activity');
|
175 |
+
$t.find('span').text('Activate');
|
176 |
+
alert('You can only have one Smart + Targeted campaign running. Please disable other campaigns first.');
|
177 |
+
return;
|
178 |
+
}
|
179 |
+
|
180 |
+
// add
|
181 |
+
Fanplayr.isWorking = true;
|
182 |
+
var url = Fanplayr.configShopUrl + 'fanplayr/compy/addwidget/';
|
183 |
+
$.postJSON(url, {
|
184 |
+
acckey: Fanplayr.configAccKey,
|
185 |
+
secret: Fanplayr.configSecret,
|
186 |
+
campkey: key,
|
187 |
+
inform: '1',
|
188 |
+
type: type
|
189 |
+
})
|
190 |
+
.success(function(result) {
|
191 |
+
Fanplayr.isWorking = false;
|
192 |
+
if (!result.error){
|
193 |
+
$t.removeClass('fanplayr-activity');
|
194 |
+
$row.removeClass('fanplayr-not-added').addClass('fanplayr-is-added');
|
195 |
+
$t.find('span').text('Deactivate');
|
196 |
+
if (type == 'genius') Fanplayr.numGenius++;
|
197 |
+
}else{
|
198 |
+
$t.removeClass('fanplayr-activity');
|
199 |
+
$t.find('span').text('Activate');
|
200 |
+
alert(result.message);
|
201 |
+
}
|
202 |
+
})
|
203 |
+
.error(function() {
|
204 |
+
Fanplayr.isWorking = false;
|
205 |
+
$t.removeClass('fanplayr-activity');
|
206 |
+
$t.find('span').text('Activate');
|
207 |
+
alert('Sorry, there was a communications error.');
|
208 |
+
});
|
209 |
+
}else{
|
210 |
+
// remove
|
211 |
+
Fanplayr.isWorking = true;
|
212 |
+
var url = Fanplayr.configShopUrl + 'fanplayr/compy/removewidget/';
|
213 |
+
$.postJSON(url, {
|
214 |
+
acckey: Fanplayr.configAccKey,
|
215 |
+
secret: Fanplayr.configSecret,
|
216 |
+
campkey: key,
|
217 |
+
inform: '1',
|
218 |
+
type: type
|
219 |
+
})
|
220 |
+
.success(function(result) {
|
221 |
+
Fanplayr.isWorking = false;
|
222 |
+
if (!result.error){
|
223 |
+
$t.removeClass('fanplayr-activity');
|
224 |
+
$row.removeClass('fanplayr-is-added').addClass('fanplayr-not-added');
|
225 |
+
$t.find('span').text('Activate');
|
226 |
+
if (type == 'genius') Fanplayr.numGenius--;
|
227 |
+
}else{
|
228 |
+
$t.removeClass('fanplayr-activity');
|
229 |
+
$t.find('span').text('Deactivate');
|
230 |
+
alert(result.message);
|
231 |
+
}
|
232 |
+
})
|
233 |
+
.error(function() {
|
234 |
+
Fanplayr.isWorking = false;
|
235 |
+
$t.removeClass('fanplayr-activity');
|
236 |
+
$t.find('span').text('Deactivate');
|
237 |
+
alert('Sorry, there was a communications error.');
|
238 |
+
});
|
239 |
+
}
|
240 |
+
}
|
241 |
+
}
|
242 |
+
}
|
243 |
+
return obj.init();
|
244 |
+
}
|
245 |
+
|
246 |
+
var campList = new CampList();
|
247 |
+
|
248 |
+
//fanplayr-add-remove-removed
|
249 |
+
}
|
250 |
+
},
|
251 |
+
|
252 |
+
addTemplates: function(){
|
253 |
+
var url = Fanplayr.configShopUrl + 'fanplayr/compy/addtemplate/';
|
254 |
+
fanplayrJQuery.postJSON(url, {
|
255 |
+
acckey: Fanplayr.configAccKey,
|
256 |
+
secret: Fanplayr.configSecret
|
257 |
+
})
|
258 |
+
.success(function(result) {
|
259 |
+
if (!result.error){
|
260 |
+
alert(result.message);
|
261 |
+
window.top.location.reload();
|
262 |
+
}else{
|
263 |
+
alert(result.message);
|
264 |
+
}
|
265 |
+
})
|
266 |
+
.error(function() {
|
267 |
+
alert('Sorry, there was a communications error. Refreshing page.');
|
268 |
+
window.top.location.reload();
|
269 |
+
});
|
270 |
+
},
|
271 |
+
|
272 |
+
console:
|
273 |
+
{
|
274 |
+
show: function(){
|
275 |
+
Fanplayr.setCookie('fanplayrsocialcoupons-console-display', 'show');
|
276 |
+
document.getElementById('fanplayrsocialcoupons-console').style.display = 'block';
|
277 |
+
},
|
278 |
+
hide: function(){
|
279 |
+
Fanplayr.setCookie('fanplayrsocialcoupons-console-display', 'hide');
|
280 |
+
document.getElementById('fanplayrsocialcoupons-console').style.display = 'none';
|
281 |
+
},
|
282 |
+
save: function(){
|
283 |
+
if (Fanplayr.isWorking){
|
284 |
+
alert('Please wait until the current task is complete.');
|
285 |
+
return;
|
286 |
+
}
|
287 |
+
|
288 |
+
var $ = fanplayrJQuery;
|
289 |
+
Fanplayr.isWorking = true;
|
290 |
+
|
291 |
+
$('#fanplayrsocialcoupons-console-saving').show();
|
292 |
+
|
293 |
+
// if we specify a custom URL, use that to update as this IS where our shop is
|
294 |
+
if ($('#fanplayrsocialcoupons-console-url').val() != '')
|
295 |
+
Fanplayr.configShopUrl = $('#fanplayrsocialcoupons-console-url').val();
|
296 |
+
|
297 |
+
var url = Fanplayr.configShopUrl + 'fanplayr/compy/consoleupdate/';
|
298 |
+
|
299 |
+
$.postJSON(url, {
|
300 |
+
acckey: Fanplayr.configAccKey,
|
301 |
+
secret: Fanplayr.configSecret,
|
302 |
+
secretinner: Fanplayr.configSecretInner,
|
303 |
+
acckeynew: $('#fanplayrsocialcoupons-console-acckey').val(),
|
304 |
+
secretnew: $('#fanplayrsocialcoupons-console-secret').val(),
|
305 |
+
shopid: $('#fanplayrsocialcoupons-console-shopid').val(),
|
306 |
+
gamafied: $('#fanplayrsocialcoupons-console-gamafied').val(),
|
307 |
+
genius: $('#fanplayrsocialcoupons-console-snt').val(),
|
308 |
+
url: $('#fanplayrsocialcoupons-console-url').val(),
|
309 |
+
disableonurls: $('#fanplayrsocialcoupons-console-disableonurls').val(),
|
310 |
+
embedtype: $('#fanplayrsocialcoupons-console-embedtype').val(),
|
311 |
+
layouthook: $('#fanplayrsocialcoupons-console-layouthook').val(),
|
312 |
+
layouthookhome: $('#fanplayrsocialcoupons-console-layouthookhome').val(),
|
313 |
+
layouthookorder: $('#fanplayrsocialcoupons-console-layouthookorder').val(),
|
314 |
+
depprefix: $('#fanplayrsocialcoupons-console-depprefix').val(),
|
315 |
+
deproutes: $('#fanplayrsocialcoupons-console-deproutes').val(),
|
316 |
+
customembedurl: $('#fanplayrsocialcoupons-console-customembedurl').val(),
|
317 |
+
gtmcontainerid: $('#fanplayrsocialcoupons-console-gtmcontainerid').val(),
|
318 |
+
trailingslash: $('#fanplayrsocialcoupons-console-trailingslash').val()
|
319 |
+
})
|
320 |
+
.success(function(result) {
|
321 |
+
Fanplayr.isWorking = false;
|
322 |
+
$('#fanplayrsocialcoupons-console-saving').hide();
|
323 |
+
if (!result.error){
|
324 |
+
alert('Saved. Refreshing page.');
|
325 |
+
window.top.location.reload();
|
326 |
+
}else{
|
327 |
+
alert(result.message);
|
328 |
+
}
|
329 |
+
})
|
330 |
+
.error(function() {
|
331 |
+
Fanplayr.isWorking = false;
|
332 |
+
$('#fanplayrsocialcoupons-console-saving').hide();
|
333 |
+
alert('Sorry, there was a communications error.');
|
334 |
+
});
|
335 |
+
}
|
336 |
+
},
|
337 |
+
|
338 |
+
setCookie: function(name, value, days)
|
339 |
+
{
|
340 |
+
var exdate = new Date();
|
341 |
+
exdate.setDate(exdate.getDate() + days);
|
342 |
+
var value = escape(value) + ((days == null) ? "" : "; expires=" + exdate.toUTCString());
|
343 |
+
document.cookie = name + "=" + value;
|
344 |
+
},
|
345 |
+
|
346 |
+
getCookies: function() {
|
347 |
+
var c = document.cookie, v = 0, cookies = {};
|
348 |
+
if (document.cookie.match(/^\s*\$Version=(?:"1"|1);\s*(.*)/)) {
|
349 |
+
c = RegExp.$1;
|
350 |
+
v = 1;
|
351 |
+
}
|
352 |
+
if (v === 0) {
|
353 |
+
c.split(/[,;]/).map(function(cookie) {
|
354 |
+
var parts = cookie.split(/=/, 2),
|
355 |
+
name = decodeURIComponent(parts[0].trimLeft()),
|
356 |
+
value = parts.length > 1 ? decodeURIComponent(parts[1].trimRight()) : null;
|
357 |
+
cookies[name] = value;
|
358 |
+
});
|
359 |
+
} else {
|
360 |
+
c.match(/(?:^|\s+)([!#$%&'*+\-.0-9A-Z^`a-z|~]+)=([!#$%&'*+\-.0-9A-Z^`a-z|~]*|"(?:[\x20-\x7E\x80\xFF]|\\[\x00-\x7F])*")(?=\s*[,;]|$)/g).map(function($0, $1) {
|
361 |
+
var name = $0,
|
362 |
+
value = $1.charAt(0) === '"'
|
363 |
+
? $1.substr(1, -1).replace(/\\(.)/g, "$1")
|
364 |
+
: $1;
|
365 |
+
cookies[name] = value;
|
366 |
+
});
|
367 |
+
}
|
368 |
+
return cookies;
|
369 |
+
},
|
370 |
+
|
371 |
+
getCookie: function(name) {
|
372 |
+
return getCookies()[name];
|
373 |
+
}
|
374 |
+
};
|
375 |
+
|
376 |
+
// Logging methods.
|
377 |
+
// ----------------------------------------
|
378 |
+
(function() {
|
379 |
+
var levels = ["log", "debug", "info", "warn", "error"];
|
380 |
+
var disableLog = true;
|
381 |
+
if ( ! disableLog) {
|
382 |
+
try {
|
383 |
+
var matt = top.console.log;
|
384 |
+
top.console.log.apply(top.console, ['Log enabled!']);
|
385 |
+
} catch (err) {
|
386 |
+
disableLog = true;
|
387 |
+
}
|
388 |
+
}
|
389 |
+
if ( "console" in window && ! disableLog ) {
|
390 |
+
if ( "firebug" in console ) {
|
391 |
+
for (var i in levels) Fanplayr[levels[i]] = top.console[levels[i]];
|
392 |
+
} else {
|
393 |
+
var empty = function() {};
|
394 |
+
// Chrome
|
395 |
+
Fanplayr.log = (top.console.log) ? function() { top.console.log.apply(top.console, arguments); } : empty;
|
396 |
+
Fanplayr.debug = (top.console.debug) ? function() { top.console.debug.apply(top.console, arguments); } : empty;
|
397 |
+
Fanplayr.info = (top.console.info) ? function() { top.console.info.apply(top.console, arguments); } : empty;
|
398 |
+
Fanplayr.warn = (top.console.warn) ? function() { top.console.warn.apply(top.console, arguments); } : empty;
|
399 |
+
Fanplayr.error = (top.console.error) ? function() { top.console.error.apply(top.console, arguments); } : empty;
|
400 |
+
}
|
401 |
+
} else {
|
402 |
+
var empty = function() {
|
403 |
+
var args = [];
|
404 |
+
for (i=0;i<arguments.length;i++) args.push(arguments[i]);
|
405 |
+
console.log(args);
|
406 |
+
};
|
407 |
+
for (var i in levels) Fanplayr[levels[i]] = empty;
|
408 |
+
}
|
409 |
+
})();
|
410 |
+
};
|
411 |
+
|
412 |
+
if ( ! window.FanplayrClass ) {
|
413 |
+
// Author: Steffen Rusitschka
|
414 |
+
// http://www.ruzee.com/blog/2008/12/javascript-inheritance-via-prototypes-and-closures
|
415 |
+
(function(){
|
416 |
+
var isFn = function(fn) { return typeof fn == "function"; };
|
417 |
+
FanplayrClass = function(){};
|
418 |
+
FanplayrClass.create = function(proto) {
|
419 |
+
var k = function(magic) { // call init only if there's no magic cookie
|
420 |
+
if (magic != isFn && isFn(this.init)) this.init.apply(this, arguments);
|
421 |
+
};
|
422 |
+
k.prototype = new this(isFn); // use our private method as magic cookie
|
423 |
+
for (key in proto) (function(fn, sfn){ // create a closure
|
424 |
+
k.prototype[key] = !isFn(fn) || !isFn(sfn) ? fn : // add _super method
|
425 |
+
function() { this._super = sfn; return fn.apply(this, arguments); };
|
426 |
+
})(proto[key], k.prototype[key]);
|
427 |
+
k.prototype.constructor = k;
|
428 |
+
k.extend = this.extend || this.create;
|
429 |
+
return k;
|
430 |
+
};
|
431 |
+
// Wrap fanplayrJQuery event binding.
|
432 |
+
FanplayrClass.prototype.on = function( events, selector, data, handler ) {
|
433 |
+
if ( ! this.__$ ) this.__$ = fanplayrJQuery("<div></div>");
|
434 |
+
this.__$.on.call(this.__$, events, selector, data, fanplayrJQuery.proxy(handler, this) );
|
435 |
+
};
|
436 |
+
FanplayrClass.prototype.off = function( events, selector, handler ) {
|
437 |
+
if ( ! this.__$ ) this.__$ = fanplayrJQuery("<div></div>");
|
438 |
+
this.__$.off.call(this.__$, events, selector, handler );
|
439 |
+
};
|
440 |
+
// Wrap fanplayrJQuery event invoking.
|
441 |
+
FanplayrClass.prototype.trigger = function( eventType, extraParameters ) {
|
442 |
+
if ( ! this.__$ ) this.__$ = fanplayrJQuery("<div></div>");
|
443 |
+
this.__$.trigger.call(this.__$, eventType, extraParameters );
|
444 |
+
};
|
445 |
+
})();
|
446 |
+
};
|
447 |
+
|
448 |
+
var FanplayrModal = FanplayrClass.create({
|
449 |
+
id : null,
|
450 |
+
$el : null,
|
451 |
+
$iframe : null,
|
452 |
+
$backdrop : null,
|
453 |
+
iframe : null,
|
454 |
+
defaults : {
|
455 |
+
url : false,
|
456 |
+
close : false,
|
457 |
+
data : null,
|
458 |
+
maxWidth : 0,
|
459 |
+
maxHeight : 0
|
460 |
+
},
|
461 |
+
_close : false,
|
462 |
+
data : null,
|
463 |
+
contexts : {},
|
464 |
+
init : function( id ) {
|
465 |
+
if ( id == undefined ) Fanplayr.warn("Must create a modal with an ID!");
|
466 |
+
this.id = id;
|
467 |
+
FanplayrModal.register(id, this);
|
468 |
+
},
|
469 |
+
create : function () {
|
470 |
+
if ( ! this.$el ) {
|
471 |
+
var html = '<div class="fanplayr-modal fanplayr-modal-frame">'
|
472 |
+
+ '<div class="icon-load"></div>'
|
473 |
+
+ '<div class="fanplayr-modal-inner"><iframe src="" frameborder="0"></iframe></div>'
|
474 |
+
+ '</div>';
|
475 |
+
this.$el = fanplayrJQuery(html).appendTo("body");
|
476 |
+
this.$iframe = this.$el.find("iframe");
|
477 |
+
this.$iframe.load(fanplayrJQuery.proxy(this.loaded, this));
|
478 |
+
this.$backdrop = fanplayrJQuery('<div class="fanplayr-modal-backdrop" />').appendTo("body");
|
479 |
+
this.$el.find('.fanplayr-modal-inner').hide();
|
480 |
+
}
|
481 |
+
},
|
482 |
+
show : function() {
|
483 |
+
this.$backdrop.show();
|
484 |
+
this.$iframe.css("visibility", "hidden");
|
485 |
+
this.$el.css("width", 76).css("height", 76).css("marginLeft", -38).css("marginTop", -38);
|
486 |
+
this.$el.show();
|
487 |
+
// stop body scroll
|
488 |
+
//$('body').css('overflow', 'hidden');
|
489 |
+
//$('html').css('overflow', 'hidden');
|
490 |
+
},
|
491 |
+
load : function (url) {
|
492 |
+
if ( ! this.$el ) {
|
493 |
+
var $el = fanplayrJQuery("#fanplayr-modal");
|
494 |
+
if ( $el.length == 0 ) {
|
495 |
+
this.create();
|
496 |
+
} else {
|
497 |
+
this.$el = $el;
|
498 |
+
}
|
499 |
+
}
|
500 |
+
|
501 |
+
var options;
|
502 |
+
|
503 |
+
this._close = false;
|
504 |
+
|
505 |
+
if (typeof url == "string") {
|
506 |
+
options = fanplayrJQuery.extend({}, this.defaults);
|
507 |
+
options.url = url;
|
508 |
+
} else {
|
509 |
+
options = fanplayrJQuery.extend({}, this.defaults, url);
|
510 |
+
this.options = options;
|
511 |
+
}
|
512 |
+
|
513 |
+
if ( options.close ) {
|
514 |
+
this._close = options.close;
|
515 |
+
}
|
516 |
+
|
517 |
+
this.data = (options.data != null && options.data != undefined) ? options.data : null;
|
518 |
+
|
519 |
+
this.show();
|
520 |
+
this.$el.addClass("loading");
|
521 |
+
this.$iframe.attr("src", options.url);
|
522 |
+
},
|
523 |
+
loaded : function () {
|
524 |
+
|
525 |
+
this.iframe = this.$iframe.get()[0].contentWindow;
|
526 |
+
|
527 |
+
//this.iframe.FanplayrModal.instance = this;
|
528 |
+
|
529 |
+
this.$el.removeClass("loading");
|
530 |
+
this.$el.find('.fanplayr-modal-inner').show();
|
531 |
+
|
532 |
+
this.autoSize();
|
533 |
+
},
|
534 |
+
autoSize: function(_w, _h) {
|
535 |
+
this.$iframe.css("width", 10).css("height", 10);
|
536 |
+
|
537 |
+
var w = (_w == undefined) ? this.$iframe.contents().width() : _w;
|
538 |
+
var h = (_h == undefined) ? this.$iframe.contents().height() : _h;
|
539 |
+
|
540 |
+
//if (this.options.maxWidth && this.options.maxWidth > 0) w = Math.min(w, this.options.maxWidth);
|
541 |
+
//if (this.options.maxHeight && this.options.maxHeight > 0) h = Math.min(h, this.options.maxHeight);
|
542 |
+
|
543 |
+
this.$el.css("width", w).css("height", h).css("marginLeft", -w/2).css("marginTop", -h/2);
|
544 |
+
this.$iframe.css("width", w).css("height", h);
|
545 |
+
this.$iframe.hide().css("visibility", "visible").fadeIn();
|
546 |
+
},
|
547 |
+
close : function () {
|
548 |
+
this.$el.hide();
|
549 |
+
this.$backdrop.hide();
|
550 |
+
if ( this._close ) {
|
551 |
+
this._close();
|
552 |
+
}
|
553 |
+
//$('body').css('overflow', 'auto');
|
554 |
+
//$('html').css('overflow', 'auto');
|
555 |
+
}
|
556 |
+
});
|
557 |
+
|
558 |
+
FanplayrModal.modals = {};
|
559 |
+
|
560 |
+
FanplayrModal.init = function( id ) {
|
561 |
+
fanplayrJQuery(document).ready(function() {
|
562 |
+
Fanplayr.log("modal init!");
|
563 |
+
if ( id == undefined ) id = "main";
|
564 |
+
var modal = FanplayrModal.parent(id);
|
565 |
+
fanplayrJQuery("*[data-modal-action='close']").click(function(event) {
|
566 |
+
Fanplayr.log("data-modal-action!!!!");
|
567 |
+
//modal.close();
|
568 |
+
event.preventDefault();
|
569 |
+
});
|
570 |
+
});
|
571 |
+
};
|
572 |
+
|
573 |
+
FanplayrModal.register = function( id, modal ) {
|
574 |
+
//Fanplayr.log("register modal: ", id);
|
575 |
+
FanplayrModal.modals[id] = modal;
|
576 |
+
};
|
577 |
+
|
578 |
+
FanplayrModal.getById = function( id ) {
|
579 |
+
if ( FanplayrModal.modals[id] ) {
|
580 |
+
return FanplayrModal.modals[id];
|
581 |
+
}
|
582 |
+
return null;
|
583 |
+
};
|
584 |
+
|
585 |
+
FanplayrModal.context = function( id ) {
|
586 |
+
if ( window.parent.FanplayrModal ) {
|
587 |
+
if ( id == undefined ) id = "main";
|
588 |
+
return window.parent.FanplayrModal.getById(id);
|
589 |
+
}
|
590 |
+
return null;
|
591 |
+
};
|
skin/frontend/socialcoupons/fanplayr_socialcoupons.min.css
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#fanplayr-campaign-list{width:100%;border:1px solid #ccc;}
|
2 |
+
#fanplayr-campaign-list td{vertical-align:middle;}
|
3 |
+
.fanplayr-camplist-header{background:none repeat scroll 0 0 #6F8992;color:#fff;}
|
4 |
+
.fanplayr-camplist-header td{padding:2px 10px;}
|
5 |
+
.fanplayr-camplist-row td{padding:2px 10px;}
|
6 |
+
#fanplayr-install-button{background-color:#46A546;background-image:-moz-linear-gradient(center top,#50B550,#46A546);background-repeat:repeat-x;border-color:#3E933E;color:#fff;display:inline-block;font-size:15px;line-height:27px;padding:8px 12px;text-decoration:none;border-radius:2px 2px 2px 2px;-moz-user-select:none;}
|
7 |
+
#fanplayr-install-button:hover{background-color:#50B550;background-image:-moz-linear-gradient(center top,#62BC62,#50B550);border-color:#378137;}
|
8 |
+
.fanplayr-list-button{-moz-user-select:none;background-color:#EDEDED;background-image:-moz-linear-gradient(center top,#F7F7F7,#EDEDED);background-repeat:repeat-x;border:1px solid #E6E6E6;border-radius:2px 2px 2px 2px;color:#000000;cursor:pointer;display:inline-block;line-height:27px;text-decoration:none;margin:4px;padding:0px 12px;}
|
9 |
+
.fanplayr-list-button:hover{box-shadow:0 1px 3px rgba(0,0,0,0.2) inset;}
|
10 |
+
#fanplayr-start-button{background-color:#46A546;background-image:-moz-linear-gradient(center top,#50B550,#46A546);background-repeat:repeat-x;border-color:#3E933E;color:#fff;display:inline-block;font-size:15px;line-height:27px;padding:8px 12px;text-decoration:none;border-radius:2px 2px 2px 2px;-moz-user-select:none;}
|
11 |
+
#fanplayr-start-button:hover{background-color:#50B550;background-image:-moz-linear-gradient(center top,#62BC62,#50B550);border-color:#378137;}
|
12 |
+
.fanplayr-icon{width:16px;height:16px;display:inline-block;margin-right:10px;padding-top:3px;}
|
13 |
+
.fanplayr-icon-star{background:url(./images/star_gold.png) 0px 3px no-repeat;}
|
14 |
+
.fanplayr-edit{background:url(./images/pencil.png) 0px 3px no-repeat;position:relative;top:3px;}
|
15 |
+
.fanplayr-add-remove,.fanplayr-add{background:url(./images/accept.png) 0px 3px no-repeat;position:relative;top:3px;}
|
16 |
+
.fanplayr-is-added .fanplayr-add-remove{background-image:url(./images/disable.png);}
|
17 |
+
.fanplayr-activity .fanplayr-icon{background-image:url(./images/activity.gif)!important;position:relative;top:3px;}
|
18 |
+
.fanplayr-type-sales{background-image:url(./images/sales_16.png);background-repeat:no-repeat;padding-left:30px!important;background-position:7px 12px;}
|
19 |
+
.fanplayr-type-genius{background-image:url(./images/genius_16.png);background-repeat:no-repeat;padding-left:30px!important;background-position:7px 12px;}
|
20 |
+
.fanplayr-modal-frame{width:76px;height:76px;margin-left:-38px;margin-top:-38px;overflow:hidden;z-index:10001;}
|
21 |
+
.fanplayr-modal-inner{position:relative;z-index:10002;background-color:#FFFFFF;border:1px solid rgba(0,0,0,0.3);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;box-shadow:0 3px 7px rgba(0,0,0,0.3);left:50%;margin:-250px 0 0 -250px;position:fixed;top:50%;z-index:11000;}
|
22 |
+
.fanplayr-modal-frame.loading{background:rgba(255,255,255,0.050000000000000044);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;border:1px solid rgba(255,255,255,0.020000000000000018);}
|
23 |
+
.fanplayr-modal-frame.loading .icon-load{display:block;position:absolute;top:50%;left:50%;width:43px;height:11px;margin:-6px 0 0 -21px;background:url("./images/progress-loader.gif") no-repeat;}
|
24 |
+
.fanplayr-modal-frame .icon-load{display:none;}
|
25 |
+
.fanplayr-modal-frame iframe{visibility:hidden;overflow:hidden;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;border:none;}
|
26 |
+
.fanplayr-modal-backdrop{background-color:#000000;position:fixed;top:0;left:0;right:0;bottom:0;z-index:10000;}
|
27 |
+
.fanplayr-modal-backdrop.fade{opacity:0;}
|
28 |
+
.fanplayr-modal-backdrop,.modal-backdrop.fade.in{filter:alpha(opacity=30);-khtml-opacity:0.3;-moz-opacity:0.3;opacity:0.3;}
|
29 |
+
#fanplayr-install-wrapper{}
|
30 |
+
#fanplayr-install-description{margin-top:30px;margin-bottom:30px;width:480px;}
|
31 |
+
#fanplayr-none-wrapper,#fanplayr-draft-wrapper,#fanplayr-head-wrapper{}
|
32 |
+
#fanplayr-none-description,#fanplayr-draft-description,#fanplayr-head-description{margin-top:30px;margin-bottom:30px;width:480px;}
|
33 |
+
#fanplayr-new-version{width:100%;margin-bottom:25px;background:#FAFAEC url("./images/warning.png") 4px 4px no-repeat;border:1px solid #FCD344;color:#3D6611;padding:5px;padding-left:30px;}
|
34 |
+
#fanplayrsocialcoupons-console{background:#eee;border:1px solid #ddd;padding:15px;margin:15px;margin-bottom:30px;width:500px;}
|
35 |
+
#fanplayrsocialcoupons-console label{font-weight:bold;display:block;float:right;margin-right:10px;}
|
36 |
+
#fanplayrsocialcoupons-console input{width:300px;margin-bottom:12px;}
|
37 |
+
#fanplayrsocialcoupons-console a{margin-top:15px;display:block;text-decoration:none;border-width:1px;border-style:solid;border-color:#ED6502 #A04300 #A04300 #ED6502;padding:1px 7px 2px 7px;background-color:#ee8b36;color:white;font:bold 12px arial,helvetica,sans-serif;cursor:pointer;text-align:center!important;white-space:nowrap;}
|
38 |
+
#fanplayrsocialcoupons-console-save{float:left;}
|
39 |
+
#fanplayrsocialcoupons-console-hide{float:right;}
|
skin/frontend/socialcoupons/images/.picasa.ini
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
[progress-loader.gif]
|
2 |
+
rotate=rotate(0)
|
skin/frontend/socialcoupons/images/accept.png
ADDED
Binary file
|
skin/frontend/socialcoupons/images/activity.gif
ADDED
Binary file
|
skin/frontend/socialcoupons/images/disable.png
ADDED
Binary file
|
skin/frontend/socialcoupons/images/fanplayr_logo.png
ADDED
Binary file
|
skin/frontend/socialcoupons/images/genius_16.png
ADDED
Binary file
|
skin/frontend/socialcoupons/images/pencil.png
ADDED
Binary file
|
skin/frontend/socialcoupons/images/progress-loader.gif
ADDED
Binary file
|
skin/frontend/socialcoupons/images/sales_16.png
ADDED
Binary file
|
skin/frontend/socialcoupons/images/star_gold.png
ADDED
Binary file
|
skin/frontend/socialcoupons/images/warning.png
ADDED
Binary file
|
skin/frontend/socialcoupons/jquery-1.7.2.min.js
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
/*! fanplayrJQuery v1.7.2 jquery.com | jquery.org/license */
|
2 |
+
(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"<!doctype html>":"")+"<html><body>"),cl.close();d=cl.createElement(a),cl.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ck)}cj[a]=e}return cj[a]}function ct(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function cs(){cq=b}function cr(){setTimeout(cs,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function ca(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function b_(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bD.test(a)?d(a,e):b_(a+"["+(typeof e=="object"?b:"")+"]",e,c,d)});else if(!c&&f.type(b)==="object")for(var e in b)b_(a+"["+e+"]",b[e],c,d);else d(a,b)}function b$(a,c){var d,e,g=f.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((g[d]?a:e||(e={}))[d]=c[d]);e&&f.extend(!0,a,e)}function bZ(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bS,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=bZ(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=bZ(a,c,d,e,"*",g));return l}function bY(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bO),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bB(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=b==="width"?1:0,g=4;if(d>0){if(c!=="border")for(;e<g;e+=2)c||(d-=parseFloat(f.css(a,"padding"+bx[e]))||0),c==="margin"?d+=parseFloat(f.css(a,c+bx[e]))||0:d-=parseFloat(f.css(a,"border"+bx[e]+"Width"))||0;return d+"px"}d=by(a,b);if(d<0||d==null)d=a.style[b];if(bt.test(d))return d;d=parseFloat(d)||0;if(c)for(;e<g;e+=2)d+=parseFloat(f.css(a,"padding"+bx[e]))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+bx[e]+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+bx[e]))||0);return d+"px"}function bo(a){var b=c.createElement("div");bh.appendChild(b),b.innerHTML=a.outerHTML;return b.firstChild}function bn(a){var b=(a.nodeName||"").toLowerCase();b==="input"?bm(a):b!=="script"&&typeof a.getElementsByTagName!="undefined"&&f.grep(a.getElementsByTagName("input"),bm)}function bm(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bl(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function bk(a,b){var c;b.nodeType===1&&(b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase(),c==="object"?b.outerHTML=a.outerHTML:c!=="input"||a.type!=="checkbox"&&a.type!=="radio"?c==="option"?b.selected=a.defaultSelected:c==="input"||c==="textarea"?b.defaultValue=a.defaultValue:c==="script"&&b.text!==a.text&&(b.text=a.text):(a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value)),b.removeAttribute(f.expando),b.removeAttribute("_submit_attached"),b.removeAttribute("_change_attached"))}function bj(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c,d,e,g=f._data(a),h=f._data(b,g),i=g.events;if(i){delete h.handle,h.events={};for(c in i)for(d=0,e=i[c].length;d<e;d++)f.event.add(b,c,i[c][d])}h.data&&(h.data=f.extend({},h.data))}}function bi(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function U(a){var b=V.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function T(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(O.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?+d:j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c<d;c++)b[a[c]]=!0;return b}var c=a.document,d=a.navigator,e=a.location,f=function(){function J(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(J,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.fanplayrJQuery,g=a.$,h,i=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){d=i[c],f=a[c];if(i===f)continue;l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)}return i},e.extend({noConflict:function(b){a.$===e&&(a.$=g),b&&a.fanplayrJQuery===e&&(a.fanplayrJQuery=f);return e},isReady:!1,readyWait:1,holdReady:function(a){a?e.readyWait++:e.ready(!0)},ready:function(a){if(a===!0&&!--e.readyWait||a!==!0&&!e.isReady){if(!c.body)return setTimeout(e.ready,1);e.isReady=!0;if(a!==!0&&--e.readyWait>0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){if(typeof c!="string"||!c)return null;var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g<h;)if(c.apply(a[g++],d)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)break;return a},trim:G?function(a){return a==null?"":G.call(a)}:function(a){return a==null?"":(a+"").replace(k,"").replace(l,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var d=e.type(a);a.length==null||d==="string"||d==="function"||d==="regexp"||e.isWindow(a)?E.call(c,a):e.merge(c,a)}return c},inArray:function(a,b,c){var d;if(b){if(H)return H.call(b,a,c);d=b.length,c=c?c<0?Math.max(0,d+c):c:0;for(;c<d;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,d){var f,g,h=[],i=0,j=a.length,k=a instanceof e||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,d),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,d),f!=null&&(h[h.length]=f);return h.concat.apply([],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var d=a[c];c=a,a=d}if(!e.isFunction(a))return b;var f=F.call(arguments,2),g=function(){return a.apply(c,f.concat(F.call(arguments)))};g.guid=a.guid=a.guid||g.guid||e.guid++;return g},access:function(a,c,d,f,g,h,i){var j,k=d==null,l=0,m=a.length;if(d&&typeof d=="object"){for(l in d)e.access(a,c,l,d[l],1,h,f);g=1}else if(f!==b){j=i===b&&e.isFunction(f),k&&(j?(j=c,c=function(a,b,c){return j.call(e(a),c)}):(c.call(a,f),c=null));if(c)for(;l<m;l++)c(a[l],d,j?f.call(a[l],l,c(a[l],d)):f,i);g=1}return g?a:k?c.call(a):m?c(a[0],d):h},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=r.exec(a)||s.exec(a)||t.exec(a)||a.indexOf("compatible")<0&&u.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}e.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(d,f){f&&f instanceof e&&!(f instanceof a)&&(f=a(f));return e.fn.init.call(this,d,f,b)},a.fn.init.prototype=a.fn;var b=a(c);return a},browser:{}}),e.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){I["[object "+b+"]"]=b.toLowerCase()}),z=e.uaMatch(y),z.browser&&(e.browser[z.browser]=!0,e.browser.version=z.version),e.browser.webkit&&(e.browser.safari=!0),j.test(" ")&&(k=/^[\s\xA0]+/,l=/[\s\xA0]+$/),h=e(c),c.addEventListener?B=function(){c.removeEventListener("DOMContentLoaded",B,!1),e.ready()}:c.attachEvent&&(B=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",B),e.ready())});return e}(),g={};f.Callbacks=function(a){a=a?g[a]||h(a):{};var c=[],d=[],e,i,j,k,l,m,n=function(b){var d,e,g,h,i;for(d=0,e=b.length;d<e;d++)g=b[d],h=f.type(g),h==="array"?n(g):h==="function"&&(!a.unique||!p.has(g))&&c.push(g)},o=function(b,f){f=f||[],e=!a.memory||[b,f],i=!0,j=!0,m=k||0,k=0,l=c.length;for(;c&&m<l;m++)if(c[m].apply(b,f)===!1&&a.stopOnFalse){e=!0;break}j=!1,c&&(a.once?e===!0?p.disable():c=[]:d&&d.length&&(e=d.shift(),p.fireWith(e[0],e[1])))},p={add:function(){if(c){var a=c.length;n(arguments),j?l=c.length:e&&e!==!0&&(k=a,o(e[0],e[1]))}return this},remove:function(){if(c){var b=arguments,d=0,e=b.length;for(;d<e;d++)for(var f=0;f<c.length;f++)if(b[d]===c[f]){j&&f<=l&&(l--,f<=m&&m--),c.splice(f--,1);if(a.unique)break}}return this},has:function(a){if(c){var b=0,d=c.length;for(;b<d;b++)if(a===c[b])return!0}return!1},empty:function(){c=[];return this},disable:function(){c=d=e=b;return this},disabled:function(){return!c},lock:function(){d=b,(!e||e===!0)&&p.disable();return this},locked:function(){return!d},fireWith:function(b,c){d&&(j?a.once||d.push([b,c]):(!a.once||!e)&&o(b,c));return this},fire:function(){p.fireWith(this,arguments);return this},fired:function(){return!!i}};return p};var i=[].slice;f.extend({Deferred:function(a){var b=f.Callbacks("once memory"),c=f.Callbacks("once memory"),d=f.Callbacks("memory"),e="pending",g={resolve:b,reject:c,notify:d},h={done:b.add,fail:c.add,progress:d.add,state:function(){return e},isResolved:b.fired,isRejected:c.fired,then:function(a,b,c){i.done(a).fail(b).progress(c);return this},always:function(){i.done.apply(i,arguments).fail.apply(i,arguments);return this},pipe:function(a,b,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=b[0],e=b[1],g;f.isFunction(c)?i[a](function(){g=c.apply(this,arguments),g&&f.isFunction(g.promise)?g.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===i?d:this,[g])}):i[a](d[e])})}).promise()},promise:function(a){if(a==null)a=h;else for(var b in h)a[b]=h[b];return a}},i=h.promise({}),j;for(j in g)i[j]=g[j].fire,i[j+"With"]=g[j].fireWith;i.done(function(){e="resolved"},c.disable,d.lock).fail(function(){e="rejected"},b.disable,d.lock),a&&a.call(i,i);return i},when:function(a){function m(a){return function(b){e[a]=arguments.length>1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c<d;c++)b[c]&&b[c].promise&&f.isFunction(b[c].promise)?b[c].promise().then(l(c),j.reject,m(c)):--g;g||j.resolveWith(j,b)}else j!==a&&j.resolveWith(j,d?[a]:[]);return k}}),f.support=function(){var b,d,e,g,h,i,j,k,l,m,n,o,p=c.createElement("div"),q=c.documentElement;p.setAttribute("className","t"),p.innerHTML=" <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",d=p.getElementsByTagName("*"),e=p.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=p.getElementsByTagName("input")[0],b={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:p.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,pixelMargin:!0},f.boxModel=b.boxModel=c.compatMode==="CSS1Compat",i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete p.test}catch(r){b.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",function(){b.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),i.setAttribute("name","t"),p.appendChild(i),j=c.createDocumentFragment(),j.appendChild(p.lastChild),b.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,j.removeChild(i),j.appendChild(p);if(p.attachEvent)for(n in{submit:1,change:1,focusin:1})m="on"+n,o=m in p,o||(p.setAttribute(m,"return;"),o=typeof p[m]=="function"),b[n+"Bubbles"]=o;j.removeChild(p),j=g=h=p=i=null,f(function(){var d,e,g,h,i,j,l,m,n,q,r,s,t,u=c.getElementsByTagName("body")[0];!u||(m=1,t="padding:0;margin:0;border:",r="position:absolute;top:0;left:0;width:1px;height:1px;",s=t+"0;visibility:hidden;",n="style='"+r+t+"5px solid #000;",q="<div "+n+"display:block;'><div style='"+t+"0;display:block;overflow:hidden;'></div></div>"+"<table "+n+"' cellpadding='0' cellspacing='0'>"+"<tr><td></td></tr></table>",d=c.createElement("div"),d.style.cssText=s+"width:0;height:0;position:static;top:0;margin-top:"+m+"px",u.insertBefore(d,u.firstChild),p=c.createElement("div"),d.appendChild(p),p.innerHTML="<table><tr><td style='"+t+"0;display:none'></td><td>t</td></tr></table>",k=p.getElementsByTagName("td"),o=k[0].offsetHeight===0,k[0].style.display="",k[1].style.display="none",b.reliableHiddenOffsets=o&&k[0].offsetHeight===0,a.getComputedStyle&&(p.innerHTML="",l=c.createElement("div"),l.style.width="0",l.style.marginRight="0",p.style.width="2px",p.appendChild(l),b.reliableMarginRight=(parseInt((a.getComputedStyle(l,null)||{marginRight:0}).marginRight,10)||0)===0),typeof p.style.zoom!="undefined"&&(p.innerHTML="",p.style.width=p.style.padding="1px",p.style.border=0,p.style.overflow="hidden",p.style.display="inline",p.style.zoom=1,b.inlineBlockNeedsLayout=p.offsetWidth===3,p.style.display="block",p.style.overflow="visible",p.innerHTML="<div style='width:5px;'></div>",b.shrinkWrapBlocks=p.offsetWidth!==3),p.style.cssText=r+s,p.innerHTML=q,e=p.firstChild,g=e.firstChild,i=e.nextSibling.firstChild.firstChild,j={doesNotAddBorder:g.offsetTop!==5,doesAddBorderForTableAndCells:i.offsetTop===5},g.style.position="fixed",g.style.top="20px",j.fixedPosition=g.offsetTop===20||g.offsetTop===15,g.style.position=g.style.top="",e.style.overflow="hidden",e.style.position="relative",j.subtractsBorderForOverflowNotVisible=g.offsetTop===-5,j.doesNotIncludeMarginInBodyOffset=u.offsetTop!==m,a.getComputedStyle&&(p.style.marginTop="1%",b.pixelMargin=(a.getComputedStyle(p,null)||{marginTop:0}).marginTop!=="1%"),typeof d.style.zoom!="undefined"&&(d.style.zoom=1),u.removeChild(d),l=p=d=null,f.extend(b,j))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"fanplayrJQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e<g;e++)delete d[b[e]];if(!(c?m:f.isEmptyObject)(d))return}}if(!c){delete j[k].data;if(!m(j[k]))return}f.support.deleteExpando||!j.setInterval?delete j[k]:j[k]=null,i&&(f.support.deleteExpando?delete a[h]:a.removeAttribute?a.removeAttribute(h):a[h]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d,e,g,h,i,j=this[0],k=0,m=null;if(a===b){if(this.length){m=f.data(j);if(j.nodeType===1&&!f._data(j,"parsedAttrs")){g=j.attributes;for(i=g.length;k<i;k++)h=g[k].name,h.indexOf("data-")===0&&(h=f.camelCase(h.substring(5)),l(j,h,m[h]));f._data(j,"parsedAttrs",!0)}}return m}if(typeof a=="object")return this.each(function(){f.data(this,a)});d=a.split(".",2),d[1]=d[1]?"."+d[1]:"",e=d[1]+"!";return f.access(this,function(c){if(c===b){m=this.triggerHandler("getData"+e,[d[0]]),m===b&&j&&(m=f.data(j,a),m=l(j,a,m));return m===b&&d[1]?this.data(d[0]):m}d[1]=c,this.each(function(){var b=f(this);b.triggerHandler("setData"+e,d),f.data(this,a,c),b.triggerHandler("changeData"+e,d)})},null,c,arguments.length>1,null,!1)},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(f._data(b,d)||1)-1;e?f._data(b,d,e):(f.removeData(b,d,!0),n(b,c,"mark"))}},queue:function(a,b,c){var d;if(a){b=(b||"fx")+"queue",d=f._data(a,b),c&&(!d||f.isArray(c)?d=f._data(a,b,f.makeArray(c)):d.push(c));return d||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",e),d.call(a,function(){f.dequeue(a,b)},e)),c.length||(f.removeData(a,b+"queue "+b+".run",!0),n(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){var d=2;typeof a!="string"&&(c=a,a="fx",d--);if(arguments.length<d)return f.queue(this[0],a);return c===b?this:this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function m(){--h||d.resolveWith(e,[e])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var d=f.Deferred(),e=this,g=e.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark",l;while(g--)if(l=f.data(e[g],i,b,!0)||(f.data(e[g],j,b,!0)||f.data(e[g],k,b,!0))&&f.data(e[g],i,f.Callbacks("once memory"),!0))h++,l.add(m);m();return d.promise(c)}});var o=/[\n\t\r]/g,p=/\s+/,q=/\r/g,r=/^(?:button|input)$/i,s=/^(?:button|input|object|select|textarea)$/i,t=/^a(?:rea)?$/i,u=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,v=f.support.getSetAttribute,w,x,y;f.fn.extend({attr:function(a,b){return f.access(this,f.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,f.prop,a,b,arguments.length>1)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(p);for(c=0,d=this.length;c<d;c++){e=this[c];if(e.nodeType===1)if(!e.className&&b.length===1)e.className=a;else{g=" "+e.className+" ";for(h=0,i=b.length;h<i;h++)~g.indexOf(" "+b[h]+" ")||(g+=b[h]+" ");e.className=f.trim(g)}}}return this},removeClass:function(a){var c,d,e,g,h,i,j;if(f.isFunction(a))return this.each(function(b){f(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(p);for(d=0,e=this.length;d<e;d++){g=this[d];if(g.nodeType===1&&g.className)if(a){h=(" "+g.className+" ").replace(o," ");for(i=0,j=c.length;i<j;i++)h=h.replace(" "+c[i]+" "," ");g.className=f.trim(h)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";if(f.isFunction(a))return this.each(function(c){f(this).toggleClass(a.call(this,c,this.className,b),b)});return this.each(function(){if(c==="string"){var e,g=0,h=f(this),i=b,j=a.split(p);while(e=j[g++])i=d?i:!h.hasClass(e),h[i?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ",c=0,d=this.length;for(;c<d;c++)if(this[c].nodeType===1&&(" "+this[c].className+" ").replace(o," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.type]||f.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.type]||f.valHooks[g.nodeName.toLowerCase()];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c<d;c++){e=i[c];if(e.selected&&(f.support.optDisabled?!e.disabled:e.getAttribute("disabled")===null)&&(!e.parentNode.disabled||!f.nodeName(e.parentNode,"optgroup"))){b=f(e).val();if(j)return b;h.push(b)}}if(j&&!h.length&&i.length)return f(i[g]).val();return h},set:function(a,b){var c=f.makeArray(b);f(a).find("option").each(function(){this.selected=f.inArray(f(this).val(),c)>=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h,i=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;i<g;i++)e=d[i],e&&(c=f.propFix[e]||e,h=u.test(e),h||f.attr(a,e,""),a.removeAttribute(v?e:c),h&&c in a&&(a[c]=!1))}},attrHooks:{type:{set:function(a,b){if(r.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},value:{get:function(a,b){if(w&&f.nodeName(a,"button"))return w.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(w&&f.nodeName(a,"button"))return w.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,g,h,i=a.nodeType;if(!!a&&i!==3&&i!==8&&i!==2){h=i!==1||!f.isXMLDoc(a),h&&(c=f.propFix[c]||c,g=f.propHooks[c]);return d!==b?g&&"set"in g&&(e=g.set(a,d,c))!==b?e:a[c]=d:g&&"get"in g&&(e=g.get(a,c))!==null?e:a[c]}},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):s.test(a.nodeName)||t.test(a.nodeName)&&a.href?0:b}}}}),f.attrHooks.tabindex=f.propHooks.tabIndex,x={get:function(a,c){var d,e=f.prop(a,c);return e===!0||typeof e!="boolean"&&(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},v||(y={name:!0,id:!0,coords:!0},w=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&(y[c]?d.nodeValue!=="":d.specified)?d.nodeValue:b},set:function(a,b,d){var e=a.getAttributeNode(d);e||(e=c.createAttribute(d),a.setAttributeNode(e));return e.nodeValue=b+""}},f.attrHooks.tabindex.set=w.set,f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})}),f.attrHooks.contenteditable={get:w.get,set:function(a,b,c){b===""&&(b="false"),w.set(a,b,c)}}),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex);return null}})),f.support.enctype||(f.propFix.enctype="encoding"),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/(?:^|\s)hover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(
|
3 |
+
a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler,g=p.selector),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k<c.length;k++){l=A.exec(c[k])||[],m=l[1],n=(l[2]||"").split(".").sort(),s=f.event.special[m]||{},m=(g?s.delegateType:s.bindType)||m,s=f.event.special[m]||{},o=f.extend({type:m,origType:l[1],data:e,handler:d,guid:d.guid,selector:g,quick:g&&G(g),namespace:n.join(".")},p),r=j[m];if(!r){r=j[m]=[],r.delegateCount=0;if(!s.setup||s.setup.call(a,e,n,i)===!1)a.addEventListener?a.addEventListener(m,i,!1):a.attachEvent&&a.attachEvent("on"+m,i)}s.add&&(s.add.call(a,o),o.handler.guid||(o.handler.guid=d.guid)),g?r.splice(r.delegateCount++,0,o):r.push(o),f.event.global[m]=!0}a=null}},global:{},remove:function(a,b,c,d,e){var g=f.hasData(a)&&f._data(a),h,i,j,k,l,m,n,o,p,q,r,s;if(!!g&&!!(o=g.events)){b=f.trim(I(b||"")).split(" ");for(h=0;h<b.length;h++){i=A.exec(b[h])||[],j=k=i[1],l=i[2];if(!j){for(j in o)f.event.remove(a,j+b[h],c,d,!0);continue}p=f.event.special[j]||{},j=(d?p.delegateType:p.bindType)||j,r=o[j]||[],m=r.length,l=l?new RegExp("(^|\\.)"+l.split(".").sort().join("\\.(?:.*\\.)?")+"(\\.|$)"):null;for(n=0;n<r.length;n++)s=r[n],(e||k===s.origType)&&(!c||c.guid===s.guid)&&(!l||l.test(s.namespace))&&(!d||d===s.selector||d==="**"&&s.selector)&&(r.splice(n--,1),s.selector&&r.delegateCount--,p.remove&&p.remove.call(a,s));r.length===0&&m!==r.length&&((!p.teardown||p.teardown.call(a,l)===!1)&&f.removeEvent(a,j,g.handle),delete o[j])}f.isEmptyObject(o)&&(q=g.handle,q&&(q.elem=null),f.removeData(a,["events","handle"],!0))}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,g){if(!e||e.nodeType!==3&&e.nodeType!==8){var h=c.type||c,i=[],j,k,l,m,n,o,p,q,r,s;if(E.test(h+f.event.triggered))return;h.indexOf("!")>=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;l<r.length&&!c.isPropagationStopped();l++)m=r[l][0],c.type=r[l][1],q=(f._data(m,"events")||{})[c.type]&&f._data(m,"handle"),q&&q.apply(m,d),q=o&&m[o],q&&f.acceptData(m)&&q.apply(m,d)===!1&&c.preventDefault();c.type=h,!g&&!c.isDefaultPrevented()&&(!p._default||p._default.apply(e.ownerDocument,d)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)&&o&&e[h]&&(h!=="focus"&&h!=="blur"||c.target.offsetWidth!==0)&&!f.isWindow(e)&&(n=e[o],n&&(e[o]=null),f.event.triggered=h,e[h](),f.event.triggered=b,n&&(e[o]=n));return c.result}},dispatch:function(c){c=f.event.fix(c||a.event);var d=(f._data(this,"events")||{})[c.type]||[],e=d.delegateCount,g=[].slice.call(arguments,0),h=!c.exclusive&&!c.namespace,i=f.event.special[c.type]||{},j=[],k,l,m,n,o,p,q,r,s,t,u;g[0]=c,c.delegateTarget=this;if(!i.preDispatch||i.preDispatch.call(this,c)!==!1){if(e&&(!c.button||c.type!=="click")){n=f(this),n.context=this.ownerDocument||this;for(m=c.target;m!=this;m=m.parentNode||this)if(m.disabled!==!0){p={},r=[],n[0]=m;for(k=0;k<e;k++)s=d[k],t=s.selector,p[t]===b&&(p[t]=s.quick?H(m,s.quick):n.is(t)),p[t]&&r.push(s);r.length&&j.push({elem:m,matches:r})}}d.length>e&&j.push({elem:this,matches:d.slice(e)});for(k=0;k<j.length&&!c.isPropagationStopped();k++){q=j[k],c.currentTarget=q.elem;for(l=0;l<q.matches.length&&!c.isImmediatePropagationStopped();l++){s=q.matches[l];if(h||!c.namespace&&!s.namespace||c.namespace_re&&c.namespace_re.test(s.namespace))c.data=s.data,c.handleObj=s,o=((f.event.special[s.origType]||{}).handle||s.handler).apply(q.elem,g),o!==b&&(c.result=o,o===!1&&(c.preventDefault(),c.stopPropagation()))}}i.postDispatch&&i.postDispatch.call(this,c);return c.result}},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){a.which==null&&(a.which=b.charCode!=null?b.charCode:b.keyCode);return a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,d){var e,f,g,h=d.button,i=d.fromElement;a.pageX==null&&d.clientX!=null&&(e=a.target.ownerDocument||c,f=e.documentElement,g=e.body,a.pageX=d.clientX+(f&&f.scrollLeft||g&&g.scrollLeft||0)-(f&&f.clientLeft||g&&g.clientLeft||0),a.pageY=d.clientY+(f&&f.scrollTop||g&&g.scrollTop||0)-(f&&f.clientTop||g&&g.clientTop||0)),!a.relatedTarget&&i&&(a.relatedTarget=i===a.target?d.toElement:i),!a.which&&h!==b&&(a.which=h&1?1:h&2?3:h&4?2:0);return a}},fix:function(a){if(a[f.expando])return a;var d,e,g=a,h=f.event.fixHooks[a.type]||{},i=h.props?this.props.concat(h.props):this.props;a=f.Event(g);for(d=i.length;d;)e=i[--d],a[e]=g[e];a.target||(a.target=g.srcElement||c),a.target.nodeType===3&&(a.target=a.target.parentNode),a.metaKey===b&&(a.metaKey=a.ctrlKey);return h.filter?h.filter(a,g):a},special:{ready:{setup:f.bindReady},load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(a,b,c){f.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}},simulate:function(a,b,c,d){var e=f.extend(new f.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?f.event.trigger(e,null,b):f.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},f.event.handle=f.event.dispatch,f.removeEvent=c.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},f.Event=function(a,b){if(!(this instanceof f.Event))return new f.Event(a,b);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?K:J):this.type=a,b&&f.extend(this,b),this.timeStamp=a&&a.timeStamp||f.now(),this[f.expando]=!0},f.Event.prototype={preventDefault:function(){this.isDefaultPrevented=K;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=K;var a=this.originalEvent;!a||(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=K,this.stopPropagation()},isDefaultPrevented:J,isPropagationStopped:J,isImmediatePropagationStopped:J},f.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){f.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c=this,d=a.relatedTarget,e=a.handleObj,g=e.selector,h;if(!d||d!==c&&!f.contains(c,d))a.type=e.origType,h=e.handler.apply(this,arguments),a.type=b;return h}}}),f.support.submitBubbles||(f.event.special.submit={setup:function(){if(f.nodeName(this,"form"))return!1;f.event.add(this,"click._submit keypress._submit",function(a){var c=a.target,d=f.nodeName(c,"input")||f.nodeName(c,"button")?c.form:b;d&&!d._submit_attached&&(f.event.add(d,"submit._submit",function(a){a._submit_bubble=!0}),d._submit_attached=!0)})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&f.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){if(f.nodeName(this,"form"))return!1;f.event.remove(this,"._submit")}}),f.support.changeBubbles||(f.event.special.change={setup:function(){if(z.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")f.event.add(this,"propertychange._change",function(a){a.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),f.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1,f.event.simulate("change",this,a,!0))});return!1}f.event.add(this,"beforeactivate._change",function(a){var b=a.target;z.test(b.nodeName)&&!b._change_attached&&(f.event.add(b,"change._change",function(a){this.parentNode&&!a.isSimulated&&!a.isTrigger&&f.event.simulate("change",this.parentNode,a,!0)}),b._change_attached=!0)})},handle:function(a){var b=a.target;if(this!==b||a.isSimulated||a.isTrigger||b.type!=="radio"&&b.type!=="checkbox")return a.handleObj.handler.apply(this,arguments)},teardown:function(){f.event.remove(this,"._change");return z.test(this.nodeName)}}),f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){var d=0,e=function(a){f.event.simulate(b,a.target,f.event.fix(a),!0)};f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.fn.extend({on:function(a,c,d,e,g){var h,i;if(typeof a=="object"){typeof c!="string"&&(d=d||c,c=b);for(i in a)this.on(i,c,d,a[i],g);return this}d==null&&e==null?(e=c,d=c=b):e==null&&(typeof c=="string"?(e=d,d=b):(e=d,d=c,c=b));if(e===!1)e=J;else if(!e)return this;g===1&&(h=e,e=function(a){f().off(a);return h.apply(this,arguments)},e.guid=h.guid||(h.guid=f.guid++));return this.each(function(){f.event.add(this,a,e,d,c)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,c,d){if(a&&a.preventDefault&&a.handleObj){var e=a.handleObj;f(a.delegateTarget).off(e.namespace?e.origType+"."+e.namespace:e.origType,e.selector,e.handler);return this}if(typeof a=="object"){for(var g in a)this.off(g,c,a[g]);return this}if(c===!1||typeof c=="function")d=c,c=b;d===!1&&(d=J);return this.each(function(){f.event.remove(this,a,d,c)})},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},live:function(a,b,c){f(this.context).on(a,this.selector,b,c);return this},die:function(a,b){f(this.context).off(a,this.selector||"**",b);return this},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return arguments.length==1?this.off(a,"**"):this.off(b,a,c)},trigger:function(a,b){return this.each(function(){f.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return f.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||f.guid++,d=0,e=function(c){var e=(f._data(this,"lastToggle"+a.guid)||0)%d;f._data(this,"lastToggle"+a.guid,e+1),c.preventDefault();return b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),f.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){f.fn[b]=function(a,c){c==null&&(c=a,a=null);return arguments.length>0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h<i;h++){var j=e[h];if(j){var k=!1;j=j[a];while(j){if(j[d]===c){k=e[j.sizset];break}if(j.nodeType===1){g||(j[d]=c,j.sizset=h);if(typeof b!="string"){if(j===b){k=!0;break}}else if(m.filter(b,[j]).length>0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h<i;h++){var j=e[h];if(j){var k=!1;j=j[a];while(j){if(j[d]===c){k=e[j.sizset];break}j.nodeType===1&&!g&&(j[d]=c,j.sizset=h);if(j.nodeName.toLowerCase()===b){k=j;break}j=j[a]}e[h]=k}}}var a=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a},m.matches=function(a,b){return m(a,null,null,b)},m.matchesSelector=function(a,b){return m(b,null,null,[a]).length>0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e<f;e++){h=o.order[e];if(g=o.leftMatch[h].exec(a)){i=g[1],g.splice(1,1);if(i.substr(i.length-1)!=="\\"){g[1]=(g[1]||"").replace(j,""),d=o.find[h](g,b,c);if(d!=null){a=a.replace(o.match[h],"");break}}}}d||(d=typeof b.getElementsByTagName!="undefined"?b.getElementsByTagName("*"):[]);return{set:d,expr:a}},m.filter=function(a,c,d,e){var f,g,h,i,j,k,l,n,p,q=a,r=[],s=c,t=c&&c[0]&&m.isXML(c[0]);while(a&&c.length){for(h in o.filter)if((f=o.leftMatch[h].exec(a))!=null&&f[2]){k=o.filter[h],l=f[1],g=!1,f.splice(1,1);if(l.substr(l.length-1)==="\\")continue;s===r&&(r=[]);if(o.preFilter[h]){f=o.preFilter[h](f,s,d,r,e,t);if(!f)g=i=!0;else if(f===!0)continue}if(f)for(n=0;(j=s[n])!=null;n++)j&&(i=k(j,f,n,s),p=e^i,d&&i!=null?p?g=!0:s[n]=!1:p&&(r.push(j),g=!0));if(i!==b){d||(s=r),a=a.replace(o.match[h],"");if(!g)return[];break}}if(a===q)if(g==null)m.error(a);else break;q=a}return s},m.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)};var n=m.getText=function(a){var b,c,d=a.nodeType,e="";if(d){if(d===1||d===9||d===11){if(typeof a.textContent=="string")return a.textContent;if(typeof a.innerText=="string")return a.innerText.replace(k,"");for(a=a.firstChild;a;a=a.nextSibling)e+=n(a)}else if(d===3||d===4)return a.nodeValue}else for(b=0;c=a[b];b++)c.nodeType!==8&&(e+=n(c));return e},o=m.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b=="string",d=c&&!l.test(b),e=c&&!d;d&&(b=b.toLowerCase());for(var f=0,g=a.length,h;f<g;f++)if(h=a[f]){while((h=h.previousSibling)&&h.nodeType!==1);a[f]=e||h&&h.nodeName.toLowerCase()===b?h||!1:h===b}e&&m.filter(b,a,!0)},">":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e<f;e++){c=a[e];if(c){var g=c.parentNode;a[e]=g.nodeName.toLowerCase()===b?g:!1}}}else{for(;e<f;e++)c=a[e],c&&(a[e]=d?c.parentNode:c.parentNode===b);d&&m.filter(b,a,!0)}},"":function(a,b,c){var d,f=e++,g=x;typeof b=="string"&&!l.test(b)&&(b=b.toLowerCase(),d=b,g=w),g("parentNode",b,f,a,d,c)},"~":function(a,b,c){var d,f=e++,g=x;typeof b=="string"&&!l.test(b)&&(b=b.toLowerCase(),d=b,g=w),g("previousSibling",b,f,a,d,c)}},find:{ID:function(a,b,c){if(typeof b.getElementById!="undefined"&&!c){var d=b.getElementById(a[1]);return d&&d.parentNode?[d]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!="undefined"){var c=[],d=b.getElementsByName(a[1]);for(var e=0,f=d.length;e<f;e++)d[e].getAttribute("name")===a[1]&&c.push(d[e]);return c.length===0?null:c}},TAG:function(a,b){if(typeof b.getElementsByTagName!="undefined")return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(j,"")+" ";if(f)return a;for(var g=0,h;(h=b[g])!=null;g++)h&&(e^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h<i;h++)if(g[h]===a)return!1;return!0}m.error(e)},CHILD:function(a,b){var c,e,f,g,h,i,j,k=b[1],l=a;switch(k){case"only":case"first":while(l=l.previousSibling)if(l.nodeType===1)return!1;if(k==="first")return!0;l=a;case"last":while(l=l.nextSibling)if(l.nodeType===1)return!1;return!0;case"nth":c=b[2],e=b[3];if(c===1&&e===0)return!0;f=b[0],g=a.parentNode;if(g&&(g[d]!==f||!a.nodeIndex)){i=0;for(l=g.firstChild;l;l=l.nextSibling)l.nodeType===1&&(l.nodeIndex=++i);g[d]=f}j=a.nodeIndex-e;return c===0?j===0:j%c===0&&j/c>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));o.match.globalPOS=p;var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c<e;c++)d.push(a[c]);else for(;a[c];c++)d.push(a[c]);return d}}var u,v;c.documentElement.compareDocumentPosition?u=function(a,b){if(a===b){h=!0;return 0}if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(u=function(a,b){if(a===b){h=!0;return 0}if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],f=[],g=a.parentNode,i=b.parentNode,j=g;if(g===i)return v(a,b);if(!g)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)f.unshift(j),j=j.parentNode;c=e.length,d=f.length;for(var k=0;k<c&&k<d;k++)if(e[k]!==f[k])return v(e[k],f[k]);return k===c?v(a,f[k],-1):v(e[k],b,1)},v=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),function(){var a=c.createElement("div"),d="script"+(new Date).getTime(),e=c.documentElement;a.innerHTML="<a name='"+d+"'/>",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="<p class='TEST'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h<i;h++)m(a,g[h],e,c);return m.filter(f,e)};m.attr=f.attr,m.selectors.attrMap={},f.find=m,f.expr=m.selectors,f.expr[":"]=f.expr.filters,f.unique=m.uniqueSort,f.text=m.getText,f.isXMLDoc=m.isXML,f.contains=m.contains}();var L=/Until$/,M=/^(?:parents|prevUntil|prevAll)/,N=/,/,O=/^.[^:#\[\.,]*$/,P=Array.prototype.slice,Q=f.expr.match.globalPOS,R={children:!0,contents:!0,next:!0,prev:!0};f.fn.extend({find:function(a){var b=this,c,d;if(typeof a!="string")return f(a).filter(function(){for(c=0,d=b.length;c<d;c++)if(f.contains(b[c],this))return!0});var e=this.pushStack("","find",a),g,h,i;for(c=0,d=this.length;c<d;c++){g=e.length,f.find(a,this[c],e);if(c>0)for(h=g;h<e.length;h++)for(i=0;i<g;i++)if(e[i]===e[h]){e.splice(h--,1);break}}return e},has:function(a){var b=f(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(f.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(T(this,a,!1),"not",a)},filter:function(a){return this.pushStack(T(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?Q.test(a)?f(a,this.context).index(this[0])>=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d<a.length;d++)f(g).is(a[d])&&c.push({selector:a[d],elem:g,level:h});g=g.parentNode,h++}return c}var i=Q.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d<e;d++){g=this[d];while(g){if(i?i.index(g)>-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ fanplayrJQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/<tbody/i,_=/<|&#?\w+;/,ba=/<(?:script|style)/i,bb=/<(?:script|object|embed|option|style)/i,bc=new RegExp("<(?:"+V+")[\\s/>]","i"),bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*<!(?:\[CDATA\[|\-\-)/,bg={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div<div>","</div>"]),f.fn.extend({text:function(a){return f.access(this,function(a){return a===b?f.text(this):this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f
|
4 |
+
.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){return f.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1></$2>");try{for(;d<e;d++)c=this[d]||{},c.nodeType===1&&(f.cleanData(c.getElementsByTagName("*")),c.innerHTML=a);c=0}catch(g){}}c&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(f.isFunction(a))return this.each(function(b){var c=f(this),d=c.html();c.replaceWith(a.call(this,b,d))});typeof a!="string"&&(a=f(a).detach());return this.each(function(){var b=this.nextSibling,c=this.parentNode;f(this).remove(),b?f(b).before(a):f(c).append(a)})}return this.length?this.pushStack(f(f.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,g,h,i,j=a[0],k=[];if(!f.support.checkClone&&arguments.length===3&&typeof j=="string"&&bd.test(j))return this.each(function(){f(this).domManip(a,c,d,!0)});if(f.isFunction(j))return this.each(function(e){var g=f(this);a[0]=j.call(this,e,c?g.html():b),g.domManip(a,c,d)});if(this[0]){i=j&&j.parentNode,f.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?e={fragment:i}:e=f.buildFragment(a,this,k),h=e.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild;if(g){c=c&&f.nodeName(g,"tr");for(var l=0,m=this.length,n=m-1;l<m;l++)d.call(c?bi(this[l],g):this[l],e.cacheable||m>1&&l<n?f.clone(h,!0,!0):h)}k.length&&f.each(k,function(a,b){b.src?f.ajax({type:"GET",global:!1,url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bf,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)})}return this}}),f.buildFragment=function(a,b,d){var e,g,h,i,j=a[0];b&&b[0]&&(i=b[0].ownerDocument||b[0]),i.createDocumentFragment||(i=c),a.length===1&&typeof j=="string"&&j.length<512&&i===c&&j.charAt(0)==="<"&&!bb.test(j)&&(f.support.checkClone||!bd.test(j))&&(f.support.html5Clone||!bc.test(j))&&(g=!0,h=f.fragments[j],h&&h!==1&&(e=h)),e||(e=i.createDocumentFragment(),f.clean(a,i,e,d)),g&&(f.fragments[j]=h?e:1);return{fragment:e,cacheable:g}},f.fragments={},f.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){f.fn[a]=function(c){var d=[],e=f(c),g=this.length===1&&this[0].parentNode;if(g&&g.nodeType===11&&g.childNodes.length===1&&e.length===1){e[b](this[0]);return this}for(var h=0,i=e.length;h<i;h++){var j=(h>0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||f.isXMLDoc(a)||!bc.test("<"+a.nodeName+">")?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g,h,i,j=[];b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);for(var k=0,l;(l=a[k])!=null;k++){typeof l=="number"&&(l+="");if(!l)continue;if(typeof l=="string")if(!_.test(l))l=b.createTextNode(l);else{l=l.replace(Y,"<$1></$2>");var m=(Z.exec(l)||["",""])[1].toLowerCase(),n=bg[m]||bg._default,o=n[0],p=b.createElement("div"),q=bh.childNodes,r;b===c?bh.appendChild(p):U(b).appendChild(p),p.innerHTML=n[1]+l+n[2];while(o--)p=p.lastChild;if(!f.support.tbody){var s=$.test(l),t=m==="table"&&!s?p.firstChild&&p.firstChild.childNodes:n[1]==="<table>"&&!s?p.childNodes:[];for(i=t.length-1;i>=0;--i)f.nodeName(t[i],"tbody")&&!t[i].childNodes.length&&t[i].parentNode.removeChild(t[i])}!f.support.leadingWhitespace&&X.test(l)&&p.insertBefore(b.createTextNode(X.exec(l)[0]),p.firstChild),l=p.childNodes,p&&(p.parentNode.removeChild(p),q.length>0&&(r=q[q.length-1],r&&r.parentNode&&r.parentNode.removeChild(r)))}var u;if(!f.support.appendChecked)if(l[0]&&typeof (u=l.length)=="number")for(i=0;i<u;i++)bn(l[i]);else bn(l);l.nodeType?j.push(l):j=f.merge(j,l)}if(d){g=function(a){return!a.type||be.test(a.type)};for(k=0;j[k];k++){h=j[k];if(e&&f.nodeName(h,"script")&&(!h.type||be.test(h.type)))e.push(h.parentNode?h.parentNode.removeChild(h):h);else{if(h.nodeType===1){var v=f.grep(h.getElementsByTagName("script"),g);j.splice.apply(j,[k+1,0].concat(v))}d.appendChild(h)}}}return j},cleanData:function(a){var b,c,d=f.cache,e=f.event.special,g=f.support.deleteExpando;for(var h=0,i;(i=a[h])!=null;h++){if(i.nodeName&&f.noData[i.nodeName.toLowerCase()])continue;c=i[f.expando];if(c){b=d[c];if(b&&b.events){for(var j in b.events)e[j]?f.event.remove(i,j):f.removeEvent(i,j,b.handle);b.handle&&(b.handle.elem=null)}g?delete i[f.expando]:i.removeAttribute&&i.removeAttribute(f.expando),delete d[c]}}}});var bp=/alpha\([^)]*\)/i,bq=/opacity=([^)]*)/,br=/([A-Z]|^ms)/g,bs=/^[\-+]?(?:\d*\.)?\d+$/i,bt=/^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,bu=/^([\-+])=([\-+.\de]+)/,bv=/^margin/,bw={position:"absolute",visibility:"hidden",display:"block"},bx=["Top","Right","Bottom","Left"],by,bz,bA;f.fn.css=function(a,c){return f.access(this,function(a,c,d){return d!==b?f.style(a,c,d):f.css(a,c)},a,c,arguments.length>1)},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=by(a,"opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=bu.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(by)return by(a,c)},swap:function(a,b,c){var d={},e,f;for(f in b)d[f]=a.style[f],a.style[f]=b[f];e=c.call(a);for(f in b)a.style[f]=d[f];return e}}),f.curCSS=f.css,c.defaultView&&c.defaultView.getComputedStyle&&(bz=function(a,b){var c,d,e,g,h=a.style;b=b.replace(br,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b))),!f.support.pixelMargin&&e&&bv.test(b)&&bt.test(c)&&(g=h.width,h.width=c,c=e.width,h.width=g);return c}),c.documentElement.currentStyle&&(bA=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f==null&&g&&(e=g[b])&&(f=e),bt.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),by=bz||bA,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0?bB(a,b,d):f.swap(a,bw,function(){return bB(a,b,d)})},set:function(a,b){return bs.test(b)?b+"px":b}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bq.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bp,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bp.test(g)?g.replace(bp,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){return f.swap(a,{display:"inline-block"},function(){return b?by(a,"margin-right"):a.style.marginRight})}})}),f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)}),f.each({margin:"",padding:"",border:"Width"},function(a,b){f.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bx[d]+b]=e[d]||e[d-2]||e[0];return f}}});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bN=/^(?:select|textarea)/i,bO=/\s+/,bP=/([?&])_=[^&]*/,bQ=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bR=f.fn.load,bS={},bT={},bU,bV,bW=["*/"]+["*"];try{bU=e.href}catch(bX){bU=c.createElement("a"),bU.href="",bU=bU.href}bV=bQ.exec(bU.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bR)return bR.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("<div>").append(c.replace(bM,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bN.test(this.nodeName)||bH.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bE,"\r\n")}}):{name:b.name,value:c.replace(bE,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b$(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b$(a,b);return a},ajaxSettings:{url:bU,isLocal:bI.test(bV[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bW},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bY(bS),ajaxTransport:bY(bT),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?ca(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cb(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bG.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bF,"").replace(bK,bV[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bO),d.crossDomain==null&&(r=bQ.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bV[1]&&r[2]==bV[2]&&(r[3]||(r[1]==="http:"?80:443))==(bV[3]||(bV[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bZ(bS,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bJ.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bL.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bP,"$1_="+x);d.url=y+(y===d.url?(bL.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bW+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bZ(bT,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)b_(g,a[g],c,e);return d.join("&").replace(bC,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cc=f.now(),cd=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cc++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=typeof b.data=="string"&&/^application\/x\-www\-form\-urlencoded/.test(b.contentType);if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cd.test(b.url)||e&&cd.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cd,l),b.url===j&&(e&&(k=k.replace(cd,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var ce=a.ActiveXObject?function(){for(var a in cg)cg[a](0,1)}:!1,cf=0,cg;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ch()||ci()}:ch,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,ce&&delete cg[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n);try{m.text=h.responseText}catch(a){}try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cf,ce&&(cg||(cg={},f(a).unload(ce)),cg[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cj={},ck,cl,cm=/^(?:toggle|show|hide)$/,cn=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,co,cp=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cq;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(ct("show",3),a,b,c);for(var g=0,h=this.length;g<h;g++)d=this[g],d.style&&(e=d.style.display,!f._data(d,"olddisplay")&&e==="none"&&(e=d.style.display=""),(e===""&&f.css(d,"display")==="none"||!f.contains(d.ownerDocument.documentElement,d))&&f._data(d,"olddisplay",cu(d.nodeName)));for(g=0;g<h;g++){d=this[g];if(d.style){e=d.style.display;if(e===""||e==="none")d.style.display=f._data(d,"olddisplay")||""}}return this},hide:function(a,b,c){if(a||a===0)return this.animate(ct("hide",3),a,b,c);var d,e,g=0,h=this.length;for(;g<h;g++)d=this[g],d.style&&(e=f.css(d,"display"),e!=="none"&&!f._data(d,"olddisplay")&&f._data(d,"olddisplay",e));for(g=0;g<h;g++)this[g].style&&(this[g].style.display="none");return this},_toggle:f.fn.toggle,toggle:function(a,b,c){var d=typeof a=="boolean";f.isFunction(a)&&f.isFunction(b)?this._toggle.apply(this,arguments):a==null||d?this.each(function(){var b=d?a:f(this).is(":hidden");f(this)[b?"show":"hide"]()}):this.animate(ct("toggle",3),a,b,c);return this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){function g(){e.queue===!1&&f._mark(this);var b=f.extend({},e),c=this.nodeType===1,d=c&&f(this).is(":hidden"),g,h,i,j,k,l,m,n,o,p,q;b.animatedProperties={};for(i in a){g=f.camelCase(i),i!==g&&(a[g]=a[i],delete a[i]);if((k=f.cssHooks[g])&&"expand"in k){l=k.expand(a[g]),delete a[g];for(i in l)i in a||(a[i]=l[i])}}for(g in a){h=a[g],f.isArray(h)?(b.animatedProperties[g]=h[1],h=a[g]=h[0]):b.animatedProperties[g]=b.specialEasing&&b.specialEasing[g]||b.easing||"swing";if(h==="hide"&&d||h==="show"&&!d)return b.complete.call(this);c&&(g==="height"||g==="width")&&(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],f.css(this,"display")==="inline"&&f.css(this,"float")==="none"&&(!f.support.inlineBlockNeedsLayout||cu(this.nodeName)==="inline"?this.style.display="inline-block":this.style.zoom=1))}b.overflow!=null&&(this.style.overflow="hidden");for(i in a)j=new f.fx(this,b,i),h=a[i],cm.test(h)?(q=f._data(this,"toggle"+i)||(h==="toggle"?d?"show":"hide":0),q?(f._data(this,"toggle"+i,q==="show"?"hide":"show"),j[q]()):j[h]()):(m=cn.exec(h),n=j.cur(),m?(o=parseFloat(m[2]),p=m[3]||(f.cssNumber[i]?"":"px"),p!=="px"&&(f.style(this,i,(o||1)+p),n=(o||1)/j.cur()*n,f.style(this,i,n+p)),m[1]&&(o=(m[1]==="-="?-1:1)*o+n),j.custom(n,o,p)):j.custom(n,h,""));return!0}var e=f.speed(b,c,d);if(f.isEmptyObject(a))return this.each(e.complete,[!1]);a=f.extend({},a);return e.queue===!1?this.each(g):this.queue(e.queue,g)},stop:function(a,c,d){typeof a!="string"&&(d=c,c=a,a=b),c&&a!==!1&&this.queue(a||"fx",[]);return this.each(function(){function h(a,b,c){var e=b[c];f.removeData(a,c,!0),e.stop(d)}var b,c=!1,e=f.timers,g=f._data(this);d||f._unmark(!0,this);if(a==null)for(b in g)g[b]&&g[b].stop&&b.indexOf(".run")===b.length-4&&h(this,g,b);else g[b=a+".run"]&&g[b].stop&&h(this,g,b);for(b=e.length;b--;)e[b].elem===this&&(a==null||e[b].queue===a)&&(d?e[b](!0):e[b].saveState(),c=!0,e.splice(b,1));(!d||!c)&&f.dequeue(this,a)})}}),f.each({slideDown:ct("show",1),slideUp:ct("hide",1),slideToggle:ct("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){f.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),f.extend({speed:function(a,b,c){var d=a&&typeof a=="object"?f.extend({},a):{complete:c||!c&&b||f.isFunction(a)&&a,duration:a,easing:c&&b||b&&!f.isFunction(b)&&b};d.duration=f.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in f.fx.speeds?f.fx.speeds[d.duration]:f.fx.speeds._default;if(d.queue==null||d.queue===!0)d.queue="fx";d.old=d.complete,d.complete=function(a){f.isFunction(d.old)&&d.old.call(this),d.queue?f.dequeue(this,d.queue):a!==!1&&f._unmark(this)};return d},easing:{linear:function(a){return a},swing:function(a){return-Math.cos(a*Math.PI)/2+.5}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig=b.orig||{}}}),f.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(f.fx.step[this.prop]||f.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=f.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,c,d){function h(a){return e.step(a)}var e=this,g=f.fx;this.startTime=cq||cr(),this.end=c,this.now=this.start=a,this.pos=this.state=0,this.unit=d||this.unit||(f.cssNumber[this.prop]?"":"px"),h.queue=this.options.queue,h.elem=this.elem,h.saveState=function(){f._data(e.elem,"fxshow"+e.prop)===b&&(e.options.hide?f._data(e.elem,"fxshow"+e.prop,e.start):e.options.show&&f._data(e.elem,"fxshow"+e.prop,e.end))},h()&&f.timers.push(h)&&!co&&(co=setInterval(g.tick,g.interval))},show:function(){var a=f._data(this.elem,"fxshow"+this.prop);this.options.orig[this.prop]=a||f.style(this.elem,this.prop),this.options.show=!0,a!==b?this.custom(this.cur(),a):this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),f(this.elem).show()},hide:function(){this.options.orig[this.prop]=f._data(this.elem,"fxshow"+this.prop)||f.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b,c,d,e=cq||cr(),g=!0,h=this.elem,i=this.options;if(a||e>=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c<b.length;c++)a=b[c],!a()&&b[c]===a&&b.splice(c--,1);b.length||f.fx.stop()},interval:13,stop:function(){clearInterval(co),co=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=a.now+a.unit:a.elem[a.prop]=a.now}}}),f.each(cp.concat.apply([],cp),function(a,b){b.indexOf("margin")&&(f.fx.step[b]=function(a){f.style(a.elem,b,Math.max(0,a.now)+a.unit)})}),f.expr&&f.expr.filters&&(f.expr.filters.animated=function(a){return f.grep(f.timers,function(b){return a===b.elem}).length});var cv,cw=/^t(?:able|d|h)$/i,cx=/^(?:body|html)$/i;"getBoundingClientRect"in c.documentElement?cv=function(a,b,c,d){try{d=a.getBoundingClientRect()}catch(e){}if(!d||!f.contains(c,a))return d?{top:d.top,left:d.left}:{top:0,left:0};var g=b.body,h=cy(b),i=c.clientTop||g.clientTop||0,j=c.clientLeft||g.clientLeft||0,k=h.pageYOffset||f.support.boxModel&&c.scrollTop||g.scrollTop,l=h.pageXOffset||f.support.boxModel&&c.scrollLeft||g.scrollLeft,m=d.top+k-i,n=d.left+l-j;return{top:m,left:n}}:cv=function(a,b,c){var d,e=a.offsetParent,g=a,h=b.body,i=b.defaultView,j=i?i.getComputedStyle(a,null):a.currentStyle,k=a.offsetTop,l=a.offsetLeft;while((a=a.parentNode)&&a!==h&&a!==c){if(f.support.fixedPosition&&j.position==="fixed")break;d=i?i.getComputedStyle(a,null):a.currentStyle,k-=a.scrollTop,l-=a.scrollLeft,a===e&&(k+=a.offsetTop,l+=a.offsetLeft,f.support.doesNotAddBorder&&(!f.support.doesAddBorderForTableAndCells||!cw.test(a.nodeName))&&(k+=parseFloat(d.borderTopWidth)||0,l+=parseFloat(d.borderLeftWidth)||0),g=e,e=a.offsetParent),f.support.subtractsBorderForOverflowNotVisible&&d.overflow!=="visible"&&(k+=parseFloat(d.borderTopWidth)||0,l+=parseFloat(d.borderLeftWidth)||0),j=d}if(j.position==="relative"||j.position==="static")k+=h.offsetTop,l+=h.offsetLeft;f.support.fixedPosition&&j.position==="fixed"&&(k+=Math.max(c.scrollTop,h.scrollTop),l+=Math.max(c.scrollLeft,h.scrollLeft));return{top:k,left:l}},f.fn.offset=function(a){if(arguments.length)return a===b?this:this.each(function(b){f.offset.setOffset(this,a,b)});var c=this[0],d=c&&c.ownerDocument;if(!d)return null;if(c===d.body)return f.offset.bodyOffset(c);return cv(c,d,d.documentElement)},f.offset={bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.support.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);f.fn[a]=function(e){return f.access(this,function(a,e,g){var h=cy(a);if(g===b)return h?c in h?h[c]:f.support.boxModel&&h.document.documentElement[e]||h.document.body[e]:a[e];h?h.scrollTo(d?f(h).scrollLeft():g,d?g:f(h).scrollTop()):a[e]=g},a,e,arguments.length,null)}}),f.each({Height:"height",Width:"width"},function(a,c){var d="client"+a,e="scroll"+a,g="offset"+a;f.fn["inner"+a]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,c,"padding")):this[c]():null},f.fn["outer"+a]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,c,a?"margin":"border")):this[c]():null},f.fn[c]=function(a){return f.access(this,function(a,c,h){var i,j,k,l;if(f.isWindow(a)){i=a.document,j=i.documentElement[d];return f.support.boxModel&&j||i.body&&i.body[d]||j}if(a.nodeType===9){i=a.documentElement;if(i[d]>=i[e])return i[d];return Math.max(a.body[e],i[e],a.body[g],i[g])}if(h===b){k=f.css(a,c),l=parseFloat(k);return f.isNumeric(l)?l:k}f(a).css(c,h)},c,a,arguments.length,null)}}),a.fanplayrJQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.fanplayrJQuery&&define("jquery",[],function(){return f})})(window);
|