Index: trunk/extensions/Survey/specials/SpecialSurvey.php |
— | — | @@ -86,7 +86,7 @@ |
87 | 87 | |
88 | 88 | $survey->setField( 'enabled', $wgRequest->getCheck( 'survey-enabled' ) ); |
89 | 89 | |
90 | | - foreach ( array( 'user_type', 'ratio', 'min_pages' ) as $field ) { |
| 90 | + foreach ( array( 'user_type', 'ratio', 'min_pages', 'expiry' ) as $field ) { |
91 | 91 | $survey->setField( $field, $wgRequest->getInt( 'survey-' . $field ) ); |
92 | 92 | } |
93 | 93 | |
— | — | @@ -203,6 +203,13 @@ |
204 | 204 | ); |
205 | 205 | |
206 | 206 | $fields[] = array( |
| 207 | + 'type' => 'hidden', |
| 208 | + 'default' => $survey->getField( 'expiry' ), |
| 209 | + 'name' => 'survey-expiry', |
| 210 | + 'id' => 'survey-expiry', |
| 211 | + ); |
| 212 | + |
| 213 | + $fields[] = array( |
207 | 214 | 'class' => 'SurveyNameField', |
208 | 215 | 'default' => $survey->getField( 'name' ), |
209 | 216 | 'label-message' => 'survey-special-label-name', |
Index: trunk/extensions/Survey/resources/ext.survey.tag.js |
— | — | @@ -10,21 +10,10 @@ |
11 | 11 | |
12 | 12 | function getCookieName( options ) { |
13 | 13 | return ( typeof options.id !== 'undefined' ) ? |
14 | | - 'ssurvey-id-' + options.id |
15 | | - : 'ssurvey-name-' + options.name |
| 14 | + 'survey-id-' + options.id |
| 15 | + : 'survey-name-' + options.name |
16 | 16 | } |
17 | 17 | |
18 | | - function shouldShowSurvey( options ) { |
19 | | - if ( !options.cookie ) { |
20 | | - return true; |
21 | | - } |
22 | | - else { |
23 | | - var cookie = getCookie( options ); |
24 | | - return ( options.pages === 0 && cookie !== 'done' ) |
25 | | - || ( options.pages !== 0 && parseInt( cookie ) >= options.pages ); |
26 | | - } |
27 | | - } |
28 | | - |
29 | 18 | function getCookie( options ) { |
30 | 19 | var cookie = $.cookie( getCookieName( options ) ); |
31 | 20 | survey.log( 'read "' + cookie + '" from cookie ' + getCookieName( options ) ); |
— | — | @@ -58,7 +47,7 @@ |
59 | 48 | var options = { |
60 | 49 | 'ratio': typeof ratioAttr === 'undefined' ? 1 : parseFloat( ratioAttr ) / 100, |
61 | 50 | 'cookie': $tag.attr( 'survey-data-cookie' ) !== 'no', |
62 | | - 'expiry': typeof expiryAttr === 'undefined' ? 60 * 60 * 24 * 30 : 60 * 60 * 24 * 30,//parseInt( expiryAttr ), |
| 51 | + 'expiry': typeof expiryAttr === 'undefined' ? 60 * 60 * 24 * 30 : parseInt( expiryAttr ), |
63 | 52 | 'pages': typeof pagesAttr === 'undefined' ? 0 : parseInt( pagesAttr ) |
64 | 53 | }; |
65 | 54 | |
— | — | @@ -72,18 +61,27 @@ |
73 | 62 | return; |
74 | 63 | } |
75 | 64 | |
76 | | - if ( hasCookie( options ) || winsLottery( options ) ) { |
77 | | - if ( shouldShowSurvey( options ) ) { |
| 65 | + if ( hasCookie( options ) || options.ratio === 1 || winsLottery( options ) ) { |
| 66 | + if ( !options.cookie ) { |
78 | 67 | $tag.mwSurvey( options ); |
79 | | - setCookie( options, 'done' ); |
80 | 68 | } |
81 | | - else if ( options.pages !== 0 ) { |
82 | | - var nr = parseInt( getCookie( options ) ); |
83 | | - setCookie( options, ( isNaN( nr ) ? 0 : nr ) + 1 ) |
| 69 | + else { |
| 70 | + var cookie = getCookie( options ); |
| 71 | + |
| 72 | + if ( cookie !== 'done' ) { |
| 73 | + if ( ( options.pages === 0 || parseInt( cookie ) >= options.pages ) ) { |
| 74 | + $tag.mwSurvey( options ); |
| 75 | + setCookie( options, 'done' ); |
| 76 | + } |
| 77 | + else if ( options.pages !== 0 ) { |
| 78 | + var nr = parseInt( getCookie( options ) ); |
| 79 | + setCookie( options, ( isNaN( nr ) ? 0 : nr ) + 1 ) |
| 80 | + } |
| 81 | + } |
84 | 82 | } |
85 | 83 | } |
86 | 84 | else { |
87 | | - onSurveyDone( options ); |
| 85 | + setCookie( options, 'done' ); |
88 | 86 | } |
89 | 87 | } |
90 | 88 | |