├── scripts ├── authentication.js ├── index.js ├── useradmin.js ├── manager.js ├── IATStyleLoader.js ├── jquery.jnotify │ ├── css │ │ ├── docs.css │ │ ├── jquery.jnotify.min.css │ │ ├── jquery.jnotify-bottom.css │ │ ├── jquery.jnotify.css │ │ └── jquery.jnotify-alt.css │ ├── lib │ │ ├── jquery.jnotify.min.js │ │ └── jquery.jnotify.js │ └── gettingstarted.htm ├── text.js ├── UserAdministration.js ├── CoreIAT.js ├── IAT.js ├── jquery.jeditable │ ├── jquery.jeditable.min.js │ └── jquery.jeditable.js └── sha1.js ├── Images ├── ajaxloader.gif └── disclosureTriangle.png ├── configuration ├── config.sample.js └── config.sample.php ├── css ├── blitzer │ └── images │ │ ├── ui-icons_004276_256x240.png │ │ ├── ui-icons_cc0000_256x240.png │ │ ├── ui-icons_ffffff_256x240.png │ │ ├── ui-bg_flat_0_333333_40x100.png │ │ ├── ui-bg_flat_65_ffffff_40x100.png │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ ├── ui-bg_glass_55_fbf8ee_1x400.png │ │ ├── ui-bg_dots-small_65_a6a6a6_2x2.png │ │ ├── ui-bg_diagonals-thick_75_f3d8d8_40x40.png │ │ ├── ui-bg_highlight-hard_100_eeeeee_1x100.png │ │ ├── ui-bg_highlight-hard_100_f6f6f6_1x100.png │ │ └── ui-bg_highlight-soft_15_cc0000_1x100.png ├── index.css ├── ClientIATManager.css └── dataTableStyle.css ├── .gitignore ├── server ├── deleteExperiment.php ├── downloadLogForExperiment.php ├── dataHandler.php ├── unlinkLogFileForExperiment.php ├── servererror.php ├── thankyou.php ├── downloadScoresFromExperiment.php ├── calculateScore.php ├── connectDatabase.php ├── downloadRawDataFromExperiment.php ├── uploadStoredData.php ├── hashGenerator.php ├── GlobalKLogger.php ├── processing.php ├── results.php ├── CSVMaker.php ├── rresults.php ├── GreenwaldIATProcessor.php └── IAT.php ├── IATStyles └── GreenwaldStimulus │ ├── GreenwaldStimulus.html │ ├── GreenwaldStimulus.css │ └── GreenwaldStimulus.js ├── readme.md ├── register └── index.html ├── about.html ├── .gitmodules ├── Testing └── testScoreCalculation.html ├── index.php ├── useradmin └── index.html ├── admin ├── index.html └── IATManager.php └── SQLVersionControl └── vc.sql /scripts/authentication.js: -------------------------------------------------------------------------------- 1 | function () { 2 | 3 | } 4 | 5 | -------------------------------------------------------------------------------- /Images/ajaxloader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/Images/ajaxloader.gif -------------------------------------------------------------------------------- /Images/disclosureTriangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/Images/disclosureTriangle.png -------------------------------------------------------------------------------- /scripts/index.js: -------------------------------------------------------------------------------- 1 | require(["jquery","IAT"],function ($,IAT) { 2 | IAT($.getUrlVar('i'),$('#contentDiv')); 3 | }); 4 | 5 | -------------------------------------------------------------------------------- /configuration/config.sample.js: -------------------------------------------------------------------------------- 1 | 2 | //Configuration 3 | define({ 4 | IATBaseURL : '', 5 | managerFilePath : '' 6 | }); 7 | -------------------------------------------------------------------------------- /css/blitzer/images/ui-icons_004276_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/css/blitzer/images/ui-icons_004276_256x240.png -------------------------------------------------------------------------------- /css/blitzer/images/ui-icons_cc0000_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/css/blitzer/images/ui-icons_cc0000_256x240.png -------------------------------------------------------------------------------- /css/blitzer/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/css/blitzer/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /css/blitzer/images/ui-bg_flat_0_333333_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/css/blitzer/images/ui-bg_flat_0_333333_40x100.png -------------------------------------------------------------------------------- /css/blitzer/images/ui-bg_flat_65_ffffff_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/css/blitzer/images/ui-bg_flat_65_ffffff_40x100.png -------------------------------------------------------------------------------- /css/blitzer/images/ui-bg_flat_75_ffffff_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/css/blitzer/images/ui-bg_flat_75_ffffff_40x100.png -------------------------------------------------------------------------------- /css/blitzer/images/ui-bg_glass_55_fbf8ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/css/blitzer/images/ui-bg_glass_55_fbf8ee_1x400.png -------------------------------------------------------------------------------- /css/blitzer/images/ui-bg_dots-small_65_a6a6a6_2x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/css/blitzer/images/ui-bg_dots-small_65_a6a6a6_2x2.png -------------------------------------------------------------------------------- /css/blitzer/images/ui-bg_diagonals-thick_75_f3d8d8_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/css/blitzer/images/ui-bg_diagonals-thick_75_f3d8d8_40x40.png -------------------------------------------------------------------------------- /css/blitzer/images/ui-bg_highlight-hard_100_eeeeee_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/css/blitzer/images/ui-bg_highlight-hard_100_eeeeee_1x100.png -------------------------------------------------------------------------------- /css/blitzer/images/ui-bg_highlight-hard_100_f6f6f6_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/css/blitzer/images/ui-bg_highlight-hard_100_f6f6f6_1x100.png -------------------------------------------------------------------------------- /css/blitzer/images/ui-bg_highlight-soft_15_cc0000_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephens2424/Web-IAT/HEAD/css/blitzer/images/ui-bg_highlight-soft_15_cc0000_1x100.png -------------------------------------------------------------------------------- /scripts/useradmin.js: -------------------------------------------------------------------------------- 1 | 2 | require(['UserAdministration'],function(UserAdministration) { 3 | $(function () { 4 | UserAdministration.appendUserTableToDiv($('#userTable')); 5 | }); 6 | }) 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #jQuery 2 | jquery.js 3 | 4 | #Logs 5 | log/* 6 | logs/* 7 | 8 | #Configuration 9 | configuration/config.js 10 | configuration/config.php 11 | 12 | #custom results 13 | Results 14 | 15 | -------------------------------------------------------------------------------- /server/deleteExperiment.php: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /scripts/manager.js: -------------------------------------------------------------------------------- 1 | require(["jquery","IAT","IATManager"], function ($,CoreIAT,IAT,IATManager) { 2 | $(function () { 3 | var IATManager = IAT.IATManager(); 4 | IATManager.appendExperimentSelectorTo($('.contentDiv')); 5 | }); 6 | }); 7 | -------------------------------------------------------------------------------- /configuration/config.sample.php: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /css/index.css: -------------------------------------------------------------------------------- 1 | /* 2 | Document : index 3 | Created on : Aug 20, 2011, 11:38:40 AM 4 | Author : Stephen 5 | Description: 6 | Purpose of the stylesheet follows. 7 | */ 8 | 9 | /* 10 | TODO customize this sample style 11 | Syntax recommendation http://www.w3.org/TR/REC-CSS2/ 12 | */ 13 | 14 | root { 15 | display: block; 16 | } 17 | -------------------------------------------------------------------------------- /server/downloadLogForExperiment.php: -------------------------------------------------------------------------------- 1 | downloadLog(); 12 | exit; 13 | ?> 14 | -------------------------------------------------------------------------------- /server/dataHandler.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /server/unlinkLogFileForExperiment.php: -------------------------------------------------------------------------------- 1 | deleteLog(); 12 | echo $success; 13 | ?> 14 | -------------------------------------------------------------------------------- /IATStyles/GreenwaldStimulus/GreenwaldStimulus.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | Web IAT 2 | Stephen Searles 3 | Originally developed for Margaret Shih and Geoff Ho, UCLA Anderson School of Management 4 | 5 | The IAT process used in this project comes from Anthony Greenwald, with his materials available on his website: http://faculty.washington.edu/agg/iat_materials.htm. 6 | 7 | This project is licensed under the Eclipse Public License, available here: http://www.eclipse.org/org/documents/epl-v10.html. -------------------------------------------------------------------------------- /server/servererror.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /server/thankyou.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 |

Thank you for your participation

16 | 17 | 18 | -------------------------------------------------------------------------------- /server/downloadScoresFromExperiment.php: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /server/calculateScore.php: -------------------------------------------------------------------------------- 1 | 20 | -------------------------------------------------------------------------------- /server/connectDatabase.php: -------------------------------------------------------------------------------- 1 | 100, 'errorString' => 'MySQL connection failed: ' . mysql_error()))); 9 | @mysql_select_db($databaseName) or die(json_encode(array('errorCode' => 100, 'errorString' => 'Could not select database'))); 10 | return $link; 11 | } 12 | 13 | 14 | ?> 15 | -------------------------------------------------------------------------------- /server/downloadRawDataFromExperiment.php: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /register/index.html: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |

Welcome to WebIAT

14 |

You need to register to access many of the features.

15 |
16 | 17 |
18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /server/uploadStoredData.php: -------------------------------------------------------------------------------- 1 | 22 | -------------------------------------------------------------------------------- /IATStyles/GreenwaldStimulus/GreenwaldStimulus.css: -------------------------------------------------------------------------------- 1 | #GreenwaldStimulus_iatStimulus,#GreenwaldStimulus_iatBlockLeft,#GreenwaldStimulus_iatBlockRight { 2 | font-size: x-large; 3 | font-family: helvetica; 4 | line-height: 35px; 5 | 6 | } 7 | #GreenwaldStimulus_iatBlockLeft,#GreenwaldStimulus_iatBlockRight { 8 | line-height: 50px; 9 | } 10 | #GreenwaldStimulus_iatStimulus { 11 | text-align: center; 12 | position: fixed; 13 | top: 40%; 14 | left: 30%; 15 | right: 30%; 16 | } 17 | #GreenwaldStimulus_iatBlockLeft { 18 | position: fixed; 19 | top: 15px; 20 | left: 15px; 21 | } 22 | #GreenwaldStimulus_iatBlockRight { 23 | position: fixed; 24 | top: 15px; 25 | right: 15px; 26 | text-align: right; 27 | } 28 | -------------------------------------------------------------------------------- /scripts/IATStyleLoader.js: -------------------------------------------------------------------------------- 1 | define(["jquery","CoreIAT"],function($,CoreIAT) { 2 | return { 3 | loadStyle : function (style) { 4 | var deferred = $.Deferred(); 5 | var html = 'text!../IATStyles/' + style + '/' + style + '.html'; 6 | var css = 'text!../IATStyles/' + style + '/' + style + '.css'; 7 | require([html,css],function (styleHtml,css) { 8 | deferred.loadedStyle = $(styleHtml).append($(' 306 | 307 | 308 | 317 |
318 | 319 | 320 | 323 | 326 | 327 | 328 | 331 | 334 | 335 | 336 | 337 | 340 | 341 |
321 |

322 |
324 |

325 |
329 |

330 |
332 |

333 |
338 |

339 |
342 |
343 | 344 | 345 | -------------------------------------------------------------------------------- /SQLVersionControl/vc.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.13 Distrib 5.5.10, for osx10.6 (i386) 2 | -- 3 | -- Host: localhost Database: testIAT 4 | -- ------------------------------------------------------ 5 | -- Server version 5.5.10 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!40101 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Table structure for table `blockComponents` 20 | -- 21 | 22 | DROP TABLE IF EXISTS `blockComponents`; 23 | /*!40101 SET @saved_cs_client = @@character_set_client */; 24 | /*!40101 SET character_set_client = utf8 */; 25 | CREATE TABLE `blockComponents` ( 26 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT, 27 | `block` int(11) DEFAULT NULL, 28 | `category` int(11) DEFAULT NULL, 29 | `position` int(11) DEFAULT NULL, 30 | PRIMARY KEY (`id`) 31 | ) ENGINE=InnoDB AUTO_INCREMENT=342 DEFAULT CHARSET=latin1; 32 | /*!40101 SET character_set_client = @saved_cs_client */; 33 | 34 | -- 35 | -- Dumping data for table `blockComponents` 36 | -- 37 | 38 | LOCK TABLES `blockComponents` WRITE; 39 | /*!40000 ALTER TABLE `blockComponents` DISABLE KEYS */; 40 | INSERT INTO `blockComponents` VALUES (320,106,81,1),(321,106,82,2),(322,107,83,1),(323,107,84,2),(324,108,81,1),(325,108,82,2),(326,108,83,3),(327,108,84,4),(328,109,81,1),(329,109,82,2),(330,109,83,3),(331,109,84,4),(332,110,82,1),(333,110,81,2),(334,111,82,1),(335,111,81,2),(336,111,83,3),(337,111,84,4),(338,112,82,1),(339,112,81,2),(340,112,83,3),(341,112,84,4); 41 | /*!40000 ALTER TABLE `blockComponents` ENABLE KEYS */; 42 | UNLOCK TABLES; 43 | 44 | -- 45 | -- Table structure for table `blockStyles` 46 | -- 47 | 48 | DROP TABLE IF EXISTS `blockStyles`; 49 | /*!40101 SET @saved_cs_client = @@character_set_client */; 50 | /*!40101 SET character_set_client = utf8 */; 51 | CREATE TABLE `blockStyles` ( 52 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT, 53 | `name` text, 54 | `filePath` text, 55 | `positions` int(11) DEFAULT NULL, 56 | `prefix` text, 57 | PRIMARY KEY (`id`) 58 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; 59 | /*!40101 SET character_set_client = @saved_cs_client */; 60 | 61 | -- 62 | -- Dumping data for table `blockStyles` 63 | -- 64 | 65 | LOCK TABLES `blockStyles` WRITE; 66 | /*!40000 ALTER TABLE `blockStyles` DISABLE KEYS */; 67 | INSERT INTO `blockStyles` VALUES (1,'Greenwald Stimulus','GreenwaldStimulus',5,'GreenwaldStimulus'); 68 | /*!40000 ALTER TABLE `blockStyles` ENABLE KEYS */; 69 | UNLOCK TABLES; 70 | 71 | -- 72 | -- Table structure for table `blocks` 73 | -- 74 | 75 | DROP TABLE IF EXISTS `blocks`; 76 | /*!40101 SET @saved_cs_client = @@character_set_client */; 77 | /*!40101 SET character_set_client = utf8 */; 78 | CREATE TABLE `blocks` ( 79 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT, 80 | `trials` int(11) DEFAULT NULL, 81 | `description` text, 82 | `experiment` int(11) NOT NULL, 83 | `blockStyle` int(11) DEFAULT NULL, 84 | PRIMARY KEY (`id`) 85 | ) ENGINE=InnoDB AUTO_INCREMENT=113 DEFAULT CHARSET=latin1; 86 | /*!40101 SET character_set_client = @saved_cs_client */; 87 | 88 | -- 89 | -- Dumping data for table `blocks` 90 | -- 91 | 92 | LOCK TABLES `blocks` WRITE; 93 | /*!40000 ALTER TABLE `blocks` DISABLE KEYS */; 94 | INSERT INTO `blocks` VALUES (106,1,'Block 1, Practice',21,1),(107,1,'Block 2, Practice',21,1),(108,1,'Block 3, Practice',21,1),(109,1,'Block 4, Test',21,1),(110,1,'Block 5, Practice',21,1),(111,1,'Block 6, Practice',21,1),(112,1,'Block 7, Test',21,1); 95 | /*!40000 ALTER TABLE `blocks` ENABLE KEYS */; 96 | UNLOCK TABLES; 97 | 98 | -- 99 | -- Table structure for table `categoryPairs` 100 | -- 101 | 102 | DROP TABLE IF EXISTS `categoryPairs`; 103 | /*!40101 SET @saved_cs_client = @@character_set_client */; 104 | /*!40101 SET character_set_client = utf8 */; 105 | CREATE TABLE `categoryPairs` ( 106 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT, 107 | `positiveCategory` int(11) DEFAULT NULL, 108 | `negativeCategory` int(11) DEFAULT NULL, 109 | `associatedPair` int(11) DEFAULT NULL, 110 | `experiment` int(11) DEFAULT NULL, 111 | PRIMARY KEY (`id`), 112 | UNIQUE KEY `positiveCategory` (`positiveCategory`), 113 | UNIQUE KEY `negativeCateogry` (`negativeCategory`), 114 | UNIQUE KEY `associatedPair` (`associatedPair`) 115 | ) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1; 116 | /*!40101 SET character_set_client = @saved_cs_client */; 117 | 118 | -- 119 | -- Dumping data for table `categoryPairs` 120 | -- 121 | 122 | LOCK TABLES `categoryPairs` WRITE; 123 | /*!40000 ALTER TABLE `categoryPairs` DISABLE KEYS */; 124 | INSERT INTO `categoryPairs` VALUES (41,81,82,42,21),(42,83,84,41,21); 125 | /*!40000 ALTER TABLE `categoryPairs` ENABLE KEYS */; 126 | UNLOCK TABLES; 127 | 128 | -- 129 | -- Table structure for table `experiments` 130 | -- 131 | 132 | DROP TABLE IF EXISTS `experiments`; 133 | /*!40101 SET @saved_cs_client = @@character_set_client */; 134 | /*!40101 SET character_set_client = utf8 */; 135 | CREATE TABLE `experiments` ( 136 | `id` int(11) NOT NULL AUTO_INCREMENT, 137 | `active` bit(1) NOT NULL DEFAULT b'0', 138 | `name` text, 139 | `endUrl` text, 140 | `hash` text, 141 | `secondEndUrl` text, 142 | `checkAnswers` tinyint(1) NOT NULL DEFAULT '0', 143 | `errorNotifications` tinyint(1) NOT NULL DEFAULT '0', 144 | `autoBalance` tinyint(1) NOT NULL DEFAULT '0', 145 | PRIMARY KEY (`id`) 146 | ) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=latin1; 147 | /*!40101 SET character_set_client = @saved_cs_client */; 148 | 149 | -- 150 | -- Dumping data for table `experiments` 151 | -- 152 | 153 | LOCK TABLES `experiments` WRITE; 154 | /*!40000 ALTER TABLE `experiments` DISABLE KEYS */; 155 | INSERT INTO `experiments` VALUES (21,'\0','New Experiment','','z8gkl','',1,1,0); 156 | /*!40000 ALTER TABLE `experiments` ENABLE KEYS */; 157 | UNLOCK TABLES; 158 | 159 | -- 160 | -- Table structure for table `responses` 161 | -- 162 | 163 | DROP TABLE IF EXISTS `responses`; 164 | /*!40101 SET @saved_cs_client = @@character_set_client */; 165 | /*!40101 SET character_set_client = utf8 */; 166 | CREATE TABLE `responses` ( 167 | `response_id` int(11) NOT NULL AUTO_INCREMENT, 168 | `subj` int(11) NOT NULL, 169 | `stimulus` int(11) DEFAULT NULL, 170 | `response` text, 171 | `response_time` int(11) DEFAULT NULL, 172 | `timeShown` timestamp NULL DEFAULT NULL, 173 | PRIMARY KEY (`response_id`) 174 | ) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=latin1; 175 | /*!40101 SET character_set_client = @saved_cs_client */; 176 | 177 | -- 178 | -- Dumping data for table `responses` 179 | -- 180 | 181 | LOCK TABLES `responses` WRITE; 182 | /*!40000 ALTER TABLE `responses` DISABLE KEYS */; 183 | INSERT INTO `responses` VALUES (1,1,6,'39',-2147483648,'0000-00-00 00:00:00'),(2,1,4,'39',-2147483648,'0000-00-00 00:00:00'),(3,1,8,'39',-2147483648,'0000-00-00 00:00:00'),(4,1,6,'39',-2147483648,'0000-00-00 00:00:00'),(5,1,2,'37',-2147483648,'0000-00-00 00:00:00'),(6,1,2,'37',-2147483648,'0000-00-00 00:00:00'),(7,1,1,'39',-2147483648,'0000-00-00 00:00:00'),(8,2,5,'37',-2147483648,'0000-00-00 00:00:00'),(9,2,8,'39',-2147483648,'0000-00-00 00:00:00'),(10,2,2,'39',-2147483648,'0000-00-00 00:00:00'),(11,2,7,'37',-2147483648,'0000-00-00 00:00:00'),(12,2,2,'37',-2147483648,'0000-00-00 00:00:00'),(13,2,8,'39',-2147483648,'0000-00-00 00:00:00'),(14,2,8,'39',-2147483648,'0000-00-00 00:00:00'),(15,3,2,'39',-2147483648,'0000-00-00 00:00:00'),(16,3,7,'37',-2147483648,'0000-00-00 00:00:00'),(17,3,5,'37',-2147483648,'0000-00-00 00:00:00'),(18,3,7,'37',-2147483648,'0000-00-00 00:00:00'),(19,3,5,'39',-2147483648,'0000-00-00 00:00:00'),(20,3,2,'37',-2147483648,'0000-00-00 00:00:00'),(21,3,8,'39',-2147483648,'0000-00-00 00:00:00'),(22,4,1,'37',6654,'0000-00-00 00:00:00'),(23,4,7,'37',2486,'0000-00-00 00:00:00'),(24,4,2,'39',718,'0000-00-00 00:00:00'),(25,4,2,'39',374,'0000-00-00 00:00:00'),(26,4,5,'39',846,'0000-00-00 00:00:00'),(27,4,8,'39',1639,'0000-00-00 00:00:00'),(28,4,3,'37',614,'0000-00-00 00:00:00'); 184 | /*!40000 ALTER TABLE `responses` ENABLE KEYS */; 185 | UNLOCK TABLES; 186 | 187 | -- 188 | -- Table structure for table `stimuli` 189 | -- 190 | 191 | DROP TABLE IF EXISTS `stimuli`; 192 | /*!40101 SET @saved_cs_client = @@character_set_client */; 193 | /*!40101 SET character_set_client = utf8 */; 194 | CREATE TABLE `stimuli` ( 195 | `id` int(11) NOT NULL AUTO_INCREMENT, 196 | `experiment` int(11) NOT NULL, 197 | `word` text, 198 | `stimulusCategory` int(11) DEFAULT NULL, 199 | PRIMARY KEY (`id`) 200 | ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1; 201 | /*!40101 SET character_set_client = @saved_cs_client */; 202 | 203 | -- 204 | -- Dumping data for table `stimuli` 205 | -- 206 | 207 | LOCK TABLES `stimuli` WRITE; 208 | /*!40000 ALTER TABLE `stimuli` DISABLE KEYS */; 209 | INSERT INTO `stimuli` VALUES (1,21,'Wonderful',81),(2,21,'Horrible',82),(3,21,'That thing',83),(4,21,'That other thing',84),(5,21,'Terrific',81),(6,21,'Crappy',82),(7,21,'This one',83),(8,21,'This other one',84); 210 | /*!40000 ALTER TABLE `stimuli` ENABLE KEYS */; 211 | UNLOCK TABLES; 212 | 213 | -- 214 | -- Table structure for table `stimulusCategories` 215 | -- 216 | 217 | DROP TABLE IF EXISTS `stimulusCategories`; 218 | /*!40101 SET @saved_cs_client = @@character_set_client */; 219 | /*!40101 SET character_set_client = utf8 */; 220 | CREATE TABLE `stimulusCategories` ( 221 | `id` int(11) NOT NULL AUTO_INCREMENT, 222 | `name` text, 223 | `experiment` int(11) DEFAULT NULL, 224 | `inPair` int(11) DEFAULT NULL, 225 | PRIMARY KEY (`id`) 226 | ) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=latin1; 227 | /*!40101 SET character_set_client = @saved_cs_client */; 228 | 229 | -- 230 | -- Dumping data for table `stimulusCategories` 231 | -- 232 | 233 | LOCK TABLES `stimulusCategories` WRITE; 234 | /*!40000 ALTER TABLE `stimulusCategories` DISABLE KEYS */; 235 | INSERT INTO `stimulusCategories` VALUES (81,'Good',21,44),(82,'Bad',21,44),(83,'One thing',21,44),(84,'Other thing',21,44); 236 | /*!40000 ALTER TABLE `stimulusCategories` ENABLE KEYS */; 237 | UNLOCK TABLES; 238 | 239 | -- 240 | -- Table structure for table `subjects` 241 | -- 242 | 243 | DROP TABLE IF EXISTS `subjects`; 244 | /*!40101 SET @saved_cs_client = @@character_set_client */; 245 | /*!40101 SET character_set_client = utf8 */; 246 | CREATE TABLE `subjects` ( 247 | `id` int(11) NOT NULL AUTO_INCREMENT, 248 | `beginTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP, 249 | `qualtrics_id` text, 250 | `score` double DEFAULT NULL, 251 | `experiment` int(11) DEFAULT NULL, 252 | PRIMARY KEY (`id`) 253 | ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1; 254 | /*!40101 SET character_set_client = @saved_cs_client */; 255 | 256 | -- 257 | -- Dumping data for table `subjects` 258 | -- 259 | 260 | LOCK TABLES `subjects` WRITE; 261 | /*!40000 ALTER TABLE `subjects` DISABLE KEYS */; 262 | INSERT INTO `subjects` VALUES (1,'0000-00-00 00:00:00',NULL,NULL,21),(2,'0000-00-00 00:00:00',NULL,NULL,21),(3,'0000-00-00 00:00:00',NULL,NULL,21),(4,'0000-00-00 00:00:00',NULL,NULL,21); 263 | /*!40000 ALTER TABLE `subjects` ENABLE KEYS */; 264 | UNLOCK TABLES; 265 | 266 | -- 267 | -- Table structure for table `users` 268 | -- 269 | 270 | DROP TABLE IF EXISTS `users`; 271 | /*!40101 SET @saved_cs_client = @@character_set_client */; 272 | /*!40101 SET character_set_client = utf8 */; 273 | CREATE TABLE `users` ( 274 | `username` text NOT NULL, 275 | `id` int(11) NOT NULL AUTO_INCREMENT, 276 | `passwordHash` text, 277 | `owner` tinyint(1) NOT NULL DEFAULT '0', 278 | `userAdministration` tinyint(11) NOT NULL DEFAULT '0', 279 | `email` text NOT NULL, 280 | `active` tinyint(11) NOT NULL DEFAULT '0', 281 | `originalActivation` tinyint(11) NOT NULL DEFAULT '0', 282 | `emailConfirmed` tinyint(11) NOT NULL DEFAULT '0', 283 | PRIMARY KEY (`id`) 284 | ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1; 285 | /*!40101 SET character_set_client = @saved_cs_client */; 286 | 287 | -- 288 | -- Dumping data for table `users` 289 | -- 290 | 291 | LOCK TABLES `users` WRITE; 292 | /*!40000 ALTER TABLE `users` DISABLE KEYS */; 293 | INSERT INTO `users` VALUES ('stephen',1,'5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8',1,1,'stephen.searles@gmail.com',1,0,0),('test',2,'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',0,0,'',0,0,0),('testuser',3,'5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8',0,0,'stephens2424@gmail.com',0,0,0),('anothertest',4,'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',0,0,'stephens2424@gmail.com',0,0,0),('newTestUser',5,'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',0,0,'stephens2424@gmail.com',0,0,0),('newTestUser2',6,'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',0,0,'stephens2424@gmail.com',0,0,0),('newTestUser3',7,'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',0,0,'stephen.searles@ucla.edu',0,0,0),('testUser2',8,'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',0,0,'stephens2424@gmail.com',0,0,0),('testUser3',9,'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',0,0,'stephens2424@gmail.com',0,0,0); 294 | /*!40000 ALTER TABLE `users` ENABLE KEYS */; 295 | UNLOCK TABLES; 296 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 297 | 298 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 299 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 300 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 301 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 302 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 303 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 304 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 305 | 306 | -- Dump completed on 2011-11-22 17:37:56 307 | -------------------------------------------------------------------------------- /scripts/jquery.jnotify/gettingstarted.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Giva Labs - jNotify jQuery Plug-in | Giva 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 52 | 53 | 58 | 59 | 60 | 61 | 62 |

Giva Labs

63 |

jNotify jQuery Plug-in

64 | 65 |

Overview

66 |

67 | The jQuery jNotify plug-in is an unobtrusive notification system for web-based applications. 68 | Use jNotify to inform users when specific actions have completed on your site–such as 69 | when an AJAX operation complete. 70 |

71 | 72 |

73 | The jNotify plug-in is designed to replace code where you may have previously used the 74 | JavaScript alert() function to provide feedback to the user. The alert() function has 75 | two significant UI issues: 76 |

77 | 78 | 90 | 91 |

92 | The jNotify plug-in provides a light-weight (3KB minified) solution to all of these problems. 93 |

94 | 95 |

Requirements

96 |

In order to use the jNotify plug-in, you need the following:

97 | 101 |
102 | * 103 | This plug-in may work with older versions of jQuery in the 1.2 family. If you try using this with an older version of jQuery, you will need to include the jquery.dimensions.js plug-in (as of jQuery v1.2.6 the jquery.dimensions.js 104 | plug-in is included in the jQuery core.) 105 |
106 | 107 |

Usage

108 | 109 |

You can invoke a new notification using the following syntax:

110 | 111 |
$.jnotify(message, [options]);
112 | $.jnotify(message, delay);
113 | $.jnotify(message, sticky);
114 | $.jnotify(message, type, [delay/sticky]);
115 | 
116 | 117 |

Arguments

118 |
119 |
options
120 |
121 |

122 | This argument is optional and allows you to customize the settings used for 123 | each instance of the plug-in. For a list of all available options, see the Options section. 124 |

125 |
126 |
delay
127 |
128 |

129 | If the second argument is a number, then this is the same as setting the "delay" option. 130 |

131 |
132 |
sticky
133 |
134 |

135 | If the second argument is either true or false, then this is the same as setting the "sticky" option. 136 |

137 |
138 |
type
139 |
140 |

141 | If the second is a string, then this is the same as setting the "type" option. 142 |

143 |
144 |
delay/sticky
145 |
146 |

147 | If the second is a string, then you can supply an optional third argument which specifies either the delay speed (a number) 148 | or if the notification is to be considered "sticky" (a boolean.). 149 |

150 |
151 |
152 | 153 |

Public API

154 |
155 |
$.jnotify.setup(options)
156 |
157 |

Sets the default options to use for all jNotify notifications.

158 |
159 |
$.jnotify.pause()
160 |
161 |

Pauses any current non-sticky notifications from being removed from the queue.

162 |
163 |
$.jnotify.resume()
164 |
165 |

Resumes the notification queue if it has previously been paused.

166 |
167 |
168 | 169 |

Options

170 |

There are a number of options available for customizing the look and feel of the jNotify widget.

171 |
{
172 |   // define core settings
173 |     type: ""                                  // if a type is specified, then an additional class of classNotification 
174 |                                               // + type is created for each notification
175 |   , delay: 2000                               // the default time to show each notification (in milliseconds)
176 |   , sticky: false                             // determines if the message should be considered "sticky" (user 
177 |                                               // must manually close notification)
178 |   , closeLabel: "×"                     // the HTML to use for the "Close" link
179 |   , showClose: true                           // determines if the "Close" link should be shown if notification is also sticky
180 |   , fadeSpeed: 1000                           // the speed to fade messages out (in milliseconds)
181 |   , slideSpeed: 250                           // the speed used to slide messages out (in milliseconds)
182 |   
183 |   // define the class statements
184 |   , classContainer: "jnotify-container"       // className to use for the outer most container--this is where all the 
185 |                                               // notifications appear
186 |   , classNotification: "jnotify-notification" // className of the individual notification containers
187 |   , classBackground: "jnotify-background"     // className of the background layer for each notification container
188 |   , classClose: "jnotify-close"               // className to use for the "Close" link
189 |   , classMessage: "jnotify-message"           // className to use for the actual notification text container--this is 
190 |                                               // where the message is actually written
191 | 
192 |   // event handlers
193 |   , init: null                                // callback that occurs when the main jnotify container is created
194 |   , create: null                              // callback that occurs when when the note is created (occurs just before 
195 |                                               // appearing in DOM)
196 |   , beforeRemove: null                        // callback that occurs when before the notification starts to fade away
197 |   , remove: null                              // callback that occurs when notification is removed
198 |   , transition: null                          // allows you to overwrite how the transitions between messages are handled
199 |                                               // receives the following arguments:
200 |                                               //   container - jQuery object containing the notification
201 |                                               //   message   - jQuery object of the actual message
202 |                                               //   count     - the number of items left in queue
203 |                                               //   callback  - a function you must execute once your transition has executed
204 |                                               //   options   - the options used for this jnotify instance
205 | }
206 | 207 | 208 |

Getting Started

209 |

The first thing we need to do is to load the required CSS stylesheet and the JavaScript libraries used by the widget:

210 |
<!---// load the jNotify CSS stylesheet //--->
211 | <link type="text/css" href="./css/jquery.jnotify.css" rel="stylesheet" media="all" />
212 | 
213 | <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
214 | <script type="text/javascript" src="./lib/jquery.jnotify.js"></script>
215 | 216 |

217 | Once you've added the jNotify plug-in to your HTML page, all you need to do is to invoke the $.jnotify() method whenever you want 218 | to display a message to the user. 219 |

220 | 221 |

Examples

222 |
223 | [Run] 224 | $.jnotify("This is a default notification."); 225 |
226 | 227 |
228 | [Run] 229 | $.jnotify("This is a notification with a 5 second delay.", 5000); 230 |
231 | 232 |
233 | [Run] 234 | $.jnotify("This is a sticky notification.", true); 235 |
236 | 237 |
238 | [Run] 239 | $.jnotify("This is an \"warning\" notification.", "warning"); 240 |
241 | 242 |
243 | [Run] 244 | $.jnotify("This is an \"error\" notification.", "error"); 245 |
246 | 247 |
248 | [Run] 249 | $.jnotify("This is a sticky \"error\" notification.", "error", true); 250 |
251 | 252 |
253 | [Run] 254 | $.jnotify("This notification shows an alert() when the notification is removed.", {remove: function (){ alert('removed!');}}); 255 |
256 | 257 |

258 | The plug-in has been designed to use CSS to all formatting and layout of the notification system. Try clicking the buttons below to see 259 | how easily you can change the default styles just by changing the CSS. 260 |

261 | 262 |

263 | 264 | 265 |

266 | 267 | 268 |

Support

269 |

This source code is provided as-is. At this time Giva is not offering direct support for this product. If you are in need of assistance, post your question to one of the jQuery Mailing Lists. Members of the Giva development team actively participate on the jQuery Mailing lists, so if we see your question we will try our best to respond.

270 | 271 |

License

272 |
Copyright 2010 Giva, Inc. (http://www.givainc.com/labs/) 
273 | 
274 | Licensed under the Apache License, Version 2.0 (the "License"); 
275 | you may not use this file except in compliance with the License. 
276 | You may obtain a copy of the License at 
277 | 	http://www.apache.org/licenses/LICENSE-2.0 
278 | 
279 | Unless required by applicable law or agreed to in writing, software 
280 | distributed under the License is distributed on an "AS IS" BASIS, 
281 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
282 | See the License for the specific language governing permissions and 
283 | limitations under the License.
284 | 285 |

286 | Revisions 287 |

288 |
289 |
v1.1.00 (2010-09-30)
290 |
291 | 294 |
295 |
296 | 297 | 298 | 299 | 300 | -------------------------------------------------------------------------------- /scripts/jquery.jeditable/jquery.jeditable.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Jeditable - jQuery in place edit plugin 3 | * 4 | * Copyright (c) 2006-2009 Mika Tuupola, Dylan Verheul 5 | * 6 | * Licensed under the MIT license: 7 | * http://www.opensource.org/licenses/mit-license.php 8 | * 9 | * Project home: 10 | * http://www.appelsiini.net/projects/jeditable 11 | * 12 | * Based on editable by Dylan Verheul : 13 | * http://www.dyve.net/jquery/?editable 14 | * 15 | */ 16 | 17 | /** 18 | * Version 1.7.1 19 | * 20 | * ** means there is basic unit tests for this parameter. 21 | * 22 | * @name Jeditable 23 | * @type jQuery 24 | * @param String target (POST) URL or function to send edited content to ** 25 | * @param Hash options additional options 26 | * @param String options[method] method to use to send edited content (POST or PUT) ** 27 | * @param Function options[callback] Function to run after submitting edited content ** 28 | * @param String options[name] POST parameter name of edited content 29 | * @param String options[id] POST parameter name of edited div id 30 | * @param Hash options[submitdata] Extra parameters to send when submitting edited content. 31 | * @param String options[type] text, textarea or select (or any 3rd party input type) ** 32 | * @param Integer options[rows] number of rows if using textarea ** 33 | * @param Integer options[cols] number of columns if using textarea ** 34 | * @param Mixed options[height] 'auto', 'none' or height in pixels ** 35 | * @param Mixed options[width] 'auto', 'none' or width in pixels ** 36 | * @param String options[loadurl] URL to fetch input content before editing ** 37 | * @param String options[loadtype] Request type for load url. Should be GET or POST. 38 | * @param String options[loadtext] Text to display while loading external content. 39 | * @param Mixed options[loaddata] Extra parameters to pass when fetching content before editing. 40 | * @param Mixed options[data] Or content given as paramameter. String or function.** 41 | * @param String options[indicator] indicator html to show when saving 42 | * @param String options[tooltip] optional tooltip text via title attribute ** 43 | * @param String options[event] jQuery event such as 'click' of 'dblclick' ** 44 | * @param String options[submit] submit button value, empty means no button ** 45 | * @param String options[cancel] cancel button value, empty means no button ** 46 | * @param String options[cssclass] CSS class to apply to input form. 'inherit' to copy from parent. ** 47 | * @param String options[style] Style to apply to input form 'inherit' to copy from parent. ** 48 | * @param String options[select] true or false, when true text is highlighted ?? 49 | * @param String options[placeholder] Placeholder text or html to insert when element is empty. ** 50 | * @param String options[onblur] 'cancel', 'submit', 'ignore' or function ?? 51 | * 52 | * @param Function options[onsubmit] function(settings, original) { ... } called before submit 53 | * @param Function options[onreset] function(settings, original) { ... } called before reset 54 | * @param Function options[onerror] function(settings, original, xhr) { ... } called on error 55 | * 56 | * @param Hash options[ajaxoptions] jQuery Ajax options. See docs.jquery.com. 57 | * 58 | */ 59 | 60 | (function($) { 61 | 62 | $.fn.editable = function(target, options) { 63 | 64 | if ('disable' == target) { 65 | $(this).data('disabled.editable', true); 66 | return; 67 | } 68 | if ('enable' == target) { 69 | $(this).data('disabled.editable', false); 70 | return; 71 | } 72 | if ('destroy' == target) { 73 | $(this) 74 | .unbind($(this).data('event.editable')) 75 | .removeData('disabled.editable') 76 | .removeData('event.editable'); 77 | return; 78 | } 79 | 80 | var settings = $.extend({}, $.fn.editable.defaults, {target:target}, options); 81 | 82 | /* setup some functions */ 83 | var plugin = $.editable.types[settings.type].plugin || function() { }; 84 | var submit = $.editable.types[settings.type].submit || function() { }; 85 | var buttons = $.editable.types[settings.type].buttons 86 | || $.editable.types['defaults'].buttons; 87 | var content = $.editable.types[settings.type].content 88 | || $.editable.types['defaults'].content; 89 | var element = $.editable.types[settings.type].element 90 | || $.editable.types['defaults'].element; 91 | var reset = $.editable.types[settings.type].reset 92 | || $.editable.types['defaults'].reset; 93 | var callback = settings.callback || function() { }; 94 | var onedit = settings.onedit || function() { }; 95 | var onsubmit = settings.onsubmit || function() { }; 96 | var onreset = settings.onreset || function() { }; 97 | var onerror = settings.onerror || reset; 98 | 99 | /* show tooltip */ 100 | if (settings.tooltip) { 101 | $(this).attr('title', settings.tooltip); 102 | } 103 | 104 | settings.autowidth = 'auto' == settings.width; 105 | settings.autoheight = 'auto' == settings.height; 106 | 107 | return this.each(function() { 108 | 109 | /* save this to self because this changes when scope changes */ 110 | var self = this; 111 | 112 | /* inlined block elements lose their width and height after first edit */ 113 | /* save them for later use as workaround */ 114 | var savedwidth = $(self).width(); 115 | var savedheight = $(self).height(); 116 | 117 | /* save so it can be later used by $.editable('destroy') */ 118 | $(this).data('event.editable', settings.event); 119 | 120 | /* if element is empty add something clickable (if requested) */ 121 | if (!$.trim($(this).html())) { 122 | $(this).html(settings.placeholder); 123 | } 124 | 125 | $(this).bind(settings.event, function(e) { 126 | 127 | /* abort if disabled for this element */ 128 | if (true === $(this).data('disabled.editable')) { 129 | return; 130 | } 131 | 132 | /* prevent throwing an exeption if edit field is clicked again */ 133 | if (self.editing) { 134 | return; 135 | } 136 | 137 | /* abort if onedit hook returns false */ 138 | if (false === onedit.apply(this, [settings, self])) { 139 | return; 140 | } 141 | 142 | /* prevent default action and bubbling */ 143 | e.preventDefault(); 144 | e.stopPropagation(); 145 | 146 | /* remove tooltip */ 147 | if (settings.tooltip) { 148 | $(self).removeAttr('title'); 149 | } 150 | 151 | /* figure out how wide and tall we are, saved width and height */ 152 | /* are workaround for http://dev.jquery.com/ticket/2190 */ 153 | if (0 == $(self).width()) { 154 | //$(self).css('visibility', 'hidden'); 155 | settings.width = savedwidth; 156 | settings.height = savedheight; 157 | } else { 158 | if (settings.width != 'none') { 159 | settings.width = 160 | settings.autowidth ? $(self).width() : settings.width; 161 | } 162 | if (settings.height != 'none') { 163 | settings.height = 164 | settings.autoheight ? $(self).height() : settings.height; 165 | } 166 | } 167 | //$(this).css('visibility', ''); 168 | 169 | /* remove placeholder text, replace is here because of IE */ 170 | if ($(this).html().toLowerCase().replace(/(;|")/g, '') == 171 | settings.placeholder.toLowerCase().replace(/(;|")/g, '')) { 172 | $(this).html(''); 173 | } 174 | 175 | self.editing = true; 176 | self.revert = $(self).html(); 177 | $(self).html(''); 178 | 179 | /* create the form object */ 180 | var form = $('
'); 181 | 182 | /* apply css or style or both */ 183 | if (settings.cssclass) { 184 | if ('inherit' == settings.cssclass) { 185 | form.attr('class', $(self).attr('class')); 186 | } else { 187 | form.attr('class', settings.cssclass); 188 | } 189 | } 190 | 191 | if (settings.style) { 192 | if ('inherit' == settings.style) { 193 | form.attr('style', $(self).attr('style')); 194 | /* IE needs the second line or display wont be inherited */ 195 | form.css('display', $(self).css('display')); 196 | } else { 197 | form.attr('style', settings.style); 198 | } 199 | } 200 | 201 | /* add main input element to form and store it in input */ 202 | var input = element.apply(form, [settings, self]); 203 | 204 | /* set input content via POST, GET, given data or existing value */ 205 | var input_content; 206 | 207 | if (settings.loadurl) { 208 | var t = setTimeout(function() { 209 | input.disabled = true; 210 | content.apply(form, [settings.loadtext, settings, self]); 211 | }, 100); 212 | 213 | var loaddata = {}; 214 | loaddata[settings.id] = self.id; 215 | if ($.isFunction(settings.loaddata)) { 216 | $.extend(loaddata, settings.loaddata.apply(self, [self.revert, settings])); 217 | } else { 218 | $.extend(loaddata, settings.loaddata); 219 | } 220 | $.ajax({ 221 | type : settings.loadtype, 222 | url : settings.loadurl, 223 | data : loaddata, 224 | async : false, 225 | success: function(result) { 226 | window.clearTimeout(t); 227 | input_content = result; 228 | input.disabled = false; 229 | } 230 | }); 231 | } else if (settings.data) { 232 | input_content = settings.data; 233 | if ($.isFunction(settings.data)) { 234 | input_content = settings.data.apply(self, [self.revert, settings]); 235 | } 236 | } else { 237 | input_content = self.revert; 238 | } 239 | content.apply(form, [input_content, settings, self]); 240 | 241 | input.attr('name', settings.name); 242 | 243 | /* add buttons to the form */ 244 | buttons.apply(form, [settings, self]); 245 | 246 | /* add created form to self */ 247 | $(self).append(form); 248 | 249 | /* attach 3rd party plugin if requested */ 250 | plugin.apply(form, [settings, self]); 251 | 252 | /* focus to first visible form element */ 253 | $(':input:visible:enabled:first', form).focus(); 254 | 255 | /* highlight input contents when requested */ 256 | if (settings.select) { 257 | input.select(); 258 | } 259 | 260 | /* discard changes if pressing esc */ 261 | input.keydown(function(e) { 262 | if (e.keyCode == 27) { 263 | e.preventDefault(); 264 | //self.reset(); 265 | reset.apply(form, [settings, self]); 266 | } 267 | }); 268 | 269 | /* discard, submit or nothing with changes when clicking outside */ 270 | /* do nothing is usable when navigating with tab */ 271 | var t; 272 | if ('cancel' == settings.onblur) { 273 | input.blur(function(e) { 274 | /* prevent canceling if submit was clicked */ 275 | t = setTimeout(function() { 276 | reset.apply(form, [settings, self]); 277 | }, 500); 278 | }); 279 | } else if ('submit' == settings.onblur) { 280 | input.blur(function(e) { 281 | /* prevent double submit if submit was clicked */ 282 | t = setTimeout(function() { 283 | form.submit(); 284 | }, 200); 285 | }); 286 | } else if ($.isFunction(settings.onblur)) { 287 | input.blur(function(e) { 288 | settings.onblur.apply(self, [input.val(), settings]); 289 | }); 290 | } else { 291 | input.blur(function(e) { 292 | /* TODO: maybe something here */ 293 | }); 294 | } 295 | 296 | form.submit(function(e) { 297 | 298 | if (t) { 299 | clearTimeout(t); 300 | } 301 | 302 | /* do no submit */ 303 | e.preventDefault(); 304 | 305 | /* call before submit hook. */ 306 | /* if it returns false abort submitting */ 307 | if (false !== onsubmit.apply(form, [settings, self])) { 308 | /* custom inputs call before submit hook. */ 309 | /* if it returns false abort submitting */ 310 | if (false !== submit.apply(form, [settings, self])) { 311 | 312 | /* check if given target is function */ 313 | if ($.isFunction(settings.target)) { 314 | var str = settings.target.apply(self, [input.val(), settings]); 315 | $(self).html(str); 316 | self.editing = false; 317 | callback.apply(self, [self.innerHTML, settings]); 318 | /* TODO: this is not dry */ 319 | if (!$.trim($(self).html())) { 320 | $(self).html(settings.placeholder); 321 | } 322 | } else { 323 | /* add edited content and id of edited element to POST */ 324 | var submitdata = {}; 325 | submitdata[settings.name] = input.val(); 326 | submitdata[settings.id] = self.id; 327 | /* add extra data to be POST:ed */ 328 | if ($.isFunction(settings.submitdata)) { 329 | $.extend(submitdata, settings.submitdata.apply(self, [self.revert, settings])); 330 | } else { 331 | $.extend(submitdata, settings.submitdata); 332 | } 333 | 334 | /* quick and dirty PUT support */ 335 | if ('PUT' == settings.method) { 336 | submitdata['_method'] = 'put'; 337 | } 338 | 339 | /* show the saving indicator */ 340 | $(self).html(settings.indicator); 341 | 342 | /* defaults for ajaxoptions */ 343 | var ajaxoptions = { 344 | type : 'POST', 345 | data : submitdata, 346 | dataType: 'html', 347 | url : settings.target, 348 | success : function(result, status) { 349 | if (ajaxoptions.dataType == 'html') { 350 | $(self).html(result); 351 | } 352 | self.editing = false; 353 | callback.apply(self, [result, settings]); 354 | if (!$.trim($(self).html())) { 355 | $(self).html(settings.placeholder); 356 | } 357 | }, 358 | error : function(xhr, status, error) { 359 | onerror.apply(form, [settings, self, xhr]); 360 | } 361 | }; 362 | 363 | /* override with what is given in settings.ajaxoptions */ 364 | $.extend(ajaxoptions, settings.ajaxoptions); 365 | $.ajax(ajaxoptions); 366 | 367 | } 368 | } 369 | } 370 | 371 | /* show tooltip again */ 372 | $(self).attr('title', settings.tooltip); 373 | 374 | return false; 375 | }); 376 | }); 377 | 378 | /* privileged methods */ 379 | this.reset = function(form) { 380 | /* prevent calling reset twice when blurring */ 381 | if (this.editing) { 382 | /* before reset hook, if it returns false abort reseting */ 383 | if (false !== onreset.apply(form, [settings, self])) { 384 | $(self).html(self.revert); 385 | self.editing = false; 386 | if (!$.trim($(self).html())) { 387 | $(self).html(settings.placeholder); 388 | } 389 | /* show tooltip again */ 390 | if (settings.tooltip) { 391 | $(self).attr('title', settings.tooltip); 392 | } 393 | } 394 | } 395 | }; 396 | }); 397 | 398 | }; 399 | 400 | 401 | $.editable = { 402 | types: { 403 | defaults: { 404 | element : function(settings, original) { 405 | var input = $(''); 406 | $(this).append(input); 407 | return(input); 408 | }, 409 | content : function(string, settings, original) { 410 | $(':input:first', this).val(string); 411 | }, 412 | reset : function(settings, original) { 413 | original.reset(this); 414 | }, 415 | buttons : function(settings, original) { 416 | var form = this; 417 | if (settings.submit) { 418 | /* if given html string use that */ 419 | if (settings.submit.match(/>$/)) { 420 | var submit = $(settings.submit).click(function() { 421 | if (submit.attr("type") != "submit") { 422 | form.submit(); 423 | } 424 | }); 425 | /* otherwise use button with given string as text */ 426 | } else { 427 | var submit = $('