Changeset 2032591
- Timestamp:
- 02/17/2019 08:48:48 AM (7 years ago)
- Location:
- wp-lottery
- Files:
-
- 9 added
- 4 edited
-
tags/2.1 (added)
-
tags/2.1/common (added)
-
tags/2.1/common/css (added)
-
tags/2.1/common/css/wordpress-lottery.css (added)
-
tags/2.1/common/js (added)
-
tags/2.1/common/js/wordpress-lottery.js (added)
-
tags/2.1/options.php (added)
-
tags/2.1/readme.txt (added)
-
tags/2.1/wordpress-lottery.php (added)
-
trunk/common/css/wordpress-lottery.css (modified) (1 diff)
-
trunk/common/js/wordpress-lottery.js (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wordpress-lottery.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-lottery/trunk/common/css/wordpress-lottery.css
r1879235 r2032591 9 9 width: 16px; 10 10 height: 16px; 11 animation: spin 2s linear infinite;11 animation: wordpress-lottery-spin 2s linear infinite; 12 12 } 13 13 14 @keyframes spin { 14 /*避免全局污染*/ 15 @keyframes wordpress-lottery-spin { 15 16 0% { 16 17 transform: rotate(0deg); -
wp-lottery/trunk/common/js/wordpress-lottery.js
r1879235 r2032591 1 const action = 'wordpress_lottery_doLottery';2 //viewData3 // noinspection JSUnresolvedVariable4 const ajaxUrl = wordpressLotteryViewData.ajaxUrl;5 // noinspection JSUnresolvedVariable6 const postId = wordpressLotteryViewData.postId;7 8 1 document.querySelectorAll('.wordpress-lottery-container').forEach(container => { 9 2 const input = container.getElementsByClassName('wordpress-lottery-input')[0]; … … 12 5 const canvas = container.getElementsByClassName('wordpress-lottery-canvas')[0]; 13 6 14 // noinspection JSUndefinedPropertyAssignment15 7 button.onclick = () => { 16 8 canvas.innerHTML = ''; 17 9 loader.hidden = false; 18 10 11 //旧版本 edge 不支持 URLSearchParams, 此问题无法解决 19 12 let urlSearchParams = new URLSearchParams(); 20 urlSearchParams.append('action', action); 21 urlSearchParams.append('postId', postId); 13 urlSearchParams.append('action', 'wordpress_lottery_doLottery'); 14 // noinspection JSUnresolvedVariable 15 urlSearchParams.append('postId', wordpressLotteryViewData.postId); 22 16 urlSearchParams.append('winnerCount', input.value); 23 17 24 18 //admin-ajax 仅支持 formData 25 fetch(ajaxUrl, { 19 // noinspection JSUnresolvedVariable 20 fetch(wordpressLotteryViewData.ajaxUrl, { 26 21 method: 'POST', 27 22 credentials: 'same-origin', … … 32 27 if (!response.ok) { 33 28 if (response.status === 400) { 34 throw Error('登陆后才能检测血统')29 throw new Error('登陆后才能检测血统') 35 30 } else { 36 throw Error('未知错误: ' + response.statusText)31 throw new Error('未知错误: ' + response.statusText) 37 32 } 38 33 } … … 42 37 .then(response => { 43 38 if (!response.success) { 44 throw Error(response.data.message)39 throw new Error(response.data.message) 45 40 } 46 41 response.data.forEach(comment => { … … 55 50 canvas.innerHTML = error.message 56 51 }) 57 .finally(() => { 52 .finally(() => { //edge 不支持 finally, 此问题无法解决 58 53 loader.hidden = true 59 54 }) -
wp-lottery/trunk/readme.txt
r1879242 r2032591 4 4 Tags: comments, spam 5 5 Requires at least: 4.0.0 6 Tested up to: 4.9.67 Stable tag: 4.9.66 Tested up to: 5.0.3 7 Stable tag: 5.0.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 28 28 29 29 == Changelog == 30 31 = 2.1 = 32 测试至 WordPress 5.0.3 30 33 31 34 = 2.0 = -
wp-lottery/trunk/wordpress-lottery.php
r1879235 r2032591 4 4 Plugin URI: https://github.com/czp3009/wordpress-lottery 5 5 Description: WordPress 抽奖插件 6 Version: 2. 06 Version: 2.1 7 7 Author: czp3009 8 8 Author URI: https://www.hiczp.com … … 113 113 //获奖人数超过了楼层数 114 114 global $wpdb; 115 /** @noinspection SqlResolve */ 115 /** @noinspection SqlDialectInspection */ 116 /** @noinspection SqlNoDataSourceInspection */ 116 117 $commentCount = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE `comment_post_ID` = $postId AND `comment_parent` = 0 AND `comment_approved` = 1"); 117 118 if ($winnerCount > $commentCount) { … … 122 123 123 124 //取出回复贴, 随机排序取首部 N 个 124 /** @noinspection SqlResolve */ 125 /** @noinspection SqlDialectInspection */ 126 /** @noinspection SqlNoDataSourceInspection */ 125 127 $winners = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE `comment_post_ID` = $postId AND `comment_parent` = 0 AND `comment_approved` = 1"); 126 128 shuffle($winners); … … 146 148 add_action('wp_ajax_wordpress_lottery_doLottery', array($wordpressLottery, 'doLottery')); 147 149 if (!get_option('wordpress_lottery_login_required')) { 150 /** @noinspection SpellCheckingInspection */ 148 151 add_action('wp_ajax_nopriv_wordpress_lottery_doLottery', array($wordpressLottery, 'doLottery')); 149 152 }
Note: See TracChangeset
for help on using the changeset viewer.