peteshow 0.8.4 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gruntfile.js +1 -0
- data/README.md +82 -5
- data/dist/peteshow.js +171 -141
- data/dist/peteshow.min.js +2 -2
- data/lib/assets/javascripts/peteshow.js +171 -141
- data/lib/assets/javascripts/peteshow.min.js +2 -2
- data/package.json +1 -1
- data/src/peteshow-core.js +90 -132
- data/src/peteshow-helpers.js +1 -1
- data/src/peteshow-storage.js +69 -0
- data/src/peteshow.js +10 -8
- data/tests/index.html +3 -3
- data/tests/playground.html +2 -1
- data/tests/suite/cookies.js +2 -2
- data/tests/suite/core.js +11 -2
- data/tests/suite/localstorage.js +3 -1
- metadata +3 -3
- data/tests/suite/helpers.js +0 -29
data/Gruntfile.js
CHANGED
data/README.md
CHANGED
@@ -1,25 +1,102 @@
|
|
1
1
|
# Peteshow
|
2
2
|
|
3
|
-
|
3
|
+
> a customizable javascript framework for filling out forms with fake data
|
4
4
|
|
5
|
-

|
6
5
|
|
7
6
|

|
8
7
|
|
9
|
-
|
10
8
|
## Getting Started
|
11
9
|
See the [Wiki on GitHub](https://github.com/brousalis/peteshow/wiki) for documentation.
|
12
10
|
|
13
11
|
- [Setup](https://github.com/brousalis/peteshow/wiki/Setup)
|
14
12
|
- [Usage](https://github.com/brousalis/peteshow/wiki/Usage)
|
15
13
|
- [Custom plugins](https://github.com/brousalis/peteshow/wiki/Custom-plugins)
|
16
|
-
- [Customization](https://github.com/brousalis/peteshow/wiki/Customization)
|
17
14
|
- [Plugin example](https://github.com/brousalis/peteshow/wiki/Plugin-example)
|
18
15
|
- [Change log](https://github.com/brousalis/peteshow/wiki/Change-log)
|
19
16
|
|
20
17
|
Also specific pages for frameworks:
|
21
18
|
- [Ruby on Rails](https://github.com/brousalis/peteshow/wiki/Ruby-on-Rails-gem)
|
22
19
|
|
20
|
+
## API
|
21
|
+
|
22
|
+
#### `Peteshow.init()`
|
23
|
+
|
24
|
+
Adds the seen above menu to the top left of your page. Press backtick <code>`</code> to toggle the menu.
|
25
|
+
|
26
|
+
#### `Peteshow.fillOutForms()`
|
27
|
+
|
28
|
+
Using the [default rules](https://github.com/brousalis/peteshow/blob/master/src/peteshow-core.js#L2), fills out inputs, checkboxes, selects, and radio buttons. While the menu is open, press `f` to call this method.
|
29
|
+
|
30
|
+
#### `Peteshow.fillOutFormsAndSubmit()`
|
31
|
+
|
32
|
+
Does the same as above, but also submits the form. Press `q` to call this method.
|
33
|
+
|
34
|
+
---
|
35
|
+
|
36
|
+
It also has several other methods exposed:
|
37
|
+
|
38
|
+
Methods | Description
|
39
|
+
--------------------|------------------------------------------------
|
40
|
+
`submitForm()` | Submits the form on the page, can be customized
|
41
|
+
`destroy()` | Removes the Peteshow menu from the dom
|
42
|
+
`hide()` | Hides the Peteshow menu
|
43
|
+
`show()` | Shows the Peteshow menu
|
44
|
+
`formatDate(format, Date)` | Returns a string with the specified format
|
45
|
+
`randomChars(length, chars)` | Returns a string made up of specific characters
|
46
|
+
`randomDate(format)` | Returns a random date string
|
47
|
+
`randomEmail()` | Returns a random email, customized using init options
|
48
|
+
`randomLetters(length)` | Returns random letters
|
49
|
+
`randomNumber(length)` | Returns a random number, you can pass an optional prefix
|
50
|
+
`randomNumberRange(min,max)` | Returns a number between `min` and `max`
|
51
|
+
|
52
|
+
To access the stored values used in the [reuse](https://github.com/brousalis/peteshow/wiki/Custom-plugins#reuse) option, use `Peteshow.storage`:
|
53
|
+
|
54
|
+
Methods | Description
|
55
|
+
--------------------|------------------------------------------------
|
56
|
+
`storage.clear()` | Clears saved fields from cookies and localstorage
|
57
|
+
`storage.get()` | Prints out the saved fields used in the `reuse` option
|
58
|
+
`storage.set(hash)` | Sets either cookie or localstorage, takes a hash
|
59
|
+
|
60
|
+
## Default options
|
61
|
+
|
62
|
+
Peteshow can be customized by creating a [custom plugin](https://github.com/brousalis/peteshow/wiki/Custom-plugins). Here are the default options:
|
63
|
+
|
64
|
+
```javascript
|
65
|
+
options = {
|
66
|
+
emailPrefix : 'test-',
|
67
|
+
emailDomain : 'example.com',
|
68
|
+
form : '',
|
69
|
+
blur : false,
|
70
|
+
cookies : false,
|
71
|
+
rules : {},
|
72
|
+
ignore : [],
|
73
|
+
filter : [],
|
74
|
+
force : {},
|
75
|
+
reuse : {},
|
76
|
+
commands : '',
|
77
|
+
special : function(){},
|
78
|
+
events : function(){},
|
79
|
+
}
|
80
|
+
$(function() {
|
81
|
+
Peteshow.init(options)
|
82
|
+
})
|
83
|
+
```
|
84
|
+
|
85
|
+
Name | Description
|
86
|
+
----------------------|---------------------------------------------------------------
|
87
|
+
`emailPrefix` | Prefix for your generated email addresses. Random numbers are added to the end
|
88
|
+
`emailDomain` | The domain for your generated email addresses
|
89
|
+
`form` | The selector of the form/forms you want to be filled out, defaults to last form on page
|
90
|
+
`blur` | Triggers blur() event after filling out an input
|
91
|
+
`cookies` | Store saved fields (from [reuse](https://github.com/brousalis/peteshow/wiki/Custom-plugins#reuse)) in cookies rather than localStorage
|
92
|
+
[rules](https://github.com/brousalis/peteshow/wiki/Custom-plugins#rules) | A hash of selectors to values that you want to be used when filling out forms. It ignores hidden inputs
|
93
|
+
[special](https://github.com/brousalis/peteshow/wiki/Custom-plugins#special) | Called after the rules are applied and can include custom javascript
|
94
|
+
[ignore](https://github.com/brousalis/peteshow/wiki/Custom-plugins#ignore) | An array of input IDs you wish to have fill out forms ignore
|
95
|
+
[force](https://github.com/brousalis/peteshow/wiki/Custom-plugins#force) | Similar to rules, but can be used for hidden inputs
|
96
|
+
[filters](https://github.com/brousalis/peteshow/wiki/Custom-plugins#filter) | Filters out options from select boxes
|
97
|
+
[reuse](https://github.com/brousalis/peteshow/wiki/Custom-plugins#reuse) | Define input selectors to be saved and reused on certain URLs
|
98
|
+
[events](https://github.com/brousalis/peteshow/wiki/Custom-plugins#events) | Used in the off chance you need to add extra javascript on Peteshow's init
|
99
|
+
|
23
100
|
### Further notes
|
24
101
|
[](http://www.enova.com)
|
25
102
|
|
@@ -27,4 +104,4 @@ Developed by [Pete Brousalis](http://twitter.com/brousalis) in his spare time fo
|
|
27
104
|
|
28
105
|
Special thanks to Matthew Bergman & Marak Squires for [Faker.js](http://github.com/marak/Faker.js/), Adam Gschwender for [jquery.formatDateTime](https://github.com/agschwender/jquery.formatDateTime), Klaus Hartl for [jquery.cookie](https://github.com/carhartl/jquery-cookie), all used by Peteshow.
|
29
106
|
|
30
|
-
And
|
107
|
+
And especially Donnie Hall for creating the original `Peepshow`
|
data/dist/peteshow.js
CHANGED
@@ -1083,16 +1083,18 @@ Peteshow.defaults = {
|
|
1083
1083
|
blur : false,
|
1084
1084
|
cookies : false,
|
1085
1085
|
|
1086
|
-
rules
|
1087
|
-
ignore
|
1088
|
-
filter
|
1089
|
-
force
|
1090
|
-
reuse
|
1091
|
-
commands
|
1092
|
-
special
|
1093
|
-
events
|
1086
|
+
rules : {},
|
1087
|
+
ignore : [],
|
1088
|
+
filter : [],
|
1089
|
+
force : {},
|
1090
|
+
reuse : {},
|
1091
|
+
commands : '',
|
1092
|
+
special : function(){},
|
1093
|
+
events : function(){},
|
1094
1094
|
}
|
1095
1095
|
|
1096
|
+
Peteshow.storage = {};
|
1097
|
+
|
1096
1098
|
window.Peteshow = Peteshow;
|
1097
1099
|
|
1098
1100
|
+function($) {
|
@@ -1115,7 +1117,7 @@ window.Peteshow = Peteshow;
|
|
1115
1117
|
|
1116
1118
|
Peteshow.randomNumberRange = function (min, max) {
|
1117
1119
|
return function() {
|
1118
|
-
return Math.floor(Math.random() * (max - min + 1)) + min
|
1120
|
+
return Math.floor(Math.random() * (max - min + 1)) + min
|
1119
1121
|
}
|
1120
1122
|
}
|
1121
1123
|
|
@@ -1156,6 +1158,76 @@ window.Peteshow = Peteshow;
|
|
1156
1158
|
|
1157
1159
|
}(jQuery)
|
1158
1160
|
|
1161
|
+
+function($) {
|
1162
|
+
var cookies = false
|
1163
|
+
|
1164
|
+
Peteshow.storage.init = function(options) {
|
1165
|
+
cookies = options.cookies
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
Peteshow.storage.set = function(data) {
|
1169
|
+
data = JSON.stringify(data)
|
1170
|
+
|
1171
|
+
if(cookies) $.cookie('peteshow', data, {domain: getDomain()})
|
1172
|
+
else localStorage.setItem('peteshow', data)
|
1173
|
+
}
|
1174
|
+
|
1175
|
+
Peteshow.storage.get = function() {
|
1176
|
+
var saved = cookies ? $.cookie('peteshow') : localStorage.getItem('peteshow')
|
1177
|
+
return (saved != undefined || saved != null) ? JSON.parse(saved) : {}
|
1178
|
+
}
|
1179
|
+
|
1180
|
+
Peteshow.storage.output = function() {
|
1181
|
+
var base = ''
|
1182
|
+
|
1183
|
+
if(savedFieldsExist()) {
|
1184
|
+
base += "<li class='list'>"
|
1185
|
+
base += "<div class='inner'>"
|
1186
|
+
$.each(Peteshow.storage.get(), function(k,v) {
|
1187
|
+
base += '<div>' + k + '<span>' + v + '</span></div>'
|
1188
|
+
})
|
1189
|
+
base += "</div>"
|
1190
|
+
base += "</li>"
|
1191
|
+
base += "<li><a data-command='R' href='#' id='clear'>Clear stored</a></li>"
|
1192
|
+
}
|
1193
|
+
|
1194
|
+
return base
|
1195
|
+
}
|
1196
|
+
|
1197
|
+
Peteshow.storage.clear = function() {
|
1198
|
+
clearLocalStorage()
|
1199
|
+
clearCookies()
|
1200
|
+
Peteshow.initCommands()
|
1201
|
+
}
|
1202
|
+
|
1203
|
+
savedFieldsExist = function() {
|
1204
|
+
var saved = cookies ? $.cookie('peteshow') : localStorage.getItem('peteshow')
|
1205
|
+
return (saved != undefined || saved != null)
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
getDomain = function() {
|
1209
|
+
// http://rossscrivener.co.uk/blog/javascript-get-domain-exclude-subdomain
|
1210
|
+
var i=0, domain=document.domain, p=domain.split('.'), s='_gd'+(new Date()).getTime()
|
1211
|
+
while(i<(p.length-1) && document.cookie.indexOf(s+'='+s)==-1){
|
1212
|
+
domain = p.slice(-1-(++i)).join('.')
|
1213
|
+
document.cookie = s+"="+s+";domain="+domain+";"
|
1214
|
+
}
|
1215
|
+
document.cookie = s+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain="+domain+";"
|
1216
|
+
return domain == 'localhost' ? '' : domain
|
1217
|
+
}
|
1218
|
+
|
1219
|
+
clearLocalStorage = function() {
|
1220
|
+
localStorage.removeItem('peteshow')
|
1221
|
+
Peteshow.initCommands()
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
clearCookies = function() {
|
1225
|
+
$.removeCookie('peteshow', {domain: getDomain()})
|
1226
|
+
Peteshow.initCommands()
|
1227
|
+
}
|
1228
|
+
|
1229
|
+
}(jQuery)
|
1230
|
+
|
1159
1231
|
+function($) {
|
1160
1232
|
getDefaultRules = function() {
|
1161
1233
|
return {
|
@@ -1205,28 +1277,9 @@ window.Peteshow = Peteshow;
|
|
1205
1277
|
|
1206
1278
|
$('body').append($div)
|
1207
1279
|
|
1208
|
-
initCommands()
|
1209
|
-
}
|
1280
|
+
Peteshow.initCommands()
|
1210
1281
|
|
1211
|
-
|
1212
|
-
Peteshow.hide()
|
1213
|
-
$div.remove();
|
1214
|
-
}
|
1215
|
-
|
1216
|
-
Peteshow.hide = function() {
|
1217
|
-
$div.hide()
|
1218
|
-
$div.removeClass('active')
|
1219
|
-
}
|
1220
|
-
|
1221
|
-
Peteshow.toggle = function() {
|
1222
|
-
$tools.toggle()
|
1223
|
-
$div.toggleClass('active')
|
1224
|
-
}
|
1225
|
-
|
1226
|
-
Peteshow.show = function() {
|
1227
|
-
$div.show()
|
1228
|
-
$tools.show()
|
1229
|
-
if(!$div.hasClass('active')) $div.addClass('active')
|
1282
|
+
Peteshow.storage.init(_options)
|
1230
1283
|
}
|
1231
1284
|
|
1232
1285
|
handleKeypress = function(e) {
|
@@ -1240,7 +1293,7 @@ window.Peteshow = Peteshow;
|
|
1240
1293
|
if($.inArray(e.keyCode, [9,16,17,18, 91, 93, 224]) != -1) return
|
1241
1294
|
if(e.metaKey) return
|
1242
1295
|
|
1243
|
-
if(e.keyCode == 192) //
|
1296
|
+
if(e.keyCode == 192) // backtick
|
1244
1297
|
Peteshow.toggle()
|
1245
1298
|
|
1246
1299
|
var action = $("[data-command='"+code+"']"),
|
@@ -1250,72 +1303,57 @@ window.Peteshow = Peteshow;
|
|
1250
1303
|
action.click()
|
1251
1304
|
}
|
1252
1305
|
|
1253
|
-
initCommands = function() {
|
1306
|
+
Peteshow.initCommands = function() {
|
1254
1307
|
var base = "<li><a data-command='F' href='#' id='fill-out-forms'>Fill Out Forms</a></li>"
|
1255
1308
|
base += "<li><a data-command='Q' href='#' id='fill-out-forms-and-submit'>Fill Out and Submit</a></li>"
|
1256
|
-
base +=
|
1309
|
+
base += Peteshow.storage.output()
|
1257
1310
|
base += "<li><a data-command='H' href='#' id='hide-peteshow'>Hide</a></li>"
|
1258
1311
|
|
1259
|
-
$
|
1260
|
-
|
1261
|
-
bindEvents()
|
1262
|
-
}
|
1312
|
+
$commands.html(_options.commands + base)
|
1263
1313
|
|
1264
|
-
|
1314
|
+
// bind events
|
1265
1315
|
var commands = [
|
1266
|
-
[ $toggle,
|
1267
|
-
[ $('#fill-out-forms'),
|
1268
|
-
[ $('#fill-out-forms-and-submit'),
|
1269
|
-
[ $('#clear'),
|
1270
|
-
[ $('#hide-peteshow'),
|
1316
|
+
[ $toggle, Peteshow.toggle ],
|
1317
|
+
[ $('#fill-out-forms'), Peteshow.fillOutForms ],
|
1318
|
+
[ $('#fill-out-forms-and-submit'), Peteshow.fillOutFormsAndSubmit ],
|
1319
|
+
[ $('#clear'), Peteshow.storage.clear ],
|
1320
|
+
[ $('#hide-peteshow'), Peteshow.hide ]
|
1271
1321
|
]
|
1272
1322
|
|
1273
1323
|
$.each(commands, function() {
|
1274
1324
|
var command = $(this)
|
1275
1325
|
$(command[0]).on('click', function() {
|
1276
|
-
command[1]()
|
1277
|
-
|
1278
|
-
|
1279
|
-
});
|
1326
|
+
command[1](); return false
|
1327
|
+
})
|
1328
|
+
})
|
1280
1329
|
|
1281
1330
|
_options.events()
|
1282
1331
|
}
|
1283
1332
|
|
1284
|
-
Peteshow.submitForm = function() {
|
1285
|
-
$(_options.form).submit()
|
1286
|
-
$('form[name*=registration], .simple_form').submit()
|
1287
|
-
$('form').last().submit()
|
1288
|
-
};
|
1289
|
-
|
1290
1333
|
Peteshow.fillOutForms = function() {
|
1291
|
-
|
1292
|
-
$('input[type=checkbox]').prop('checked', true)
|
1334
|
+
var rules = $.extend(true, getDefaultRules(), _options.rules || {})
|
1293
1335
|
|
1294
|
-
|
1295
|
-
|
1336
|
+
$('input:checkbox').filterFields().prop('checked', true)
|
1337
|
+
|
1338
|
+
$('input:radio').each(randomRadioValue)
|
1296
1339
|
|
1297
|
-
// select
|
1298
1340
|
$('select').each(randomSelectValue)
|
1299
1341
|
|
1300
|
-
// force rules
|
1342
|
+
// force rules (for hidden fields)
|
1301
1343
|
$.each(_options.force, function(element,v) {
|
1302
1344
|
$(element)
|
1303
|
-
.
|
1345
|
+
.filterFields()
|
1304
1346
|
.val($.isFunction(v) ? v() : v)
|
1305
1347
|
|
1306
1348
|
if(_options.blur) $(element).blur()
|
1307
1349
|
})
|
1308
1350
|
|
1309
|
-
//
|
1310
|
-
var rules = $.extend(true, getDefaultRules(), _options.rules || {})
|
1311
|
-
reused = {},
|
1312
|
-
saved = Peteshow.getSavedFields()
|
1313
|
-
|
1314
|
-
// apply value to rule element, if visible and not in ignore list
|
1351
|
+
// fill out fields with rules
|
1315
1352
|
$.each(rules, function(element,v) {
|
1316
|
-
$(element)
|
1317
|
-
|
1318
|
-
|
1353
|
+
$(element)
|
1354
|
+
.filter(':visible')
|
1355
|
+
.filterFields()
|
1356
|
+
.val($.isFunction(v) ? v() : v)
|
1319
1357
|
|
1320
1358
|
if(_options.blur) $(element).blur()
|
1321
1359
|
})
|
@@ -1323,15 +1361,24 @@ window.Peteshow = Peteshow;
|
|
1323
1361
|
// special rules
|
1324
1362
|
_options.special()
|
1325
1363
|
|
1326
|
-
//
|
1364
|
+
// localstorage functionality
|
1365
|
+
reuseLocalStorage()
|
1366
|
+
}
|
1367
|
+
|
1368
|
+
reuseLocalStorage = function() {
|
1369
|
+
var reused = {},
|
1370
|
+
saved = Peteshow.storage.get()
|
1371
|
+
|
1327
1372
|
$.each(_options.reuse, function(element,v) {
|
1328
1373
|
var url = _options.reuse[element]
|
1329
1374
|
|
1375
|
+
// exists on page
|
1330
1376
|
if($(element).length > 0) {
|
1331
|
-
//
|
1332
|
-
if(!(element in saved))
|
1377
|
+
// element isnt in saved, save it
|
1378
|
+
if(!(element in saved))
|
1379
|
+
reused[element] = $(element).val()
|
1333
1380
|
|
1334
|
-
//
|
1381
|
+
// element is saved and we're not on the reused url, save it
|
1335
1382
|
if((element in saved) && window.location.href.indexOf(url) < 0)
|
1336
1383
|
reused[element] = $(element).val()
|
1337
1384
|
}
|
@@ -1340,79 +1387,22 @@ window.Peteshow = Peteshow;
|
|
1340
1387
|
// save if found rules to reuse
|
1341
1388
|
if(!$.isEmptyObject(reused)) {
|
1342
1389
|
$.extend(saved, reused)
|
1343
|
-
Peteshow.
|
1390
|
+
Peteshow.storage.set(saved)
|
1344
1391
|
}
|
1345
1392
|
|
1346
1393
|
// apply saved rule values if they exist and on the right page
|
1347
1394
|
if(savedFieldsExist()) {
|
1348
|
-
$.each(Peteshow.
|
1395
|
+
$.each(Peteshow.storage.get(), function(element,v) {
|
1349
1396
|
var url = _options.reuse[element]
|
1350
1397
|
if(window.location.href.indexOf(url) > -1) $(element).val(v)
|
1351
1398
|
})
|
1352
|
-
// reinit menu
|
1353
|
-
initCommands()
|
1354
|
-
}
|
1355
|
-
}
|
1356
|
-
|
1357
|
-
outputSavedFields = function() {
|
1358
|
-
var base = ''
|
1359
1399
|
|
1360
|
-
|
1361
|
-
|
1362
|
-
base += "<div class='inner'>"
|
1363
|
-
$.each(Peteshow.getSavedFields(), function(k,v) {
|
1364
|
-
base += '<div>' + k + '<span>' + v + '</span></div>'
|
1365
|
-
})
|
1366
|
-
base += "</div>"
|
1367
|
-
base += "</li>"
|
1368
|
-
base += "<li><a data-command='R' href='#' id='clear'>Clear stored</a></li>"
|
1400
|
+
// redraw menu
|
1401
|
+
Peteshow.initCommands()
|
1369
1402
|
}
|
1370
|
-
|
1371
|
-
return base
|
1372
|
-
}
|
1373
|
-
|
1374
|
-
savedFieldsExist = function() {
|
1375
|
-
var saved = _options.cookies ? $.cookie('peteshow') : localStorage.getItem('peteshow')
|
1376
|
-
return saved != undefined || saved != null
|
1377
|
-
}
|
1378
|
-
|
1379
|
-
Peteshow.setSavedFields = function(data) {
|
1380
|
-
_options.cookies ? $.cookie('peteshow', data, {domain: getDomain()}) : localStorage.setItem('peteshow', data)
|
1381
|
-
}
|
1382
|
-
|
1383
|
-
Peteshow.getSavedFields = function() {
|
1384
|
-
var saved = _options.cookies ? $.cookie('peteshow') : localStorage.getItem('peteshow')
|
1385
|
-
return (saved != undefined || saved != null) ? JSON.parse(saved) : {}
|
1386
|
-
}
|
1387
|
-
|
1388
|
-
getDomain = function() {
|
1389
|
-
// http://rossscrivener.co.uk/blog/javascript-get-domain-exclude-subdomain
|
1390
|
-
var i=0, domain=document.domain, p=domain.split('.'), s='_gd'+(new Date()).getTime();
|
1391
|
-
while(i<(p.length-1) && document.cookie.indexOf(s+'='+s)==-1){
|
1392
|
-
domain = p.slice(-1-(++i)).join('.');
|
1393
|
-
document.cookie = s+"="+s+";domain="+domain+";";
|
1394
|
-
}
|
1395
|
-
document.cookie = s+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain="+domain+";";
|
1396
|
-
return domain;
|
1397
|
-
}
|
1398
|
-
|
1399
|
-
Peteshow.clearSaved = function() {
|
1400
|
-
Peteshow.clearLocalStorage()
|
1401
|
-
Peteshow.clearCookies()
|
1402
|
-
initCommands()
|
1403
|
-
}
|
1404
|
-
|
1405
|
-
Peteshow.clearLocalStorage = function() {
|
1406
|
-
localStorage.removeItem('peteshow')
|
1407
|
-
initCommands()
|
1408
|
-
}
|
1409
|
-
|
1410
|
-
Peteshow.clearCookies = function() {
|
1411
|
-
$.removeCookie('peteshow', {domain: getDomain()})
|
1412
|
-
initCommands()
|
1413
1403
|
}
|
1414
1404
|
|
1415
|
-
randomSelectValue = function(i,select) {
|
1405
|
+
randomSelectValue = function(i, select) {
|
1416
1406
|
var options = $(select).find('option'),
|
1417
1407
|
filters = _options.filter.toString().replace(new RegExp(',', 'g'), '|'),
|
1418
1408
|
regex = new RegExp('other|select'+(filters == '' ? '' : '|' + filters),'gi'),
|
@@ -1423,18 +1413,18 @@ window.Peteshow = Peteshow;
|
|
1423
1413
|
|
1424
1414
|
if(value.match(regex) == null && value != '')
|
1425
1415
|
filtered.push(value)
|
1426
|
-
})
|
1416
|
+
})
|
1427
1417
|
|
1428
1418
|
var random = Math.floor(Math.random() * filtered.length)
|
1429
1419
|
|
1430
1420
|
$(select)
|
1431
|
-
.
|
1421
|
+
.filterFields()
|
1432
1422
|
.val(filtered[random])
|
1433
1423
|
.change()
|
1434
1424
|
}
|
1435
1425
|
|
1436
|
-
randomRadioValue = function() {
|
1437
|
-
var names = $(
|
1426
|
+
randomRadioValue = function(i, radios) {
|
1427
|
+
var names = $(radios).map(function() {
|
1438
1428
|
return $(this).attr('name')
|
1439
1429
|
})
|
1440
1430
|
|
@@ -1444,12 +1434,52 @@ window.Peteshow = Peteshow;
|
|
1444
1434
|
var radios = $('input:radio[name="'+name+'"]')
|
1445
1435
|
|
1446
1436
|
$(radios[Math.floor(Math.random() * radios.length)])
|
1447
|
-
.
|
1437
|
+
.filterFields()
|
1448
1438
|
.prop('checked', true)
|
1449
1439
|
.change()
|
1450
1440
|
})
|
1451
1441
|
}
|
1452
1442
|
|
1453
|
-
|
1443
|
+
$.fn.filterFields = function() {
|
1444
|
+
return this.filter(function() {
|
1445
|
+
return _options.ignore.indexOf(this.name) === -1
|
1446
|
+
})
|
1447
|
+
}
|
1448
|
+
|
1449
|
+
Peteshow.submitForm = function() {
|
1450
|
+
$(_options.form).submit()
|
1451
|
+
$('form[name*=registration], .simple_form').submit()
|
1452
|
+
$('form').last().submit()
|
1453
|
+
}
|
1454
|
+
|
1455
|
+
Peteshow.fillOutFormsAndSubmit = function() {
|
1456
|
+
Peteshow.fillOutForms()
|
1457
|
+
Peteshow.submitForm()
|
1458
|
+
}
|
1459
|
+
|
1460
|
+
Peteshow.destroy = function() {
|
1461
|
+
Peteshow.hide()
|
1462
|
+
$div.remove()
|
1463
|
+
}
|
1464
|
+
|
1465
|
+
Peteshow.hide = function() {
|
1466
|
+
$div.hide()
|
1467
|
+
$div.removeClass('active')
|
1468
|
+
}
|
1469
|
+
|
1470
|
+
Peteshow.toggle = function() {
|
1471
|
+
$tools.toggle()
|
1472
|
+
$div.toggleClass('active')
|
1473
|
+
}
|
1474
|
+
|
1475
|
+
Peteshow.show = function() {
|
1476
|
+
$div.show()
|
1477
|
+
$tools.show()
|
1478
|
+
|
1479
|
+
if(!$div.hasClass('active'))
|
1480
|
+
$div.addClass('active')
|
1481
|
+
}
|
1482
|
+
|
1483
|
+
$(document).keydown(handleKeypress)
|
1454
1484
|
}(jQuery)
|
1455
1485
|
|