diff --git a/DesignSurvey/Age_groups.php b/DesignSurvey/Age_groups.php new file mode 100644 index 0000000000000000000000000000000000000000..411d95d1073abb0b6e9217edc6ca7578d8d46a4f --- /dev/null +++ b/DesignSurvey/Age_groups.php @@ -0,0 +1,24 @@ +<?php +/** + * Table Definition for age_groups + */ +require_once 'DB/DataObject.php'; + +class DesignSurvey_Age_groups extends DB_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + var $__table = 'age_groups'; // table name + var $id; // int(11) not_null primary_key auto_increment + var $age_group; // string(50) not_null + + /* ZE2 compatibility trick*/ + function __clone() { return $this;} + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Age_groups',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE +} diff --git a/DesignSurvey/Audiences.php b/DesignSurvey/Audiences.php new file mode 100644 index 0000000000000000000000000000000000000000..51b1866bd3f46658450dff514a1fc533162be32b --- /dev/null +++ b/DesignSurvey/Audiences.php @@ -0,0 +1,24 @@ +<?php +/** + * Table Definition for audiences + */ +require_once 'DB/DataObject.php'; + +class DesignSurvey_Audiences extends DB_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + var $__table = 'audiences'; // table name + var $id; // int(11) not_null primary_key auto_increment + var $audience; // string(50) not_null + + /* ZE2 compatibility trick*/ + function __clone() { return $this;} + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Audiences',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE +} diff --git a/DesignSurvey/Prototype.php b/DesignSurvey/Prototype.php new file mode 100644 index 0000000000000000000000000000000000000000..1b7b7c8200bca32879a20a3d80c5e04aae33de88 --- /dev/null +++ b/DesignSurvey/Prototype.php @@ -0,0 +1,27 @@ +<?php +/** + * Table Definition for prototype + */ +require_once 'DB/DataObject.php'; + +class DesignSurvey_Prototype extends DB_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + var $__table = 'prototype'; // table name + var $id; // int(11) not_null primary_key auto_increment + var $title; // string(20) multiple_key + var $splash_image; // string(255) not_null + var $full_image; // string(255) + var $thumb_image; // string(255) + + /* ZE2 compatibility trick*/ + function __clone() { return $this;} + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Prototype',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE +} diff --git a/DesignSurvey/Prototype_ranking.php b/DesignSurvey/Prototype_ranking.php new file mode 100644 index 0000000000000000000000000000000000000000..b0e13a16460eea64977885fc60eb80be256309f4 --- /dev/null +++ b/DesignSurvey/Prototype_ranking.php @@ -0,0 +1,28 @@ +<?php +/** + * Table Definition for prototype_ranking + */ +require_once 'DB/DataObject.php'; + +class DesignSurvey_Prototype_ranking extends DB_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + var $__table = 'prototype_ranking'; // table name + var $id; // int(11) not_null primary_key auto_increment + var $voter_id; // int(11) not_null multiple_key + var $prototype_id; // int(11) not_null + var $rank; // int(11) not_null + var $why_response; // blob(16777215) blob + var $improve_response; // blob(16777215) blob + + /* ZE2 compatibility trick*/ + function __clone() { return $this;} + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Prototype_ranking',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE +} diff --git a/DesignSurvey/Prototype_rating.php b/DesignSurvey/Prototype_rating.php new file mode 100644 index 0000000000000000000000000000000000000000..b313ea3bc9b92e3f3ddbe2ed2ebf8cb57709713b --- /dev/null +++ b/DesignSurvey/Prototype_rating.php @@ -0,0 +1,26 @@ +<?php +/** + * Table Definition for prototype_rating + */ +require_once 'DB/DataObject.php'; + +class DesignSurvey_Prototype_rating extends DB_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + var $__table = 'prototype_rating'; // table name + var $id; // int(11) not_null primary_key auto_increment + var $voter_id; // int(11) not_null multiple_key + var $prototype_id; // int(11) not_null + var $rating; // int(11) not_null + + /* ZE2 compatibility trick*/ + function __clone() { return $this;} + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Prototype_rating',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE +} diff --git a/DesignSurvey/Prototype_sent.php b/DesignSurvey/Prototype_sent.php new file mode 100644 index 0000000000000000000000000000000000000000..883b0a99685e86a5d5cc37fd49f093659720459e --- /dev/null +++ b/DesignSurvey/Prototype_sent.php @@ -0,0 +1,25 @@ +<?php +/** + * Table Definition for prototype_sent + */ +require_once 'DB/DataObject.php'; + +class DesignSurvey_Prototype_sent extends DB_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + var $__table = 'prototype_sent'; // table name + var $id; // int(11) not_null primary_key auto_increment + var $voter_id; // int(11) not_null multiple_key + var $prototype_id; // int(11) not_null + + /* ZE2 compatibility trick*/ + function __clone() { return $this;} + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Prototype_sent',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE +} diff --git a/DesignSurvey/Questions.php b/DesignSurvey/Questions.php new file mode 100644 index 0000000000000000000000000000000000000000..4ff0a689a3e4912855e4786f7f54dd719dbde98a --- /dev/null +++ b/DesignSurvey/Questions.php @@ -0,0 +1,28 @@ +<?php +/** + * Table Definition for questions + */ +require_once 'DB/DataObject.php'; + +class DesignSurvey_Questions extends DB_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + var $__table = 'questions'; // table name + var $id; // int(11) not_null primary_key auto_increment + var $audience_id; // int(11) not_null + var $question; // string(255) not_null + + /* ZE2 compatibility trick*/ + function __clone() { return $this;} + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Questions',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE + + var $fb_linkDisplayFields = array('question'); + +} diff --git a/DesignSurvey/Rating_lead_questions.php b/DesignSurvey/Rating_lead_questions.php new file mode 100644 index 0000000000000000000000000000000000000000..e2ffd4f614531d0027f71b7a3d18c3f264250aee --- /dev/null +++ b/DesignSurvey/Rating_lead_questions.php @@ -0,0 +1,24 @@ +<?php +/** + * Table Definition for rating_lead_questions + */ +require_once 'DB/DataObject.php'; + +class DesignSurvey_Rating_lead_questions extends DB_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + var $__table = 'rating_lead_questions'; // table name + var $id; // int(11) not_null primary_key auto_increment + var $lead_question; // string(255) not_null + + /* ZE2 compatibility trick*/ + function __clone() { return $this;} + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Rating_lead_questions',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE +} diff --git a/DesignSurvey/Rating_questions.php b/DesignSurvey/Rating_questions.php new file mode 100644 index 0000000000000000000000000000000000000000..3d7b8aaf278e545f3824837a4076fce367279704 --- /dev/null +++ b/DesignSurvey/Rating_questions.php @@ -0,0 +1,26 @@ +<?php +/** + * Table Definition for rating_questions + */ +require_once 'DB/DataObject.php'; + +class DesignSurvey_Rating_questions extends DB_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + var $__table = 'rating_questions'; // table name + var $id; // int(11) not_null primary_key auto_increment + var $audience_id; // int(11) not_null multiple_key + var $lead_question_id; // int(11) not_null multiple_key + var $question; // string(50) not_null + + /* ZE2 compatibility trick*/ + function __clone() { return $this;} + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Rating_questions',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE +} diff --git a/DesignSurvey/Rating_responses.php b/DesignSurvey/Rating_responses.php new file mode 100644 index 0000000000000000000000000000000000000000..73dfa6e70675963ed34002e1f2f669600a44197a --- /dev/null +++ b/DesignSurvey/Rating_responses.php @@ -0,0 +1,26 @@ +<?php +/** + * Table Definition for rating_responses + */ +require_once 'DB/DataObject.php'; + +class DesignSurvey_Rating_responses extends DB_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + var $__table = 'rating_responses'; // table name + var $id; // int(11) not_null primary_key auto_increment + var $voter_id; // int(11) not_null multiple_key + var $question_id; // int(11) not_null + var $response; // int(11) + + /* ZE2 compatibility trick*/ + function __clone() { return $this;} + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Rating_responses',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE +} diff --git a/DesignSurvey/Responses.php b/DesignSurvey/Responses.php new file mode 100644 index 0000000000000000000000000000000000000000..ee2185cb0bfc6dfb1d9c981e39f05a3da8581a44 --- /dev/null +++ b/DesignSurvey/Responses.php @@ -0,0 +1,26 @@ +<?php +/** + * Table Definition for responses + */ +require_once 'DB/DataObject.php'; + +class DesignSurvey_Responses extends DB_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + var $__table = 'responses'; // table name + var $id; // int(11) not_null primary_key auto_increment + var $voter_id; // int(11) not_null multiple_key + var $question_id; // int(11) not_null + var $response; // blob(16777215) blob + + /* ZE2 compatibility trick*/ + function __clone() { return $this;} + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Responses',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE +} diff --git a/DesignSurvey/Voter.php b/DesignSurvey/Voter.php new file mode 100644 index 0000000000000000000000000000000000000000..93fb45de323bdc8a2b9a5b6035485a0c41856f80 --- /dev/null +++ b/DesignSurvey/Voter.php @@ -0,0 +1,30 @@ +<?php +/** + * Table Definition for voter + */ +require_once 'DB/DataObject.php'; + +class DesignSurvey_Voter extends DB_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + var $__table = 'voter'; // table name + var $id; // int(11) not_null primary_key auto_increment + var $audience_id; // int(11) + var $age_group_id; // int(11) + var $gender; // string(1) + var $ip; // string(15) not_null + var $step; // int(10) unsigned + var $prototype_order; // blob(16777215) blob + var $submitdatetime; // datetime(19) + + /* ZE2 compatibility trick*/ + function __clone() { return $this;} + + /* Static get */ + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Voter',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE +} diff --git a/DesignSurvey/designsurvey.ini b/DesignSurvey/designsurvey.ini new file mode 100644 index 0000000000000000000000000000000000000000..f7160a4a36e0b0ab9ff4421e89f335ef5ee3c5eb --- /dev/null +++ b/DesignSurvey/designsurvey.ini @@ -0,0 +1,107 @@ + +[age_groups] +id = 129 +age_group = 130 + +[age_groups__keys] +id = N + +[audiences] +id = 129 +audience = 130 + +[audiences__keys] +id = N + +[prototype] +id = 129 +title = 2 +splash_image = 130 +full_image = 2 +thumb_image = 2 + +[prototype__keys] +id = N + +[prototype_ranking] +id = 129 +voter_id = 129 +prototype_id = 129 +rank = 129 +why_response = 66 +improve_response = 66 + +[prototype_ranking__keys] +id = N + +[prototype_rating] +id = 129 +voter_id = 129 +prototype_id = 129 +rating = 129 + +[prototype_rating__keys] +id = N + +[prototype_sent] +id = 129 +voter_id = 129 +prototype_id = 129 + +[prototype_sent__keys] +id = N + +[questions] +id = 129 +audience_id = 129 +question = 130 + +[questions__keys] +id = N + +[rating_lead_questions] +id = 129 +lead_question = 130 + +[rating_lead_questions__keys] +id = N + +[rating_questions] +id = 129 +audience_id = 129 +lead_question_id = 129 +question = 130 + +[rating_questions__keys] +id = N + +[rating_responses] +id = 129 +voter_id = 129 +question_id = 129 +response = 1 + +[rating_responses__keys] +id = N + +[responses] +id = 129 +voter_id = 129 +question_id = 129 +response = 66 + +[responses__keys] +id = N + +[voter] +id = 129 +audience_id = 1 +age_group_id = 1 +gender = 2 +ip = 130 +step = 1 +prototype_order = 66 +submitdatetime = 14 + +[voter__keys] +id = N diff --git a/DesignSurvey/designsurvey.links.ini b/DesignSurvey/designsurvey.links.ini new file mode 100644 index 0000000000000000000000000000000000000000..6898f862db2cb527bc05e141b5403147dbaafc37 --- /dev/null +++ b/DesignSurvey/designsurvey.links.ini @@ -0,0 +1,31 @@ +[prototype_ranking] +voter_id = voter:id +prototype_id = prototypes:id + +[prototype_rating] +voter_id = voter:id +prototype_id = prototypes:id + +[prototype_sent] +voter_id = voter:id +prototype_id = prototypes:id + +[questions] +audience_id = audiences:id + +[rating_questions] +audience_id = audiences:id +lead_question_id = rating_lead_questions:id + +[rating_responses] +voter_id = voter:id +prototype_id = prototypes:id + +[responses] +voter_id = voter:id +prototype_id = prototypes:id +question_id = questions:id + +[voter] +age_group_id = age_groups:id +audience_id = audiences:id diff --git a/ajax_client.js b/ajax_client.js new file mode 100644 index 0000000000000000000000000000000000000000..5e1190d2ee1544e5a3ca6d572270e1546d2d1a69 --- /dev/null +++ b/ajax_client.js @@ -0,0 +1,2763 @@ +// Main.js +/** + * JavaScript library for use with HTML_AJAX + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to: + * Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * @category HTML + * @package Ajax + * @author Joshua Eichorn <josh@bluga.net> + * @author Arpad Ray <arpad@php.net> + * @author David Coallier <davidc@php.net> + * @author Elizabeth Smith <auroraeosrose@gmail.com> + * @copyright 2005 Joshua Eichorn, Arpad Ray, David Coallier, Elizabeth Smith + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ + +/** + * Functions for compatibility with older browsers + */ +if (!String.fromCharCode && !String.prototype.fromCharCode) { + String.prototype.fromCharCode = function(code) + { + var h = code.toString(16); + if (h.length == 1) { + h = '0' + h; + } + return unescape('%' + h); + } +} +if (!String.charCodeAt && !String.prototype.charCodeAt) { + String.prototype.charCodeAt = function(index) + { + var c = this.charAt(index); + for (i = 1; i < 256; i++) { + if (String.fromCharCode(i) == c) { + return i; + } + } + } +} +// http://www.crockford.com/javascript/remedial.html +if (!Array.splice && !Array.prototype.splice) { + Array.prototype.splice = function(s, d) + { + var max = Math.max, + min = Math.min, + a = [], // The return value array + e, // element + i = max(arguments.length - 2, 0), // insert count + k = 0, + l = this.length, + n, // new length + v, // delta + x; // shift count + + s = s || 0; + if (s < 0) { + s += l; + } + s = max(min(s, l), 0); // start point + d = max(min(typeof d == 'number' ? d : l, l - s), 0); // delete count + v = i - d; + n = l + v; + while (k < d) { + e = this[s + k]; + if (!e) { + a[k] = e; + } + k += 1; + } + x = l - s - d; + if (v < 0) { + k = s + i; + while (x) { + this[k] = this[k - v]; + k += 1; + x -= 1; + } + this.length = n; + } else if (v > 0) { + k = 1; + while (x) { + this[n - k] = this[l - k]; + k += 1; + x -= 1; + } + } + for (k = 0; k < i; ++k) { + this[s + k] = arguments[k + 2]; + } + return a; + } +} +if (!Array.push && !Array.prototype.push) { + Array.prototype.push = function() + { + for (var i = 0, startLength = this.length; i < arguments.length; i++) { + this[startLength + i] = arguments[i]; + } + return this.length; + } +} +if (!Array.pop && !Array.prototype.pop) { + Array.prototype.pop = function() + { + return this.splice(this.length - 1, 1)[0]; + } +} + +/** + * HTML_AJAX static methods, this is the main proxyless api, it also handles global error and event handling + */ +var HTML_AJAX = { + defaultServerUrl: false, + defaultEncoding: 'Null', + queues: false, + clientPools: {}, + // get an HttpClient, supply a name to use the pool of that name or the default if it isn't found + httpClient: function(name) { + if (name) { + if (this.clientPools[name]) { + return this.clientPools[name].getClient(); + } + } + return this.clientPools['default'].getClient(); + }, + // Pushing the given request to queue specified by it, in default operation this will immediately make a request + // request might be delayed or never happen depending on the queue setup + // making a sync request to a non immediate queue will cause you problems so just don't do it + makeRequest: function(request) { + if (!HTML_AJAX.queues[request.queue]) { + var e = new Error('Unknown Queue: '+request.queue); + if (HTML_AJAX.onError) { + HTML_AJAX.onError(e); + return false; + } + else { + throw(e); + } + } + else { + var qn = request.queue; + var q = HTML_AJAX.queues[qn]; + + HTML_AJAX.queues[request.queue].addRequest(request); + return HTML_AJAX.queues[request.queue].processRequest(); + } + }, + // get a serializer object for a specific encoding + serializerForEncoding: function(encoding) { + for(var i in HTML_AJAX.contentTypeMap) { + if (encoding == HTML_AJAX.contentTypeMap[i] || encoding == i) { + return eval("new HTML_AJAX_Serialize_"+i+";"); + } + } + return new HTML_AJAX_Serialize_Null(); + }, + fullcall: function(url,encoding,className,method,callback,args, customHeaders, grab) { + var serializer = HTML_AJAX.serializerForEncoding(encoding); + + var request = new HTML_AJAX_Request(serializer); + if (callback) { + request.isAsync = true; + } + request.requestUrl = url; + request.className = className; + request.methodName = method; + request.callback = callback; + request.args = args; + if (customHeaders) { + request.customHeaders = customHeaders; + } + if (grab) { + request.grab = true; + if (!args || !args.length) { + request.requestType = 'GET'; + } + } + + return HTML_AJAX.makeRequest(request); + }, + call: function(className,method,callback) { + var args = new Array(); + for(var i = 3; i < arguments.length; i++) { + args.push(arguments[i]); + } + return HTML_AJAX.fullcall(HTML_AJAX.defaultServerUrl,HTML_AJAX.defaultEncoding,className,method,callback,args); + }, + grab: function(url,callback) { + return HTML_AJAX.fullcall(url,'Null',false,null,callback, '', false, true); + }, + replace: function(id) { + var callback = function(result) { + document.getElementById(id).innerHTML = result; + } + if (arguments.length == 2) { + // grab replacement + HTML_AJAX.grab(arguments[1],callback); + } + else { + // call replacement + var args = new Array(); + for(var i = 3; i < arguments.length; i++) { + args.push(arguments[i]); + } + HTML_AJAX.fullcall(HTML_AJAX.defaultServerUrl,HTML_AJAX.defaultEncoding,arguments[1],arguments[2],callback,args, false, true); + } + }, + append: function(id) { + var callback = function(result) { + document.getElementById(id).innerHTML += result; + } + if (arguments.length == 2) { + // grab replacement + HTML_AJAX.grab(arguments[1],callback); + } + else { + // call replacement + var args = new Array(); + for(var i = 3; i < arguments.length; i++) { + args.push(arguments[i]); + } + HTML_AJAX.fullcall(HTML_AJAX.defaultServerUrl,HTML_AJAX.defaultEncoding,arguments[1],arguments[2],callback,args, false, true); + } + }, + // override to add top level loading notification (start) + Open: function(request) { + }, + // override to add top level loading notification (finish) + Load: function(request) { + }, + /* + // A really basic error handler + onError: function(e) { + msg = ""; + for(var i in e) { + msg += i+':'+e[i]+"\n"; + } + alert(msg); + }, + */ + // Class postfix to content-type map + contentTypeMap: { + 'JSON': 'application/json', + 'Null': 'text/plain', + 'Error': 'application/error', + 'PHP': 'application/php-serialized', + 'HA' : 'application/html_ajax_action', + 'Urlencoded': 'application/x-www-form-urlencoded' + }, + // used internally to make queues work, override Load or onError to perform custom events when a request is complete + // fires on success and error + requestComplete: function(request,error) { + for(var i in HTML_AJAX.queues) { + if (HTML_AJAX.queues[i].requestComplete) { + HTML_AJAX.queues[i].requestComplete(request,error); + } + } + }, + // submits a form through ajax. both arguments can be either DOM nodes or IDs, if the target is omitted then the form is set to be the target + formSubmit: function (form, target, customRequest) + { + if (typeof form == 'string') { + form = document.getElementById(form); + if (!form) { + // let the submit be processed normally + return false; + } + } + if (typeof target == 'string') { + target = document.getElementById('target'); + } + if (!target) { + target = form; + } + var action = form.action; + var el, type, value, name, nameParts, useValue = true; + var out = '', tags = form.elements; + childLoop: + for (i in tags) { + el = tags[i]; + if (!el || !el.getAttribute) { + continue; + } + name = el.getAttribute('name'); + if (!name) { + // no element name so skip + continue; + } + // find the element value + type = el.nodeName.toLowerCase(); + switch (type) { + case 'input': + var inpType = el.getAttribute('type'); + switch (inpType) { + case 'submit': + type = 'button'; + break; + case 'checkbox': + case 'radio': + if (el.checked) { + value = 'checked'; + useValue = false; + break; + } + // unchecked radios/checkboxes don't get submitted + continue childLoop; + case 'text': + default: + type = 'text'; + // continue for value + break; + } + break; + case 'button': + case 'textarea': + case 'select': + break; + default: + // unknown element + continue childLoop; + } + if (useValue) { + value = el.value; + } + // add element to output array + out += escape(name) + '=' + escape(value) + '&'; + useValue = true; + } // end childLoop + var callback = function(result) { + target.innerHTML = result; + } + + var serializer = HTML_AJAX.serializerForEncoding('Null'); + var request = new HTML_AJAX_Request(serializer); + request.isAsync = true; + request.callback = callback; + + switch (form.method.toLowerCase()) { + case 'post': + var headers = {}; + headers['Content-Type'] = 'application/x-www-form-urlencoded'; + request.customHeaders = headers; + request.requestType = 'POST'; + request.requestUrl = action; + request.args = out; + break; + default: + if (action.indexOf('?') == -1) { + out = '?' + out.substr(0, out.length - 1); + } + request.requestUrl = action+out; + request.requestType = 'GET'; + } + + if(customRequest) { + for(var i in customRequest) { + request[i] = customRequest[i]; + } + } + HTML_AJAX.makeRequest(request); + return true; + } // end formSubmit() +} + + + + +// small classes that I don't want to put in there own file + +function HTML_AJAX_Serialize_Null() {} +HTML_AJAX_Serialize_Null.prototype = { + contentType: 'text/plain; charset=UTF-8;', + serialize: function(input) { + return new String(input).valueOf(); + }, + + unserialize: function(input) { + return new String(input).valueOf(); + } +} + +// serialization class for JSON, wrapper for JSON.stringify in json.js +function HTML_AJAX_Serialize_JSON() {} +HTML_AJAX_Serialize_JSON.prototype = { + contentType: 'application/json; charset=UTF-8', + serialize: function(input) { + return HTML_AJAX_JSON.stringify(input); + }, + unserialize: function(input) { + try { + return eval(input); + } catch(e) { + // sometimes JSON encoded input isn't created properly, if eval of it fails we use the more forgiving but slower parser so will at least get something + return HTML_AJAX_JSON.parse(input); + } + } +} + +function HTML_AJAX_Serialize_Error() {} +HTML_AJAX_Serialize_Error.prototype = { + contentType: 'application/error; charset=UTF-8', + serialize: function(input) { + var ser = new HTML_AJAX_Serialize_JSON(); + return ser.serialize(input); + }, + unserialize: function(input) { + var ser = new HTML_AJAX_Serialize_JSON(); + var data = new ser.unserialize(input); + + var e = new Error('PHP Error: '+data.errStr); + for(var i in data) { + e[i] = data[i]; + } + throw e; + } +} + +// Processing Queues + +// simple queue, just processes the request immediately +function HTML_AJAX_Queue_Immediate() {} +HTML_AJAX_Queue_Immediate.prototype = { + request: false, + addRequest: function(request) { + this.request = request; + }, + processRequest: function() { + var client = HTML_AJAX.httpClient(); + client.request = this.request; + return client.makeRequest(); + } + // requestComplete: function() {} // this is also possible but this queue doesn't need it +} + +// Single Buffer queue with interval +// works by attempting to send a request every x miliseconds +// if an item is currently in the queue when a new item is added it will be replaced +// simple queue, just processes the request immediately +// the first request starts the interval timer +function HTML_AJAX_Queue_Interval_SingleBuffer(interval) { + this.interval = interval; +} +HTML_AJAX_Queue_Interval_SingleBuffer.prototype = { + request: false, + _intervalId: false, + addRequest: function(request) { + this.request = request; + }, + processRequest: function() { + if (!this._intervalId) { + this.runInterval(); + this.start(); + } + }, + start: function() { + var self = this; + this._intervalId = setInterval(function() { self.runInterval() },this.interval); + }, + stop: function() { + clearInterval(this._intervalId); + }, + runInterval: function() { + if (this.request) { + var client = HTML_AJAX.httpClient(); + client.request = this.request; + this.request = false; + client.makeRequest(); + } + } +} + + +// create a default queue, has to happen after the Queue class has been defined +HTML_AJAX.queues = new Object(); +HTML_AJAX.queues['default'] = new HTML_AJAX_Queue_Immediate(); + +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +// priorityQueue.js +/** + * Priority queue + * + * @category HTML + * @package AJAX + * @author Arpad Ray <arpad@rajeczy.com> + * @copyright 2005 Arpad Ray + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ + +function HTML_AJAX_Queue_Priority_Item(item, time) { + this.item = item; + this.time = time; +} +HTML_AJAX_Queue_Priority_Item.prototype = { + compareTo: function (other) { + var ret = this.item.compareTo(other.item); + if (ret == 0) { + ret = this.time - other.time; + } + return ret; + } +} + +function HTML_AJAX_Queue_Priority_Simple(interval) { + this.interval = interval; + this.idleMax = 10; // keep the interval going with an empty queue for 10 intervals + this.requestTimeout = 5; // retry uncompleted requests after 5 seconds + this.checkRetryChance = 0.1; // check for uncompleted requests to retry on 10% of intervals + this._intervalId = 0; + this._requests = []; + this._removed = []; + this._len = 0; + this._removedLen = 0; + this._idle = 0; +} +HTML_AJAX_Queue_Priority_Simple.prototype = { + isEmpty: function () { + return this._len == 0; + }, + addRequest: function (request) { + request = new HTML_AJAX_Queue_Priority_Item(request, new Date().getTime()); + ++this._len; + if (this.isEmpty()) { + this._requests[0] = request; + return; + } + for (i = 0; i < this._len - 1; i++) { + if (request.compareTo(this._requests[i]) < 0) { + this._requests.splice(i, 1, request, this._requests[i]); + return; + } + } + this._requests.push(request); + }, + peek: function () { + return (this.isEmpty() ? false : this._requests[0]); + }, + requestComplete: function (request) { + for (i = 0; i < this._removedLen; i++) { + if (this._removed[i].item == request) { + this._removed.splice(i, 1); + --this._removedLen; + out('removed from _removed'); + return true; + } + } + return false; + }, + processRequest: function() { + if (!this._intervalId) { + this._runInterval(); + this._start(); + } + this._idle = 0; + }, + _runInterval: function() { + if (Math.random() < this.checkRetryChance) { + this._doRetries(); + } + if (this.isEmpty()) { + if (++this._idle > this.idleMax) { + this._stop(); + } + return; + } + var client = HTML_AJAX.httpClient(); + if (!client) { + return; + } + var request = this.peek(); + if (!request) { + this._requests.splice(0, 1); + return; + } + client.request = request.item; + client.makeRequest(); + this._requests.splice(0, 1); + --this._len; + this._removed[this._removedLen++] = new HTML_AJAX_Queue_Priority_Item(request, new Date().getTime()); + }, + _doRetries: function () { + for (i = 0; i < this._removedLen; i++) { + if (this._removed[i].time + this._requestTimeout < new Date().getTime()) { + this.addRequest(request.item); + this._removed.splice(i, 1); + --this._removedLen; + return true; + } + } + }, + _start: function() { + var self = this; + this._intervalId = setInterval(function() { self._runInterval() }, this.interval); + }, + _stop: function() { + clearInterval(this._intervalId); + this._intervalId = 0; + } +};// clientPool.js +HTML_AJAX_Client_Pool = function(maxClients, startingClients) +{ + this.maxClients = maxClients; + this._clients = []; + this._len = 0; + while (--startingClients > 0) { + this.addClient(); + } +} + +HTML_AJAX_Client_Pool.prototype = { + isEmpty: function() + { + return this._len == 0; + }, + addClient: function() + { + if (this.maxClients != 0 && this._len > this.maxClients) { + return false; + } + var key = this._len++; + this._clients[key] = new HTML_AJAX_HttpClient(); + return this._clients[key]; + }, + getClient: function () + { + for (i = 0; i < this._len; i++) { + if (!this._clients[i].callInProgress()) { + return this._clients[i]; + } + } + var client = this.addClient(); + if (client) { + return client; + } + return false; + }, + removeClient: function (client) + { + for (i = 0; i < this._len; i++) { + if (!this._clients[i] == client) { + this._clients.splice(i, 1); + return true; + } + } + return false; + }, + clear: function () + { + this._clients = []; + this._len = 0; + } +}; + +// create a default client pool with unlimited clients +HTML_AJAX.clientPools['default'] = new HTML_AJAX_Client_Pool(0);// IframeXHR.js +/** + * XMLHttpRequest Iframe fallback + * + * http://lxr.mozilla.org/seamonkey/source/extensions/xmlextras/tests/ - should work with these + * + * @category HTML + * @package AJAX + * @author Elizabeth Smith <auroraeosrose@gmail.com> + * @copyright 2005 Elizabeth Smith + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ +HTML_AJAX_IframeXHR_instances = new Object(); +function HTML_AJAX_IframeXHR() +{ + this._id = 'HAXHR_iframe_' + new Date().getTime(); + HTML_AJAX_IframeXHR_instances[this._id] = this; +} +HTML_AJAX_IframeXHR.prototype = { +// Data not sent with text/xml Content-Type will only be available via the responseText property + + // properties available in safari/mozilla/IE xmlhttprequest object + onreadystatechange: null, // Event handler for an event that fires at every state change + readyState: 0, // Object status integer: 0 = uninitialized 1 = loading 2 = loaded 3 = interactive 4 = complete + responseText: '', // String version of data returned from server process + responseXML: null, // DOM-compatible document object of data returned from server process + status: 0, // Numeric code returned by server, such as 404 for "Not Found" or 200 for "OK" + statusText: '', // String message accompanying the status code + iframe: true, // flag for iframe + + //these are private properties used internally to keep track of stuff + _id: null, // iframe id, unique to object(hopefully) + _url: null, // url sent by open + _method: null, // get or post + _async: null, // sync or async sent by open + _headers: new Object(), //request headers to send, actually sent as form vars + _response: new Object(), //response headers received + _phpclass: null, //class to send + _phpmethod: null, //method to send + _history: null, // opera has to have history munging + + // Stops the current request + abort: function() + { + var iframe = document.getElementById(this._id); + if (iframe) { + document.body.removeChild(iframe); + } + if (this._timeout) { + window.clearTimeout(this._timeout); + } + this.readyState = 1; + if (typeof(this.onreadystatechange) == "function") { + this.onreadystatechange(); + } + }, + + // This will send all headers in this._response and will include lastModified and contentType if not already set + getAllResponseHeaders: function() + { + var string = ''; + for (i in this._response) { + string += i + ' : ' + this._response[i] + "\n"; + } + return string; + }, + + // This will use lastModified and contentType if they're not set + getResponseHeader: function(header) + { + return (this._response[header] ? this._response[header] : null); + }, + + // Assigns a label/value pair to the header to be sent with a request + setRequestHeader: function(label, value) { + this._headers[label] = value; + return; }, + + // Assigns destination URL, method, and other optional attributes of a pending request + open: function(method, url, async, username, password) + { + if (!document.body) { + throw('CANNOT_OPEN_SEND_IN_DOCUMENT_HEAD'); + } + //exceptions for not enough arguments + if (!method || !url) { + throw('NOT_ENOUGH_ARGUMENTS:METHOD_URL_REQUIRED'); + } + //get and post are only methods accepted + this._method = (method.toUpperCase() == 'POST' ? 'POST' : 'GET'); + this._decodeUrl(url); + this._async = async; + if(!this._async && document.readyState && !window.opera) { + throw('IE_DOES_NOT_SUPPORT_SYNC_WITH_IFRAMEXHR'); + } + //set status to loading and call onreadystatechange + this.readyState = 1; + if(typeof(this.onreadystatechange) == "function") { + this.onreadystatechange(); + } + }, + + // Transmits the request, optionally with postable string or DOM object data + send: function(content) + { + //attempt opera history munging + if (window.opera) { + this._history = window.history.length; + } + //create a "form" for the contents of the iframe + var form = '<html><body><form method="' + + (this._url.indexOf('px=') < 0 ? this._method : 'post') + + '" action="' + this._url + '">'; + //tell iframe unwrapper this IS an iframe + form += '<input name="Iframe_XHR" value="1" />'; + //class and method + if (this._phpclass != null) { + form += '<input name="Iframe_XHR_class" value="' + this._phpclass + '" />'; + } + if (this._phpmethod != null) { + form += '<input name="Iframe_XHR_method" value="' + this._phpmethod + '" />'; + } + // fake headers + for (label in this._headers) { + form += '<textarea name="Iframe_XHR_headers[]">' + label +':'+ this._headers[label] + '</textarea>'; + } + // add id + form += '<textarea name="Iframe_XHR_id">' + this._id + '</textarea>'; + if (content != null && content.length > 0) { + form += '<textarea name="Iframe_XHR_data">' + content + '</textarea>'; + } + form += '<input name="Iframe_XHR_HTTP_method" value="' + this._method + '" />'; + form += '<s'+'cript>document.forms[0].submit();</s'+'cript></form></body></html>'; + form = "javascript:document.write('" + form.replace(/\'/g,"\\'") + "');void(0);"; + this.readyState = 2; + if (typeof(this.onreadystatechange) == "function") { + this.onreadystatechange(); + } + // try to create an iframe with createElement and append node + try { + var iframe = document.createElement('iframe'); + iframe.id = this._id; + // display: none will fail on some browsers + iframe.style.visibility = 'hidden'; + // for old browsers with crappy css + iframe.style.border = '0'; + iframe.style.width = '0'; + iframe.style.height = '0'; + + if (document.all) { + // MSIE, opera + iframe.src = form; + document.body.appendChild(iframe); + } else { + document.body.appendChild(iframe); + iframe.src = form; + } + } catch(exception) { + // dom failed, write the sucker manually + var html = '<iframe src="' + form +'" id="' + this._id + '" style="visibility:hidden;border:0;height:0;width:0;"></iframe>'; + document.body.innerHTML += html; + } + if (this._async == true) { + //avoid race state if onload is called first + if (this.readyState < 3) { + this.readyState = 3; + if(typeof(this.onreadystatechange) == "function") { + this.onreadystatechange(); + } + } + } else { + //we force a while loop for sync, it's ugly but hopefully it works + while (this.readyState != 4) { + //just check to see if we can up readyState + if (this.readyState < 3) { + this.readyState = 3; + if(typeof(this.onreadystatechange) == "function") { + this.onreadystatechange(); + } + } + } + } + }, + + // attached as an onload function to the iframe to trigger when we're done + isLoaded: function(headers, data) + { + this.readyState = 4; + //set responseText, Status, StatusText + this.status = 200; + this.statusText = 'OK'; + this.responseText = data; + this._response = headers; + if (!this._response['Last-Modified']) { + string += 'Last-Modified : ' + document.getElementById(this._id).lastModified + "\n"; + } + if (!this._response['Content-Type']) { + string += 'Content-Type : ' + document.getElementById(this._id).contentType + "\n"; + } + //attempt opera history munging in opera 8+ - this is a REGRESSION IN OPERA + if (window.opera && window.opera.version) { + //go back current history - old history + window.history.go(this._history - window.history.length); + } + if (typeof(this.onreadystatechange) == "function") { + this.onreadystatechange(); + } + document.body.removeChild(document.getElementById(this._id)); + }, + + // strip off the c and m from the url send...yuck + _decodeUrl: function(querystring) + { + //opera 7 is too stupid to do a relative url...go figure + var url = unescape(location.href); + url = url.substring(0, url.lastIndexOf("/") + 1); + var item = querystring.split('?'); + //rip off any path info and append to path above <- relative paths (../) WILL screw this + this._url = url + item[0].substring(item[0].lastIndexOf("/") + 1,item[0].length); + if(item[1]) { + item = item[1].split('&'); + for (i in item) { + var v = item[i].split('='); + if (v[0] == 'c') { + this._phpclass = v[1]; + } else if (v[0] == 'm') { + this._phpmethod = v[1]; + } + } + } + if (!this._phpclass || !this._phpmethod) { + var cloc = window.location.href; + this._url = cloc + (cloc.indexOf('?') >= 0 ? '&' : '?') + 'px=' + escape(HTML_AJAX_Util.absoluteURL(querystring)); + } + } +} +// serializer/UrlSerializer.js +// {{{ HTML_AJAX_Serialize_Urlencoded +/** + * URL-encoding serializer + * + * This class can be used to serialize and unserialize data in a + * format compatible with PHP's handling of HTTP query strings. + * Due to limitations of the format, all input is serialized as an + * array or a string. See examples/serialize.url.examples.php + * + * @version 0.0.1 + * @copyright 2005 Arpad Ray <arpad@php.net> + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * + * See Main.js for Author/license details + */ +function HTML_AJAX_Serialize_Urlencoded() {} +HTML_AJAX_Serialize_Urlencoded.prototype = { + contentType: 'application/x-www-form-urlencoded; charset=UTF-8', + base: '_HTML_AJAX', + _keys: [], + error: false, + message: "", + cont: "", + // {{{ serialize + /** + * Serializes a variable + * + * @param mixed inp the variable to serialize + * @return string a string representation of the input, + * which can be reconstructed by unserialize() + */ + serialize: function(input, _internal) { + if (typeof input == 'undefined') { + return ''; + } + if (!_internal) { + this._keys = []; + } + var ret = '', first = true; + for (i = 0; i < this._keys.length; i++) { + ret += (first ? escape(this._keys[i]) : '[' + escape(this._keys[i]) + ']'); + first = false; + } + ret += '='; + switch (HTML_AJAX_Util.getType(input)) { + case 'string': + case 'number': + ret += escape(input.toString()); + break; + case 'boolean': + ret += (input ? '1' : '0'); + break; + case 'array': + case 'object': + ret = ''; + for (i in input) { + this._keys.push(i); + ret += this.serialize(input[i], true) + '&'; + this._keys.pop(); + } + ret = ret.substr(0, ret.length - 1); + } + return ret; + }, + // }}} + // {{{ unserialize + /** + * Reconstructs a serialized variable + * + * @param string inp the string to reconstruct + * @return array an array containing the variable represented by the input string, or void on failure + */ + unserialize: function(input) { + if (!input.length || input.length == 0) { + // null + return; + } + if (!/^(\w+(\[[^\[\]]*\])*=[^&]*(&|$))+$/.test(input)) { + this.raiseError("invalidly formed input", input); + return; + } + input = input.split("&"); + var pos, key, keys, val, _HTML_AJAX = []; + if (input.length == 1) { + return unescape(input[0].substr(this.base.length + 1)); + } + for (var i in input) { + pos = input[i].indexOf("="); + if (pos < 1 || input[i].length - pos - 1 < 1) { + this.raiseError("input is too short", input[i]); + return; + } + key = unescape(input[i].substr(0, pos)); + val = unescape(input[i].substr(pos + 1)); + key = key.replace(/\[((\d*\D+)+)\]/g, '["$1"]'); + keys = key.split(']'); + for (j in keys) { + if (!keys[j].length || keys[j].length == 0) { + continue; + } + try { + if (eval('typeof ' + keys[j] + ']') == 'undefined') { + var ev = keys[j] + ']=[];'; + eval(ev); + } + } catch (e) { + this.raiseError("error evaluating key", ev); + return; + } + } + try { + eval(key + '="' + val + '";'); + } catch (e) { + this.raiseError("error evaluating value", input); + return; + } + } + return _HTML_AJAX; + }, + // }}} + // {{{ getError + /** + * Gets the last error message + * + * @return string the last error message from unserialize() + */ + getError: function() { + return this.message + "\n" + this.cont; + }, + // }}} + // {{{ raiseError + /** + * Raises an eror (called by unserialize().) + * + * @param string message the error message + * @param string cont the remaining unserialized content + */ + raiseError: function(message, cont) { + this.error = 1; + this.message = message; + this.cont = cont; + } + // }}} +} +// }}} +// serializer/phpSerializer.js +// {{{ HTML_AJAX_Serialize_PHP +/** + * PHP serializer + * + * This class can be used to serialize and unserialize data in a + * format compatible with PHP's native serialization functions. + * + * @version 0.0.3 + * @copyright 2005 Arpad Ray <arpad@php.net> + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * + * See Main.js for Author/license details + */ +function HTML_AJAX_Serialize_PHP() {} +HTML_AJAX_Serialize_PHP.prototype = { + error: false, + message: "", + cont: "", + defaultEncoding: 'UTF-8', + contentType: 'application/php-serialized; charset: UTF-8', + // {{{ serialize + /** + * Serializes a variable + * + * @param mixed inp the variable to serialize + * @return string a string representation of the input, + * which can be reconstructed by unserialize() + * @author Arpad Ray <arpad@rajeczy.com> + * @author David Coallier <davidc@php.net> + */ + serialize: function(inp) { + var type = HTML_AJAX_Util.getType(inp); + var val; + switch (type) { + case "undefined": + val = "N"; + break; + case "boolean": + val = "b:" + (inp ? "1" : "0"); + break; + case "number": + val = (Math.round(inp) == inp ? "i" : "d") + ":" + inp; + break; + case "string": + val = "s:" + inp.length + ":\"" + inp + "\""; + break; + case "array": + val = "a"; + case "object": + if (type == "object") { + var objname = inp.constructor.toString().match(/(\w+)\(\)/); + if (objname == undefined) { + return; + } + objname[1] = this.serialize(objname[1]); + val = "O" + objname[1].substring(1, objname[1].length - 1); + } + var count = 0; + var vals = ""; + var okey; + for (key in inp) { + okey = (key.match(/^[0-9]+$/) ? parseInt(key) : key); + vals += this.serialize(okey) + + this.serialize(inp[key]); + count++; + } + val += ":" + count + ":{" + vals + "}"; + break; + } + if (type != "object" && type != "array") val += ";"; + return val; + }, + // }}} + // {{{ unserialize + /** + * Reconstructs a serialized variable + * + * @param string inp the string to reconstruct + * @return mixed the variable represented by the input string, or void on failure + */ + unserialize: function(inp) { + this.error = 0; + if (inp == "" || inp.length < 2) { + this.raiseError("input is too short"); + return; + } + var val, kret, vret, cval; + var type = inp.charAt(0); + var cont = inp.substring(2); + var size = 0, divpos = 0, endcont = 0, rest = "", next = ""; + + switch (type) { + case "N": // null + if (inp.charAt(1) != ";") { + this.raiseError("missing ; for null", cont); + } + // leave val undefined + rest = cont; + break; + case "b": // boolean + if (!/[01];/.test(cont.substring(0,2))) { + this.raiseError("value not 0 or 1, or missing ; for boolean", cont); + } + val = (cont.charAt(0) == "1"); + rest = cont.substring(1); + break; + case "s": // string + val = ""; + divpos = cont.indexOf(":"); + if (divpos == -1) { + this.raiseError("missing : for string", cont); + break; + } + size = parseInt(cont.substring(0, divpos)); + if (size == 0) { + if (cont.length - divpos < 4) { + this.raiseError("string is too short", cont); + break; + } + rest = cont.substring(divpos + 4); + break; + } + if ((cont.length - divpos - size) < 4) { + this.raiseError("string is too short", cont); + break; + } + if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\";") { + this.raiseError("string is too long, or missing \";", cont); + } + val = cont.substring(divpos + 2, divpos + 2 + size); + rest = cont.substring(divpos + 4 + size); + break; + case "i": // integer + case "d": // float + var dotfound = 0; + for (var i = 0; i < cont.length; i++) { + cval = cont.charAt(i); + if (isNaN(parseInt(cval)) && !(type == "d" && cval == "." && !dotfound++)) { + endcont = i; + break; + } + } + if (!endcont || cont.charAt(endcont) != ";") { + this.raiseError("missing or invalid value, or missing ; for int/float", cont); + } + val = cont.substring(0, endcont); + val = (type == "i" ? parseInt(val) : parseFloat(val)); + rest = cont.substring(endcont + 1); + break; + case "a": // array + if (cont.length < 4) { + this.raiseError("array is too short", cont); + return; + } + divpos = cont.indexOf(":", 1); + if (divpos == -1) { + this.raiseError("missing : for array", cont); + return; + } + size = parseInt(cont.substring(1, divpos - 1)); + cont = cont.substring(divpos + 2); + val = new Array(); + if (cont.length < 1) { + this.raiseError("array is too short", cont); + return; + } + for (var i = 0; i + 1 < size * 2; i += 2) { + kret = this.unserialize(cont, 1); + if (this.error || kret[0] == undefined || kret[1] == "") { + this.raiseError("missing or invalid key, or missing value for array", cont); + return; + } + vret = this.unserialize(kret[1], 1); + if (this.error) { + this.raiseError("invalid value for array", cont); + return; + } + val[kret[0]] = vret[0]; + cont = vret[1]; + } + if (cont.charAt(0) != "}") { + this.raiseError("missing ending }, or too many values for array", cont); + return; + } + rest = cont.substring(1); + break; + case "O": // object + divpos = cont.indexOf(":"); + if (divpos == -1) { + this.raiseError("missing : for object", cont); + return; + } + size = parseInt(cont.substring(0, divpos)); + var objname = cont.substring(divpos + 2, divpos + 2 + size); + if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\":") { + this.raiseError("object name is too long, or missing \":", cont); + return; + } + var objprops = this.unserialize("a:" + cont.substring(divpos + 4 + size), 1); + if (this.error) { + this.raiseError("invalid object properties", cont); + return; + } + rest = objprops[1]; + var objout = "function " + objname + "(){"; + for (key in objprops[0]) { + objout += "this." + key + "=objprops[0]['" + key + "'];"; + } + objout += "}val=new " + objname + "();"; + eval(objout); + break; + default: + this.raiseError("invalid input type", cont); + } + return (arguments.length == 1 ? val : [val, rest]); + }, + // }}} + // {{{ getError + /** + * Gets the last error message + * + * @return string the last error message from unserialize() + */ + getError: function() { + return this.message + "\n" + this.cont; + }, + // }}} + // {{{ raiseError + /** + * Raises an eror (called by unserialize().) + * + * @param string message the error message + * @param string cont the remaining unserialized content + */ + raiseError: function(message, cont) { + this.error = 1; + this.message = message; + this.cont = cont; + } + // }}} +} +// }}} + +// Dispatcher.js +/** + * Class that is used by generated stubs to make actual AJAX calls + * + * @category HTML + * @package AJAX + * @author Joshua Eichorn <josh@bluga.net> + * @copyright 2005 Joshua Eichorn + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ +function HTML_AJAX_Dispatcher(className,mode,callback,serverUrl,serializerType) +{ + this.className = className; + this.mode = mode; + this.callback = callback; + this.serializerType = serializerType; + + if (serverUrl) { + this.serverUrl = serverUrl + } + else { + this.serverUrl = window.location; + } +} + +HTML_AJAX_Dispatcher.prototype = { + /** + * Queue to use when making a request + */ + queue: 'default', + + /** + * Timeout for async calls + */ + timeout: 20000, + + /** + * Default request priority + */ + priority: 0, + + /** + * Make an ajax call + * + * @param string callName + * @param Array args arguments to the report method + */ + doCall: function(callName,args) + { + var request = new HTML_AJAX_Request(); + request.requestUrl = this.serverUrl; + request.className = this.className; + request.methodName = callName; + request.timeout = this.timeout; + request.contentType = this.contentType; + request.serializer = eval('new HTML_AJAX_Serialize_'+this.serializerType); + request.queue = this.queue; + request.priority = this.priority; + + for(var i=0; i < args.length; i++) { + request.addArg(i,args[i]); + }; + + if ( this.mode == "async" ) { + request.isAsync = true; + if (this.callback[callName]) { + var self = this; + request.callback = function(result) { self.callback[callName](result); } + } + + } else { + request.isAsync = false; + } + + return HTML_AJAX.makeRequest(request); + }, + + Sync: function() + { + this.mode = 'sync'; + }, + + Async: function(callback) + { + this.mode = 'async'; + if (callback) { + this.callback = callback; + } + } + +}; +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +// HttpClient.js +/** + * XMLHttpRequest Wrapper + * @category HTML + * @package AJAX + * @author Joshua Eichorn <josh@bluga.net> + * @copyright 2005 Joshua Eichorn + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + */ +function HTML_AJAX_HttpClient() { } +HTML_AJAX_HttpClient.prototype = { + // request object + request: null, + + // timeout id + _timeoutId: null, + + // method to initialize an xmlhttpclient + init:function() + { + try { + // Mozilla / Safari + //this.xmlhttp = new HTML_AJAX_IframeXHR(); //uncomment these two lines to test iframe + //return; + this.xmlhttp = new XMLHttpRequest(); + } catch (e) { + // IE + var XMLHTTP_IDS = new Array( + 'MSXML2.XMLHTTP.5.0', + 'MSXML2.XMLHTTP.4.0', + 'MSXML2.XMLHTTP.3.0', + 'MSXML2.XMLHTTP', + 'Microsoft.XMLHTTP' ); + var success = false; + for (var i=0;i < XMLHTTP_IDS.length && !success; i++) { + try { + this.xmlhttp = new ActiveXObject(XMLHTTP_IDS[i]); + success = true; + } catch (e) {} + } + if (!success) { + try{ + this.xmlhttp = new HTML_AJAX_IframeXHR(); + this.request.iframe = true; + } catch(e) { + throw new Error('Unable to create XMLHttpRequest.'); + } + } + } + }, + + // check if there is a call in progress + callInProgress: function() + { + switch ( this.xmlhttp.readyState ) { + case 1: + case 2: + case 3: + return true; + break; + default: + return false; + break; + } + }, + + // make the request defined in the request object + makeRequest: function() + { + if (!this.xmlhttp) { + this.init(); + } + + try { + if (this.request.Open) { + this.request.Open(); + } + else if (HTML_AJAX.Open) { + HTML_AJAX.Open(this.request); + } + + // set onreadystatechange here since it will be reset after a completed call in Mozilla + var self = this; + this.xmlhttp.open(this.request.requestType,this.request.completeUrl(),this.request.isAsync); + if (this.request.customHeaders) { + for (i in this.request.customHeaders) { + this.xmlhttp.setRequestHeader(i, this.request.customHeaders[i]); + } + } + if (this.request.customHeaders && !this.request.customHeaders['Content-Type']) { + //opera is stupid!! + if(window.opera) + { + this.xmlhttp.setRequestHeader('Content-Type','text/plain; charset=utf-8'); + this.xmlhttp.setRequestHeader('x-Content-Type',this.request.getContentType() + '; charset=utf-8'); + } + else + { + this.xmlhttp.setRequestHeader('Content-Type',this.request.getContentType() + '; charset=utf-8'); + } + } + this.xmlhttp.onreadystatechange = function() { self._readyStateChangeCallback(); } + var payload = this.request.getSerializedPayload(); + if (payload) { + this.xmlhttp.setRequestHeader('Content-Length', payload.length); + } + this.xmlhttp.send(payload); + + if (!this.request.isAsync) { + if ( this.xmlhttp.status == 200 ) { + HTML_AJAX.requestComplete(this.request); + if (this.request.Load) { + this.request.Load(); + } else if (HTML_AJAX.Load) { + HTML_AJAX.Load(this.request); + } + + return this._decodeResponse(); + } else { + var e = new Error('['+this.xmlhttp.status +'] '+this.xmlhttp.statusText); + e.headers = this.xmlhttp.getAllResponseHeaders(); + this._handleError(e); + } + } + else { + // setup timeout + var self = this; + this._timeoutId = window.setTimeout(function() { self.abort(true); },this.request.timeout); + } + } catch (e) { + this._handleError(e); + } + }, + + // abort an inprogress request + abort: function (automatic) + { + if (this.callInProgress()) { + this.xmlhttp.abort(); + + if (automatic) { + HTML_AJAX.requestComplete(this.request); + this._handleError(new Error('Request Timed Out: time out was '+this.request.timeout+'ms')); + } + } + }, + + // internal method used to handle ready state changes + _readyStateChangeCallback:function() + { + try { + switch(this.xmlhttp.readyState) { + // XMLHTTPRequest.open() has just been called + case 1: + break; + // XMLHTTPRequest.send() has just been called + case 2: + if (this.request.Send) { + this.request.Send(); + } else if (HTML_AJAX.Send) { + HTML_AJAX.Send(this.request); + } + break; + // Fetching response from server in progress + case 3: + if (this.request.Progress) { + this.request.Progress(); + } else if (HTML_AJAX.Progress ) { + HTML_AJAX.Progress(this.request); + } + break; + // Download complete + case 4: + window.clearTimeout(this._timeoutId); + + if (this.xmlhttp.status == 200) { + HTML_AJAX.requestComplete(this.request); + if (this.request.Load) { + this.request.Load(); + } else if (HTML_AJAX.Load ) { + HTML_AJAX.Load(this.request); + } + + if (this.request.callback) { + this.request.callback(this._decodeResponse()); + } + } + + else { + var e = new Error('HTTP Error Making Request: ['+this.xmlhttp.status+'] '+this.xmlhttp.statusText); + this._handleError(e); + } + break; + } + } catch (e) { + this._handleError(e); + } + }, + + // decode response as needed + _decodeResponse: function() { + //try for x-Content-Type first + var content = null; + try { + content = this.xmlhttp.getResponseHeader('X-Content-Type'); + } catch(e) {} + if(!content || content == null) + { + content = this.xmlhttp.getResponseHeader('Content-Type'); + } + //strip anything after ; + if(content.indexOf(';') != -1) + { + content = content.substring(0, content.indexOf(';')); + } + var unserializer = HTML_AJAX.serializerForEncoding(content); + //alert(this.xmlhttp.getAllResponseHeaders()); // some sort of debug hook is needed here + + // some sort of sane way for a serializer to ask for XML needs to be added + return unserializer.unserialize(this.xmlhttp.responseText); + }, + + // handle sending an error where it needs to go + _handleError: function(e) + { + HTML_AJAX.requestComplete(this.request,e); + if (this.request.onError) { + this.request.onError(e); + } else if (HTML_AJAX.onError) { + HTML_AJAX.onError(e,this.request); + } + else { + throw e; + } + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +// Request.js +/** + * Class that contains everything needed to make a request + * This includes: + * The url were calling + * If were calling a remote method, the class and method name + * The payload, unserialized + * The timeout for async calls + * The callback method + * Optional event handlers: onError, onLoad, onSend + * A serializer instance + * + * @category HTML + * @package AJAX + * @author Joshua Eichorn <josh@bluga.net> + * @copyright 2005 Joshua Eichorn + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * + * See Main.js for author/license details + */ +function HTML_AJAX_Request(serializer) { + this.serializer = serializer; +} +HTML_AJAX_Request.prototype = { + + // Instance of a serializer + serializer: null, + + // Is this an async request + isAsync: false, + + // HTTP verb + requestType: 'POST', + + // The actual URL the request is sent to + requestUrl: '', + + // Remote Class + className: null, + + // Remote Method + methodName: null, + + // Timeout in milliseconds for requests + timeout: 20000, + + // unserialized data, for rpc calls use add args, to send raw data just set this directly + args: null, + + // async callback method + callback: null, + + // Queue to push this request too + queue: 'default', + + // default priority + priority: 0, + + // a hash of headers to add to add to this request + customHeaders: {}, + + // true if this request will be sent using iframes + iframe: false, + + // is this a grab request? if so we need to proxy for iframes + grab: false, + + /** + * Add an argument for the remote method + * @param string argument name + * @param mixed value + * @return void + * @throws Error code 1004 + */ + addArg: function(name, value) + { + if ( !this.args ) { + this.args = []; + } + if (!/[^a-zA-Z_0-9]/.test(name) ) { + this.args[name] = value; + } else { + throw new Error('Invalid parameter name ('+name+')'); + } + }, + + /** + * Get the payload in a serialized manner + */ + getSerializedPayload: function() { + return this.serializer.serialize(this.args); + }, + + /** + * Get the content type + */ + getContentType: function() { + return this.serializer.contentType; + }, + + /** + * Get the complete url, adding in any needed get params for rpc + */ + completeUrl: function() { + var url = new String(this.requestUrl); + var delimiter = '?'; + if (url.indexOf('?') >= 0) { + delimiter = '&'; + } + if (this.className || this.methodName) { + url += delimiter+'c='+escape(this.className)+'&m='+escape(this.methodName); + } + return url; + }, + + /** + * Compare to another request by priority + */ + compareTo: function(other) { + if (this.priority == other.priority) { + return 0; + } + return (this.priority > other.priority ? 1 : -1); + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +// serializer/JSON.js +/* +Copyright (c) 2005 JSON.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The Software shall be used for Good, not Evil. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +Array.prototype.______array = '______array'; + +var HTML_AJAX_JSON = { + org: 'http://www.JSON.org', + copyright: '(c)2005 JSON.org', + license: 'http://www.crockford.com/JSON/license.html', + + stringify: function (arg) { + var c, i, l, s = '', v; + + switch (typeof arg) { + case 'object': + if (arg) { + if (arg.______array == '______array') { + for (i = 0; i < arg.length; ++i) { + v = this.stringify(arg[i]); + if (s) { + s += ','; + } + s += v; + } + return '[' + s + ']'; + } else if (typeof arg.toString != 'undefined') { + for (i in arg) { + v = arg[i]; + if (typeof v != 'undefined' && typeof v != 'function') { + v = this.stringify(v); + if (s) { + s += ','; + } + s += this.stringify(i) + ':' + v; + } + } + return '{' + s + '}'; + } + } + return 'null'; + case 'number': + return isFinite(arg) ? String(arg) : 'null'; + case 'string': + l = arg.length; + s = '"'; + for (i = 0; i < l; i += 1) { + c = arg.charAt(i); + if (c >= ' ') { + if (c == '\\' || c == '"') { + s += '\\'; + } + s += c; + } else { + switch (c) { + case '\b': + s += '\\b'; + break; + case '\f': + s += '\\f'; + break; + case '\n': + s += '\\n'; + break; + case '\r': + s += '\\r'; + break; + case '\t': + s += '\\t'; + break; + default: + c = c.charCodeAt(); + s += '\\u00' + Math.floor(c / 16).toString(16) + + (c % 16).toString(16); + } + } + } + return s + '"'; + case 'boolean': + return String(arg); + default: + return 'null'; + } + }, + parse: function (text) { + var at = 0; + var ch = ' '; + + function error(m) { + throw { + name: 'JSONError', + message: m, + at: at - 1, + text: text + }; + } + + function next() { + ch = text.charAt(at); + at += 1; + return ch; + } + + function white() { + while (ch) { + if (ch <= ' ') { + next(); + } else if (ch == '/') { + switch (next()) { + case '/': + while (next() && ch != '\n' && ch != '\r') {} + break; + case '*': + next(); + for (;;) { + if (ch) { + if (ch == '*') { + if (next() == '/') { + next(); + break; + } + } else { + next(); + } + } else { + error("Unterminated comment"); + } + } + break; + default: + error("Syntax error"); + } + } else { + break; + } + } + } + + function string() { + var i, s = '', t, u; + + if (ch == '"') { +outer: while (next()) { + if (ch == '"') { + next(); + return s; + } else if (ch == '\\') { + switch (next()) { + case 'b': + s += '\b'; + break; + case 'f': + s += '\f'; + break; + case 'n': + s += '\n'; + break; + case 'r': + s += '\r'; + break; + case 't': + s += '\t'; + break; + case 'u': + u = 0; + for (i = 0; i < 4; i += 1) { + t = parseInt(next(), 16); + if (!isFinite(t)) { + break outer; + } + u = u * 16 + t; + } + s += String.fromCharCode(u); + break; + default: + s += ch; + } + } else { + s += ch; + } + } + } + error("Bad string"); + } + + function array() { + var a = []; + + if (ch == '[') { + next(); + white(); + if (ch == ']') { + next(); + return a; + } + while (ch) { + a.push(value()); + white(); + if (ch == ']') { + next(); + return a; + } else if (ch != ',') { + break; + } + next(); + white(); + } + } + error("Bad array"); + } + + function object() { + var k, o = {}; + + if (ch == '{') { + next(); + white(); + if (ch == '}') { + next(); + return o; + } + while (ch) { + k = string(); + white(); + if (ch != ':') { + break; + } + next(); + o[k] = value(); + white(); + if (ch == '}') { + next(); + return o; + } else if (ch != ',') { + break; + } + next(); + white(); + } + } + error("Bad object"); + } + + function number() { + var n = '', v; + if (ch == '-') { + n = '-'; + next(); + } + while (ch >= '0' && ch <= '9') { + n += ch; + next(); + } + if (ch == '.') { + n += '.'; + while (next() && ch >= '0' && ch <= '9') { + n += ch; + } + } + if (ch == 'e' || ch == 'E') { + n += 'e'; + next(); + if (ch == '-' || ch == '+') { + n += ch; + next(); + } + while (ch >= '0' && ch <= '9') { + n += ch; + next(); + } + } + v = +n; + if (!isFinite(v)) { + ////error("Bad number"); + } else { + return v; + } + } + + function word() { + switch (ch) { + case 't': + if (next() == 'r' && next() == 'u' && next() == 'e') { + next(); + return true; + } + break; + case 'f': + if (next() == 'a' && next() == 'l' && next() == 's' && + next() == 'e') { + next(); + return false; + } + break; + case 'n': + if (next() == 'u' && next() == 'l' && next() == 'l') { + next(); + return null; + } + break; + } + error("Syntax error"); + } + + function value() { + white(); + switch (ch) { + case '{': + return object(); + case '[': + return array(); + case '"': + return string(); + case '-': + return number(); + default: + return ch >= '0' && ch <= '9' ? number() : word(); + } + } + + return value(); + } +}; +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +// serializer/haSerializer.js +/** + * HTML_AJAX_Serialize_HA - custom serialization + * + * This class is used with the JSON serializer and the HTML_AJAX_Action php class + * to allow users to easily write data handling and dom manipulation related to + * ajax actions directly from their php code + * + * See Main.js for Author/license details + */ +function HTML_AJAX_Serialize_HA() {} +HTML_AJAX_Serialize_HA.prototype = +{ + /** + * Takes data from JSON - which should be parseable into a nice array + * reads the action to take and pipes it to the right method + * + * @param string payload incoming data from php + * @return true on success, false on failure + */ + unserialize: function(payload) + { + var actions = eval(payload); + for(var i = 0; i < actions.length; i++) + { + var action = actions[i]; + switch(action.action) + { + case 'prepend': + this._prependAttr(action.id, action.attributes); + break; + case 'append': + this._appendAttr(action.id, action.attributes); + break; + case 'assign': + this._assignAttr(action.id, action.attributes); + break; + case 'clear': + this._clearAttr(action.id, action.attributes); + break; + case 'create': + this._createNode(action.id, action.tag, action.attributes, action.type); + break; + case 'replace': + this._replaceNode(action.id, action.tag, action.attributes); + break; + case 'remove': + this._removeNode(action.id); + break; + case 'script': + this._insertScript(action.data); + break; + case 'alert': + this._insertAlert(action.data); + break; + } + } + }, + _prependAttr: function(id, attributes) + { + var node = document.getElementById(id); + for (var i in attributes) + { + //innerHTML hack bailout + if(i == 'innerHTML') + { + node.innerHTML = attributes[i] + node.innerHTML; + } + //value hack + else if(i == 'value') + { + node.value = attributes[i]; + } + //I'd use hasAttribute but IE is stupid stupid stupid + else + { + var value = node.getAttribute(i); + if(value) + { + node.setAttribute(i, attributes[i] + value); + } + else + { + node.setAttribute(i, attributes[i]); + } + } + } + }, + _appendAttr: function(id, attributes) + { + var node = document.getElementById(id); + for (var i in attributes) + { + //innerHTML hack bailout + if(i == 'innerHTML') + { + node.innerHTML += attributes[i]; + } + //value hack + else if(i == 'value') + { + node.value = attributes[i]; + } + //I'd use hasAttribute but IE is stupid stupid stupid + else + { + var value = node.getAttribute(i); + if(value) + { + node.setAttribute(i, value + attributes[i]); + } + else + { + node.setAttribute(i, attributes[i]); + } + } + } + }, + _assignAttr: function(id, attributes) + { + var node = document.getElementById(id); + for (var i in attributes) + { + //innerHTML hack bailout + if(i == 'innerHTML') + { + node.innerHTML = attributes[i]; + } + //value hack + else if(i == 'value') + { + node.value = attributes[i]; + } + //I'd use hasAttribute but IE is stupid stupid stupid + else + { + //node.setAttribute(i, attributes[i]); + node[i] = attributes[i]; + } + } + }, + _clearAttr: function(id, attributes) + { + var node = document.getElementById(id); + for(var i = 0; i < attributes.length; i++) + { + //innerHTML hack bailout + if(attributes[i] == 'innerHTML') + { + node.innerHTML = ''; + } + //value hack + else if(attributes[i] == 'value') + { + node.value = ''; + } + //I'd use hasAttribute but IE is stupid stupid stupid + else + { + node.removeAttribute(attributes[i]); + } + } + }, + _createNode: function(id, tag, attributes, type) + { + var newnode = document.createElement(tag); + for (var i in attributes) + { + //innerHTML hack bailout + if(i == 'innerHTML') + { + newnode.innerHTML = attributes[i]; + } + //value hack + else if(i == 'value') + { + newnode.value = attributes[i]; + } + //I'd use hasAttribute but IE is stupid stupid stupid + else + { + newnode.setAttribute(i, attributes[i]); + } + } + switch(type) + { + case 'append': + document.getElementById(id).appendChild(newnode); + break + case 'prepend': + var parent = document.getElementById(id); + var sibling = parent.firstChild; + parent.insertBefore(newnode, sibling); + break; + case 'insertBefore': + var sibling = document.getElementById(id); + var parent = sibling.parentNode; + parent.insertBefore(newnode, sibling); + break; + //this one is tricky, if it's the last one we use append child...ewww + case 'insertAfter': + var sibling = document.getElementById(id); + var parent = sibling.parentNode; + var next = sibling.nextSibling; + if(next == null) + { + parent.appendChild(newnode); + } + else + { + parent.insertBefore(newnode, next); + } + break; + } + }, + _replaceNode: function(id, tag, attributes) + { + var node = document.getElementById(id); + var parent = node.parentNode; + var newnode = document.createElement(tag); + for (var i in attributes) + { + //innerHTML hack bailout + if(i == 'innerHTML') + { + newnode.innerHTML = attributes[i]; + } + //value hack + else if(i == 'value') + { + newnode.value = attributes[i]; + } + } + parent.replaceChild(newnode, node); + }, + _removeNode: function(id) + { + var node = document.getElementById(id); + if(node) + { + var parent = node.parentNode; + parent.removeChild(node); + } + }, + _insertScript: function(data) + { + eval(data); + }, + _insertAlert: function(data) + { + alert(data); + } +} + +// Loading.js +/** + * Default loading implementation + * + * @category HTML + * @package Ajax + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @copyright 2005 Joshua Eichorn + * see Main.js for license Author details + */ +HTML_AJAX.Open = function(request) { + var loading = document.getElementById('HTML_AJAX_LOADING'); + if (!loading) { + loading = document.createElement('div'); + loading.id = 'HTML_AJAX_LOADING'; + loading.innerHTML = 'Loading...'; + + loading.style.color = '#fff'; + loading.style.position = 'absolute'; + loading.style.top = 0; + loading.style.right = 0; + loading.style.backgroundColor = '#f00'; + loading.style.border = '1px solid #f99'; + loading.style.width = '80px'; + loading.style.padding = '4px'; + loading.style.fontFamily = 'Arial, Helvetica, sans'; + + document.body.insertBefore(loading,document.body.firstChild); + } + if (request.isAsync) { + HTML_AJAX.onOpen_Timeout = window.setTimeout(function() { loading.style.display = 'block'; },500); + } + else { + loading.style.display = 'block'; + } +} +HTML_AJAX.Load = function(request) { + if (HTML_AJAX.onOpen_Timeout) { + window.clearTimeout(HTML_AJAX.onOpen_Timeout); + HTML_AJAX.onOpen_Timeout = false; + } + var loading = document.getElementById('HTML_AJAX_LOADING'); + if (loading) { + loading.style.display = 'none'; + } +} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +// util.js +/** + * Utility methods + * + * @category HTML + * @package Ajax + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * + * See Main.js for author/license details + */ +// {{{ HTML_AJAX_Util +/** + * All the utilities we will be using thorough the classes + */ +var HTML_AJAX_Util = { + // Set the element event + registerEvent: function(element, event, handler) + { + //var element = document.getElementById(id); + if (typeof element.addEventListener != "undefined") { //Dom2 + element.addEventListener(event, handler, false); + } else if (typeof element.attachEvent != "undefined") { //IE 5+ + element.attachEvent("on" + event, handler); + } else { + if (element["on" + event] != null) { + var oldHandler = element["on" + event]; + element["on" + event] = function(e) { + oldHander(e); + handler(e); + }; + } else { + element["on" + event] = handler; + } + } + }, + // get the target of an event, automatically checks window.event for ie + eventTarget: function(event) + { + if (!event) var event = window.event; + if (event.target) return event.target; // w3c + if (event.srcElement) return event.srcElement; // ie 5 + }, + // gets the type of a variable or its primitive equivalent as a string + getType: function(inp) + { + var type = typeof inp, match; + if(type == 'object' && !inp) + { + return 'null'; + } + if (type == "object") { + if(!inp.constructor) + { + return 'object'; + } + var cons = inp.constructor.toString(); + if (match = cons.match(/(\w+)\(/)) { + cons = match[1].toLowerCase(); + } + var types = ["boolean", "number", "string", "array"]; + for (key in types) { + if (cons == types[key]) { + type = types[key]; + break; + } + } + } + return type; + }, + // repeats the input string the number of times given by multiplier. exactly like PHP's str_repeat() + strRepeat: function(inp, multiplier) { + var ret = ""; + while (--multiplier > 0) ret += inp; + return ret; + }, + // recursive variable dumper similar in output to PHP's var_dump(), the differences being: this function displays JS types and type names; JS doesn't provide an object number like PHP does + varDump: function(inp, printFuncs, _indent, _recursionLevel) + { + if (!_recursionLevel) _recursionLevel = 0; + if (!_indent) _indent = 1; + var tab = this.strRepeat(" ", ++_indent); + var type = this.getType(inp), out = type; + var consrx = /(\w+)\(/; + consrx.compile(); + if (++_recursionLevel > 6) { + return tab + inp + "Loop Detected\n"; + } + switch (type) { + case "boolean": + case "number": + out += "(" + inp.toString() + ")"; + break; + case "string": + out += "(" + inp.length + ") \"" + inp + "\""; + break; + case "function": + if (printFuncs) { + out += inp.toString().replace(/\n/g, "\n" + tab); + } + break; + case "array": + case "object": + var atts = "", attc = 0; + try { + for (k in inp) { + atts += tab + "[" + (/\D/.test(k) ? "\"" + k + "\"" : k) + + "]=>\n" + tab + this.varDump(inp[k], printFuncs, _indent, _recursionLevel); + ++attc; + } + } catch (e) {} + if (type == "object") { + var objname, objstr = inp.toString(); + if (objname = objstr.match(/^\[object (\w+)\]$/)) { + objname = objname[1]; + } else { + try { + objname = inp.constructor.toString().match(consrx)[1]; + } catch (e) { + objname = 'unknown'; + } + } + out += "(" + objname + ") "; + } + out += "(" + attc + ") {\n" + atts + this.strRepeat(" ", _indent - 1) +"}"; + break; + } + return out + "\n"; + }, + quickPrint: function(input) { + var ret = ""; + for(var i in input) { + ret += i+':'+input[i]+"\n"; + } + return ret; + }, + //compat function for stupid browsers in which getElementsByTag with a * dunna work + getAllElements: function(parentElement) + { + //check for idiot browsers + if( document.all) + { + if(!parentElement) { + var allElements = document.all; + } + else + { + var allElements = [], rightName = new RegExp( parentElement, 'i' ), i; + for( i=0; i<document.all.length; i++ ) { + if( rightName.test( document.all[i].parentElement ) ) + allElements.push( document.all[i] ); + } + } + return allElements; + } + //real browsers just do this + else + { + if (!parentElement) { parentElement = document.body; } + return parentElement.getElementsByTagName('*'); + } + }, + getElementsByClassName: function(className, parentElement) { + var allElements = HTML_AJAX_Util.getAllElements(parentElement); + var items = []; + var exp = new RegExp('(^| )' + className + '( |$)'); + for(var i=0,j=allElements.length; i<j; i++) + { + if(exp.test(allElements[i].className)) + { + items.push(allElements[i]); + } + } + return items; + }, + htmlEscape: function(inp) { + var rxp, chars = [ + ['&', '&'], + ['<', '<'], + ['>', '>'] + ]; + for (i in chars) { + inp.replace(new RegExp(chars[i][0]), chars[i][1]); + } + return inp; + }, + // return the base of the given absolute url + baseURL: function(absolute) { + var qPos = absolute.indexOf('?'); + if (qPos >= 0) { + absolute = absolute.substr(0, qPos); + } + var slashPos = absolute.lastIndexOf('/'); + if (slashPos < 0) { + return absolute; + } + return absolute.substr(0, slashPos + 1); + }, + // return the query string from a url + queryString: function(url) { + var qPos = url.indexOf('?'); + if (qPos >= 0) { + return url.substr(qPos+1); + } + }, + // return the absolute path to the given relative url + absoluteURL: function(rel, absolute) { + if (/^https?:\/\//i.test(rel)) { + return rel; + } + if (!absolute) { + var bases = document.getElementsByTagName('base'); + for (i in bases) { + if (bases[i].href) { + absolute = bases[i].href; + break; + } + } + if (!absolute) { + absolute = window.location.href; + } + } + if (rel == '') { + return absolute; + } + if (rel.substr(0, 2) == '//') { + // starts with '//', replace everything but the protocol + var slashesPos = absolute.indexOf('//'); + if (slashesPos < 0) { + return 'http:' + rel; + } + return absolute.substr(0, slashesPos) + rel; + } + var base = this.baseURL(absolute); + var absParts = base.substr(0, base.length - 1).split('/'); + var absHost = absParts.slice(0, 3).join('/') + '/'; + if (rel.substr(0, 1) == '/') { + // starts with '/', append it to the host + return absHost + rel; + } + if (rel.substr(0, 1) == '.' && rel.substr(1, 1) != '.') { + // starts with '.', append it to the base + return base + rel.substr(1); + } + // remove everything upto the path and beyond + absParts.splice(0, 3); + var relParts = rel.split('/'); + var loopStart = relParts.length - 1; + relParts = absParts.concat(relParts); + for (i = loopStart; i < relParts.length;) { + if (relParts[i] == '..') { + if (i == 0) { + return absolute; + } + relParts.splice(i - 1, 2); + --i; + continue; + } + i++; + } + return absHost + relParts.join('/'); + } +} +// }}} +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +// behavior/behavior.js +/** + +ModifiedBehavior v1.0 by Ron Lancaster based on Ben Nolan's Behaviour, June 2005 implementation. +Modified to use Dean Edward's CSS Query. + +Description +---------- + +Uses css selectors to apply javascript Behaviors to enable unobtrusive javascript in html documents. + +Dependencies +------------ + +Requires [Dean Edwards CSSQuery](http://dean.edwards.name/my/cssQuery/ "CSSQuery"). + +Usage +------ + + Behavior.register( + "b.someclass", + function(element) { + element.onclick = function(){ + alert(this.innerHTML); + } + } + ); + + Behavior.register( + "#someid u", + function(element) { + element.onmouseover = function(){ + this.innerHTML = "BLAH!"; + } + }, + getElementByID("parent") + ); + +Call `Behavior.apply()` to re-apply the rules (if you update the dom, etc). + +License +------ + +Reproduced under BSD licensed. Same license as Ben Nolan's implementation. + +More information for Ben Nolan's implementation: <http://ripcord.co.nz/behaviour/> + +*/ + +var Behavior = { + + // private data member + list : new Array(), + + // private method + addLoadEvent : function(func) { + var oldonload = window.onload; + + if (typeof window.onload != 'function') { + window.onload = func; + } else { + window.onload = function() { + oldonload(); + func(); + } + } + }, + + // void apply() : Applies the registered ruleset. + apply : function() { + for (i = 0; i < Behavior.list.length; i++) { + var rule = Behavior.list[i]; + var tags = cssQuery(rule.selector, rule.from); + if (tags) { + for (j = 0; j < tags.length; j++) { + rule.action(tags[j]); + } + } + } + }, + + // void register() : register a css selector, and the action (function) to take, + // from (optional) is a document, element or array of elements which is filtered by selector. + register : function(selector, action, from) { + Behavior.list.push(new BehaviorRule(selector, from, action)); + }, + + // void start() : initial application of ruleset at document load. + start : function() { + Behavior.addLoadEvent(function() { + Behavior.apply(); + }); + } +} + +function BehaviorRule(selector, from, action) { + this.selector = selector; + this.from = from; + this.action = action; +} + +Behavior.start();// behavior/cssQuery-p.js +/* + cssQuery, version 2.0.2 (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 x=6(){7 1D="2.0.2";7 C=/\\s*,\\s*/;7 x=6(s,A){33{7 m=[];7 u=1z.32.2c&&!A;7 b=(A)?(A.31==22)?A:[A]:[1g];7 1E=18(s).1l(C),i;9(i=0;i<1E.y;i++){s=1y(1E[i]);8(U&&s.Z(0,3).2b("")==" *#"){s=s.Z(2);A=24([],b,s[1])}1A A=b;7 j=0,t,f,a,c="";H(j<s.y){t=s[j++];f=s[j++];c+=t+f;a="";8(s[j]=="("){H(s[j++]!=")")a+=s[j];a=a.Z(0,-1);c+="("+a+")"}A=(u&&V[c])?V[c]:21(A,t,f,a);8(u)V[c]=A}m=m.30(A)}2a x.2d;5 m}2Z(e){x.2d=e;5[]}};x.1Z=6(){5"6 x() {\\n [1D "+1D+"]\\n}"};7 V={};x.2c=L;x.2Y=6(s){8(s){s=1y(s).2b("");2a V[s]}1A V={}};7 29={};7 19=L;x.15=6(n,s){8(19)1i("s="+1U(s));29[n]=12 s()};x.2X=6(c){5 c?1i(c):o};7 D={};7 h={};7 q={P:/\\[([\\w-]+(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\]]*)\\]/};7 T=[];D[" "]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=X(f[i],t,n);9(j=0;(e=s[j]);j++){8(M(e)&&14(e,n))r.z(e)}}};D["#"]=6(r,f,i){7 e,j;9(j=0;(e=f[j]);j++)8(e.B==i)r.z(e)};D["."]=6(r,f,c){c=12 1t("(^|\\\\s)"+c+"(\\\\s|$)");7 e,i;9(i=0;(e=f[i]);i++)8(c.l(e.1V))r.z(e)};D[":"]=6(r,f,p,a){7 t=h[p],e,i;8(t)9(i=0;(e=f[i]);i++)8(t(e,a))r.z(e)};h["2W"]=6(e){7 d=Q(e);8(d.1C)9(7 i=0;i<d.1C.y;i++){8(d.1C[i]==e)5 K}};h["2V"]=6(e){};7 M=6(e){5(e&&e.1c==1&&e.1f!="!")?e:23};7 16=6(e){H(e&&(e=e.2U)&&!M(e))28;5 e};7 G=6(e){H(e&&(e=e.2T)&&!M(e))28;5 e};7 1r=6(e){5 M(e.27)||G(e.27)};7 1P=6(e){5 M(e.26)||16(e.26)};7 1o=6(e){7 c=[];e=1r(e);H(e){c.z(e);e=G(e)}5 c};7 U=K;7 1h=6(e){7 d=Q(e);5(2S d.25=="2R")?/\\.1J$/i.l(d.2Q):2P(d.25=="2O 2N")};7 Q=6(e){5 e.2M||e.1g};7 X=6(e,t){5(t=="*"&&e.1B)?e.1B:e.X(t)};7 17=6(e,t,n){8(t=="*")5 M(e);8(!14(e,n))5 L;8(!1h(e))t=t.2L();5 e.1f==t};7 14=6(e,n){5!n||(n=="*")||(e.2K==n)};7 1e=6(e){5 e.1G};6 24(r,f,B){7 m,i,j;9(i=0;i<f.y;i++){8(m=f[i].1B.2J(B)){8(m.B==B)r.z(m);1A 8(m.y!=23){9(j=0;j<m.y;j++){8(m[j].B==B)r.z(m[j])}}}}5 r};8(![].z)22.2I.z=6(){9(7 i=0;i<1z.y;i++){o[o.y]=1z[i]}5 o.y};7 N=/\\|/;6 21(A,t,f,a){8(N.l(f)){f=f.1l(N);a=f[0];f=f[1]}7 r=[];8(D[t]){D[t](r,A,f,a)}5 r};7 S=/^[^\\s>+~]/;7 20=/[\\s#.:>+~()@]|[^\\s#.:>+~()@]+/g;6 1y(s){8(S.l(s))s=" "+s;5 s.P(20)||[]};7 W=/\\s*([\\s>+~(),]|^|$)\\s*/g;7 I=/([\\s>+~,]|[^(]\\+|^)([#.:@])/g;7 18=6(s){5 s.O(W,"$1").O(I,"$1*$2")};7 1u={1Z:6(){5"\'"},P:/^(\'[^\']*\')|("[^"]*")$/,l:6(s){5 o.P.l(s)},1S:6(s){5 o.l(s)?s:o+s+o},1Y:6(s){5 o.l(s)?s.Z(1,-1):s}};7 1s=6(t){5 1u.1Y(t)};7 E=/([\\/()[\\]?{}|*+-])/g;6 R(s){5 s.O(E,"\\\\$1")};x.15("1j-2H",6(){D[">"]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=1o(f[i]);9(j=0;(e=s[j]);j++)8(17(e,t,n))r.z(e)}};D["+"]=6(r,f,t,n){9(7 i=0;i<f.y;i++){7 e=G(f[i]);8(e&&17(e,t,n))r.z(e)}};D["@"]=6(r,f,a){7 t=T[a].l;7 e,i;9(i=0;(e=f[i]);i++)8(t(e))r.z(e)};h["2G-10"]=6(e){5!16(e)};h["1x"]=6(e,c){c=12 1t("^"+c,"i");H(e&&!e.13("1x"))e=e.1n;5 e&&c.l(e.13("1x"))};q.1X=/\\\\:/g;q.1w="@";q.J={};q.O=6(m,a,n,c,v){7 k=o.1w+m;8(!T[k]){a=o.1W(a,c||"",v||"");T[k]=a;T.z(a)}5 T[k].B};q.1Q=6(s){s=s.O(o.1X,"|");7 m;H(m=s.P(o.P)){7 r=o.O(m[0],m[1],m[2],m[3],m[4]);s=s.O(o.P,r)}5 s};q.1W=6(p,t,v){7 a={};a.B=o.1w+T.y;a.2F=p;t=o.J[t];t=t?t(o.13(p),1s(v)):L;a.l=12 2E("e","5 "+t);5 a};q.13=6(n){1d(n.2D()){F"B":5"e.B";F"2C":5"e.1V";F"9":5"e.2B";F"1T":8(U){5"1U((e.2A.P(/1T=\\\\1v?([^\\\\s\\\\1v]*)\\\\1v?/)||[])[1]||\'\')"}}5"e.13(\'"+n.O(N,":")+"\')"};q.J[""]=6(a){5 a};q.J["="]=6(a,v){5 a+"=="+1u.1S(v)};q.J["~="]=6(a,v){5"/(^| )"+R(v)+"( |$)/.l("+a+")"};q.J["|="]=6(a,v){5"/^"+R(v)+"(-|$)/.l("+a+")"};7 1R=18;18=6(s){5 1R(q.1Q(s))}});x.15("1j-2z",6(){D["~"]=6(r,f,t,n){7 e,i;9(i=0;(e=f[i]);i++){H(e=G(e)){8(17(e,t,n))r.z(e)}}};h["2y"]=6(e,t){t=12 1t(R(1s(t)));5 t.l(1e(e))};h["2x"]=6(e){5 e==Q(e).1H};h["2w"]=6(e){7 n,i;9(i=0;(n=e.1F[i]);i++){8(M(n)||n.1c==3)5 L}5 K};h["1N-10"]=6(e){5!G(e)};h["2v-10"]=6(e){e=e.1n;5 1r(e)==1P(e)};h["2u"]=6(e,s){7 n=x(s,Q(e));9(7 i=0;i<n.y;i++){8(n[i]==e)5 L}5 K};h["1O-10"]=6(e,a){5 1p(e,a,16)};h["1O-1N-10"]=6(e,a){5 1p(e,a,G)};h["2t"]=6(e){5 e.B==2s.2r.Z(1)};h["1M"]=6(e){5 e.1M};h["2q"]=6(e){5 e.1q===L};h["1q"]=6(e){5 e.1q};h["1L"]=6(e){5 e.1L};q.J["^="]=6(a,v){5"/^"+R(v)+"/.l("+a+")"};q.J["$="]=6(a,v){5"/"+R(v)+"$/.l("+a+")"};q.J["*="]=6(a,v){5"/"+R(v)+"/.l("+a+")"};6 1p(e,a,t){1d(a){F"n":5 K;F"2p":a="2n";1a;F"2o":a="2n+1"}7 1m=1o(e.1n);6 1k(i){7 i=(t==G)?1m.y-i:i-1;5 1m[i]==e};8(!Y(a))5 1k(a);a=a.1l("n");7 m=1K(a[0]);7 s=1K(a[1]);8((Y(m)||m==1)&&s==0)5 K;8(m==0&&!Y(s))5 1k(s);8(Y(s))s=0;7 c=1;H(e=t(e))c++;8(Y(m)||m==1)5(t==G)?(c<=s):(s>=c);5(c%m)==s}});x.15("1j-2m",6(){U=1i("L;/*@2l@8(@\\2k)U=K@2j@*/");8(!U){X=6(e,t,n){5 n?e.2i("*",t):e.X(t)};14=6(e,n){5!n||(n=="*")||(e.2h==n)};1h=1g.1I?6(e){5/1J/i.l(Q(e).1I)}:6(e){5 Q(e).1H.1f!="2g"};1e=6(e){5 e.2f||e.1G||1b(e)};6 1b(e){7 t="",n,i;9(i=0;(n=e.1F[i]);i++){1d(n.1c){F 11:F 1:t+=1b(n);1a;F 3:t+=n.2e;1a}}5 t}}});19=K;5 x}();',62,190,'|||||return|function|var|if|for||||||||pseudoClasses||||test|||this||AttributeSelector|||||||cssQuery|length|push|fr|id||selectors||case|nextElementSibling|while||tests|true|false|thisElement||replace|match|getDocument|regEscape||attributeSelectors|isMSIE|cache||getElementsByTagName|isNaN|slice|child||new|getAttribute|compareNamespace|addModule|previousElementSibling|compareTagName|parseSelector|loaded|break|_0|nodeType|switch|getTextContent|tagName|document|isXML|eval|css|_1|split|ch|parentNode|childElements|nthChild|disabled|firstElementChild|getText|RegExp|Quote|x22|PREFIX|lang|_2|arguments|else|all|links|version|se|childNodes|innerText|documentElement|contentType|xml|parseInt|indeterminate|checked|last|nth|lastElementChild|parse|_3|add|href|String|className|create|NS_IE|remove|toString|ST|select|Array|null|_4|mimeType|lastChild|firstChild|continue|modules|delete|join|caching|error|nodeValue|textContent|HTML|prefix|getElementsByTagNameNS|end|x5fwin32|cc_on|standard||odd|even|enabled|hash|location|target|not|only|empty|root|contains|level3|outerHTML|htmlFor|class|toLowerCase|Function|name|first|level2|prototype|item|scopeName|toUpperCase|ownerDocument|Document|XML|Boolean|URL|unknown|typeof|nextSibling|previousSibling|visited|link|valueOf|clearCache|catch|concat|constructor|callee|try'.split('|'),0,{})) diff --git a/ajax_server.php b/ajax_server.php new file mode 100644 index 0000000000000000000000000000000000000000..7fa2da7be4217bd894ca4d048abe086d3c115fe6 --- /dev/null +++ b/ajax_server.php @@ -0,0 +1,15 @@ +<?php +if (isset($_GET['client']) && $_GET['client']=='all') { + include 'ajax_client.js'; +} elseif (isset($_GET['stub']) && $_GET['stub']=='Voting_System') { + include 'ajax_stub.js'; +} else { + require_once 'HTML/AJAX/Server.php'; + require_once 'config.inc.php'; + require_once 'functions.php'; + + $voter = new Voting_System(); + $server = new HTML_AJAX_Server(); + $server->registerClass($voter); + $server->handleRequest(); +} \ No newline at end of file diff --git a/ajax_stub.js b/ajax_stub.js new file mode 100644 index 0000000000000000000000000000000000000000..f21d8d9966f810704f9b0453a6a0a25ac3353cba --- /dev/null +++ b/ajax_stub.js @@ -0,0 +1,42 @@ +// Client stub for the voting_system PHP Class +function voting_system(callback) { + mode = 'sync'; + if (callback) { mode = 'async'; } + this.className = 'voting_system'; + this.dispatcher = new HTML_AJAX_Dispatcher(this.className,mode,callback,'ajax_server.php?','JSON'); +} +voting_system.prototype = { + Sync: function() { this.dispatcher.Sync(); }, + Async: function(callback) { this.dispatcher.Async(callback); }, + displayHeaderData: function() { return this.dispatcher.doCall('displayHeaderData',arguments); }, + initializeVoter: function() { return this.dispatcher.doCall('initializeVoter',arguments); }, + setStep: function() { return this.dispatcher.doCall('setStep',arguments); }, + hasRatedAllPrototypes: function() { return this.dispatcher.doCall('hasRatedAllPrototypes',arguments); }, + sentPrototypes: function() { return this.dispatcher.doCall('sentPrototypes',arguments); }, + getVoterId: function() { return this.dispatcher.doCall('getVoterId',arguments); }, + run: function() { return this.dispatcher.doCall('run',arguments); }, + start: function() { return this.dispatcher.doCall('start',arguments); }, + introduction: function() { return this.dispatcher.doCall('introduction',arguments); }, + heavyLoadNotice: function() { return this.dispatcher.doCall('heavyLoadNotice',arguments); }, + ranking: function() { return this.dispatcher.doCall('ranking',arguments); }, + displayRankForm: function() { return this.dispatcher.doCall('displayRankForm',arguments); }, + gatherAudienceType: function() { return this.dispatcher.doCall('gatherAudienceType',arguments); }, + displayImagesAndForms: function() { return this.dispatcher.doCall('displayImagesAndForms',arguments); }, + comments: function() { return this.dispatcher.doCall('comments',arguments); }, + hasSubmittedComments: function() { return this.dispatcher.doCall('hasSubmittedComments',arguments); }, + displayThumbnails: function() { return this.dispatcher.doCall('displayThumbnails',arguments); }, + displayCommentForm: function() { return this.dispatcher.doCall('displayCommentForm',arguments); }, + displayPrototype: function() { return this.dispatcher.doCall('displayPrototype',arguments); }, + displayPrototypeImage: function() { return this.dispatcher.doCall('displayPrototypeImage',arguments); }, + displayRatingForm: function() { return this.dispatcher.doCall('displayRatingForm',arguments); }, + submitRank: function() { return this.dispatcher.doCall('submitRank',arguments); }, + submitComment: function() { return this.dispatcher.doCall('submitComment',arguments); }, + tallyVote: function() { return this.dispatcher.doCall('tallyVote',arguments); }, + questionnaire: function() { return this.dispatcher.doCall('questionnaire',arguments); }, + questionnaireform: function() { return this.dispatcher.doCall('questionnaireform',arguments); }, + starForm: function() { return this.dispatcher.doCall('starForm',arguments); }, + handlePostData: function() { return this.dispatcher.doCall('handlePostData',arguments); }, + storeResponse: function() { return this.dispatcher.doCall('storeResponse',arguments); }, + thankyou: function() { return this.dispatcher.doCall('thankyou',arguments); } +} + diff --git a/config.sample.php b/config.sample.php new file mode 100644 index 0000000000000000000000000000000000000000..14221ca8d54fa002a6c254ea7f7e1dc8ab27d4eb --- /dev/null +++ b/config.sample.php @@ -0,0 +1,18 @@ +<?php +require_once 'MDB2.php'; +require_once 'DB/DataObject.php'; +require_once 'HTML/Table.php'; + +// Load database settings +$dboptions = &PEAR::getStaticProperty('DB_DataObject', 'options'); +$dboptions = array( + 'database' => 'mysqli://designsurvey:designsurvey@localhost/designsurvey', + 'schema_location' => 'DataObjects', + 'class_location' => dirname(__FILE__).'/DataObjects', + 'require_prefix' => dirname(__FILE__).'/DataObjects', + 'class_prefix' => 'DataObjects_', + 'db_driver' => 'MDB2' +); + +session_set_cookie_params(0, '/workspace/wdndesignsurvey/', 'ucommbieber.unl.edu'); +session_start(); diff --git a/database/.htaccess b/database/.htaccess new file mode 100644 index 0000000000000000000000000000000000000000..ab5b2b967cfcc4a02bcf253bdccef5958f87d1cd --- /dev/null +++ b/database/.htaccess @@ -0,0 +1,2 @@ +Order deny,allow +deny from all \ No newline at end of file diff --git a/database/designsurvey.sql b/database/designsurvey.sql new file mode 100644 index 0000000000000000000000000000000000000000..054b94df030579a45775a8b8659347924657e6eb --- /dev/null +++ b/database/designsurvey.sql @@ -0,0 +1,197 @@ +CREATE USER 'designsurvey'@'localhost' IDENTIFIED BY 'designsurvey'; + +GRANT USAGE ON * . * TO 'designsurvey'@'localhost' IDENTIFIED BY 'designsurvey' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; + +CREATE DATABASE IF NOT EXISTS `designsurvey` ; + +GRANT ALL PRIVILEGES ON `designsurvey` . * TO 'designsurvey'@'localhost'; + +USE `designsurvey`; + +-- +-- Table structure for table `age_groups` +-- + +CREATE TABLE IF NOT EXISTS `age_groups` ( + `id` int(11) NOT NULL auto_increment, + `age_group` varchar(50) NOT NULL default '', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `audiences` +-- + +CREATE TABLE IF NOT EXISTS `audiences` ( + `id` int(11) NOT NULL auto_increment, + `audience` varchar(50) NOT NULL default '', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `auth` +-- + +CREATE TABLE IF NOT EXISTS `auth` ( + `username` varchar(50) NOT NULL default '', + `password` varchar(32) NOT NULL default '', + PRIMARY KEY (`username`), + KEY `password` (`password`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `prototype` +-- + +CREATE TABLE IF NOT EXISTS `prototype` ( + `id` int(11) NOT NULL auto_increment, + `title` varchar(20) default NULL, + `splash_image` varchar(255) NOT NULL default '', + `full_image` varchar(255) default NULL, + `thumb_image` varchar(255) default NULL, + PRIMARY KEY (`id`), + KEY `title` (`title`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `prototype_ranking` +-- + +CREATE TABLE IF NOT EXISTS `prototype_ranking` ( + `id` int(11) NOT NULL auto_increment, + `voter_id` int(11) NOT NULL default '0', + `prototype_id` int(11) NOT NULL default '0', + `rank` int(11) NOT NULL default '0', + `why_response` mediumtext, + `improve_response` mediumtext, + PRIMARY KEY (`id`), + KEY `voter_id` (`voter_id`,`prototype_id`,`rank`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `prototype_rating` +-- + +CREATE TABLE IF NOT EXISTS `prototype_rating` ( + `id` int(11) NOT NULL auto_increment, + `voter_id` int(11) NOT NULL default '0', + `prototype_id` int(11) NOT NULL default '0', + `rating` int(11) NOT NULL default '0', + PRIMARY KEY (`id`), + KEY `voter_id` (`voter_id`,`prototype_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `prototype_sent` +-- + +CREATE TABLE IF NOT EXISTS `prototype_sent` ( + `id` int(11) NOT NULL auto_increment, + `voter_id` int(11) NOT NULL default '0', + `prototype_id` int(11) NOT NULL default '0', + PRIMARY KEY (`id`), + KEY `voter_id` (`voter_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `questions` +-- + +CREATE TABLE IF NOT EXISTS `questions` ( + `id` int(11) NOT NULL auto_increment, + `audience_id` int(11) NOT NULL default '0', + `question` varchar(255) NOT NULL default '', + PRIMARY KEY (`id`), + KEY `audience_id` (`audience_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rating_lead_questions` +-- + +CREATE TABLE IF NOT EXISTS `rating_lead_questions` ( + `id` int(11) NOT NULL auto_increment, + `lead_question` varchar(255) NOT NULL default '', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rating_questions` +-- + +CREATE TABLE IF NOT EXISTS `rating_questions` ( + `id` int(11) NOT NULL auto_increment, + `audience_id` int(11) NOT NULL default '0', + `lead_question_id` int(11) NOT NULL default '0', + `question` varchar(50) NOT NULL default '', + PRIMARY KEY (`id`), + KEY `audience_id` (`audience_id`), + KEY `lead_question_id` (`lead_question_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `rating_responses` +-- + +CREATE TABLE IF NOT EXISTS `rating_responses` ( + `id` int(11) NOT NULL auto_increment, + `voter_id` int(11) NOT NULL default '0', + `question_id` int(11) NOT NULL default '0', + `response` int(11) default NULL, + PRIMARY KEY (`id`), + KEY `voter_id` (`voter_id`,`question_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `responses` +-- + +CREATE TABLE IF NOT EXISTS `responses` ( + `id` int(11) NOT NULL auto_increment, + `voter_id` int(11) NOT NULL default '0', + `question_id` int(11) NOT NULL default '0', + `response` mediumtext, + PRIMARY KEY (`id`), + KEY `voter_id` (`voter_id`,`question_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `voter` +-- + +CREATE TABLE IF NOT EXISTS `voter` ( + `id` int(11) NOT NULL auto_increment, + `audience_id` int(11) default NULL, + `age_group_id` int(11) default NULL, + `gender` char(1) default NULL, + `ip` varchar(15) NOT NULL default '', + `step` int(10) unsigned default NULL, + `prototype_order` mediumtext, + `submitdatetime` datetime default NULL, + PRIMARY KEY (`id`), + KEY `ip` (`ip`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; diff --git a/drag/index.html b/drag/index.html new file mode 100644 index 0000000000000000000000000000000000000000..8bb1c843cff68c0d2bccf27836f705d485e5bfb1 --- /dev/null +++ b/drag/index.html @@ -0,0 +1,77 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" version="-//W3C//DTD XHTML 1.1//EN" xml:lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + + <title>Test</title> + + <style> + + * { + margin: 0px; + padding: 0px; + } + body { + background:#DDD; + font-family: verdana, arial, sans-serif; + font-size:14px; + } + #form{ + text-align:left; + margin:25px; +} +#form ul{ + list-style:none; +} +#form li{ + margin:0 0 1em 0; +} +#form textarea{ + width:100%; + height:150px; +} +#name2 form{ + background-color:#333; + padding:10px; + cursor:move; +} + </style> + +<script type="text/javascript" src="wz_dragdrop.js"></script> + <title>Sample Windows</title> +</head> +<body> +<div id="name2" style="position:absolute;"> + +<form id="form"> + <h2>Example Form</h2> + <ul> + <li> + <label>Name</label><br /> + <input id="" type="text" /> + </li> + <li> + <label>Message</label><br /> + <textarea></textarea> + </li> + + <li> + <a href="image.html" class="lbAction" rel="insert"><button>Submit</button></a> + <a href="#" class="lbAction" rel="deactivate"><button>Cancel</button></a> + </li> + </ul> +</form> + +</div> + + +<script type="text/javascript"> +<!-- + +SET_DHTML("name2"); + +//--> +</script> +</body> +</html> diff --git a/drag/transparentpixel.gif b/drag/transparentpixel.gif new file mode 100755 index 0000000000000000000000000000000000000000..b7406476aa46e4d98eefacf95f6d3e8c5439e330 Binary files /dev/null and b/drag/transparentpixel.gif differ diff --git a/drag/wz_dragdrop.js b/drag/wz_dragdrop.js new file mode 100755 index 0000000000000000000000000000000000000000..386b3f0290b86f9f82082bd07f643fe12c54d1bb --- /dev/null +++ b/drag/wz_dragdrop.js @@ -0,0 +1,1416 @@ +/* This notice must be untouched at all times. + +wz_dragdrop.js v. 4.85 +The latest version is available at +http://www.walterzorn.com +or http://www.devira.com +or http://www.walterzorn.de + +Copyright (c) 2002-2003 Walter Zorn. All rights reserved. +Created 26. 8. 2002 by Walter Zorn (Web: http://www.walterzorn.com ) +Last modified: 10. 2. 2006 + +This DHTML & Drag&Drop Library adds Drag&Drop functionality +to the following types of html-elements: +- images, even if not positioned via layers, + nor via stylesheets or any other kind of "hard-coding" +- relatively and absolutely positioned layers (DIV elements). +Moreover, it provides extended DHTML abilities. + +LICENSE: LGPL + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License (LGPL) as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +For more details on the GNU Lesser General Public License, +see http://www.gnu.org/copyleft/lesser.html +*/ + + +// PATH TO THE TRANSPARENT 1*1 PX IMAGE (required by NS 4 as spacer) +var spacer = 'transparentpixel.gif'; + + + + +//window.onerror = new Function('return true;'); + + +// Optional commands passed to SET_DHTML() on the html-page (g: may be applied globally, i: individually) +var CLONE = 'C10nE'; // i img clone image +var COPY = 'C0pY'; // i img create copies +var DETACH_CHILDREN = 'd37aCH'; // i lyr detach images +var HORIZONTAL = 'H0r1Z'; // i img,lyr horizontally draggable only +var MAXHEIGHT = 'm7x8I'; // i img,lyr maximum height limit, " +var MAXOFFBOTTOM = 'm7xd0wN'; // i img,lyr downward offset limit +var MAXOFFLEFT = 'm7x23Ft'; // i img,lyr leftward offset limit +var MAXOFFRIGHT = 'm7x0Ff8'; // i img,lyr rightward offset limit +var MAXOFFTOP = 'm7xu9'; // i img,lyr upward offset limit +var MAXWIDTH = 'm7xW1'; // i img,lyr maximum width limit, use with resizable or scalable +var MINWIDTH = 'm1nw1'; // i img,lyr minimum width limit, " +var MINHEIGHT = 'm1n8I'; // i img,lyr minimum height limit, " +var NO_ALT = 'no81T'; // gi img disable alt and title attributes +var NO_DRAG = 'N0d4Ag'; // i img,lyr disable draggability +var RESET_Z = 'r35E7z'; // gi img,lyr reset z-index when dropped +var RESIZABLE = 'r5IZbl'; // gi img,lyr resizable if <ctrl> or <shift> pressed +var SCALABLE = 'SCLbl'; // gi img,lyr scalable " +var SCROLL = 'sC8lL'; // gi img,lyr enable auto scroll functionality +var TRANSPARENT = 'dIApHAn'; // gi img,lyr translucent while dragged +var VERTICAL = 'V3Rt1C'; // i img,lyr vertically draggable only +var dd_cursors = new Array( + 'c:default', + 'c:crosshair', + 'c:e-resize', + 'c:hand', + 'c:help', + 'c:move', + 'c:n-resize', + 'c:ne-resize', + 'c:nw-resize', + 'c:s-resize', + 'c:se-resize', + 'c:sw-resize', + 'c:text', + 'c:w-resize', + 'c:wait' +); +var dd_i = dd_cursors.length; while(dd_i--) + eval('var CURSOR_' + (dd_cursors[dd_i].substring(2).toUpperCase().replace('-', '_')) + ' = "' + dd_cursors[dd_i] + '";'); +var dd_u = "undefined"; +function WZDD() +{ + this.elements = new Array(0); + this.obj = null; + this.n = navigator.userAgent.toLowerCase(); + this.db = (document.compatMode && document.compatMode.toLowerCase() != "backcompat")? + document.documentElement + : (document.body || null); + this.op = !!(window.opera && document.getElementById); + if(this.op) document.onmousedown = new Function('e', + 'if(((e = e || window.event).target || e.srcElement).tagName == "IMAGE") return false;'); + this.ie = !!(this.n.indexOf("msie") >= 0 && document.all && this.db && !this.op); + this.iemac = !!(this.ie && this.n.indexOf("mac") >= 0); + this.ie4 = !!(this.ie && !document.getElementById); + this.n4 = !!(document.layers && typeof document.classes != dd_u); + this.n6 = !!(typeof window.getComputedStyle != dd_u && typeof document.createRange != dd_u); + this.w3c = !!(!this.op && !this.ie && !this.n6 && document.getElementById); + this.ce = !!(document.captureEvents && document.releaseEvents); + this.px = this.n4? '' : 'px'; + this.tiv = this.w3c? 40 : 10; +} +var dd = new WZDD(); + +dd.Int = function(d_x, d_y) +{ + return isNaN(d_y = parseInt(d_x))? 0 : d_y; +}; +dd.getWndW = function() +{ + return dd.Int( + (dd.db && !dd.op && !dd.w3c && dd.db.clientWidth)? dd.db.clientWidth + : (window.innerWidth || 0) + ); +}; +dd.getWndH = function() +{ + return dd.Int( + (dd.db && !dd.op && !dd.w3c && dd.db.clientHeight)? dd.db.clientHeight + : (window.innerHeight || 0) + ); +}; +dd.getScrollX = function() +{ + return dd.Int(window.pageXOffset || (dd.db? dd.db.scrollLeft : 0)); +}; +dd.getScrollY = function() +{ + return dd.Int(window.pageYOffset || (dd.db? dd.db.scrollTop : 0)); +}; +dd.getPageXY = function(d_o) +{ + if(dd.n4 && d_o) + { + dd.x = d_o.pageX || 0; + dd.y = d_o.pageY || 0; + } + else + { + dd.x = dd.y = 0; //global helper vars + while(d_o) + { + dd.x += dd.Int(d_o.offsetLeft); + dd.y += dd.Int(d_o.offsetTop); + d_o = d_o.offsetParent || null; + } + } +}; +dd.getCssXY = function(d_o) +{ + if(d_o.div) + { + if(dd.n4) + { + d_o.cssx = d_o.div.x; + d_o.cssy = d_o.div.y; + } + else if(dd.ie4) + { + d_o.cssx = d_o.css.pixelLeft; + d_o.cssy = d_o.css.pixelTop; + } + else + { + d_o.css.left = d_o.css.top = 0 + dd.px; + dd.getPageXY(d_o.div); + d_o.cssx = d_o.x - dd.x; + d_o.cssy = d_o.y - dd.y; + d_o.css.left = d_o.cssx + dd.px; + d_o.css.top = d_o.cssy + dd.px; + } + } + else + { + d_o.cssx = 0; + d_o.cssy = 0; + } +}; +dd.getImgW = function(d_o) +{ + return d_o? dd.Int(d_o.width) : 0; +}; +dd.getImgH = function(d_o) +{ + return d_o? dd.Int(d_o.height) : 0; +}; +dd.getDivW = function(d_o) +{ + return dd.Int( + dd.n4? (d_o.div? d_o.div.clip.width : 0) + : d_o.div? (d_o.div.offsetWidth || d_o.css.pixelWidth || d_o.css.width || 0) + : 0 + ); +}; +dd.getDivH = function(d_o) +{ + return dd.Int( + dd.n4? (d_o.div? d_o.div.clip.height : 0) + : d_o.div? (d_o.div.offsetHeight || d_o.css.pixelHeight || d_o.css.height || 0) + : 0 + ); +}; +dd.getWH = function(d_o) +{ + d_o.w = dd.getDivW(d_o); + d_o.h = dd.getDivH(d_o); + if(d_o.css) + { + d_o.css.width = d_o.w + dd.px; + d_o.css.height = d_o.h + dd.px; + d_o.dw = dd.getDivW(d_o)-d_o.w; + d_o.dh = dd.getDivH(d_o)-d_o.h; + d_o.css.width = (d_o.w-d_o.dw) + dd.px; + d_o.css.height = (d_o.h-d_o.dh) + dd.px; + } + else d_o.dw = d_o.dh = 0; +}; +dd.getCssProp = function(d_o, d_pn6, d_pstyle, d_pn4) +{ + if(d_o && dd.n6) return ''+window.getComputedStyle(d_o, null).getPropertyValue(d_pn6); + if(d_o && d_o.currentStyle) return ''+eval('d_o.currentStyle.'+d_pstyle); + if(d_o && d_o.style) return ''+eval('d_o.style.'+d_pstyle); + if(d_o && dd.n4) return ''+eval('d_o.'+d_pn4); + return ''; +}; +dd.getDiv = function(d_x, d_d) +{ + d_d = d_d || document; + if(dd.n4) + { + if(d_d.layers[d_x]) return d_d.layers[d_x]; + for(var d_i = d_d.layers.length; d_i--;) + { + var d_y = dd.getDiv(d_x, d_d.layers[d_i].document); + if(d_y) return d_y; + } + } + if(dd.ie) return d_d.all[d_x] || null; + if(d_d.getElementById) return d_d.getElementById(d_x) || null; + return null; +}; +dd.getImg = function(d_o, d_nm, d_xy, d_w) +{ + d_w = d_w || window; + var d_img; + if(document.images && (d_img = d_w.document.images[d_nm])) + { + if(d_xy) + { + if(dd.n4) + { + dd.getPageXY(d_w); + d_o.defx = d_img.x + dd.x; + d_o.defy = d_img.y + dd.y; + } + else + { + dd.getPageXY(d_img); + d_o.defx = dd.x; + d_o.defy = dd.y; + } + } + return d_img; + } + if(dd.n4) for(var d_i = d_w.document.layers.length; d_i--;) + { + var d_y = dd.getImg(d_o, d_nm, d_xy, d_w.document.layers[d_i]); + if(d_y) return d_y; + } + return null; +}; +dd.getParent = function(d_o, d_p) +{ + if(dd.n4) + { + for(d_p, d_i = dd.elements.length; d_i--;) + { + if(!((d_p = dd.elements[d_i]).is_image) && d_p.div && (d_p.div.document.layers[d_o.name] || d_o.oimg && d_p.div.document.images[d_o.oimg.name])) + d_p.addChild(d_o, d_p.detach, 1); + } + } + else + { + d_p = d_o.is_image? dd.getImg(d_o, d_o.oimg.name) : (d_o.div || null); + while(d_p && !!(d_p = d_p.offsetParent || d_p.parentNode || null)) + { + if(d_p.ddObj) + { + d_p.ddObj.addChild(d_o, d_p.ddObj.detach, 1); + break; + } + } + } +}; +dd.getCmd = function(d_o, d_cmd, d_cmdStr) +{ + var d_i = d_o.id.indexOf(d_cmd), d_j, + d_y = (d_i >= 0)*1; + if(d_y) + { + d_j = d_i+d_cmd.length; + if(d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j); + d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j); + } + return d_y; +}; +dd.getCmdVal = function(d_o, d_cmd, d_cmdStr, int0) +{ + var d_i = d_o.id.indexOf(d_cmd), d_j, + d_y = (d_o.id.indexOf(d_cmd) >= 0)? dd.Int(d_o.id.substring(d_o.id.indexOf(d_cmd)+d_cmd.length)) : int0? -1 : 0; + if(!int0 && d_y || int0 && d_y >= 0) + { + d_j = d_i+d_cmd.length+(""+d_y).length; + if(d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j); + d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j); + } + return d_y; +}; +dd.addElt = function(d_o, d_p) +{ + dd.elements[d_o.name] = dd.elements[d_o.index = dd.elements.length] = d_o; + if(d_p) d_p.copies[d_o.name] = d_p.copies[d_p.copies.length] = d_o; +}; +dd.mkWzDom = function() +{ + var d_o, d_i = dd.elements.length; while(d_i--) dd.getParent(dd.elements[d_i]); + d_i = dd.elements.length; while(d_i--) + { + d_o = dd.elements[d_i]; + if(d_o.children && !d_o.parent) + { + var d_j = d_o.children.length; while(d_j--) + d_o.children[d_j].setZ(d_o.z+d_o.children[d_j].z, 1); + } + } +}; +dd.addProps = function(d_o) +{ + var d_i, d_c; + if(d_o.is_image) + { + d_o.div = dd.getDiv(d_o.id); + d_o.css = (d_o.div && typeof d_o.div.style != dd_u)? d_o.div.style : null; + d_o.nimg = (dd.n4 && d_o.div)? d_o.div.document.images[0] : (document.images[d_o.id+"NI1m6G"] || null); + if(!d_o.noalt && !dd.noalt && d_o.nimg && d_o.oimg) + { + d_o.nimg.alt = d_o.oimg.alt || ''; + if(d_o.oimg.title) d_o.nimg.title = d_o.oimg.title; + } + d_o.bgColor = ''; + } + else + { + d_o.bgColor = dd.getCssProp(d_o.div, 'background-color','backgroundColor','bgColor').toLowerCase(); + if(dd.n6 && d_o.div) + { + if((d_c = d_o.bgColor).indexOf('rgb') >= 0) + { + d_c = d_c.substring(4, d_c.length-1).split(','); + d_o.bgColor = '#'; + for(d_i = 0; d_i < d_c.length; d_i++) d_o.bgColor += parseInt(d_c[d_i]).toString(0x10); + } + else d_o.bgColor = d_c; + } + } + if(dd.scalable) d_o.scalable = d_o.resizable^1; + else if(dd.resizable) d_o.resizable = d_o.scalable^1; + d_o.setZ(d_o.defz); + d_o.cursor = d_o.cursor || dd.cursor || 'auto'; + d_o._setCrs(d_o.nodrag? 'auto' : d_o.cursor); + d_o.diaphan = d_o.diaphan || dd.diaphan || 0; + d_o.opacity = 1.0; + d_o.visible = true; +}; +dd.initz = function() +{ + if(!(dd && (dd.n4 || dd.n6 || dd.ie || dd.op || dd.w3c))) return; + else if(dd.n6 || dd.ie || dd.op || dd.w3c) dd.recalc(1); + var d_drag = (document.onmousemove == DRAG), + d_resize = (document.onmousemove == RESIZE); + if(dd.loadFunc) dd.loadFunc(); + if(d_drag) dd.setMovHdl(DRAG); + else if(d_resize) dd.setMovHdl(RESIZE); + if(d_drag || d_resize) dd.setUpHdl(DROP); + dd.setDwnHdl(PICK); +}; +dd.finlz = function() +{ + if(dd.ie && dd.elements) + { + var d_i = dd.elements.length; while(d_i--) + dd.elements[d_i].del(); + } + if(dd.uloadFunc) dd.uloadFunc(); +}; +dd.setCe = function(d_e, d_fnc) +{ + d_fnc? document.captureEvents(d_e) : document.releaseEvents(d_e); +}; +dd.setDwnHdl = function(d_x) +{ + if(document.onmousedown != d_x) + { + dd.downFunc = document.onmousedown; + document.onmousedown = d_x; + if(dd.ce) dd.setCe(Event.MOUSEDOWN, d_x); + } +}; +dd.setMovHdl = function(d_x) +{ + if(document.onmousemove != d_x) + { + dd.moveFunc = document.onmousemove; + document.onmousemove = d_x; + if(dd.ce) dd.setCe(Event.MOUSEMOVE, d_x); + } +}; +dd.setUpHdl = function(d_x) +{ + if(document.onmouseup != d_x) + { + dd.upFunc = document.onmouseup; + document.onmouseup = d_x; + if(dd.ce) dd.setCe(Event.MOUSEUP, d_x); + } +}; +dd.evt = function(d_e) +{ + this.but = (this.e = d_e || window.event).which || this.e.button || 0; + this.button = (this.e.type == 'mousedown')? this.but + : (dd.e && dd.e.button)? dd.e.button + : 0; + this.src = this.e.target || this.e.srcElement || null; + this.src.tag = ("" + (this.src.tagName || this.src)).toLowerCase(); + this.x = dd.Int(this.e.pageX || this.e.clientX || 0); + this.y = dd.Int(this.e.pageY || this.e.clientY || 0); + if(dd.ie) + { + this.x += dd.getScrollX() - (dd.ie && !dd.iemac)*1; + this.y += dd.getScrollY() - (dd.ie && !dd.iemac)*1; + } + this.modifKey = this.e.modifiers? this.e.modifiers&Event.SHIFT_MASK : (this.e.shiftKey || false); +}; +dd.getEventTarget = function(d_e, d_s, d_n) +{ + d_e = d_e || window.event; + if(d_e && (d_s = d_e.target || d_e.srcElement || null) != null) + { + if(null != (d_n = d_s.id || d_s.name || null)) + { + if(d_n.indexOf("dIi15vNI1m6G") == d_n.length-12) + return dd.elements[d_n.substring(0, d_n.length-12)] || null; + if(d_n.indexOf("dIi15v") == d_n.length-6) + return dd.elements[d_n.substring(0, d_n.length-6)] || null; + return dd.elements[d_n] || null; + } + } + return null; +}; +dd.recalc = function(d_x) +{ + var d_o, d_i = dd.elements.length; while(d_i--) + { + if(!(d_o = dd.elements[d_i]).is_image && d_o.div) + { + dd.getWH(d_o); + if(d_o.div.pos_rel) + { + dd.getPageXY(d_o.div); + var d_dx = dd.x - d_o.x, d_dy = dd.y - d_o.y; + d_o.defx += d_dx; + d_o.x += d_dx; + d_o.defy += d_dy; + d_o.y += d_dy; + var d_p, d_j = d_o.children.length; while(d_j--) + { + if(!(d_p = d_o.children[d_j]).detached && (d_o != d_p.defparent || !(d_p.is_image && dd.getImg(d_p, d_p.oimg.name, 1)))) + { + d_p.defx += d_dx; + d_p.defy += d_dy; + d_p.moveBy(d_dx, d_dy); + } + } + } + } + else if(d_o.is_image && !dd.n4) + { + if(dd.n6 && d_x && !d_o.defw) d_o.resizeTo(d_o.defw = dd.getImgW(d_o.oimg), d_o.defh = dd.getImgH(d_o.oimg)); + var d_defx = d_o.defx, d_defy = d_o.defy; + if(!(d_o.parent && d_o.parent != d_o.defparent) && (d_x || !d_o.detached || d_o.horizontal || d_o.vertical) && dd.getImg(d_o, d_o.oimg.name, 1)) + d_o.moveBy(d_o.defx-d_defx, d_o.defy-d_defy); + } + } +}; +function WINSZ(d_x) +{ + if(d_x) + { + if(dd.n4) + { + dd.iW = innerWidth; + dd.iH = innerHeight; + } + window.onresize = new Function('WINSZ();'); + } + else if(dd.n4 && (innerWidth != dd.iW || innerHeight != dd.iH)) location.reload(); + else if(!dd.n4) setTimeout('dd.recalc()', 0xa); +} +WINSZ(1); + +function DDObj(d_o, d_i) +{ + this.id = d_o; + this.cmd = ''; + this.cpy_n = dd.getCmdVal(this, COPY); + this.maxoffb = dd.getCmdVal(this, MAXOFFBOTTOM, 0, 1); + this.maxoffl = dd.getCmdVal(this, MAXOFFLEFT, 0, 1); + this.maxoffr = dd.getCmdVal(this, MAXOFFRIGHT, 0, 1); + this.maxofft = dd.getCmdVal(this, MAXOFFTOP, 0, 1); + var d_j = dd_cursors.length; while(d_j--) + if(dd.getCmd(this, dd_cursors[d_j], 1)) this.cursor = dd_cursors[d_j].substring(2); + this.clone = dd.getCmd(this, CLONE, 1); + this.detach = dd.getCmd(this, DETACH_CHILDREN); + this.scalable = dd.getCmd(this, SCALABLE, 1); + this.horizontal = dd.getCmd(this, HORIZONTAL); + this.noalt = dd.getCmd(this, NO_ALT, 1); + this.nodrag = dd.getCmd(this, NO_DRAG); + this.scroll = dd.getCmd(this, SCROLL, 1); + this.resizable = dd.getCmd(this, RESIZABLE, 1); + this.re_z = dd.getCmd(this, RESET_Z, 1); + this.diaphan = dd.getCmd(this, TRANSPARENT, 1); + this.vertical = dd.getCmd(this, VERTICAL); + this.maxw = dd.getCmdVal(this, MAXWIDTH, 1, 1); + this.minw = Math.abs(dd.getCmdVal(this, MINWIDTH, 1, 1)); + this.maxh = dd.getCmdVal(this, MAXHEIGHT, 1, 1); + this.minh = Math.abs(dd.getCmdVal(this, MINHEIGHT, 1, 1)); + this.pickFunc = this.dragFunc = this.resizeFunc = this.dropFunc = null; + + this.name = this.id + (d_i || ''); + this.oimg = dd.getImg(this, this.id, 1); + this.is_image = !!this.oimg; + this.copies = new Array(); + this.children = new Array(); + this.parent = this.original = null; + if(this.oimg) + { + this.id = this.name + "dIi15v"; + this.w = dd.getImgW(this.oimg); + this.h = dd.getImgH(this.oimg); + this.dw = this.dh = 0; + this.defz = dd.Int(dd.getCssProp(this.oimg, 'z-index','zIndex','zIndex')) || 1; + this.defsrc = this.src = this.oimg.src; + this.htm = '<img name="' + this.id + 'NI1m6G"'+ + ' src="' + this.oimg.src + '" '+ + 'width="' + this.w + '" height="' + this.h + '">'; + this.t_htm = '<div id="' + this.id + + '" style="position:absolute;'+ + 'left:' + (this.cssx = this.x = this.defx) + 'px;'+ + 'top:' + (this.cssy = this.y = this.defy) + 'px;'+ + 'width:' + this.w + 'px;'+ + 'height:' + this.h + 'px;">'+ + this.htm + '</div>'; + } + else + { + if(!!(this.div = dd.getDiv(this.id)) && typeof this.div.style != dd_u) this.css = this.div.style; + dd.getWH(this); + if(this.div) + { + this.div.ddObj = this; + this.div.pos_rel = ("" + (this.div.parentNode? this.div.parentNode.tagName : this.div.parentElement? this.div.parentElement.tagName : '').toLowerCase().indexOf('body') < 0); + } + dd.getPageXY(this.div); + this.defx = this.x = dd.x; + this.defy = this.y = dd.y; + dd.getCssXY(this); + this.defz = dd.Int(dd.getCssProp(this.div, 'z-index','zIndex','zIndex')); + } + this.defw = this.w || 0; + this.defh = this.h || 0; +} +DDObj.prototype.setPickFunc = function(d_x) +{ + this.pickFunc = d_x; +}; +DDObj.prototype.setDragFunc = function(d_x) +{ + this.dragFunc = d_x; +}; +DDObj.prototype.setResizeFunc = function(d_x) +{ + this.resizeFunc = d_x; +}; +DDObj.prototype.setDropFunc = function(d_x) +{ + this.dropFunc = d_x; +}; +DDObj.prototype.moveBy = function(d_x, d_y, d_kds, d_o) +{ + if(!this.div) return; + this.x += (d_x = dd.Int(d_x)); + this.y += (d_y = dd.Int(d_y)); + if(!d_kds || this.is_image || this.parent != this.defparent) + { + (d_o = this.css || this.div).left = (this.cssx += d_x) + dd.px; + d_o.top = (this.cssy += d_y) + dd.px; + } + var d_i = this.children.length; while(d_i--) + { + if(!(d_o = this.children[d_i]).detached) d_o.moveBy(d_x, d_y, 1); + d_o.defx += d_x; + d_o.defy += d_y; + } +}; + +DDObj.prototype.moveTo = function(d_x, d_y) +{ + this.moveBy(dd.Int(d_x)-this.x, dd.Int(d_y)-this.y); +}; +DDObj.prototype.hide = function(d_m, d_o, d_p) +{ + if(this.div && this.visible) + { + d_p = this.css || this.div; + if(d_m && !dd.n4) + { + this.display = dd.getCssProp(this.div, "display", "display", "display"); + if(this.oimg) + { + this.oimg.display = dd.getCssProp(this.oimg, "display", "display", "display"); + this.oimg.style.display = "none"; + } + d_p.display = "none"; + dd.recalc(); + } + else d_p.visibility = "hidden"; + } + this.visible = false; + var d_i = this.children.length; while(d_i--) + if(!(d_o = this.children[d_i]).detached) d_o.hide(d_m); +}; +DDObj.prototype.show = function(d_o, d_p) +{ + if(this.div) + { + d_p = this.css || this.div; + if(d_p.display && d_p.display == "none") + { + d_p.display = this.display || "block"; + if(this.oimg) this.oimg.style.display = this.oimg.display || "inline"; + dd.recalc(); + } + else d_p.visibility = "visible"; + } + this.visible = true; + var d_i = this.children.length; while(d_i--) + if(!(d_o = this.children[d_i]).detached) d_o.show(); +}; +DDObj.prototype.resizeTo = function(d_w, d_h, d_o) +{ + if(!this.div) return; + d_w = (this.w = dd.Int(d_w))-this.dw; + d_h = (this.h = dd.Int(d_h))-this.dh; + if(dd.n4) + { + this.div.resizeTo(d_w, d_h); + if(this.is_image) + { + this.write('<img src="' + this.src + '" width="' + d_w + '" height="' + d_h + '">'); + (this.nimg = this.div.document.images[0]).src = this.src; + } + } + else if(typeof this.css.pixelWidth != dd_u) + { + this.css.pixelWidth = d_w; + this.css.pixelHeight = d_h; + if(this.is_image) + { + (d_o = this.nimg.style).pixelWidth = d_w; + d_o.pixelHeight = d_h; + } + } + else + { + this.css.width = d_w + dd.px; + this.css.height = d_h + dd.px; + if(this.is_image) + { + (d_o = this.nimg).width = d_w; + d_o.height = d_h; + if(!d_o.complete) d_o.src = this.src; + } + } +}; +DDObj.prototype.resizeBy = function(d_dw, d_dh) +{ + this.resizeTo(this.w+dd.Int(d_dw), this.h+dd.Int(d_dh)); +}; +DDObj.prototype.swapImage = function(d_x, d_cp) +{ + if(!this.nimg) return; + this.nimg.src = d_x; + this.src = this.nimg.src; + if(d_cp) + { + var d_i = this.copies.length; while(d_i--) + this.copies[d_i].src = this.copies[d_i].nimg.src = this.nimg.src; + } +}; +DDObj.prototype.setBgColor = function(d_x) +{ + if(dd.n4 && this.div) this.div.bgColor = d_x; + else if(this.css) this.css.background = d_x; + this.bgColor = d_x; +}; +DDObj.prototype.write = function(d_x, d_o) +{ + this.text = d_x; + if(!this.div) return; + if(dd.n4) + { + (d_o = this.div.document).open(); + d_o.write(d_x); + d_o.close(); + dd.getWH(this); + } + else + { + this.css.height = 'auto'; + this.div.innerHTML = d_x; + if(!dd.ie4) dd.recalc(); + if(dd.ie4 || dd.n6) setTimeout('dd.recalc();', 0); // n6.0: recalc twice + } +}; +DDObj.prototype.copy = function(d_n, d_p, d_b) +{ + if(!this.oimg) return; + d_b = (dd.ie && document.all.tags('body'))? document.all.tags('body')[0] : document.getElementsByTagName? (document.getElementsByTagName('body')[0] || dd.db) : dd.db; + d_n = d_n || 1; + while(d_n--) + { + var d_l = this.copies.length, + d_o = new DDObj(this.name+this.cmd, d_l+1); + if(dd.n4) + { + d_o.id = (d_p = new Layer(d_o.w)).name; + d_p.clip.height = d_o.h; + d_p.visibility = 'show'; + (d_p = d_p.document).open(); + d_p.write(d_o.htm); + d_p.close(); + } + else if(d_b && d_b.insertAdjacentHTML) d_b.insertAdjacentHTML("AfterBegin", d_o.t_htm); + else if(document.createElement && d_b && d_b.appendChild) + { + d_b.appendChild(d_p = document.createElement("dIi15v")); + d_p.innerHTML = d_o.htm; + d_p.id = d_o.id; + d_p.style.position = 'absolute'; + d_p.style.width = d_o.w + 'px'; + d_p.style.height = d_o.h + 'px'; + } + else if(d_b && d_b.innerHTML) d_b.innerHTML += d_o.t_htm; + d_o.defz = this.defz+1+d_l; + dd.addProps(d_o); + d_o.original = this; + dd.addElt(d_o, this); + if(this.parent) + { + this.parent.addChild(d_o, this.detached); + d_o.defparent = this.defparent; + } + d_o.moveTo(d_o.defx = this.defx, d_o.defy = this.defy); + if(dd.n4) d_o.defsrc = d_o.src = this.defsrc; + d_o.swapImage(this.src); + } +}; +DDObj.prototype.addChild = function(d_kd, detach, defp) +{ + if(typeof d_kd != "object") d_kd = dd.elements[d_kd]; + if(d_kd.parent && d_kd.parent == this || d_kd == this || !d_kd.is_image && d_kd.defparent && !defp) return; + + this.children[this.children.length] = this.children[d_kd.name] = d_kd; + d_kd.detached = detach || 0; + if(defp) d_kd.defparent = this; + else if(this == d_kd.defparent && d_kd.is_image) dd.getImg(this, d_kd.oimg.name, 1); + if(!d_kd.defparent || this != d_kd.defparent) + { + d_kd.defx = d_kd.x; + d_kd.defy = d_kd.y; + } + if(!detach) + { + d_kd.defz = d_kd.defz+this.defz-(d_kd.parent? d_kd.parent.defz : 0)+(!d_kd.is_image*1); + d_kd.setZ(d_kd.z+this.z-(d_kd.parent? d_kd.parent.z : 0)+(!d_kd.is_image*1), 1); + } + if(d_kd.parent) d_kd.parent._removeChild(d_kd, 1); + d_kd.parent = this; +}; +DDObj.prototype._removeChild = function(d_kd, d_newp) +{ + if(typeof d_kd != "object") d_kd = this.children[d_kd]; + var d_oc = this.children, d_nc = new Array(); + for(var d_i = 0; d_i < d_oc.length; d_i++) + if(d_oc[d_i] != d_kd) d_nc[d_nc.length] = d_oc[d_i]; + this.children = d_nc; + d_kd.parent = null; + if(!d_newp) + { + d_kd.detached = d_kd.defp = 0; + if(d_kd.is_image) dd.getImg(d_kd, d_kd.oimg.name, 1); + } +}; +DDObj.prototype.attachChild = function(d_kd) +{ + (d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 0; + d_kd.setZ(d_kd.defz + this.z-this.defz, 1); +}; +DDObj.prototype.detachChild = function(d_kd) +{ + (d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 1; +}; +DDObj.prototype.setZ = function(d_x, d_kds, d_o) +{ + if(d_kds) + { + var d_dz = d_x-this.z, + d_i = this.children.length; while(d_i--) + if(!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.z+d_dz, 1); + } + dd.z = Math.max(dd.z, this.z = this.div? ((this.css || this.div).zIndex = d_x) : 0); +}; +DDObj.prototype.maximizeZ = function() +{ + this.setZ(dd.z+1, 1); +}; +DDObj.prototype._resetZ = function(d_o) +{ + if(this.re_z || dd.re_z) + { + this.setZ(this.defz); + var d_i = this.children.length; while(d_i--) + if(!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.defz); + } +}; +DDObj.prototype.setOpacity = function(d_x) +{ + this.opacity = d_x; + this._setOpaRel(1.0, 1); +}; +DDObj.prototype._setOpaRel = function(d_x, d_kd, d_y, d_o) +{ + if(this.css && (this.diaphan || d_kd)) + { + d_y = this.opacity*d_x; + if(typeof this.css.MozOpacity != dd_u) this.css.MozOpacity = d_y; + else if(typeof this.css.filter != dd_u) + this.css.filter = "Alpha(opacity="+parseInt(100*d_y)+")"; + else this.css.opacity = d_y; + var d_i = this.children.length; while(d_i--) + if(!(d_o = this.children[d_i]).detached) d_o._setOpaRel(d_x, 1); + } +}; +DDObj.prototype.setCursor = function(d_x) +{ + this._setCrs(this.cursor = (d_x.indexOf('c:')+1)? d_x.substring(2) : d_x); +}; +DDObj.prototype._setCrs = function(d_x) +{ + if(this.css) this.css.cursor = ((!dd.ie || dd.iemac) && d_x == 'hand')? 'pointer' : d_x; +}; +DDObj.prototype.setDraggable = function(d_x) +{ + this.nodrag = !d_x*1; + this._setCrs(d_x? this.cursor : 'auto'); +}; +DDObj.prototype.setResizable = function(d_x) +{ + this.resizable = d_x*1; + if(d_x) this.scalable = 0; +}; +DDObj.prototype.setScalable = function(d_x) +{ + this.scalable = d_x*1; + if(d_x) this.resizable = 0; +}; +DDObj.prototype.getEltBelow = function(d_ret, d_x, d_y) +{ + var d_o, d_cmp = -1, d_i = dd.elements.length; while(d_i--) + { + d_o = dd.elements[d_i]; + d_x = d_o.x-this.w/2; + d_y = d_o.y-this.h/2; + if(d_o.visible && d_o.z < this.z && this.x >= d_x && this.x <= d_x+d_o.w && this.y >= d_y && this.y <= d_y+d_o.h) + { + if(d_o.z > d_cmp) + { + d_cmp = d_o.z; + d_ret = d_o; + } + } + } + return d_ret; +}; +DDObj.prototype.del = function(d_os, d_o) +{ + var d_i; + if(this.parent && this.parent._removeChild) this.parent._removeChild(this); + if(this.original) + { + this.hide(); + if(this.original.copies) + { + d_os = new Array(); + for(d_i = 0; d_i < this.original.copies.length; d_i++) + if((d_o = this.original.copies[d_i]) != this) d_os[d_o.name] = d_os[d_os.length] = d_o; + this.original.copies = d_os; + } + } + else if(this.is_image) + { + this.hide(); + if(this.oimg) + { + if(dd.n4) this.oimg.src = this.defsrc; + else this.oimg.style.visibility = 'visible'; + } + } + else if(this.moveTo) + { + if(this.css) this.css.cursor = 'default'; + this.moveTo(this.defx, this.defy); + this.resizeTo(this.defw, this.defh); + } + d_os = new Array(); + for(d_i = 0; d_i < dd.elements.length; d_i++) + { + if((d_o = dd.elements[d_i]) != this) d_os[d_o.name] = d_os[d_o.index = d_os.length] = d_o; + else d_o._free(); + } + dd.elements = d_os; + if(!dd.n4) dd.recalc(); +}; +DDObj.prototype._free = function() +{ + for(var d_i in this) + this[d_i] = null; + dd.elements[this.name] = null; +}; +dd.n4RectVis = function(vis) +{ + for(var d_i = 4; d_i--;) + { + dd.rectI[d_i].visibility = dd.rectA[d_i].visibility = vis? 'show' : 'hide'; + if(vis) dd.rectI[d_i].zIndex = dd.rectA[d_i].zIndex = dd.z+2; + } +}; +dd.n4RectPos = function(d_o, d_x, d_y, d_w, d_h) +{ + d_o.x = d_x; + d_o.y = d_y; + d_o.clip.width = d_w; + d_o.clip.height = d_h; +}; +// NN4: Draw img sizing rect +dd.n4Rect = function(d_w, d_h) +{ + var d_i; + if(!dd.rectI) + { + dd.rectI = new Array(); + dd.rectA = new Array(); + } + if(!dd.rectI[0]) + { + for(d_i = 4; d_i--;) + { + (dd.rectI[d_i] = new Layer(1)).bgColor = '#000000'; + (dd.rectA[d_i] = new Layer(1)).bgColor = '#ffffff'; + } + } + if(!dd.rectI[0].visibility || dd.rectI[0].visibility == 'hide') dd.n4RectVis(1); + dd.obj.w = d_w; + dd.obj.h = d_h; + for(d_i = 4; d_i--;) + { + dd.n4RectPos(dd.rectI[d_i], dd.obj.x + (!(d_i-1)? (dd.obj.w-1) : 0), dd.obj.y + (!(d_i-2)? (dd.obj.h-1) : 0), d_i&1 || dd.obj.w, !(d_i&1) || dd.obj.h); + dd.n4RectPos(dd.rectA[d_i], !(d_i-1)? dd.rectI[1].x+1 : (dd.obj.x-1), !(d_i-2)? dd.rectI[2].y+1 : (dd.obj.y-1), d_i&1 || dd.obj.w+2, !(d_i&1) || dd.obj.h+2); + } +}; +dd.reszTo = function(d_w, d_h) +{ + if(dd.n4 && dd.obj.is_image) dd.n4Rect(d_w, d_h); + else dd.obj.resizeTo(d_w, d_h); +}; +dd.embedVis = function(d_vis) +{ + var d_o = new Array('iframe', 'applet', 'embed', 'object'); + var d_i = d_o.length; while(d_i--) + { + var d_p = dd.ie? document.all.tags(d_o[d_i]) : document.getElementsByTagName? document.getElementsByTagName(d_o[d_i]) : null; + if(d_p) + { + var d_j = d_p.length; while(d_j--) + { + var d_q = d_p[d_j]; + while(d_q.offsetParent || d_q.parentNode) + { + if((d_q = d_q.parentNode || d_q.offsetParent || null) == dd.obj.div) + { + d_p[d_j].style.visibility = d_vis; + break; + } + } + } + } + } +}; + +dd.maxOffX = function(d_x, d_y) +{ + return( + (dd.obj.maxoffl+1 && (d_y = dd.obj.defx-dd.obj.maxoffl)-d_x > 0 + || dd.obj.maxoffr+1 && (d_y = dd.obj.defx+dd.obj.maxoffr)-d_x < 0)? d_y + : d_x + ); +}; +dd.maxOffY = function(d_x, d_y) +{ + return( + (dd.obj.maxofft+1 && (d_y = dd.obj.defy-dd.obj.maxofft)-d_x > 0 + || dd.obj.maxoffb+1 && (d_y = dd.obj.defy+dd.obj.maxoffb)-d_x < 0)? d_y + : d_x + ); +}; +dd.inWndW = function(d_x, d_y) +{ + var d_wx = dd.getScrollX(), + d_ww = dd.getWndW(); + return( + ((d_y = d_wx+2)-d_x > 0) || ((d_y = d_wx+d_ww+dd.obj.w-2)-d_x < 0)? d_y + : d_x + ); +}; +dd.inWndH = function(d_x, d_y) +{ + var d_wy = dd.getScrollY(), + d_wh = dd.getWndH(); + return( + ((d_y = d_wy+2)-d_x > 0) || ((d_y = d_wy+d_wh+dd.obj.h-2)-d_x < 0)? d_y + : d_x + ); +}; +// These two funcs limit the size of element when mouseresized. +// Implemented 22.5.2003 by Gregor Ltolf <gregor@milou.ch>, modified by Walter Zorn +dd.limW = function(d_w) +{ + return( + (dd.obj.minw-d_w > 0)? dd.obj.minw + : (dd.obj.maxw > 0 && dd.obj.maxw-d_w < 0)? dd.obj.maxw + : d_w + ); +}; +dd.limH = function(d_h) +{ + return( + (dd.obj.minh-d_h > 0)? dd.obj.minh + : (dd.obj.maxh > 0 && dd.obj.maxh-d_h < 0)? dd.obj.maxh + : d_h + ); +}; +// Optional autoscroll-page functionality. Courtesy Cedric Savarese. +// Implemented by Walter Zorn +function DDScroll() +{ + if(!dd.obj || !dd.obj.scroll && !dd.scroll || dd.ie4 || dd.whratio) + { + dd.scrx = dd.scry = 0; + return; + } + var d_bnd = 0x1c, + d_wx = dd.getScrollX(), d_wy = dd.getScrollY(); + if(dd.msmoved) + { + var d_ww = dd.getWndW(), d_wh = dd.getWndH(), d_y; + dd.scrx = ((d_y = dd.e.x-d_ww-d_wx+d_bnd) > 0)? (d_y>>=2)*d_y + : ((d_y = d_wx+d_bnd-dd.e.x) > 0)? -(d_y>>=2)*d_y + : 0; + dd.scry = ((d_y = dd.e.y-d_wh-d_wy+d_bnd) > 0)? (d_y>>=2)*d_y + : ((d_y = d_wy+d_bnd-dd.e.y) > 0)? -(d_y>>=2)*d_y + : 0; + } + if(dd.scrx || dd.scry) + { + window.scrollTo( + d_wx + (dd.scrx = dd.obj.is_resized? dd.limW(dd.obj.w+dd.scrx)-dd.obj.w : dd.obj.vertical? 0 : (dd.maxOffX(dd.obj.x+dd.scrx)-dd.obj.x)), + d_wy + (dd.scry = dd.obj.is_resized? dd.limH(dd.obj.h+dd.scry)-dd.obj.h : dd.obj.horizontal? 0 : (dd.maxOffY(dd.obj.y+dd.scry)-dd.obj.y)) + ); + dd.obj.is_dragged? dd.obj.moveTo(dd.obj.x+dd.getScrollX()-d_wx, dd.obj.y+dd.getScrollY()-d_wy) + : dd.reszTo(dd.obj.w+dd.getScrollX()-d_wx, dd.obj.h+dd.getScrollY()-d_wy); + } + dd.msmoved = 0; + window.setTimeout('DDScroll()', 0x33); +} +function PICK(d_ev) +{ + dd.e = new dd.evt(d_ev); + if(dd.e.x >= dd.getWndW()+dd.getScrollX() || dd.e.y >= dd.getWndH()+dd.getScrollY()) return true; // on scrollbar + var d_o, d_t, d_cmp = -1, d_i = dd.elements.length; while(d_i--) + { + d_o = dd.elements[d_i]; + if(dd.n4 && dd.e.but > 1 && dd.e.src == d_o.oimg && !d_o.clone) return false; + if(d_o.visible && dd.e.but <= 1 && dd.e.x >= d_o.x && dd.e.x <= d_o.x+d_o.w && dd.e.y >= d_o.y && dd.e.y <= d_o.y+d_o.h) + { + if(d_o.z > d_cmp && (d_t = dd.e.src.tag).indexOf('inpu') < 0 && d_t.indexOf('texta') < 0 && d_t.indexOf('sele') < 0 && d_t.indexOf('opti') < 0 && d_t.indexOf('scrol') < 0) + { + d_cmp = d_o.z; + dd.obj = d_o; + } + } + } + if(dd.obj) + { + if(dd.obj.nodrag) dd.obj = null; + else + { + dd.e.e.cancelBubble = true; + var d_rsz = dd.e.modifKey && (dd.obj.resizable || dd.obj.scalable); + if(dd.op) + { + (d_o = document.getElementById('OpBlUr')).style.pixelLeft = dd.e.x; + d_o.style.pixelTop = dd.e.y; + (d_o = d_o.children[0].children[0]).focus(); + d_o.blur(); + } + else if(dd.ie && !dd.ie4) + { + if(document.selection && document.selection.empty) document.selection.empty(); + dd.db.onselectstart = function() + { + event.returnValue = false; + }; + } + if(d_rsz) + { + dd.obj._setCrs('se-resize'); + dd.obj.is_resized = 1; + dd.whratio = dd.obj.scalable? dd.obj.defw/dd.obj.defh : 0; + if(dd.ie) + { + if(dd.ie4) + { + window.dd_x = dd.getScrollX(); + window.dd_y = dd.getScrollY(); + } + setTimeout( + 'if(dd.obj && document.selection && document.selection.empty)'+ + '{'+ + 'document.selection.empty();'+ + 'if(dd.ie4) window.scrollTo(window.dd_x, window.dd_y);'+ + '}' + ,0); + } + dd.setMovHdl(RESIZE); + dd.reszTo(dd.obj.w, dd.obj.h); + } + else + { + dd.obj.is_dragged = 1; + dd.setMovHdl(DRAG); + } + dd.setUpHdl(DROP); + dd.embedVis('hidden'); + dd.obj._setOpaRel(0.7); + dd.obj.maximizeZ(); + dd.ofx = dd.obj.x+dd.obj.w-dd.e.x; + dd.ofy = dd.obj.y+dd.obj.h-dd.e.y; + if(window.my_PickFunc) my_PickFunc(); + if(dd.obj.pickFunc) dd.obj.pickFunc(); + DDScroll(); + return !( + dd.obj.is_resized + || dd.n4 && dd.obj.is_image + || dd.n6 || dd.w3c + ); + } + } + if(dd.downFunc) return dd.downFunc(d_ev); + return true; +} +function DRAG(d_ev) +{ + if(!dd.obj || !dd.obj.visible) return true; + if(dd.ie4 || dd.w3c || dd.n6 || dd.obj.children.length > 0xf) + { + if(dd.wait) return false; + dd.wait = 1; + setTimeout('dd.wait = 0;', dd.tiv); + } + dd.e = new dd.evt(d_ev); + if(dd.ie && !dd.e.but) + { + DROP(d_ev); + return true; + } + dd.msmoved = 1; + dd.obj.moveTo( + dd.obj.vertical? dd.obj.x : dd.maxOffX(dd.inWndW(dd.ofx+dd.e.x)-dd.obj.w), + dd.obj.horizontal? dd.obj.y : dd.maxOffY(dd.inWndH(dd.ofy+dd.e.y)-dd.obj.h) + ); + + if(window.my_DragFunc) my_DragFunc(); + if(dd.obj.dragFunc) dd.obj.dragFunc(); + if(dd.moveFunc) return dd.moveFunc(d_ev); + return false; +} +function RESIZE(d_ev) +{ + if(!dd.obj || !dd.obj.visible) return true; + if(dd.wait) return false; + dd.wait = 1; + setTimeout('dd.wait = 0;', dd.tiv); + dd.e = new dd.evt(d_ev); + if(dd.ie && !dd.e.but) + { + DROP(d_ev); + return true; + } + dd.msmoved = 1; + var d_w = dd.limW(dd.inWndW(dd.ofx+dd.e.x)-dd.obj.x), d_h; + if(!dd.whratio) d_h = dd.limH(dd.inWndH(dd.ofy+dd.e.y)-dd.obj.y); + else + { + d_h = dd.limH(dd.inWndH(Math.round(d_w/dd.whratio)+dd.obj.y)-dd.obj.y); + d_w = Math.round(d_h*dd.whratio); + } + dd.reszTo(d_w, d_h); + if(window.my_ResizeFunc) my_ResizeFunc(); + if(dd.obj.resizeFunc) dd.obj.resizeFunc(); + if(dd.moveFunc) return dd.moveFunc(d_ev); + return false; +} +function DROP(d_ev) +{ + if(dd.obj) + { + if(dd.obj.is_dragged) + { + if(!dd.obj.is_image) dd.getWH(dd.obj); + } + else if(dd.n4) + { + if(dd.obj.is_image) + { + dd.n4RectVis(0); + dd.obj.resizeTo(dd.obj.w, dd.obj.h); + } + } + if(!dd.n4 || !dd.obj.is_image) dd.recalc(); + dd.setMovHdl(dd.moveFunc); + dd.setUpHdl(dd.upFunc); + if(dd.db) dd.db.onselectstart = null; + dd.obj._setOpaRel(1.0); + dd.obj._setCrs(dd.obj.cursor); + dd.embedVis('visible'); + dd.obj._resetZ(); + dd.e = new dd.evt(d_ev); + if(window.my_DropFunc) my_DropFunc(); + if(dd.obj.dropFunc) dd.obj.dropFunc(); + dd.msmoved = dd.obj.is_dragged = dd.obj.is_resized = dd.whratio = 0; + dd.obj = null; + } + dd.setDwnHdl(PICK); +} +function SET_DHTML() +{ + var d_a = arguments, d_ai, d_htm = '', d_o, d_i = d_a.length; while(d_i--) + { + if(!(d_ai = d_a[d_i]).indexOf('c:')) dd.cursor = d_ai.substring(2); + else if(d_ai == NO_ALT) dd.noalt = 1; + else if(d_ai == SCROLL) dd.scroll = 1; + else if(d_ai == RESET_Z) dd.re_z = 1; + else if(d_ai == RESIZABLE) dd.resizable = 1; + else if(d_ai == SCALABLE) dd.scalable = 1; + else if(d_ai == TRANSPARENT) dd.diaphan = 1; + else + { + d_o = new DDObj(d_ai); + dd.addElt(d_o); + d_htm += d_o.t_htm || ''; + if(d_o.oimg && d_o.cpy_n) + { + var d_j = 0; while(d_j < d_o.cpy_n) + { + var d_p = new DDObj(d_o.name+d_o.cmd, ++d_j); + dd.addElt(d_p, d_o); + d_p.defz = d_o.defz+d_j; + d_p.original = d_o; + d_htm += d_p.t_htm; + } + } + } + } + if (dd.n4 || dd.n6 || dd.ie || dd.op || dd.w3c) document.write( + (dd.n4? '<div style="position:absolute;"><\/div>\n' + : (dd.op && !dd.op6)? '<div id="OpBlUr" style="position:absolute;visibility:hidden;width:0px;height:0px;"><form><input type="text" style="width:0px;height:0px;"><\/form><\/div>' + : '') + d_htm + ); + dd.z = 0x33; + d_i = dd.elements.length; while(d_i--) + { + dd.addProps(d_o = dd.elements[d_i]); + if(d_o.is_image && !d_o.original && !d_o.clone) + dd.n4? d_o.oimg.src = spacer : d_o.oimg.style.visibility = 'hidden'; + } + dd.mkWzDom(); + if(window.onload) dd.loadFunc = window.onload; + if(window.onunload) dd.uloadFunc = window.onunload; + window.onload = dd.initz; + window.onunload = dd.finlz; + dd.setDwnHdl(PICK); +} +function ADD_DHTML(d_o) // layers only! +{ + d_o = new DDObj(d_o); + dd.addElt(d_o); + dd.addProps(d_o); + dd.mkWzDom(); +} + + + + +//////////////////////////////////////////////////////////// +// If not needed, all code below this line may be removed + + +// For backward compatibility +dd.d = document; // < v. 2.72 +var RESET_ZINDEX = RESET_Z; // < 3.44 +var KEYDOWN_RESIZE = RESIZABLE; // < 4.43 +var CURSOR_POINTER = CURSOR_HAND; // < 4.44 +var NO_SCROLL = ''; // < v. 4.49 + + + + +//////////////////////////////////////////////////////////// +// FUNCTIONS FOR EXTENDED SCRIPTING +// Use these for your own extensions, +// or to call functions defined elsewhere + + + +/* my_PickFunc IS AUTOMATICALLY CALLED WHEN AN ITEM STARTS TO BE DRAGGED. +The following objects/properties are accessible from here: + +- dd.e: current mouse event +- dd.e.property: access to a property of the current mouse event. + Mostly requested properties: + - dd.e.x: document-related x co-ordinate + - dd.e.y: document-related y co-ord + - dd.e.src: target of mouse event (not identical with the drag drop object itself). + - dd.e.button: currently pressed mouse button. Left button: dd.e.button <= 1 + +- dd.obj: reference to currently dragged item. +- dd.obj.property: access to any property of that item. +- dd.obj.method(): for example dd.obj.resizeTo() or dd.obj.swapImage() . + Mostly requested properties: + - dd.obj.name: image name or layer ID passed to SET_DHTML(); + - dd.obj.x and dd.obj.y: co-ordinates; + - dd.obj.w and dd.obj.h: size; + - dd.obj.is_dragged: 1 while item is dragged, else 0; + - dd.obj.is_resized: 1 while item is resized, i.e. if <ctrl> or <shift> is pressed, else 0 + +For more properties and details, visit the API documentation +at http://www.walterzorn.com/dragdrop/api_e.htm (english) or +http://www.walterzorn.de/dragdrop/api.htm (german) */ +function my_PickFunc() +{ +} + + + + +/* my_DragFunc IS CALLED WHILE AN ITEM IS DRAGGED +See the description of my_PickFunc above for what's accessible from here. */ +function my_DragFunc() +{ + //window.status = 'dd.elements.' + dd.obj.name + '.x = ' + dd.obj.x + ' dd.elements.' + dd.obj.name + '.y = ' + dd.obj.y; +} + + + + +/* my_ResizeFunc IS CALLED WHILE AN ITEM IS RESIZED +See the description of my_PickFunc above for what's accessible from here. */ +function my_ResizeFunc() +{ + //window.status = 'dd.elements.' + dd.obj.name + '.w = ' + dd.obj.w + ' dd.elements.' + dd.obj.name + '.h = ' + dd.obj.h; +} + + + + +/* THIS ONE IS CALLED ONCE AN ITEM IS DROPPED +See the description of my_PickFunc for what's accessible from here. +Here may be investigated, for example, what's the name (dd.obj.name) +of the dropped item, and where (dd.obj.x, dd.obj.y) it has been dropped... */ +function my_DropFunc() +{ +} diff --git a/functions.php b/functions.php new file mode 100644 index 0000000000000000000000000000000000000000..3a87be4a5a54d8edd5d89a3c707ad68ae01bc2c7 --- /dev/null +++ b/functions.php @@ -0,0 +1,789 @@ +<?php +require_once 'config.inc.php'; +require_once 'Numbers/Words.php'; +define('START', 0); +define('INTRODUCTION', 1); +define('SPLASH_RATING', 2); +define('RANKING', 3); +define('COMMENTS', 4); +define('AUDIENCE', 5); +define('QUESTIONNAIRE', 6); +define('THANKYOU', 7); + +function heavyLoad() { + $line = shell_exec("top -l 1 | grep 'CPU usage'"); + + $idle = shell_exec("top -l 1 | grep 'CPU usage' | awk '{print $12}'"); + $idle = substr($idle,0,3); + + $load = shell_exec("top -l 1 | grep 'CPU usage' | awk '{print $3}'"); + $load = substr($load,0,4); + + //if ($load<3.2 && $idle>10) { + if ($load<3.0) { + return false; + } else { + return true; + } +} + +class Voting_System +{ + private $voter; + + function displayHeaderData() + { + echo '<script type="text/javascript" src="ajax_server.php?client=all"></script>'; + echo '<script type="text/javascript" src="ajax_server.php?stub=Voting_System"></script>'; + echo '<script type="text/javascript" src="drag/wz_dragdrop.js"></script>'; + echo '<script type="text/javascript" src="voting_system.js"></script>'; + echo '<link type="text/css" rel="stylesheet" href="style.css" />'; + } + + /** + * This function initializes a voter, creates a record within the database. + * + */ + function initializeVoter() + { + $options = &PEAR::getStaticProperty('DB_DataObject', 'options'); + $this->voter->ip = $_SERVER['REMOTE_ADDR']; + $this->voter->step = START; + $this->voter->submitdatetime = date('Y-m-d H:i:s'); + if (isset($_GET['at'])) { + switch($_GET['at']) { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + $this->voter->audience_id = $_GET['at']; + break; + default: + break; + } + } + $mdb2 =& MDB2::factory($options['database']); + if (PEAR::isError($mdb2)) { + echo ($mdb2->getMessage()); + } + + $query ='SELECT id FROM prototype'; + + // run the query and get a result handler + $result = $mdb2->queryCol($query); + + // check if the query was executed properly + if (PEAR::isError($result)) { + echo ($result->getMessage()); + exit(); + } + + // Randomize the prototypes. + shuffle($result); + + $this->voter->prototype_order = serialize($result); + + if ($this->voter->insert()) { + $this->step = INTRODUCTION; + $_SESSION['voter_id'] = $this->getVoterId(); + return true; + } else { + return false; + } + } + + function setStep($step) + { + $this->voter->step = $step; + return $this->voter->update(); + } + + function __construct() + { + $this->functions = array( + START=>'start', + INTRODUCTION=>'introduction', + SPLASH_RATING=>'', + COMMENTS=>'comments', + RANKING=>'ranking', + AUDIENCE=>'gatherAudienceType', + QUESTIONNAIRE=>'questionnaire', + THANKYOU=>'thankyou'); + + $sharedIPs = array('64.39.251.226'); + + $found = false; + $this->voter = DB_DataObject::factory('voter'); + if (isset($_SESSION['voter_id']) && $this->voter->get($_SESSION['voter_id'])) { + $found = true; + } elseif (!in_array($_SERVER['REMOTE_ADDR'],$sharedIPs)) { + $this->voter->ip = $_SERVER['REMOTE_ADDR']; + if ($this->voter->find() && $this->voter->fetch()) { + $found = true; + $_SESSION['voter_id'] = $this->getVoterId(); + } + } + + if ($found) { + if (isset($_GET['man_step'])) { + $this->setStep($_GET['man_step']); + } else { + $this->step = $this->voter->step; + } + if (heavyLoad()) { + $this->functions[START] = 'heavyLoadNotice'; + } else { + $this->functions[START] = 'start'; + } + + $this->handlePostData(); + if ($this->step == 2 && $this->hasRatedAllPrototypes()) { + $this->setStep(3); + } elseif ($this->step == 5 && isset($this->voter->audience_id) && !isset($_GET['man_step'])) { + switch($this->voter->audience_id) { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + $this->setStep(6); + break; + } + } + } elseif($this->initializeVoter()) { + // Success + if (heavyLoad()) { + $this->functions[START] = 'heavyLoadNotice'; + } else { + $this->functions[START] = 'start'; + } + } else { + echo 'Error: could find voter record or create a new voter record'; + exit(); + } + } + + /** + * Checks if this user has rated all prototypes. + * @return bool true or false. + */ + function hasRatedAllPrototypes() + { + $prototypes = DB_DataObject::factory('prototype'); + $prototype_rating = DB_DataObject::factory('prototype_rating'); + $prototype_rating->voter_id = $this->getVoterId(); + if ($prototypes->find() <= $prototype_rating->find()) { + return true; + } else { + return false; + } + } + + /** + * Checks if this user has been sent all prototypes. + * @return bool true or false + */ + function sentPrototypes() + { + $prototype_sent = DB_DataObject::factory('prototype_sent'); + $prototype_sent->voter_id = $this->getVoterId(); + if ($prototype_sent->find()==3) { + return true; + } else { + return false; + } + } + + /** + * Returns the voter's unique ID (which is in the database). + * @return int voter_id + */ + function getVoterId() + { + return $this->voter->id; + } + + /** + * Runs the main page and calls the appropriate function based on what step the voter is on. + * + */ + function run() + { + if (is_callable(array($this,$this->functions[$this->voter->step]))) { + call_user_func(array($this,$this->functions[$this->voter->step])); + return true; + } else { + echo 'You entered a state that doesn\'t exist... your state is ['.$this->voter->step.']'; + return false; + } + } + + /** + * This is the Introduction function. + * + * + */ + function start() + { + echo'<div id="introduction"> + <div id="content"> + <h1 id="header">University Communications | UNL | Next Generation Redevelopment Group Research </h1> + <div id="left"> <img src="images/design_survey_008.gif" alt="We need change" /> </div> + <div id="right"> + <p>The UNL Web Developer Network, a group of more than 140 UNL employees + engaged in developing websites across the university, has developed three + candidate designs for the next generation of the UNL website.</p> + + <p>These three designs were developed in a collaborative process involving + representatives from a wide array of colleges, departments and units at UNL.</p> + + <p>The candidate designs are intended to represent interior pages of the site, + which comprise an estimated 95 percent of the UNL website. Further page + designs, including home pages, will be built upon the base design resulting + from this phase of the development and testing process.</p> + + <p>This is a five-part procedure. It should not take more than 5 minutes to + complete. The first test will gauge your first impression, asking you to rate + each proposed design on a 1-5 stars scale after viewing each momentarily + (5 indicating the most favorable rating).</p> + </div> + </div><!--close content--> + <p id="submit_test"> + <a id="step2" href="#" onclick="changeStep(1); return false;"> + <img src="images/design_survey_12.gif" alt="proceed" /> + </a> + </p> + </div><!--close introduction-->'; + } + + function introduction() + { + echo'<div id="introduction"> + <div id="content_demo"> + <p id="impressionintro">The first test measures a first impression. A sample will be shown to you for 2 and a half seconds. + Then you will rank what you\'ve seen on a scale of 1 to 5, with 5 being highest. + </p> + <p id="impressioncont" style="display:none">You can <a href="#" onclick="sampleSplashRating(); return false;">click to view the demo again</a>, or continue with the first impression test.</p> + <p id="submit"> + <a href="#" id="demo" onclick="sampleSplashRating(); return false;"> + <img id="demo" src="images/design_demo.gif" alt="demo button" /> + </a> + <a id="step2" style="display:none" href="#" onclick="beginSplashRating(); return false;"> + <img src="images/design_continue.gif" alt="proceed" /> + </a> + <img style="display:none" id="loading" src="images/indicator_medium.gif" alt="loading" /> + </p> + </div><!--close content--> + </div> + <div id="samplesplash" class="splash" style="display:none;"><img src="images/samplesplash.png" alt="Sample Splash Image" /></div> + <div id="countdown"></div> + '; + $this->displayImagesAndForms('displayRatingForm'); + } + + + function heavyLoadNotice() + { + echo '<div id="introduction">'; + echo '<p>The server is under heavy load now, please try back again later. Thanks.</p>'; + echo '</div>'; + } + + + function ranking() + { + echo '<div id="introduction" class="rankintro"> + <div id="ranking_last"> + <p>Now, we will ask you to rank the designs.<br />Click thumbnails for full-size images.</p>'; + echo ("<form action='{$_SERVER['SCRIPT_NAME']}' id='ranking_form' onsubmit='submitRankings(this); return false;'> + <ul class='thumbs'>"); + $this->displayImagesAndForms('displayRankForm'); + echo ("</ul> + <div class='submit_below'> + <input type='image' src='images/design_ranking1.png' id='submit' value='submit' /> + </div> + </form> + </div> + </div>"); + } + + function displayRankForm($prototype,$order) + { + echo(" <li>\n<a href='prototype_server.php?id={$prototype->id}&format=full' target='_blank'>"); + $this->displayPrototypeImage($prototype->id,'thumb'); + echo ("</a> + <ul> + <li><input type='radio' name='prototype_{$prototype->id}' value='1' />First</li> + <li><input type='radio' name='prototype_{$prototype->id}' value='2' />Second</li> + <li><input type='radio' name='prototype_{$prototype->id}' value='3' />Third</li> + </ul> + </li> + "); + } + + function gatherAudienceType() + { + echo '<div id="introduction" class="audience"><p id="aud">Please choose the group that best identifies you:</p>'; + echo "<form method='post' action='{$_SERVER['SCRIPT_NAME']}'>"; + $audiences = DB_DataObject::factory('audiences'); + if ($audiences->find()) { + echo '<select name="audience_id">'; + while ($audiences->fetch()) { + echo "<option value='{$audiences->id}'>{$audiences->audience}</option>"; + } + echo '</select>'; + } + echo ' <p><input type="image" src="images/design_ranking.gif" id="submit" value="submit" /></p> + <input type="hidden" name="step" value="'.AUDIENCE.'" /></form> + </div>'; + } + + function displayImagesAndForms($formFunction) + { + $order = 0; + foreach(unserialize($this->voter->prototype_order) as $prototype_id) { + $order++; + $prototype = DB_DataObject::factory('prototype'); + if ($prototype->get($prototype_id)) { + $this->$formFunction($prototype,$order); + } else { + echo 'Error: Prototypes could not be found.'; + exit(); + } + } + } + + function comments() + { + if (!isset($_GET['prototype'])) { + echo '<div id="introduction" class="comments"> + <p>Thank you for providing your input.</p> + <p>You will now have time to examine the prototypes in detail and provide comments.</p>'; + $this->displayThumbnails(); + echo '<div class="submit_below"><img src="images/design_word.gif" id="commentproceed" alt="Click thumbnails to comment or " /> + <a href="#" onclick="changeStep(5); return false;">'; + if ($this->hasSubmittedComments()) { + echo '<img src="images/design_continue1.png" alt="Continue to next section" />'; + } else { + echo '<img src="images/design_skip.gif" alt="Skip comment" />'; + } + echo ' </a> + </div> + </div>'; + } else { + $prototype = DB_DataObject::factory('prototype'); + $prototype->get($_GET['prototype']); + $this->displayCommentForm($prototype,$prototype->id); + echo '<script type="text/javascript"> + <!-- + SET_DHTML("float_form_'.$prototype->id.'"); + //--> + </script>'; + } + } + + function hasSubmittedComments($prototype_id = NULL) + { + $comments = DB_DataObject::factory('prototype_ranking'); + $comments->voter_id = $this->getVoterId(); + if (isset($prototype_id)) { + $comments->prototype_id = $prototype_id; + } + $comments->whereAdd('why_response IS NOT NULL OR improve_response IS NOT NULL'); + return $comments->find(); + } + + function displayThumbnails() { + echo '<ul class="thumbs">'; + $order = 0; + foreach(unserialize($this->voter->prototype_order) as $prototype_id) { + $order++; + $prototype = DB_DataObject::factory('prototype'); + if ($prototype->get($prototype_id)) { + echo "<li><a href='{$_SERVER['SCRIPT_NAME']}?prototype={$prototype->id}'>"; + $this->displayPrototypeImage($prototype->id,'thumb'); + echo '</a>'; + if ($this->hasSubmittedComments($prototype_id)) { + echo '<span class="comments_saved"><img src="images/commentsaved.png" alt="your comment has been saved" /></span>'; + } + echo '</li>'; + } else { + echo 'Error: Prototypes could not be found.'; + exit(); + } + } + echo '</ul>'; + } + + function displayCommentForm($prototype,$order) + { + $prototype_ranking = DB_DataObject::factory('prototype_ranking'); + $prototype_ranking->voter_id = $this->getVoterId(); + $prototype_ranking->prototype_id = $prototype->id; + if ($prototype_ranking->find()>0 && $prototype_ranking->fetch()) { + if ($prototype_ranking->rank==1) { + $why_question = 'Why <span>did</span> you choose this candidate design as your favorite?'; + } else { + $why_question = 'Why <span>didn\'t</span> you choose this candidate design as your favorite?'; + } + $why_response = $prototype_ranking->why_response; + $improve_response = $prototype_ranking->improve_response; + } else { + $why_question = 'What do you like about this design?'; + $why_response = ''; + $improve_response = ''; + } + echo(" <div id='float_form_wrapper_$order' class='float_form_wrapper'>\n". + $this->displayPrototype($prototype,$order,'full'). + "<div id='float_form_$order' class='float_form' style='position:absolute;'> + <form method='post' action='{$_SERVER['SCRIPT_NAME']}' id='rating_form_$order'> + <ul> + <li>{$why_question}</li> + <li><textarea name='why_response' rows='5' cols='40'>{$why_response}</textarea></li> + <li>What changes would you recommend?</li> + <li><textarea name='improve_response' rows='5' cols='40'>{$improve_response}</textarea></li> + <li><input class='submit' type='submit' value='' /></li> + </ul> + <input type='hidden' name='step' value='".COMMENTS."' /> + <input type='hidden' name='prototype_id' value='{$prototype->id}' /> + </form> + </div> + </div>\n"); + } + + /** + * Displays a prototype image. + * + * @param $prototype DB_DataObject_prototype object + * @param $order An integer corresponding to the order in which this image is presented to the user. + * @param $image Format of the image, splash, thumb, full + */ + function displayPrototype($prototype,$order,$image_format='splash') + { + if ($image_format == 'full') { + $style = ''; + } else { + $style = 'display:none;'; + } + echo "<div style='$style' id='prototype_img_$order' class='$image_format'>"; + $this->displayPrototypeImage($prototype->id,$image_format); + echo "</div>\n"; + } + + function displayPrototypeImage($prototype_id,$image_format) + { + echo "<img src='prototype_server.php?id={$prototype_id}&format={$image_format}' alt='Prototype number {$prototype_id}' />"; + } + + + + + /** + * Displays a Form as well as an image for rating the prototype in the first impression (splash) test. + * + * @param $prototype DB_DataObject_prototype object + * @param $order An integer corresponding to the order in which this image is presented to the user. + * + */ + function displayRatingForm($prototype,$order) + { + echo("<div class='rating'>\n". + $this->displayPrototype($prototype,$order,'splash'). + "<form action='{$_SERVER['SCRIPT_NAME']}' style='display:none;' id='rating_form_$order'> + <p>Please rate the prototype you were shown on a scale of 1 to 5 (with 5 being the highest).</p> + <ul class='star-rating'> + <li><a href='#' onclick='voteAndMove($order,$prototype->id,1); return false;' title='Rate this design 1 star out of 5' class='one-star'>1</a></li> + <li><a href='#' onclick='voteAndMove($order,$prototype->id,2); return false;' title='Rate this design 2 stars out of 5' class='two-stars'>2</a></li> + <li><a href='#' onclick='voteAndMove($order,$prototype->id,3); return false;' title='Rate this design 3 stars out of 5' class='three-stars'>3</a></li> + <li><a href='#' onclick='voteAndMove($order,$prototype->id,4); return false;' title='Rate this design 4 stars out of 5' class='four-stars'>4</a></li> + <li><a href='#' onclick='voteAndMove($order,$prototype->id,5); return false;' title='Rate this design 5 stars out of 5' class='five-stars'>5</a></li> + </ul> + <img src='images/scale.gif' id='scale' alt='More stars if you like it more' /> + </form> + + </div>"); + } + + /** + * This function records the prototype rating the user chose for a given prototype. + * + * @param $prototype_id The primary key for the prototype in the database. + * @param $rank The rank the user has given this prototype. + * + */ + function submitRank($prototype_id,$rank) + { + $prototype_ranking = DB_DataObject::factory('prototype_ranking'); + $prototype_ranking->voter_id = $this->getVoterId(); + $prototype_ranking->prototype_id = $prototype_id; + if ($prototype_ranking->find()>0 && $prototype_ranking->fetch()) { + $prototype_ranking->rank = $rank; + return $prototype_ranking->update(); + } else { + $prototype_ranking->rank = $rank; + return $prototype_ranking->insert(); + } + } + + /** + * This function stores the comment submitted into the database. + * + * @param int $prototype_id The primary key for the prototype in the database. + * @param string $comment The text comment this user has submitted. + * @return result of the insert() or update() call. + */ + function submitComment($prototype_id,$why_response,$improve_response) + { + $prototype_ranking = DB_DataObject::factory('prototype_ranking'); + $prototype_ranking->voter_id = $this->getVoterId(); + $prototype_ranking->prototype_id = $prototype_id; + if ($prototype_ranking->find()>0 && $prototype_ranking->fetch()) { + if (!empty($why_response)) { + $prototype_ranking->why_response = $why_response; + } + if (!empty($improve_response)) { + $prototype_ranking->improve_response = $improve_response; + } + return $prototype_ranking->update(); + } else { + if (!empty($why_response)) { + $prototype_ranking->why_response = $why_response; + } + if (!empty($improve_response)) { + $prototype_ranking->improve_response = $improve_response; + } + return $prototype_ranking->insert(); + } + } + + /** + * Records the rating for a prototype. + * + * @param int $prototype_id The primary key for the prototype in the database. + * @param int $rating The user's rating of the prototype. + * + */ + function tallyVote($prototype_id,$rating) + { + $prototype_rating = DB_DataObject::factory('prototype_rating'); + $prototype_rating->voter_id = $this->getVoterId(); + $prototype_rating->prototype_id = $prototype_id; + if ($prototype_rating->find()>0 && $prototype_rating->fetch()) { + $prototype_rating->rating = $rating; + return $prototype_rating->update(); + } else { + $prototype_rating->rating = $rating; + return $prototype_rating->insert(); + } + } + + /** + * This page is the questionnaire. + * + */ + function questionnaire() + { + echo ' + <div id="introduction_brett" class="questions"> + <div class="quest" id="question_head"><p>We will now ask you some questions:</p></div> + <div class="quest" id="question_mid"> + '; + $this->questionnaireform(); + echo' + </div> + <div class="quest" id="question_foot"></div> + </div> + '; + } + + /** + * This function displays the questionnaire form for this audience. + * + */ + function questionnaireform() + { + echo "<form action='{$_SERVER['SCRIPT_NAME']}' method='post'>"; + $table = new HTML_Table('class="questionnaire"'); + $question = DB_DataObject::factory('questions'); + $question->audience_id = $this->voter->audience_id; + if ($question->find()) { + while ($question->fetch()) { + $response = DB_DataObject::factory('responses'); + $response->voter_id = $this->getVoterId(); + $response->question_id = $question->id; + if ($response->find()>=1 && $response->fetch()) { + $value = $response->response; + } else { + $value = ""; + } + $table->addRow(array('<p>'.$question->question.'</p>',"<textarea name='question[{$question->id}]'>{$value}</textarea>")); + } + } + $question = DB_DataObject::factory('rating_questions'); + $question->audience_id = $this->voter->audience_id; + if ($question->find()) { + $current_lead_question = 0; + while ($question->fetch()) { + if ($current_lead_question != $question->lead_question_id) { + //Display lead question. + if ($current_lead_question != 0) { + $table->addRow(array("<p class='subq'>{$lead_question->lead_question}</p><img src='images/scale_2.gif' class='scale' alt='More stars if you like it more' />".$subtable->toHtml()),array('colspan'=>2)); + } + $subtable = new HTML_Table('class="subquestions"'); + $lead_question = DB_DataObject::factory('rating_lead_questions'); + $lead_question->get($question->lead_question_id); + $current_lead_question = $lead_question->id; + } + $input = "<input type='hidden' id='rq_{$question->id}' name='rq[{$question->id}]' value='' />"; + $subtable->addRow(array($question->question, + $this->starForm("setQuestionRating({$question->id},\$i); return false;",'$i','rq_ul_'.$question->id). + $input) + ); + } + $table->addRow(array("<p class='subq'>{$lead_question->lead_question}</p><img src='images/scale_2.gif' class='scale' alt='More stars if you like it more' />".$subtable->toHtml()),array('colspan'=>2)); + } + $age_input = '<select name="age_group" id="age_group">'; + $ages = DB_DataObject::factory('age_groups'); + $age_input .= '<option value="">Select your age range: </option>'; + if ($ages->find()) { + while ($ages->fetch()) { + $age_input .= "<option value='{$ages->id}'>{$ages->age_group}</option>"; + } + } + $age_input .= '</select>'; + $table->addRow(array('<p>Age</p>',$age_input),''); + $table->addRow(array('<p>Gender</p>',' <select name="gender"> + <option value="">Select your gender: </option> + <option value="M">Male</option> + <option value="F">Female</option> + </select>')); + echo $table->toHtml(); + + echo ' + <div class="question_submit"><input type="image" src="images/design_ranking.gif" id="submit" value="submit" /></div> + <input type="hidden" name="step" value="'.QUESTIONNAIRE.'" /></form>'; + } + + function starForm($function='',$replaceText='',$id='') + { + $text = 'Rate this'; + $form = "\n<ul class='star-rating' id='{$id}'>\n"; + for ($i=1;$i<=5;$i++) { + $nums = new Numbers_Words(); + $form .= "<li><a href='#'"; + if (!empty($function)) { + if (!empty($replaceText)) { + $form .= "onclick='".str_replace($replaceText,$i,$function)."'"; + } else { + $form .= "onclick='{$function}'"; + } + } + $form .= " title='$text $i star(s) out of 5' class='".$nums->toWords($i)."-stars'>$i</a></li>\n"; + } + $form .= ' </ul>'; + return $form; + } + + function handlePostData() + { + if (isset($_POST['step'])) { + switch($_POST['step']) { + case QUESTIONNAIRE: + foreach ($_POST['question'] as $key=>$var) { + $trimmed = trim($var); + if (!empty($trimmed)) { + $response = DB_DataObject::factory('responses'); + $response->voter_id = $this->getVoterId(); + $response->question_id = $key; + if ($response->find()>=1 && $response->fetch()) { + $response->response = $trimmed; + $response->update(); + } else { + $response->response = $trimmed; + $response->insert(); + } + } + } + if (isset($_POST['rq'])) { + foreach ($_POST['rq'] as $key=>$var) { + if (!empty($var)) { + $rating_response = DB_DataObject::factory('rating_responses'); + $rating_response->voter_id = $this->getVoterId(); + $rating_response->question_id = $key; + if ($rating_response->find()>=1 && $rating_response->fetch()) { + $rating_response->response = (int)$var; + $rating_response->update(); + } else { + $rating_response->response = (int)$var; + $rating_response->insert(); + } + } + } + } + if (!empty($_POST['gender'])) { + switch($_POST['gender']) { + case 'M': + $this->voter->gender = 'M'; + break; + case 'F': + $this->voter->gender = 'F'; + break; + } + $this->voter->update(); + } + if (!empty($_POST['age_group'])) { + $age_group = DB_DataObject::factory('age_groups'); + if ($age_group->get($_POST['age_group'])) { + $this->voter->age_group_id = $age_group->id; + $this->voter->update(); + } + } + $this->setStep(THANKYOU); + break; + case AUDIENCE: + $audiences = DB_DataObject::factory('audiences'); + if ($audiences->get($_POST['audience_id'])) { + $this->voter->audience_id = $audiences->id; + $this->voter->update(); + $this->setStep(QUESTIONNAIRE); + } + break; + case COMMENTS: + $this->submitComment($_POST['prototype_id'],$_POST['why_response'],$_POST['improve_response']); + break; + } + } + } + + function storeResponse($question_id,$response) + { + $response = DB_DataObject::factory('responses'); + $response->voter_id = $this->getVoterId(); + $response->question_id = $question_id; + $response->response = $response; + return $response->insert(); + } + + function thankyou() + { + echo'<div id="introduction"> + <div id="content"> + <h2>THANK YOU! </h2> + <div id="left"><a href="http://www.unl.edu/"><img src="images/design_survey_111.gif" alt="We need change" /></a> </div> + <div id="right"> + <p> + <strong>Thank you for your participation!</strong><br /> + This is the first phase of testing on the redevelopment process of the UNL website. The results of this testing will influence the continuing development of the redesigned web templates, targeted for launch in August.</p> + <p>USABILITY will be tested after the chosen design is developed and coded as a website.</p> + <p>Thank you for participating in this phase of testing of the next generation visual design for the UNL website. We may contact you in the future for further testing.</p> + + </div> + <div id="imagelogo"><a href="http://www.unl.edu/"><img src="images/unllogo.gif" alt="UNL logo" /></a></div> + </div><!--close content--> + </div><!--close introduction-->'; + + } +} diff --git a/images/Temp.tmp b/images/Temp.tmp new file mode 100644 index 0000000000000000000000000000000000000000..3041382df1658d4501a639b04f07c169318043cb Binary files /dev/null and b/images/Temp.tmp differ diff --git a/images/casual.png b/images/casual.png new file mode 100644 index 0000000000000000000000000000000000000000..cb4aa018432430d8e144436470cb9bcbac2d55a0 Binary files /dev/null and b/images/casual.png differ diff --git a/images/casual_full.png b/images/casual_full.png new file mode 100644 index 0000000000000000000000000000000000000000..637088988d3b6397a50cef039086b2d5c450a194 Binary files /dev/null and b/images/casual_full.png differ diff --git a/images/casual_thumb.png b/images/casual_thumb.png new file mode 100644 index 0000000000000000000000000000000000000000..3f4ae613eb41a07d02a5aadd2874a7f8d8782cfa Binary files /dev/null and b/images/casual_thumb.png differ diff --git a/images/comment.gif b/images/comment.gif new file mode 100644 index 0000000000000000000000000000000000000000..39fcf94be3dd209728201c8742daa312e0f134ae Binary files /dev/null and b/images/comment.gif differ diff --git a/images/comment.png b/images/comment.png new file mode 100644 index 0000000000000000000000000000000000000000..60a1ac3af86ecc3fad0b16d48ee924fb64831f50 Binary files /dev/null and b/images/comment.png differ diff --git a/images/comment_02.png b/images/comment_02.png new file mode 100644 index 0000000000000000000000000000000000000000..b67670ccf0fafc2127cdc657c742735f450cfb63 Binary files /dev/null and b/images/comment_02.png differ diff --git a/images/comment_03.gif b/images/comment_03.gif new file mode 100644 index 0000000000000000000000000000000000000000..6bb4f3510145e8221aab81e2b9860bbadfb6a52e Binary files /dev/null and b/images/comment_03.gif differ diff --git a/images/comment_03.png b/images/comment_03.png new file mode 100644 index 0000000000000000000000000000000000000000..daf4307a8a067dfdae3a3a64b610190ab45acb19 Binary files /dev/null and b/images/comment_03.png differ diff --git a/images/comment_04.png b/images/comment_04.png new file mode 100644 index 0000000000000000000000000000000000000000..8fcbb79682015054d1160bd1aebc044fe0f0cb95 Binary files /dev/null and b/images/comment_04.png differ diff --git a/images/comment_09.png b/images/comment_09.png new file mode 100644 index 0000000000000000000000000000000000000000..ca4e92f3285bfca726acd2c849cade65d9cf4b75 Binary files /dev/null and b/images/comment_09.png differ diff --git a/images/comment_main.png b/images/comment_main.png new file mode 100644 index 0000000000000000000000000000000000000000..9650745a3fa10b819f83ffa99c07fffbba7c05cd Binary files /dev/null and b/images/comment_main.png differ diff --git a/images/commentsaved.png b/images/commentsaved.png new file mode 100644 index 0000000000000000000000000000000000000000..0e1ff48a0406cbd1ac3f8beb8fd4a6da1a6e6c4c Binary files /dev/null and b/images/commentsaved.png differ diff --git a/images/demo b/images/demo new file mode 100644 index 0000000000000000000000000000000000000000..f31b1cf7ec421d013e8834e2e7103caf736f36ed Binary files /dev/null and b/images/demo differ diff --git a/images/design_continue.gif b/images/design_continue.gif new file mode 100644 index 0000000000000000000000000000000000000000..47a75a40f8e903df497796e6330693cd7bf219e2 Binary files /dev/null and b/images/design_continue.gif differ diff --git a/images/design_continue1.png b/images/design_continue1.png new file mode 100644 index 0000000000000000000000000000000000000000..e8c2a8375451b1c7f7024d040ce5a4cb310c9d55 Binary files /dev/null and b/images/design_continue1.png differ diff --git a/images/design_demo.gif b/images/design_demo.gif new file mode 100644 index 0000000000000000000000000000000000000000..495cbf959c33cb875e886f283a6da1d0e35e453c Binary files /dev/null and b/images/design_demo.gif differ diff --git a/images/design_ranking.gif b/images/design_ranking.gif new file mode 100644 index 0000000000000000000000000000000000000000..3041382df1658d4501a639b04f07c169318043cb Binary files /dev/null and b/images/design_ranking.gif differ diff --git a/images/design_ranking1.png b/images/design_ranking1.png new file mode 100644 index 0000000000000000000000000000000000000000..6c470c454c97c9636444ea2bc973281d61f99bdd Binary files /dev/null and b/images/design_ranking1.png differ diff --git a/images/design_replaydemo.gif b/images/design_replaydemo.gif new file mode 100644 index 0000000000000000000000000000000000000000..0004e6f673244955ca10fc0611600953691bf74f Binary files /dev/null and b/images/design_replaydemo.gif differ diff --git a/images/design_skip.gif b/images/design_skip.gif new file mode 100644 index 0000000000000000000000000000000000000000..c1cff25b9e41a2701eac20928bd6a29bf53a34eb Binary files /dev/null and b/images/design_skip.gif differ diff --git a/images/design_survey_008.gif b/images/design_survey_008.gif new file mode 100644 index 0000000000000000000000000000000000000000..9774cdffaeab7fc0c876b1c74dd156c829ef1139 Binary files /dev/null and b/images/design_survey_008.gif differ diff --git a/images/design_survey_008.psd b/images/design_survey_008.psd new file mode 100644 index 0000000000000000000000000000000000000000..d0a4c5bb390a8e126c039a233bba01212cd78551 Binary files /dev/null and b/images/design_survey_008.psd differ diff --git a/images/design_survey_01.gif b/images/design_survey_01.gif new file mode 100644 index 0000000000000000000000000000000000000000..5d21a87ddd5417c3a09993f2079772b558c6ae14 Binary files /dev/null and b/images/design_survey_01.gif differ diff --git a/images/design_survey_02.gif b/images/design_survey_02.gif new file mode 100644 index 0000000000000000000000000000000000000000..8f58024da966a5c4ab3744f08efb9893ffe2beca Binary files /dev/null and b/images/design_survey_02.gif differ diff --git a/images/design_survey_03.gif b/images/design_survey_03.gif new file mode 100644 index 0000000000000000000000000000000000000000..c908100173766fb094b0455ff5afcc23ecfb600d Binary files /dev/null and b/images/design_survey_03.gif differ diff --git a/images/design_survey_04.gif b/images/design_survey_04.gif new file mode 100644 index 0000000000000000000000000000000000000000..ffec98cabe8f4c1996ed49308a9d27b5e333db9e Binary files /dev/null and b/images/design_survey_04.gif differ diff --git a/images/design_survey_05.gif b/images/design_survey_05.gif new file mode 100644 index 0000000000000000000000000000000000000000..180031ae3134c021911771d2a578dd59933204f6 Binary files /dev/null and b/images/design_survey_05.gif differ diff --git a/images/design_survey_06.gif b/images/design_survey_06.gif new file mode 100644 index 0000000000000000000000000000000000000000..d294beb3e146de1e04d6fc461a73606e6127ed96 Binary files /dev/null and b/images/design_survey_06.gif differ diff --git a/images/design_survey_07.gif b/images/design_survey_07.gif new file mode 100644 index 0000000000000000000000000000000000000000..8a24de736a7347e4a078faf011f2eee94caf5528 Binary files /dev/null and b/images/design_survey_07.gif differ diff --git a/images/design_survey_08.gif b/images/design_survey_08.gif new file mode 100644 index 0000000000000000000000000000000000000000..e35fdebb90b9b7a0f5f8698159869682469023e2 Binary files /dev/null and b/images/design_survey_08.gif differ diff --git a/images/design_survey_09.gif b/images/design_survey_09.gif new file mode 100644 index 0000000000000000000000000000000000000000..2491cde94c2cb4b4d1d0afd80979a7eebebacec9 Binary files /dev/null and b/images/design_survey_09.gif differ diff --git a/images/design_survey_10.gif b/images/design_survey_10.gif new file mode 100644 index 0000000000000000000000000000000000000000..dbf2bd367f7aa7a38261aa29b1a4dc59bb9ea601 Binary files /dev/null and b/images/design_survey_10.gif differ diff --git a/images/design_survey_11.gif b/images/design_survey_11.gif new file mode 100644 index 0000000000000000000000000000000000000000..cf9aa34fc402155df4cb90c388fe2d124240d0be Binary files /dev/null and b/images/design_survey_11.gif differ diff --git a/images/design_survey_111.gif b/images/design_survey_111.gif new file mode 100644 index 0000000000000000000000000000000000000000..01365cccb93e2f8468ef49eacf113cc398549fd7 Binary files /dev/null and b/images/design_survey_111.gif differ diff --git a/images/design_survey_12.gif b/images/design_survey_12.gif new file mode 100644 index 0000000000000000000000000000000000000000..c67558072417ebf5db79ec87bf520ea00185d0df Binary files /dev/null and b/images/design_survey_12.gif differ diff --git a/images/design_survey_13.gif b/images/design_survey_13.gif new file mode 100644 index 0000000000000000000000000000000000000000..ea270a174a7eb48ca9b98d9d5480219e9015cade Binary files /dev/null and b/images/design_survey_13.gif differ diff --git a/images/design_survey_14.gif b/images/design_survey_14.gif new file mode 100644 index 0000000000000000000000000000000000000000..46f1ed25e631fe983e0ffa931bc75152f2d92423 Binary files /dev/null and b/images/design_survey_14.gif differ diff --git a/images/design_word.gif b/images/design_word.gif new file mode 100644 index 0000000000000000000000000000000000000000..070a4c53c26b3dcd9a3f5cf8865d181373fc5c04 Binary files /dev/null and b/images/design_word.gif differ diff --git a/images/footer.gif b/images/footer.gif new file mode 100644 index 0000000000000000000000000000000000000000..6362cf8770a661641e26c5c89e386086bfbdf3bf Binary files /dev/null and b/images/footer.gif differ diff --git a/images/formal.png b/images/formal.png new file mode 100644 index 0000000000000000000000000000000000000000..0886e335f96f4188aacbffe118244333736cec37 Binary files /dev/null and b/images/formal.png differ diff --git a/images/formal_full.png b/images/formal_full.png new file mode 100644 index 0000000000000000000000000000000000000000..d520c591ba30bd5dab1cd172ae3b0b6183ea9008 Binary files /dev/null and b/images/formal_full.png differ diff --git a/images/formal_thumb.png b/images/formal_thumb.png new file mode 100644 index 0000000000000000000000000000000000000000..4f6d89edf8fd29d5c40e0594141c7b97fce8eac3 Binary files /dev/null and b/images/formal_thumb.png differ diff --git a/images/gradient.gif b/images/gradient.gif new file mode 100644 index 0000000000000000000000000000000000000000..231aa820f3625dd0895708a925d53e7f412b9dbc Binary files /dev/null and b/images/gradient.gif differ diff --git a/images/header.gif b/images/header.gif new file mode 100644 index 0000000000000000000000000000000000000000..ea7666ea02afa4622400423436ccd469e524ff8f Binary files /dev/null and b/images/header.gif differ diff --git a/images/indicator_medium copy.gif b/images/indicator_medium copy.gif new file mode 100644 index 0000000000000000000000000000000000000000..cbb115746efeb07215275fed84f1a214ecbbcdb6 Binary files /dev/null and b/images/indicator_medium copy.gif differ diff --git a/images/indicator_medium.gif b/images/indicator_medium.gif new file mode 100644 index 0000000000000000000000000000000000000000..d86130062b9ee81ae817462769625da676b49d3f Binary files /dev/null and b/images/indicator_medium.gif differ diff --git a/images/indicator_medium_backup.gif b/images/indicator_medium_backup.gif new file mode 100644 index 0000000000000000000000000000000000000000..5bb90fd6a49107a321c35b9cee4a7b810314b51f Binary files /dev/null and b/images/indicator_medium_backup.gif differ diff --git a/images/middle.gif b/images/middle.gif new file mode 100644 index 0000000000000000000000000000000000000000..eefa4d872a40faf224795aafac01af5eab66c24d Binary files /dev/null and b/images/middle.gif differ diff --git a/images/modern.png b/images/modern.png new file mode 100644 index 0000000000000000000000000000000000000000..2b8cff017e1548e98cdf7dc4bc08b62a2ef37f83 Binary files /dev/null and b/images/modern.png differ diff --git a/images/modern_full.png b/images/modern_full.png new file mode 100644 index 0000000000000000000000000000000000000000..26e893c4be68d8c12f2bdb12982bba751991a3be Binary files /dev/null and b/images/modern_full.png differ diff --git a/images/modern_thumb.png b/images/modern_thumb.png new file mode 100644 index 0000000000000000000000000000000000000000..2ca8acd516646c1b7b12ba519d929074a561e467 Binary files /dev/null and b/images/modern_thumb.png differ diff --git a/images/samplesplash.png b/images/samplesplash.png new file mode 100644 index 0000000000000000000000000000000000000000..ee4fb2043691b925a2665cd8745090e8569195f1 Binary files /dev/null and b/images/samplesplash.png differ diff --git a/images/scale.gif b/images/scale.gif new file mode 100644 index 0000000000000000000000000000000000000000..4640840e443ec03611a6fe927a0119f2b8907a51 Binary files /dev/null and b/images/scale.gif differ diff --git a/images/scale.png b/images/scale.png new file mode 100644 index 0000000000000000000000000000000000000000..051a56a72d7d99b28ddd2c8088c6ca22dc79dac2 Binary files /dev/null and b/images/scale.png differ diff --git a/images/scale_2.gif b/images/scale_2.gif new file mode 100644 index 0000000000000000000000000000000000000000..05a4ec3d7b94deb9161bd60176c6fa47beebd33e Binary files /dev/null and b/images/scale_2.gif differ diff --git a/images/stars.gif b/images/stars.gif new file mode 100644 index 0000000000000000000000000000000000000000..1744bcbefaed884776d10c095d16dedf474a7e81 Binary files /dev/null and b/images/stars.gif differ diff --git a/images/stars_backup.gif b/images/stars_backup.gif new file mode 100644 index 0000000000000000000000000000000000000000..b9e422ba456b525cec9210e037129dcb6a3ab001 Binary files /dev/null and b/images/stars_backup.gif differ diff --git a/images/unllogo.gif b/images/unllogo.gif new file mode 100644 index 0000000000000000000000000000000000000000..494f4a56c7503bf4128e19914b968f60e93fe705 Binary files /dev/null and b/images/unllogo.gif differ diff --git a/index.php b/index.php new file mode 100644 index 0000000000000000000000000000000000000000..7cd825d7be423c4d612ebd4b780b4dafab6a0c09 --- /dev/null +++ b/index.php @@ -0,0 +1,50 @@ +<?php +require_once 'config.inc.php'; +require_once 'functions.php'; + +$voter = new Voting_System(); +if ($voter->step==0 && $voter->functions[START] == 'heavyLoadNotice') { +?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> +<title>University Communications | UNL | Next Generation Redevelopment Group Research</title> +<link type="text/css" rel="stylesheet" href="style.css" /> +</head> + +<body> + +<div id="introduction"> + <div id="content"> + + <h1 id="header">University Communications | UNL | Next Generation Redevelopment Group Research </h1> + <div id="left"> <img src="images/design_survey_008.gif" alt="We need change" /> </div> + <div id="right"> + <p style="font-size:1.2em;">The server is under heavy load right now. But please don't give up — we value your opinion. Please try back later.</p> + <p>Thank you for your patience.</p> + </div> + </div> +</div> +</body> +</html> +<?php +} else { ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> +<title>University Communications | UNL | Next Generation Redevelopment Group Research</title> +<?php $voter->displayHeaderData(); ?> +</head> + +<body> + +<?php +$voter->run(); +?> +</body> +</html> +<?php +} +?> diff --git a/process.php b/process.php new file mode 100644 index 0000000000000000000000000000000000000000..8ec536f7c0b47b260c5b7687b9617d7aafef0d45 --- /dev/null +++ b/process.php @@ -0,0 +1,24 @@ +<?php + +function heavyLoad() { + $line = shell_exec("top -l 1 | grep 'CPU usage'"); + + $idle = shell_exec("top -l 1 | grep 'CPU usage' | awk '{print $12}'"); + $idle = substr($idle,0,3); + + $load = shell_exec("top -l 1 | grep 'CPU usage' | awk '{print $3}'"); + $load = substr($load,0,4); + echo "$line\n"; + + if ($load<3.0 && $idle>10) { + //echo "let 'em in!\n"; + return false; + } else { + return true; + //echo "Too busy!\n"; + } +} + + +var_dump(heavyLoad()); + diff --git a/prototype_server.php b/prototype_server.php new file mode 100644 index 0000000000000000000000000000000000000000..cfa1df71beb4276a47f94519381a5176cee81d32 --- /dev/null +++ b/prototype_server.php @@ -0,0 +1,42 @@ +<?php +/** + * This file is intended to serve out the prototype images to the client. + * + */ + require_once 'config.inc.php'; + require_once 'functions.php'; + + $image_path = 'images/'; + + $prototype = DB_DataObject::factory('prototype'); + if ($prototype->get($_GET['id'])) { + switch ($_GET['format']) { + case 'splash': + default: + $format = 'splash_image'; + $voter = new Voting_System(); + header('Last-Modified: '.gmdate('D, d M Y H:i:s', date('u')).' GMT'); + header('Cache-Control: no-cache, must-revalidate'); + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); + break; + case 'thumb': + $format = 'thumb_image'; + break; + case 'full': + $format = 'full_image'; + break; + } + header('Content-type: image/png'); + echo file_get_contents($image_path.$prototype->$format); + if ($format=='splash_image') { + flush(); + $prototype_sent = DB_DataObject::factory('prototype_sent'); + $prototype_sent->voter_id = $voter->getVoterId(); + $prototype_sent->prototype_id = $prototype->id; + if (!$prototype_sent->find()) { + $prototype_sent->voter_id = $voter->getVoterId(); + $prototype_sent->prototype_id = $prototype->id; + $prototype_sent->insert(); + } + } + } \ No newline at end of file diff --git a/results/charts.php b/results/charts.php new file mode 100644 index 0000000000000000000000000000000000000000..fb5d4565a72525729d0be3250d9f17814043eb25 --- /dev/null +++ b/results/charts.php @@ -0,0 +1,135 @@ +<?php +// charts.php v4.5 +// ------------------------------------------------------------------------ +// Copyright (c) 2003-2005, maani.us +// ------------------------------------------------------------------------ +// This file is part of "PHP/SWF Charts" +// +// PHP/SWF Charts is a shareware. See http://www.maani.us/charts/ for +// more information. +// ------------------------------------------------------------------------ + +//==================================== +function InsertChart( $flash_file, $library_path, $php_source, $width=400, $height=250, $bg_color="666666", $transparent=false, $license=null ){ + + $php_source=urlencode($php_source); + $library_path=urlencode($library_path); + + $html="<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' "; + $html.="WIDTH=".$width." HEIGHT=".$height." id='charts' ALIGN=''>"; + $u=(strpos ($flash_file,"?")===false)? "?" : ((substr($flash_file, -1)==="&")? "":"&"); + $html.="<PARAM NAME=movie VALUE='".$flash_file.$u."library_path=".$library_path."&php_source=".$php_source; + if($license!=null){$html.="&license=".$license;} + $html.="'> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#".$bg_color."> "; + if($transparent){$html.="<PARAM NAME=wmode VALUE=transparent> ";} + $html.="<EMBED src='".$flash_file.$u."library_path=".$library_path."&php_source=".$php_source; + if($license!=null){$html.="&license=".$license;} + $html.="' quality=high bgcolor=#".$bg_color." WIDTH=".$width." HEIGHT=".$height." NAME='charts' ALIGN='' swLiveConnect='true' "; + if($transparent){$html.="wmode=transparent ";} + $html.="TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED></OBJECT>"; + return $html; + +} + +//==================================== +function SendChartData( $chart=array() ){ + + $xml="<chart>\r\n"; + $Keys1= array_keys((array) $chart); + for ($i1=0;$i1<count($Keys1);$i1++){ + if(is_array($chart[$Keys1[$i1]])){ + $Keys2=array_keys($chart[$Keys1[$i1]]); + if(is_array($chart[$Keys1[$i1]][$Keys2[0]])){ + $xml.="\t<".$Keys1[$i1].">\r\n"; + for($i2=0;$i2<count($Keys2);$i2++){ + $Keys3=array_keys((array) $chart[$Keys1[$i1]][$Keys2[$i2]]); + switch($Keys1[$i1]){ + case "chart_data": + $xml.="\t\t<row>\r\n"; + for($i3=0;$i3<count($Keys3);$i3++){ + switch(true){ + case ($chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]===null): + $xml.="\t\t\t<null/>\r\n"; + break; + + case ($Keys2[$i2]>0 and $Keys3[$i3]>0): + $xml.="\t\t\t<number>".$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]."</number>\r\n"; + break; + + default: + $xml.="\t\t\t<string>".$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]."</string>\r\n"; + break; + } + } + $xml.="\t\t</row>\r\n"; + break; + + case "chart_value_text": + $xml.="\t\t<row>\r\n"; + $count=0; + for($i3=0;$i3<count($Keys3);$i3++){ + if($chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]===null){$xml.="\t\t\t<null/>\r\n";} + else{$xml.="\t\t\t<string>".$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]."</string>\r\n";} + } + $xml.="\t\t</row>\r\n"; + break; + + /*case "link_data_text": + $xml.="\t\t<row>\r\n"; + $count=0; + for($i3=0;$i3<count($Keys3);$i3++){ + if($chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]===null){$xml.="\t\t\t<null/>\r\n";} + else{$xml.="\t\t\t<string>".$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]."</string>\r\n";} + } + $xml.="\t\t</row>\r\n"; + break;*/ + + case "draw": + $text=""; + $xml.="\t\t<".$chart[$Keys1[$i1]][$Keys2[$i2]]['type']; + for($i3=0;$i3<count($Keys3);$i3++){ + if($Keys3[$i3]!="type"){ + if($Keys3[$i3]=="text"){$text=$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]];} + else{$xml.=" ".$Keys3[$i3]."=\"".$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]."\"";} + } + } + if($text!=""){$xml.=">".$text."</text>\r\n";} + else{$xml.=" />\r\n";} + break; + + + default://link, etc. + $xml.="\t\t<value"; + for($i3=0;$i3<count($Keys3);$i3++){ + $xml.=" ".$Keys3[$i3]."=\"".$chart[$Keys1[$i1]][$Keys2[$i2]][$Keys3[$i3]]."\""; + } + $xml.=" />\r\n"; + break; + } + } + $xml.="\t</".$Keys1[$i1].">\r\n"; + }else{ + if($Keys1[$i1]=="chart_type" or $Keys1[$i1]=="series_color" or $Keys1[$i1]=="series_image" or $Keys1[$i1]=="series_explode" or $Keys1[$i1]=="axis_value_text"){ + $xml.="\t<".$Keys1[$i1].">\r\n"; + for($i2=0;$i2<count($Keys2);$i2++){ + if($chart[$Keys1[$i1]][$Keys2[$i2]]===null){$xml.="\t\t<null/>\r\n";} + else{$xml.="\t\t<value>".$chart[$Keys1[$i1]][$Keys2[$i2]]."</value>\r\n";} + } + $xml.="\t</".$Keys1[$i1].">\r\n"; + }else{//axis_category, etc. + $xml.="\t<".$Keys1[$i1]; + for($i2=0;$i2<count($Keys2);$i2++){ + $xml.=" ".$Keys2[$i2]."=\"".$chart[$Keys1[$i1]][$Keys2[$i2]]."\""; + } + $xml.=" />\r\n"; + } + } + }else{//chart type, etc. + $xml.="\t<".$Keys1[$i1].">".$chart[$Keys1[$i1]]."</".$Keys1[$i1].">\r\n"; + } + } + $xml.="</chart>\r\n"; + echo $xml; +} +//==================================== +?> diff --git a/results/charts.swf b/results/charts.swf new file mode 100644 index 0000000000000000000000000000000000000000..79cd4fd2d5c51ae98c509bb3b087f37c8bdc7162 Binary files /dev/null and b/results/charts.swf differ diff --git a/results/charts_library/arno.swf b/results/charts_library/arno.swf new file mode 100644 index 0000000000000000000000000000000000000000..08d0fa874f544e454206dc75f36d3009b1b4ae80 Binary files /dev/null and b/results/charts_library/arno.swf differ diff --git a/results/charts_library/arst.swf b/results/charts_library/arst.swf new file mode 100644 index 0000000000000000000000000000000000000000..85bde6957ea2921dbee1e2206d25c106f64e54b5 Binary files /dev/null and b/results/charts_library/arst.swf differ diff --git a/results/charts_library/brfl.swf b/results/charts_library/brfl.swf new file mode 100644 index 0000000000000000000000000000000000000000..4ac3e201630ef3018ac0a4476760e3643890edd4 Binary files /dev/null and b/results/charts_library/brfl.swf differ diff --git a/results/charts_library/brno.swf b/results/charts_library/brno.swf new file mode 100644 index 0000000000000000000000000000000000000000..243adcdfdc0a2be764cb1c28126d8825edbc9039 Binary files /dev/null and b/results/charts_library/brno.swf differ diff --git a/results/charts_library/brst.swf b/results/charts_library/brst.swf new file mode 100644 index 0000000000000000000000000000000000000000..1b2912a7378cc3e6727fde46a846bb0636e1f371 Binary files /dev/null and b/results/charts_library/brst.swf differ diff --git a/results/charts_library/cl3d.swf b/results/charts_library/cl3d.swf new file mode 100644 index 0000000000000000000000000000000000000000..503893a3596990e202f8a9e65ef654feb198a9ec Binary files /dev/null and b/results/charts_library/cl3d.swf differ diff --git a/results/charts_library/clfl.swf b/results/charts_library/clfl.swf new file mode 100644 index 0000000000000000000000000000000000000000..05219ad64c94f83e54a25f940230cf5f9c298e63 Binary files /dev/null and b/results/charts_library/clfl.swf differ diff --git a/results/charts_library/clno.swf b/results/charts_library/clno.swf new file mode 100644 index 0000000000000000000000000000000000000000..8b594b816db0c691f5b486e4b74b5440823d4814 Binary files /dev/null and b/results/charts_library/clno.swf differ diff --git a/results/charts_library/clp3.swf b/results/charts_library/clp3.swf new file mode 100644 index 0000000000000000000000000000000000000000..193408b7fb329cdb3b08f9243ada74406cb590f6 Binary files /dev/null and b/results/charts_library/clp3.swf differ diff --git a/results/charts_library/cls3.swf b/results/charts_library/cls3.swf new file mode 100644 index 0000000000000000000000000000000000000000..20783ffc158e51c62a70a57abd1283e3cda3f758 Binary files /dev/null and b/results/charts_library/cls3.swf differ diff --git a/results/charts_library/clst.swf b/results/charts_library/clst.swf new file mode 100644 index 0000000000000000000000000000000000000000..6bfd583b2d7386ccf9a72cd295ab4d45043b528d Binary files /dev/null and b/results/charts_library/clst.swf differ diff --git a/results/charts_library/cnno.swf b/results/charts_library/cnno.swf new file mode 100644 index 0000000000000000000000000000000000000000..d56b6bac0fbff9cceac2d347e5e67189f8d9e0bd Binary files /dev/null and b/results/charts_library/cnno.swf differ diff --git a/results/charts_library/lnno.swf b/results/charts_library/lnno.swf new file mode 100644 index 0000000000000000000000000000000000000000..dfaa6732fa41947fdc52cd8b0f12a85e334baa7a Binary files /dev/null and b/results/charts_library/lnno.swf differ diff --git a/results/charts_library/mxno.swf b/results/charts_library/mxno.swf new file mode 100644 index 0000000000000000000000000000000000000000..c0a69534c7ba5ae8a65083d1535fc773dfb3f551 Binary files /dev/null and b/results/charts_library/mxno.swf differ diff --git a/results/charts_library/pi3d.swf b/results/charts_library/pi3d.swf new file mode 100644 index 0000000000000000000000000000000000000000..8e042b0e49fc1846861351735499baa605b5e59a Binary files /dev/null and b/results/charts_library/pi3d.swf differ diff --git a/results/charts_library/pino.swf b/results/charts_library/pino.swf new file mode 100644 index 0000000000000000000000000000000000000000..4a0951c3e0b9899faeff26720158def90a2ac219 Binary files /dev/null and b/results/charts_library/pino.swf differ diff --git a/results/charts_library/pono.swf b/results/charts_library/pono.swf new file mode 100644 index 0000000000000000000000000000000000000000..75620dccaf512fa66d4c99a35fdb06f07c4b9b85 Binary files /dev/null and b/results/charts_library/pono.swf differ diff --git a/results/charts_library/scno.swf b/results/charts_library/scno.swf new file mode 100644 index 0000000000000000000000000000000000000000..fbe9c6748b9213808e2c010d35d9a154e5d5eb97 Binary files /dev/null and b/results/charts_library/scno.swf differ diff --git a/results/graph_server.php b/results/graph_server.php new file mode 100644 index 0000000000000000000000000000000000000000..6924da86f13c5b1ba4f9a8b1480bbf58f37d34f9 --- /dev/null +++ b/results/graph_server.php @@ -0,0 +1,45 @@ +<?php + +require_once '../config.inc.php'; +require_once 'result.functions.php'; +require_once 'Image/Graph.php'; +require_once 'Image/Canvas.php'; +require_once 'charts.php'; + +if (isset($_GET['at'])) { + $at = $_GET['at']; +} else { + $at = NULL; +} +if (isset($_GET['gender'])) { + $gender = $_GET['gender']; +} else { + $gender = NULL; +} + +switch($_GET['graph']) { + default: + case 'ranking': + $chart['chart_data'] = array(); + $chart['chart_data'][] = array('','First','Second','Third'); + + foreach (array('Modern','Casual','Formal') as $prototype) { + $chart['chart_data'][] = array($prototype, rankingCount($prototype,1, $at, $gender), + rankingCount($prototype,2, $at, $gender), + rankingCount($prototype,3, $at, $gender)); + } + break; + case 'splash': + $chart['chart_data'] = array(); + $chart['chart_data'][] = array('',1,2,3,4,5); + foreach (array('Modern','Casual','Formal') as $prototype) { + $chart['chart_data'][] = array($prototype, ratingCount($prototype,1,$at, $gender), + ratingCount($prototype,2,$at, $gender), + ratingCount($prototype,3,$at, $gender), + ratingCount($prototype,4,$at, $gender), + ratingCount($prototype,5,$at, $gender)); + } + break; +} + +SendChartData ($chart); diff --git a/results/images/0030_arr.png b/results/images/0030_arr.png new file mode 100644 index 0000000000000000000000000000000000000000..442c0e70b64c76d1c771716c1e33c58f3f37d8d3 Binary files /dev/null and b/results/images/0030_arr.png differ diff --git a/results/images/0050_pfeil.png b/results/images/0050_pfeil.png new file mode 100644 index 0000000000000000000000000000000000000000..11f4ea2b5bc9ebf84931656a07d489806e8191fc Binary files /dev/null and b/results/images/0050_pfeil.png differ diff --git a/results/images/0066_double_arrow.png b/results/images/0066_double_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..e20d170faf52d37027714f85907602226965886c Binary files /dev/null and b/results/images/0066_double_arrow.png differ diff --git a/results/images/0175_post_bullet.png b/results/images/0175_post_bullet.png new file mode 100644 index 0000000000000000000000000000000000000000..ca484e1d7710efa0658ae9c4d37fd0368a684cbc Binary files /dev/null and b/results/images/0175_post_bullet.png differ diff --git a/results/images/16-arrow-right.png b/results/images/16-arrow-right.png new file mode 100755 index 0000000000000000000000000000000000000000..00a443dbe512f343ef3c515b977fc858f2e10c86 Binary files /dev/null and b/results/images/16-arrow-right.png differ diff --git a/results/images/16-cube-green.png b/results/images/16-cube-green.png new file mode 100755 index 0000000000000000000000000000000000000000..4d62e48ec9db42cd212595fc26a5bf270e31117d Binary files /dev/null and b/results/images/16-cube-green.png differ diff --git a/results/images/IEFixes.htc b/results/images/IEFixes.htc new file mode 100644 index 0000000000000000000000000000000000000000..5152c5e0814166b68ab712029514a4eaec40bd65 --- /dev/null +++ b/results/images/IEFixes.htc @@ -0,0 +1,21 @@ +<PUBLIC:ATTACH EVENT="onmouseover" ONEVENT="DoHover()" /> +<PUBLIC:ATTACH EVENT="onmouseout" ONEVENT="RestoreHover()" /> +<PUBLIC:ATTACH EVENT="onmousedown" ONEVENT="DoActive()" /> +<PUBLIC:ATTACH EVENT="onmouseup" ONEVENT="RestoreActive()" /> +<SCRIPT LANGUAGE="JScript"> +function DoHover() + { element.className += ' hover'; + } + +function DoActive() + { element.className += ' active'; + } + +function RestoreHover() + { element.className = element.className.replace(/\shover\b/,''); + } + +function RestoreActive() + { element.className = element.className.replace(/\sactive\b/,''); + } +</SCRIPT> \ No newline at end of file diff --git a/results/images/bandstand_24.png b/results/images/bandstand_24.png new file mode 100644 index 0000000000000000000000000000000000000000..2172294acd17131aabaf4a543552c815f6019a3b Binary files /dev/null and b/results/images/bandstand_24.png differ diff --git a/results/images/box.png b/results/images/box.png new file mode 100644 index 0000000000000000000000000000000000000000..bba0330bf938183027cbfce7dccc56af37953c9c Binary files /dev/null and b/results/images/box.png differ diff --git a/results/images/box_hover.png b/results/images/box_hover.png new file mode 100644 index 0000000000000000000000000000000000000000..c41a982ff7a38079d8d374b3e502d4a57c7fafca Binary files /dev/null and b/results/images/box_hover.png differ diff --git a/results/images/groom_24.png b/results/images/groom_24.png new file mode 100644 index 0000000000000000000000000000000000000000..22fc4b78e972d811cb32f0ebcb5bb40f523c8942 Binary files /dev/null and b/results/images/groom_24.png differ diff --git a/results/images/hip-hop_16.png b/results/images/hip-hop_16.png new file mode 100644 index 0000000000000000000000000000000000000000..66236426f54f96fd2ef714c14f5a0b1f658a2692 Binary files /dev/null and b/results/images/hip-hop_16.png differ diff --git a/results/images/hover.png b/results/images/hover.png new file mode 100644 index 0000000000000000000000000000000000000000..416b3e6ab179a6fe8587ce09db632debce1e32f2 Binary files /dev/null and b/results/images/hover.png differ diff --git a/results/images/jogger_16.png b/results/images/jogger_16.png new file mode 100644 index 0000000000000000000000000000000000000000..59d701e1fd175b5d7412c40432f8cecb4a3b1ce2 Binary files /dev/null and b/results/images/jogger_16.png differ diff --git a/results/images/jogger_24.png b/results/images/jogger_24.png new file mode 100644 index 0000000000000000000000000000000000000000..66280dead238296e426c3c90833498979717e5f5 Binary files /dev/null and b/results/images/jogger_24.png differ diff --git a/results/images/main.jpg b/results/images/main.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2cd219822963c80fb2c2e146fcee2a7050e32862 Binary files /dev/null and b/results/images/main.jpg differ diff --git a/results/index.php b/results/index.php new file mode 100644 index 0000000000000000000000000000000000000000..dda934831723ab0c2bad5143540ea08dd99fee57 --- /dev/null +++ b/results/index.php @@ -0,0 +1,222 @@ +<?php + +require_once 'Auth.php'; +require_once 'HTML/QuickForm.php'; +require_once 'UNL/Templates.php'; +require_once '../config.inc.php'; +require_once 'HTML/Table.php'; +$page = UNL_Templates::factory('fixed'); +require_once 'charts.php'; +require_once 'Image/Graph.php'; +require_once 'result.functions.php'; + +$GLOBALS['navarray'] = array( 'Home'=>'', + 'Ranking'=>'ranking', + 'Design Comments'=>'design', + 'Marketing Responses'=>'responses', + 'First Impressions'=>'splash', + 'Rating Question Responses'=>'rating_responses', + 'Logout >'=>'logout'); + + +if (isset($_GET['view']) && !empty($_GET['view'])) { + $fnav = array_flip($navarray); + $page->doctitle = '<title>NGRG Research Results | '.$fnav[$_GET['view']].'</title>'; +} else { + $page->doctitle = '<title>NGRG Research Results</title>'; +} +$page->titlegraphic = '<h1>NGRG Research Results</h1>'; +$page->maincontentarea = ''; +$page->navlinks = navigation(); +$page->head .= '<link rel="stylesheet" href="result.css" type="text/css" /><script type="text/javascript" src="main.js"></script>'; + +function login() +{ + $form = new HTML_QuickForm('login','POST'); + $form->addElement('header','loginheader','Research Results Login'); + $form->addElement('text','username','User'); + $form->addElement('password','password','Password'); + $form->addElement('submit','submit','Submit'); + return $form->toHtml(); +} + +$options = PEAR::getStaticProperty('DB_DataObject','options'); +$a = new Auth('DB', array('dsn'=>$options['database']), 'login',false); +$a->start(); +if (isset($_GET['view']) && $_GET['view'] == 'logout' && $a->checkAuth()) { + $a->logout(); + $a->start(); +} +function navigation() +{ + $nav = ''; + foreach ($GLOBALS['navarray'] as $title=>$view) { + + $nav .= "<li><a href='?view={$view}'>{$title}</a></li>\n"; + } + return '<ul>'.$nav.'</ul>'; +} + +if (isset($_GET['view'])) { + $view = $_GET['view']; +} else { + $view = ''; +} + +if (isset($_GET['gender'])) { + $gender = $_GET['gender']; +} else { + $gender = NULL; +} +switch($gender) { + case 'M': + $genderdesc = 'Male '; + break; + case 'F': + $genderdesc = 'Female '; + break; + default: + $genderdesc = NULL; + break; +} + +if ($a->checkAuth()) { + switch ($view) { + default: + case '': + $page->maincontentarea = '<h2>Welcome to the NGRG research results page.</h2><p>Choose the area you wish to view:</p>'; + $page->maincontentarea .= '<div id="homecontainer" class="home">'.navigation().'</div>'; + break; + case 'splash': + case 'ranking': + if ($view=='splash') { + $page->maincontentarea .= '<h2>First Impression Test Results</h2>'; + } else { + $page->maincontentarea .= '<h2>First, Second, Third Ranking Results</h2>'; + } + $page->maincontentarea .= genderNav(); + $page->maincontentarea .= '<h2>'.$genderdesc.'OVERALL</h2>'; + $page->maincontentarea .= InsertChart ( 'charts.swf', 'charts_library', 'graph_server.php?graph='.$view.'&gender='.$gender ); + $audiences = DB_DataObject::factory('audiences'); + $audiences->orderBy('audience'); + $audiences->find(); + while ($audiences->fetch()) { + $page->maincontentarea .= '<h2>'.$genderdesc.$audiences->audience.'</h2>'; + $page->maincontentarea .= InsertChart ( 'charts.swf', 'charts_library', 'graph_server.php?graph='.$view.'&at='.$audiences->id.'&gender='.$gender ); + } + break; + case 'responses': + + if (isset($_GET['question_id'])) { + $question = DB_DataObject::factory('questions'); + $question->get($_GET['question_id']); + $page->maincontentarea = '<h2>Responses for "'.$question->question.'"</h2>'; + $table = new HTML_Table(); + $responses = DB_DataObject::factory('responses'); + $responses->question_id = $question->id; + $numResults = $responses->find(); + if ($numResults) { + $page->maincontentarea .= "<p class='sserifstoryheadred'>$numResults responses.</p>"; + $table->addRow(array('Gender','Age','Response'),NULL,'TH'); + while ($responses->fetch()) { + $voter = DB_DataObject::factory('voter'); + $voter->get($responses->voter_id); + $age_group = $voter->getLink('age_group_id'); + $table->addRow(array($voter->gender,$age_group->age_group,nl2br($responses->response))); + } + } + $page->maincontentarea .= $table->toHtml(); + } else { + ob_start(); + include 'questions.php'; + $page->maincontentarea = ob_get_contents(); + ob_end_clean(); + } + break; + case 'rating_responses': + $audiences = DB_DataObject::factory('audiences'); + if ($audiences->find()) { + $ratings = array(); + while ($audiences->fetch()) { + $rating_q = DB_DataObject::factory('rating_questions'); + $rating_q->audience_id = $audiences->id; + $rating_q->orderBy('lead_question_id'); + if ($rating_q->find()) { + $curr_q = 0; + $ratings[$audiences->audience] = array(); + while ($rating_q->fetch()) { + if ($curr_q != $rating_q->lead_question_id) { + $lead_q = $rating_q->getLink('lead_question_id'); + $ratings[$audiences->audience][$lead_q->lead_question] = array(); + $curr_q = $rating_q->lead_question_id; + } + $ratings[$audiences->audience][$lead_q->lead_question][$rating_q->question] = getAverageRating($rating_q->id); + } + } + } + } + foreach ($ratings as $audience=>$questions) { + $page->maincontentarea .= '<h2>'.$audience.'</h2>'; + foreach ($questions as $question=>$responses) { + $page->maincontentarea .= '<h3>'.$question.'</h3>'; + arsort($responses); + + $table = new HTML_Table(); + foreach ($responses as $rating_q=>$response) { + $table->addRow(array($rating_q,round($response,3))); + } + $table->setColAttributes(0,'class="response_q"'); + $page->maincontentarea .= $table->toHtml(); + } + } + break; + case 'design': + if(isset($_GET['response'])) { + $prototype = DB_DataObject::factory('prototype'); + $prototype->get($_GET['id']); + $page->maincontentarea .= '<h2>Comments on the '.$prototype->title.' Design</h2>'; + $responses = DB_DataObject::factory('prototype_ranking'); + $responses->prototype_id = $_GET['id']; + if ($_GET['response']=='why') { + if (isset($_GET['rank'])) { + $responses->rank = 1; + $page->maincontentarea .= '<h3>Why did you choose this design as your favorite?</h3>'; + } else { + $responses->whereAdd('rank>1'); + $page->maincontentarea .= '<h3>Why didn\'t you choose this design as your favorite?</h3>'; + } + } else { + $page->maincontentarea .= '<h3>What improvements would you recommend?</h3>'; + } + if ($responses->find()) { + $table = new HTML_Table(); + while ($responses->fetch()) { + $field = $_GET['response'].'_response'; + if (!empty($responses->$field)) { + $voter = $responses->getLink('voter_id'); + $age_group = $voter->getLink('age_group_id'); + $table->addRow(array($voter->gender,$age_group->age_group,$responses->$field)); + } + } + $page->maincontentarea .= $table->toHtml(); + } else { + $page->maincontentarea .= '<p>Sorry, couldn\'t find any responses to that question.</p>'; + } + } else { + $page->maincontentarea .= '<h2>Comments on Design</h2>'; + $prototypes = DB_DataObject::factory('prototype'); + $prototypes->find(); + while ($prototypes->fetch()) { + $page->maincontentarea .= '<h3>Comments for '.$prototypes->title.'</h3><ul>'; + $page->maincontentarea .= '<li><a href="?view=design&id='.$prototypes->id.'&rank=1&response=why">Why did you choose this design as your favorite?</a></li>'; + $page->maincontentarea .= '<li><a href="?view=design&id='.$prototypes->id.'&response=why">Why didn\'t you choose this design as your favorite?</a></li>'; + $page->maincontentarea .= '<li><a href="?view=design&id='.$prototypes->id.'&response=improve">What changes would you recommend?</a></li>'; + $page->maincontentarea .= '</ul>'; + } + } + break; + } +} else { + $page->maincontentarea .= login(); +} +echo $page->toHtml(); diff --git a/results/main.js b/results/main.js new file mode 100644 index 0000000000000000000000000000000000000000..689afa457e9d609880df0ad50d96bf1a6d862773 --- /dev/null +++ b/results/main.js @@ -0,0 +1,43 @@ + + +dc={ + + + init:function(e){ + +if(document.getElementsByTagName) { +(function() { +var className = 'hovered', +pattern = new RegExp('(^|\\s+)' + className + '(\\s+|$)'), +rows = document.getElementsByTagName('tr'); + +for(var i = 0, n = rows.length; i < n; ++i) { +rows[i].onmouseover = function() { +this.className += ' ' + className; +}; +rows[i].onmouseout = function() { +this.className = this.className.replace(pattern, ' '); +}; +} +rows = null; +})(); +} + + }, + + /* substitute window.onload */ + addEvent: function(elm, evType, fn, useCapture){ + if (elm.addEventListener) + { + elm.addEventListener(evType, fn, useCapture); + return true; + } else if (elm.attachEvent) { + var r = elm.attachEvent('on' + evType, fn); + return r; + } else { + elm['on' + evType] = fn; + } + } + +} +dc.addEvent(window, 'load', dc.init, false); diff --git a/results/questions.php b/results/questions.php new file mode 100644 index 0000000000000000000000000000000000000000..ed579cbeff4d084dfbcb41a85575e05e2c96dbfc --- /dev/null +++ b/results/questions.php @@ -0,0 +1,23 @@ +<?php +require_once '../config.inc.php'; +require_once 'HTML/Table.php'; +$audiences = DB_DataObject::factory('audiences'); +$audiences->find(); +while ($audiences->fetch()) { + echo '<h2>'.$audiences->audience.'</h2>'; + $table = new HTML_Table(); + $questions = DB_DataObject::factory('questions'); + $questions->audience_id = $audiences->id; + $questions->find(); + while ($questions->fetch()) { + $responses = DB_DataObject::factory('responses'); + $responses->question_id = $questions->id; + $text = $questions->question; + if ($responses->find()) { + $text = "<a href='?view=responses&question_id={$questions->id}'>$text</a>"; + } + $table->addRow(array($text)); + } + echo $table->toHtml(); +} + diff --git a/results/responses.php b/results/responses.php new file mode 100644 index 0000000000000000000000000000000000000000..9121331ead8c003e1982667420c49395bb6c577e --- /dev/null +++ b/results/responses.php @@ -0,0 +1,76 @@ +<?php +/** + * This file generates an excel spreadsheet for each question, and contains + * voter details with responses. + * + * File are created in /tmp/ngrg/ + * + * + */ +require_once '../config.inc.php'; +require_once 'Structures/DataGrid.php'; + +ini_set('display_errors',true); +/* +$questions = DB_DataObject::factory('questions'); +//$questions->limit(1); +$questions->find(); +while ($questions->fetch()) { + $responses = DB_DataObject::factory('responses'); + $voter = DB_DataObject::factory('voter'); + $age_group = DB_DataObject::factory('age_groups'); + $audience = DB_DataObject::factory('audiences'); + $voter->joinAdd($audience); + $voter->joinAdd($age_group); + $question = DB_DataObject::factory('questions'); + $responses->question_id = $questions->id; + + $responses->getLinks(); + $responses->joinAdd($voter); + $responses->joinAdd($question); + $responses->orderBy('questions.question, voter.submitdatetime'); + + if ($responses->find()) { + + $dg =& new Structures_DataGrid(null, null, DATAGRID_RENDER_XLS); + $dg->bind($responses); + + $at = $questions->getLink('audience_id'); + $at = explode(' ',$at->audience); + $dir = '/tmp/ngrg/'.$at[0]; + if (!is_dir($dir)) { + mkdir($dir); + } + $dg->renderer->setFilename($dir.'/ngrg_responses_'.$questions->id.'.xls',false); + $dg->render(); + } +} +*/ +DB_DataObject::debugLevel(2); +$voter = DB_DataObject::factory('voter'); +$responses = DB_DataObject::factory('responses'); +$age_group = DB_DataObject::factory('age_groups'); +$audience = DB_DataObject::factory('audiences'); +$prototype_ranking = DB_DataObject::factory('prototype_ranking'); +$prototype_rating = DB_DataObject::factory('prototype_rating'); +$rating_responses = DB_DataObject::factory('rating_responses'); + +$voter->joinAdd($audience); +$voter->joinAdd($age_group); +$voter->joinAdd($responses); +$voter->joinAdd($prototype_ranking); +$voter->joinAdd($prototype_rating); +$voter->joinAdd($rating_responses); + + +$voter->limit(10); +if ($voter->find()) { + $dg =& new Structures_DataGrid(); + //$dg =& new Structures_DataGrid(null, null, DATAGRID_RENDER_XLS); + $dg->bind($voter); + //$dg->renderer->setFilename($dir.'/ngrg_responses_'.$questions->id.'.xls',false); + $dg->render(); +} + +?> +Done; diff --git a/results/result.css b/results/result.css new file mode 100644 index 0000000000000000000000000000000000000000..a800dd9c207c67bb93a164de399486bcfd5fc9ff --- /dev/null +++ b/results/result.css @@ -0,0 +1,90 @@ + + #maincontent{ + color:#666; + font-family:"Lucida Grande", verdana; + font-size:small; + } + #maincontent *{ + margin:0; + padding:0; + + } + #maincontent h2{ + font-size:23px; + font-family:Helvetica, sans-serif; + letter-spacing:1px; + font-weight:normal; + margin:20px 0 0 0; + color:#d00238; + padding-left:17px; + background:url(images/16-cube-green.png) no-repeat; + } + #maincontent h3{ + font-weight:normal; + color:#333; + } + #maincontent table{ + border-collapse:collapse; + text-align:left; + background:#fafafa; + border:3px double #ccc; + margin:5px 0 10px 0; + } + #maincontent table td{ + position:relative; + padding: 5px; + border-bottom:1px solid #ccc; + } + + #maincontent table tr.hovered{ + background:#eee; + color:#d33308; + } + #maincontent ul{ + list-style:none; + padding:0 0 10px 10px; + } + #maincontent ul li{ + list-style:none; + padding:2px 0 2px 15px; + background:url(images/0175_post_bullet.png) no-repeat; + background-position:0 3px; + } + + #homecontainer{ + text-align:center; + } + #homecontainer ul{ + margin:10px auto 0 100px; + background:url(images/main.jpg) no-repeat; + width:485px; + height:332px; + padding:30px 0 0 130px; + } + #homecontainer ul li{ + text-align:left; + background:none; + padding:0 0 0 18px; + width:160px; + } + + #homecontainer ul li:hover{ + background:url(images/16-arrow-right.png) no-repeat; + position:relative; + } + + #homecontainer ul li a{ + display:block; + border-bottom:1px solid #eee; + padding:3px;width:150px; + } + #homecontainer ul li a:hover{ + text-decoration:none; + background:#e1f9c2; + } + + + + + + \ No newline at end of file diff --git a/results/result.functions.php b/results/result.functions.php new file mode 100644 index 0000000000000000000000000000000000000000..c6bd76e21bdc51bf79fc314d282a84a57ba5b240 --- /dev/null +++ b/results/result.functions.php @@ -0,0 +1,74 @@ +<?php + +function rankingCount($title,$rank,$at=NULL, $gender=NULL) +{ + $prototype = DB_DataObject::factory('prototype'); + $prototype->title = $title; + if ($prototype->find() && $prototype->fetch()) { + $prototype_ranking = DB_DataObject::factory('prototype_ranking'); + $voter = DB_DataObject::factory('voter'); + $voter->audience_id = $at; + if (!empty($gender)) { + $voter->gender = $gender; + } + $prototype_ranking->joinAdd($voter); + $prototype_ranking->prototype_id = $prototype->id; + $prototype_ranking->rank = $rank; + return $prototype_ranking->find(); + } else { + return NULL; + } +} + +function rankingTotal($rank) +{ + $prototype_ranking = DB_DataObject::factory('prototype_ranking'); + $prototype_ranking->rank = $rank; + return $prototype_ranking->find(); +} + +function ratingCount($title,$rating,$at=NULL, $gender=NULL) +{ + $prototype = DB_DataObject::factory('prototype'); + $prototype->title = $title; + if ($prototype->find() && $prototype->fetch()) { + $prototype_rating = DB_DataObject::factory('prototype_rating'); + $voter = DB_DataObject::factory('voter'); + if (!empty($gender)) { + $voter->gender = $gender; + } + $voter->audience_id = $at; + $prototype_rating->joinAdd($voter); + $prototype_rating->prototype_id = $prototype->id; + $prototype_rating->rating = $rating; + return $prototype_rating->find(); + } else { + return NULL; + } +} + +function getAverageRating($id) +{ + $responses = DB_DataObject::factory('rating_responses'); + $responses->question_id = $id; + $total = $responses->find(); + if ($total) { + $avg = 0; + while ($responses->fetch()) { + $avg += (int)$responses->response; + } + return $avg/$total; + } else { + return 0; + } +} + +function genderNav() +{ + $ul = '<ul class="gendernav"> + <li id="total"><a href="?view='.$_GET['view'].'">Total</a></li> + <li id="female"><a href="?view='.$_GET['view'].'&gender=F">Female</a></li> + <li id="male"><a href="?view='.$_GET['view'].'&gender=M">Male</a></li> + </ul>'; + return $ul; +} diff --git a/style.css b/style.css new file mode 100644 index 0000000000000000000000000000000000000000..58cd45cf702c9e66719c7ab06ee7b777c63c06bb --- /dev/null +++ b/style.css @@ -0,0 +1,416 @@ + +/* styles for the star rater */ +.star-rating{ + list-style:none; + margin: 10px auto; + padding:0px; + width: 150px; + height: 30px; + position: relative; + background:#efebdb url(images/stars.gif) top left repeat-x; +} +.star-rating li{ + padding:0px; + margin:0px; + /*\*/ + float: left; + /* */ +} +.star-rating li a{ + display:block; + width:30px; + height: 30px; + text-decoration: none; + text-indent: -9000px; + z-index: 20; + position: absolute; + padding: 0px; + outline:none; +} +.star-rating li a:hover{ + background: url(images/stars.gif) left bottom; + z-index: 1; + left: 0px; +} +.star-rating a.one-star{ + left: 0px; +} +.star-rating a.one-star:hover{ + width:30px; +} +.star-rating a.two-stars{ + left:30px; +} +.star-rating a.two-stars:hover{ + width: 60px; +} +.star-rating a.three-stars{ + left: 60px; +} +.star-rating a.three-stars:hover{ + width: 90px; +} +.star-rating a.four-stars{ + left: 90px; +} +.star-rating a.four-stars:hover{ + width: 120px; +} +.star-rating a.five-stars{ + left: 120px; +} +.star-rating a.five-stars:hover{ + width: 150px; +} + +/*--- Alvin's css (note-to-self: always download the latest version before editing ---*/ +/* Universal properties */ +*{ +padding:0; +margin:0; +} +img{border:0;} +a{outline:none;} +body{ + background:#f7f1e6 url(images/design_survey_01.gif) repeat-x;background-position:0 -30px; + font-size:small; + font-family:Arial, Helvetica, sans-serif; + text-align:center; + } +/* container */ +#introduction{ + margin:70px auto 0px auto; + text-align:left; + width:850px; + } + +#introduction.rankintro, #introduction.comments { +width:1000px; +font-size:1.5em; +} + +#introduction.rankintro p, #introduction.comments p{ +width:100%; +text-align:center; +font-size:1.2em; +} + #introduction.audience p#aud { + font-size:1.6em; + text-align:center; + margin:100px 0 -20px 0; + _margin:40px 0 -20px 0; + } +#introduction.audience form { +width:100%; +text-align:center; +margin-top:100px; +} + +#introduction.audience select { +font-size:1.3em; +margin:2em; +} + +#introduction:after{ + content: "."; + display: block; + clear: both; + visibility: hidden; + } + + #introduction h1{ + text-indent:-9999px; + background:url(images/design_survey_04.gif) no-repeat; + width:705px; + height:100px; + } + + #introduction h2{ + font-size:1.8em; + width:705px; + text-align:left; + padding-bottom:38px; + margin:110px 0 0 0; + _margin:40px 0 0 0; /*bloody hell IE*/ + color:#545351; + } + +#left{ + float:left; + width:374px; + height:310px; + } + +#right{ + font-size:1em; + line-height:16px; + width:460px; + float:right; + } +#right p{ +padding:7px 0; + } +/*proceed button*/ +#submit_test{ + clear:both; + width:460px; + float:right; +} +#content_demo #submit{ + margin:1em auto 0 auto; + text-align:center; + padding:0; + width:600px; +} + +#submit img{ + border:0; + margin:-0.5em auto 0 auto;position:relative; +} +/******* FIRST IMPRESSION TEST ******/ +#content_demo{ + margin-top:210px; + _margin-top:150px; + font-size:1.8em; + line-height:29px; + } +#content_demo a{ + font-weight:bold; +} +#countdown{ + font-size:40px; + font-weight:bold; + margin-top:7.5em; + width:100%; + text-align:center; +} +div.rating { + left:0;width:100%; + text-align:center; + font-size:20px; + position:absolute; + top:250px; + } + +div.splash{ + position:absolute; + top:0; + left:0;width:100%; + text-align:center; +} + + + + +ul.thumbs { +list-style:none; +width:1000px; +margin:50px auto 0 auto; +_margin:75px auto 0 auto; +} +ul.thumbs li { +padding:0 4px; +display:inline; +} + +ul.thumbs li a img, #ranking_last a img { +background:#e8dfcb; +padding:10px; +border:1px solid #d5d0c1; +} +ul.thumbs li a:hover img, #ranking_last a:hover img { +background:#585532; +padding:10px; +border:1px solid #d5d0c1; +} +form#ranking_form ul.thumbs{ +font-size:0.7em; +} + +form#ranking_form ul.thumbs li { +padding:0 2px; +float:left; +display:inline; +} + +form#ranking_form ul.thumbs li ul{ +margin:0 0 0 50px; +} + + +.float_form form{ +background:url(images/comment.png) no-repeat; +_background:url(images/comment.gif) no-repeat; + /* + _background:none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/comment.png',sizingMethod='scale'); + */ + width:350px; + height:440px;font-size:11px;color:#666; + margin:0; + padding:28px 0 0 15px; + cursor:move; +} +.float_form ul{ + list-style:none;text-align:left; +} +.float_form li{ + margin:7px 0 0 0; +} +.float_form textarea{ + width:305px; + height:145px; + border:1px solid #d7d7d7; + background:#e8e8e8; + padding:3px 5px; +} + +.float_form form span{ + border-bottom:1px solid #F1A1AE; +} +.float_form form input.submit{ + background:url(images/comment_09.png) no-repeat; + _background:none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/comment_09.png',sizingMethod='scale'); + width:74px; + height:36px; + border:0; + float:right; + margin:0 30px 0 0; +} +.float_form form textarea:focus{ + background:#fff; +} + +img#commentproceed{ + vertical-align:top; +} + +.full{ + position:absolute; + left:0;top:0; +} +#imagelogo { +clear:both; +text-align:center; +} + +.buttoncentered, .submit_below { +width:1000px; +text-align:center; +} +.submit_below { +position:absolute; +top:480px; +} + +#scale{ + margin-left:-18px; +} + +div#introduction_brett{ +width:726px;margin:70px auto; +} + + +div#introduction_brett select{ +float:left; +_margin-left:10px; +} +#question_head{ + background:transparent url(images/header.gif) no-repeat; + width:726px; + height:23px; + margin:0 0 0 -7px; + _margin:0px;position:relative; +} +#question_head p { +padding:10px; +font-size:1.5em; +color:#706E67; +} +#question_mid table.questionnaire { + border-collapse:collapse; + width:710px; + margin:15px auto 0 auto; + _margin:0 0 0 -20px; + position:relative; + border:1px solid #ccc; +} + +.question_submit { +width:100%;position:relative; +text-align:center;} + +#question_mid table.questionnaire tr{ + border-bottom:1px solid #ccc; + padding:0; + margin:0; +} + +#question_mid table.questionnaire td{ + height:80px; + padding:5px; + _padding:0px; + background:#EEE4CF url(images/gradient.gif) repeat-x; + color:#706E67; + font-size:0.85em; +} +#question_mid p.subq { +margin:5px; +text-align:left; +} + +#question_mid table.subquestions td { +height:30px; +background:none; +} + +#question_mid p { + text-align:right; + font-size:1.5em; +} +#question_mid textarea {width:420px;height:70px;margin:5px;} +#question_mid{ + background:transparent url(images/middle.gif) repeat-y; + width:726px; + padding-top:3px; + _padding:20px 0 0 10px; /*stupid IE */ + margin:0 0 0 -7px; _margin:-20px 0 0 0; +} +#question_foot{ + background: #fff url(images/footer.gif) no-repeat; + width:726px; + height:23px; + margin:-13px 0 0 -7px; _margin:-13px 0 0 0; +} +#introduction.comments ul { +} +#introduction.comments ul li { +position:relative; +height:235px; +} + +.comments_saved{ +position:absolute; +top:-110px; +_top:110px; +left:100px; + +} + +.subquestions{ + font-size:18px; +} +.subquestions td{ +position:relative; +text-align:right;width:200px;margin:0;padding:0; +} +.subquestions ul{ +position:relative; +text-align:left;float:left; +border-right:1px solid #ccc;border-bottom:1px solid #ccc; +padding:0; +margin:0; +_margin-left:5px; +} \ No newline at end of file diff --git a/voting_system.js b/voting_system.js new file mode 100644 index 0000000000000000000000000000000000000000..bb389d7f5ba60448f26e9d35050e1bc055b52210 --- /dev/null +++ b/voting_system.js @@ -0,0 +1,191 @@ +var voter = new voting_system(); +var splashdelay = 2500; +var debug = false; +var formprefix = "rating_form_"; +var imgprefix = "prototype_img_"; +function hideIntroduction() +{ + if (debug) alert("hideIntroduction()"); + document.getElementById('introduction').style.display = 'none'; + +} +function beginSplashRating() +{ + //setSize(1024,768); + hideIntroduction(); + //voter.setStep(2); + countDown(5,"splashImage(1)"); +} +function unHideImageAndForm(prototype) +{ + unHideImage(prototype); + unHideForm(prototype); +} +function voteAndMove(form,prototype_id,rating) +{ + if (debug) alert("voteAndMove("+form+","+prototype_id+","+rating+")"); + hideForm(form); + voter.tallyVote(prototype_id,rating); + if (form<3) { + var next = form+1; + countDown(5,"splashImage("+next+")"); + } else { + // This is the last prototype. + changeStep(3); + } +} +function changeStep(step) +{ + voter.setStep(step); + window.location.reload(); +} +function splashImage(prototype) +{ + if (debug) alert("splashImage("+imgprefix+prototype+")"); + unHideImage(prototype); + setTimeout('hideImageShowForm('+prototype+')',splashdelay); +} +function unHideImage(prototype) +{ + document.getElementById(imgprefix+prototype).style.display='block'; +} +function hideImage(prototype) +{ + if (debug) alert("hideImage("+imgprefix+prototype+")"); + document.getElementById(imgprefix+prototype).style.display='none'; +} +function hideImageShowForm(num) +{ + hideImage(num); + unHideForm(num); +} +function unHideForm(form) +{ + if (debug) alert("unRatingForm("+formprefix+form+")"); + document.getElementById(formprefix+form).style.display='block'; +} +function hideForm(form) +{ + if (debug) alert("hideForm("+formprefix+form+")"); + document.getElementById(formprefix+form).style.display='none'; +} +function checkImageLoading() +{ + if (voter.sentPrototypes() == true) { + document.getElementById("loading").style.display='none'; + document.getElementById("step2").style.display='block'; + } else { + setTimeout("checkImageLoading()",2000); + } +} +function setSize(width,height) { + if (window.outerWidth) { + window.outerWidth = width; + window.outerHeight = height; + } + else if (window.resizeTo) { + window.resizeTo(width,height); + } + else { + alert("Not supported."); + } +} +function unHideFullImage(order) +{ + formprefix = "float_form_warpper_"; + unHideImageAndForm(order); +} +function countDown(seconds,callback) +{ + if (debug) alert("countDown("+seconds+","+callback+")"); + if (seconds>0) { + document.getElementById("countdown").innerHTML = seconds.toString(); + seconds = seconds-1; + setTimeout("countDown("+seconds+",'"+callback+"')",1000); + } else { + document.getElementById("countdown").innerHTML = ""; + eval(callback); + } +} +function submitRankings(form) +{ + if (debug) alert('submitRankings(form)'); + var rank_1,rank_2,rank_3; + rank_1 = rank_2 = rank_3 = 0; + for (var i=0; i<form.prototype_1.length; i++) { + if (form.prototype_1[i].checked) { + rank_1 = form.prototype_1[i].value; + } + } + for (var i=0; i<form.prototype_2.length; i++) { + if (form.prototype_2[i].checked) { + rank_2 = form.prototype_2[i].value; + } + } + for (var i=0; i<form.prototype_3.length; i++) { + if (form.prototype_3[i].checked) { + rank_3 = form.prototype_3[i].value; + } + } + if (rank_1>0 && rank_2>0 && rank_3>0) { + if ((rank_1 != rank_2) && (rank_1 != rank_3) && (rank_2 != rank_3)) { + voter.submitRank(1,rank_1); + voter.submitRank(2,rank_2); + voter.submitRank(3,rank_3); + changeStep(4); + } else { + alert('Please select a unique rank for each prototype.'); + } + } else { + alert('Please rank each prototype'); + } +} + +function sampleSplashRating() +{ + hideIntroduction(); + // Display sample splash image. + countDown(5,'showSampleSplash()'); +} +function showSampleSplash() +{ + showId('samplesplash'); + setTimeout('hideSampleSplash()',splashdelay); +} +function hideSampleSplash() +{ + hideId('samplesplash'); + hideId('demo'); + showId('impressioncont'); + showId('introduction'); + if (voter.sentPrototypes() != true) { + showId('loading'); + setTimeout("checkImageLoading()",3000); + } else { + showId('step2'); + } +} +function showId(id) +{ + document.getElementById(id).style.display = 'block'; +} +function hideId(id) +{ + document.getElementById(id).style.display = 'none'; +} + +function setQuestionRating(qid,value) +{ + ul = document.getElementById('rq_ul_'+qid); + as = ul.getElementsByTagName('a'); + for(var i=0;i<as.length;i++) { + if (i<value) { + as[i].style.background = 'url(images/stars.gif) left bottom'; + } else { + as[i].style.background = 'url(images/stars.gif) top left' + } + } + input = document.getElementById('rq_'+qid); + input.value = value; +} +