Importing JS
This commit is contained in:
parent
bf4a25c206
commit
4e05a51f15
23 changed files with 3827 additions and 0 deletions
327
www/extras/wobject/Survey/administersurvey.js
Normal file
327
www/extras/wobject/Survey/administersurvey.js
Normal file
|
|
@ -0,0 +1,327 @@
|
||||||
|
if (typeof Survey == "undefined") {
|
||||||
|
var Survey = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Survey.Form = new function() {
|
||||||
|
|
||||||
|
var multipleChoice = {'Multiple Choice':1,'Gender':1,'Yes/No':1,'True/False':1,'Agree/Disagree':1,'Oppose/Support':1,'Importance':1,
|
||||||
|
'Likelihood':1,'Certainty':1,'Satisfaction':1,'Confidence':1,'Effectiveness':1,'Concern':1,'Risk':1,'Threat':1,'Security':1,'Ideology':1,
|
||||||
|
'Race':1,'Party':1,'Education':1};
|
||||||
|
var text = {'Text':1, 'Email':1, 'Phone Number':1, 'Text Date':1, 'Currency':1};
|
||||||
|
var slider = {'Slider':1, 'Dual Slider - Range':1, 'Multi Slider - Allocate':1};
|
||||||
|
var dateType = {'Date':1,'Date Range':1};
|
||||||
|
var fileUpload = {'File Upload':1};
|
||||||
|
var hidden = {'Hidden':1};
|
||||||
|
|
||||||
|
var hasFile;
|
||||||
|
|
||||||
|
this.displayQuestions = function(params){
|
||||||
|
|
||||||
|
var qs = params.questions;
|
||||||
|
var s = params.section;
|
||||||
|
|
||||||
|
|
||||||
|
//What to show and where
|
||||||
|
document.getElementById('survey').innerHTML = params.html;
|
||||||
|
var te = document.createElement('span');
|
||||||
|
te.innerHTML = "<input type=button id=testB name='Reload Page' value='Reload Page'>";
|
||||||
|
document.getElementById('survey').appendChild(te);
|
||||||
|
YAHOO.util.Event.addListener("testB", "click", function(){Survey.Comm.callServer('','loadQuestions');});
|
||||||
|
|
||||||
|
if(qs[0] != undefined){
|
||||||
|
if(qs[0].sequenceNumber == '1' || s.everyPageTitle > 0){
|
||||||
|
document.getElementById('headertitle').style.display='block';
|
||||||
|
}
|
||||||
|
if(qs[0].sequenceNumber == '1' || s.everyPageText > 0){
|
||||||
|
document.getElementById('headertext').style.display = 'block';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(qs[0].sequenceNumber == '1' && s.questionsOnSectionPage != '1'){
|
||||||
|
var span = document.createElement("div");
|
||||||
|
span.innerHTML = "<input type=button id='showQuestionsButton' value='Continue'>";
|
||||||
|
span.style.display = 'block';
|
||||||
|
|
||||||
|
document.getElementById('header').appendChild(span);
|
||||||
|
YAHOO.util.Event.addListener("showQuestionsButton", "click",
|
||||||
|
function(){
|
||||||
|
document.getElementById('showQuestionsButton').style.display = 'none';
|
||||||
|
if(s.everyPageTitle == 0){
|
||||||
|
document.getElementById('headertitle').style.display = 'none';
|
||||||
|
}
|
||||||
|
if(s.everyPageText == 0){
|
||||||
|
document.getElementById('headertext').style.display = 'none';
|
||||||
|
}
|
||||||
|
document.getElementById('questions').style.display='inline';
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
document.getElementById('questions').style.display='inline';
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
document.getElementById('headertitle').style.display='block';
|
||||||
|
document.getElementById('headertext').style.display = 'block';
|
||||||
|
document.getElementById('questions').style.display='inline';
|
||||||
|
}
|
||||||
|
|
||||||
|
//Display questions
|
||||||
|
|
||||||
|
var html;
|
||||||
|
hasFile = false;
|
||||||
|
for(var i = 0; i < qs.length; i++){
|
||||||
|
var q = qs[i];
|
||||||
|
var verts = '';
|
||||||
|
var verte = '';
|
||||||
|
for(var x in q.answers){
|
||||||
|
for(var y in q.answers[x]){
|
||||||
|
if(q.answers[x][y] == undefined){q.answers[x][y] = '';}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
html += "<hr>";
|
||||||
|
html += "<div class='question'>Q"+q.sequenceNumber+": "+q.questionText+"</div>";
|
||||||
|
|
||||||
|
if(multipleChoice[q.questionType]){
|
||||||
|
var butts = new Array();
|
||||||
|
for(var x = 0; x < q.answers.length; x++){
|
||||||
|
var a = q.answers[x];
|
||||||
|
var b = new YAHOO.widget.Button({ type: "checkbox", label: a.answerText, id: a.Survey_answerId+'button', name: a.Survey_answerId+'button',
|
||||||
|
value: a.Survey_answerId,
|
||||||
|
container: a.Survey_answerId+"container", checked: false });
|
||||||
|
b.on("click", this.buttonChanged,[b,a.Survey_questionId,q.maxAnswers,butts]);
|
||||||
|
b.hid = a.Survey_answerId;
|
||||||
|
butts.push(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(dateType[q.questionType]){
|
||||||
|
for(var x = 0; x < q.answers.length; x++){
|
||||||
|
var a = q.answers[x];
|
||||||
|
var calid = a.Survey_answerId+'container';
|
||||||
|
var c = new YAHOO.widget.Calendar(calid,{title:'Choose a date:', close:true});
|
||||||
|
c.selectEvent.subscribe(this.selectCalendar,[c,a.Survey_answerId],true);
|
||||||
|
c.render();
|
||||||
|
c.hide();
|
||||||
|
var b = new YAHOO.widget.Button({ label:"Select Date", id:"pushbutton"+a.Survey_answerId, container:a.Survey_answerId+'button' });
|
||||||
|
b.on("click", this.showCalendar,[c]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(slider[q.questionType]){
|
||||||
|
//First run through and put up the span placeholders and find the max value for an answer, to know how big the allocation points will be.
|
||||||
|
var max = 0;
|
||||||
|
if(q.questionType == 'Dual Slider - Range'){
|
||||||
|
new this.dualSliders(q);
|
||||||
|
}else{
|
||||||
|
for(var s in q.answers){
|
||||||
|
var a = q.answers[s];
|
||||||
|
if(a.max - a.min > max){max = a.max - a.min;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(q.questionType == 'Multi Slider - Allocate'){
|
||||||
|
//sliderManagers[sliderManagers.length] = new this.sliderManager(q,max);
|
||||||
|
new this.sliderManager(q,max);
|
||||||
|
}
|
||||||
|
else if(q.questionType == 'Slider'){
|
||||||
|
new this.sliders(q);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(fileUpload[q.questionType]){
|
||||||
|
hasFile = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
YAHOO.util.Event.addListener("submitbutton", "click", this.formsubmit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.formsubmit = function(){
|
||||||
|
Survey.Comm.callServer('','submitQuestions','surveyForm',hasFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.dualSliders = function(q){
|
||||||
|
var total = 200;
|
||||||
|
var sliders = new Array();
|
||||||
|
var a1 = q.answers[0];
|
||||||
|
var a2 = q.answers[1];
|
||||||
|
var scale = 200/a1.max;
|
||||||
|
|
||||||
|
var id = q.Survey_questionId;
|
||||||
|
var a1id = a1.Survey_answerId;
|
||||||
|
var a2id = a2.Survey_answerId;
|
||||||
|
|
||||||
|
var a1h = document.getElementById(a1id);
|
||||||
|
var a2h = document.getElementById(a2id);
|
||||||
|
var a1s = document.getElementById(a1id+'show');
|
||||||
|
var a2s = document.getElementById(a2id+'show');
|
||||||
|
var s = YAHOO.widget.Slider.getHorizDualSlider(id+'slider-bg',
|
||||||
|
a1id+"slider-min-thumb", a2id+"slider-max-thumb",
|
||||||
|
200, 1*scale, [1,200]);
|
||||||
|
|
||||||
|
s.minRange = 4;
|
||||||
|
var updateUI = function () {
|
||||||
|
var min = Math.round(s.minVal/scale),
|
||||||
|
max = Math.round(s.maxVal/scale);
|
||||||
|
a1h.value = min;
|
||||||
|
a1s.innerHTML = min;
|
||||||
|
a2h.value = max;
|
||||||
|
a2s.innerHTML = max;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Subscribe to the dual thumb slider's change and ready events to
|
||||||
|
// report the state.
|
||||||
|
// s.subscribe('ready', updateUI);
|
||||||
|
s.subscribe('change', updateUI);
|
||||||
|
}
|
||||||
|
this.sliders = function(q){
|
||||||
|
var total = 200;
|
||||||
|
for(var i in q.answers){
|
||||||
|
var a = q.answers[i];
|
||||||
|
var step = q.answers[i].step;
|
||||||
|
var scale = 200/q.answers[i].max;
|
||||||
|
var Event = YAHOO.util.Event;
|
||||||
|
var lang = YAHOO.lang;
|
||||||
|
var id = a.Survey_answerId;
|
||||||
|
var s = YAHOO.widget.Slider.getHorizSlider(id+'slider-bg', id+'slider-thumb',
|
||||||
|
0, 200, (scale*step));
|
||||||
|
// 0, 200, 1);
|
||||||
|
s.max = a.max*scale;
|
||||||
|
s.input = a.Survey_answerId;
|
||||||
|
s.scale = scale;
|
||||||
|
document.getElementById(id).value = a.min;
|
||||||
|
var check = function() {
|
||||||
|
var t = document.getElementById(this.input);
|
||||||
|
var tshow = document.getElementById(this.input+'show');
|
||||||
|
t.value = this.getRealValue();
|
||||||
|
tshow.innerHTML = this.getRealValue();
|
||||||
|
};
|
||||||
|
s.getRealValue = function() {
|
||||||
|
return this.getValue() / this.scale;
|
||||||
|
}
|
||||||
|
s.subscribe("slideEnd", check);
|
||||||
|
s.subscribe("change", check);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//an object which creates sliders for allocation type questions and then manages their events and keeps them from overallocating
|
||||||
|
this.sliderManager = function(q,t){
|
||||||
|
var total = 200;
|
||||||
|
var step = q.answers[0].step;
|
||||||
|
var scale = 200/q.answers[0].max;
|
||||||
|
var sliders = new Array();
|
||||||
|
|
||||||
|
for(var i in q.answers){
|
||||||
|
var a = q.answers[i];
|
||||||
|
var Event = YAHOO.util.Event;
|
||||||
|
var lang = YAHOO.lang;
|
||||||
|
var id = a.Survey_answerId+'slider-bg';
|
||||||
|
var s = YAHOO.widget.Slider.getHorizSlider(id, a.Survey_answerId+'slider-thumb',
|
||||||
|
0, 200, scale*step);
|
||||||
|
s.input = a.Survey_answerId;
|
||||||
|
s.lastValue = 0;
|
||||||
|
var check = function() {
|
||||||
|
var t = 0;
|
||||||
|
for(var x in sliders){
|
||||||
|
t+= sliders[x].getValue();
|
||||||
|
}
|
||||||
|
if(t > total){
|
||||||
|
t -= this.getValue();
|
||||||
|
t = Math.round(t);
|
||||||
|
this.setValue(total-t + scale*step);
|
||||||
|
}else{
|
||||||
|
this.lastValue = this.getValue();
|
||||||
|
document.getElementById(this.input).value = this.getRealValue();
|
||||||
|
document.getElementById(this.input+'show').innerHTML = this.getRealValue();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
s.subscribe("slideEnd", check);
|
||||||
|
s.subscribe("change", check);
|
||||||
|
var manualEntry = function(e){
|
||||||
|
// set the value when the 'return' key is detected
|
||||||
|
if (Event.getCharCode(e) === 13 || e.type == 'blur') {
|
||||||
|
var v = parseFloat(this.value, 10);
|
||||||
|
v = (lang.isNumber(v)) ? v : 0;
|
||||||
|
v *= scale;
|
||||||
|
|
||||||
|
// convert the real value into a pixel offset
|
||||||
|
for(var sl in sliders){
|
||||||
|
if(sliders[sl].input == this.id){
|
||||||
|
sliders[sl].setValue(Math.round(v));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event.on(document.getElementById(s.input), "keydown", manualEntry);
|
||||||
|
Event.on(document.getElementById(s.input), "blur", manualEntry);
|
||||||
|
|
||||||
|
s.getRealValue = function() {
|
||||||
|
return Math.round(this.getValue() / scale);
|
||||||
|
}
|
||||||
|
sliders.push(s);
|
||||||
|
document.getElementById(s.input).value = s.getRealValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selectCalendar = function(event,args,obj){
|
||||||
|
var id = obj[1];
|
||||||
|
var selected = args[0];
|
||||||
|
var date = selected[0];
|
||||||
|
var year = date[0], month = date[1], day = date[2];
|
||||||
|
var input = document.getElementById(id);
|
||||||
|
input.value = month + "/" + day + "/" + year;
|
||||||
|
obj[0].hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.showCalendar = function(event,objs){
|
||||||
|
objs[0].show();
|
||||||
|
}
|
||||||
|
this.buttonChanged = function(event,objs){
|
||||||
|
var b = objs[0];
|
||||||
|
var qid = objs[1];
|
||||||
|
var maxA = objs[2];
|
||||||
|
var butts = objs[3];
|
||||||
|
max = parseInt(max);
|
||||||
|
if(maxA == 1){
|
||||||
|
for(var i in butts){
|
||||||
|
butts[i].set('checked',false);
|
||||||
|
document.getElementById(butts[i].hid).value = '';
|
||||||
|
}
|
||||||
|
b.set('checked',true);
|
||||||
|
document.getElementById(b.hid).value = 1;
|
||||||
|
}
|
||||||
|
else if(b.get('checked')){
|
||||||
|
var max = parseInt(document.getElementById(qid+'max').innerHTML);
|
||||||
|
if(max == 0){
|
||||||
|
b.set('checked',false);
|
||||||
|
//warn that options used up
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
document.getElementById(qid+'max').innerHTML = parseInt(max-1);
|
||||||
|
document.getElementById(b.hid).value = '';
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
var max = parseInt(document.getElementById(qid+'max').innerHTML);
|
||||||
|
document.getElementById(qid+'max').innerHTML = parseInt(max+1);
|
||||||
|
document.getElementById(b.hid).value = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Initialize survey
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
Survey.OnLoad = new function() {
|
||||||
|
var e = YAHOO.util.Event;
|
||||||
|
this.init = function() {
|
||||||
|
e.onDOMReady(this.initHandler);
|
||||||
|
}
|
||||||
|
this.initHandler = function(){
|
||||||
|
Survey.Comm.setUrl('/'+document.getElementById('assetPath').value);
|
||||||
|
Survey.Comm.callServer('','loadQuestions');
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
Survey.OnLoad.init();
|
||||||
404
www/extras/wobject/Survey/administersurvey.js.backup
Normal file
404
www/extras/wobject/Survey/administersurvey.js.backup
Normal file
|
|
@ -0,0 +1,404 @@
|
||||||
|
if (typeof Survey == "undefined") {
|
||||||
|
var Survey = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Survey.Form = new function() {
|
||||||
|
|
||||||
|
var sliders;
|
||||||
|
var dSliders;
|
||||||
|
var texts;
|
||||||
|
var buttons;
|
||||||
|
var cals;
|
||||||
|
var files;
|
||||||
|
|
||||||
|
var multipleChoice = {'Multiple Choice':1,'Gender':1,'Yes/No':1,'True/False':1,'Agree/Disagree':1,'Oppose/Support':1,'Importance':1,
|
||||||
|
'Likelihood':1,'Certainty':1,'Satisfaction':1,'Confidence':1,'Effectiveness':1,'Concern':1,'Risk':1,'Threat':1,'Security':1,'Ideology':1,
|
||||||
|
'Race':1,'Party':1,'Education':1};
|
||||||
|
var text = {'Text':1, 'Email':1, 'Phone Number':1, 'Text Date':1, 'Currency':1};
|
||||||
|
var slider = {'Slider':1, 'Dual Slider - Range':1, 'Multi Slider - Allocate':1};
|
||||||
|
var dateType = {'Date':1,'Date Range':1};
|
||||||
|
var fileUpload = {'File Upload':1};
|
||||||
|
var hidden = {'Hidden':1};
|
||||||
|
|
||||||
|
this.displayQuestions = function(params){
|
||||||
|
sliders = new Array();
|
||||||
|
dSliders = new Array();
|
||||||
|
texts = new Array();
|
||||||
|
buttons = new Array();
|
||||||
|
cals = new Array();
|
||||||
|
files = new Array();
|
||||||
|
|
||||||
|
var section = params.section;
|
||||||
|
var questions = params.questions;
|
||||||
|
document.getElementById('headertitle').innerHTML = "Section: "+section.sequenceNumber+" "+section.sectionName + "<hr>";
|
||||||
|
|
||||||
|
if(section.questionsOnSectionPage){
|
||||||
|
document.getElementById('headertext').innerHTML = section.sectionText;
|
||||||
|
}
|
||||||
|
|
||||||
|
var qs = params.questions;
|
||||||
|
var s = params.survey;
|
||||||
|
var html = "";
|
||||||
|
|
||||||
|
// html = '<form id=surveyForm>';
|
||||||
|
document.getElementById('survey').innerHTML = html;html = '';
|
||||||
|
for(var i = 0; i < qs.length; i++){
|
||||||
|
var q = qs[i];
|
||||||
|
var verts = '';
|
||||||
|
var verte = '';
|
||||||
|
for(var x in q.answers){
|
||||||
|
for(var y in q.answers[x]){
|
||||||
|
if(q.answers[x][y] == undefined){q.answers[x][y] = '';}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(q.verticalDisplay != 0){
|
||||||
|
verts = "<p>";
|
||||||
|
verte = "</p>";
|
||||||
|
}
|
||||||
|
|
||||||
|
html += "<hr>";
|
||||||
|
html += "<div class='question'>Q"+q.sequenceNumber+": "+q.questionText+"</div>";
|
||||||
|
|
||||||
|
if(multipleChoice[q.questionType]){
|
||||||
|
if(q.maxAnswers > 1){
|
||||||
|
html += "<div class='"+q.Survey_questionId+"qmessage'>Selections left: <span id='"+q.Survey_questionId+"max'>"+q.maxAnswers+"</span></div>";
|
||||||
|
}
|
||||||
|
var butts = new Array();
|
||||||
|
for(var x = 0; x < q.answers.length; x++){
|
||||||
|
var a = q.answers[x];
|
||||||
|
html += verts+"<span class=answer id="+a.Survey_answerId+"container></span>"+verte;
|
||||||
|
// html += verts+"<input type=checkbox id="+a.Survey_answerId+" name="+a.Survey_answerId+" value=1></input>"+verte;
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
var b = new YAHOO.widget.Button({ type: "checkbox", label: a.answerText, id: a.Survey_answerId, name: a.Survey_answerId, value: a.Survey_answerId,
|
||||||
|
container: a.Survey_answerId+"container", checked: false });
|
||||||
|
b.on("click", this.buttonChanged,[b,a.Survey_questionId,q.maxAnswers,butts]);
|
||||||
|
butts.push(b);
|
||||||
|
buttons.push(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(text[q.questionType]){
|
||||||
|
for(var x = 0; x < q.answers.length; x++){
|
||||||
|
var a = q.answers[x];
|
||||||
|
html += verts+"<span class=answer>";
|
||||||
|
|
||||||
|
if(q.questionType == 'Text'){
|
||||||
|
html += "<textarea name="+a.Survey_answerId+"></textarea>";
|
||||||
|
}else if(q.questionType == 'Email'){
|
||||||
|
html += "<input type=text name="+a.Survey_answerId+"></input>";
|
||||||
|
}else if(q.questionType == 'Phone Number'){
|
||||||
|
html += "<input type=text name="+a.Survey_answerId+"></input>";
|
||||||
|
}else if(q.questionType == 'Text Date'){
|
||||||
|
html += "<input type=text name="+a.Survey_answerId+"></input>";
|
||||||
|
}else if(q.questionType == 'Currency'){
|
||||||
|
html += "<input type=text name="+a.Survey_answerId+"></input>";
|
||||||
|
}
|
||||||
|
html += "</span>"+verte;
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(dateType[q.questionType]){
|
||||||
|
for(var x = 0; x < q.answers.length; x++){
|
||||||
|
var a = q.answers[x];
|
||||||
|
var calid = a.Survey_answerId+'container';
|
||||||
|
html += verts+"<span class=dateanswer>";
|
||||||
|
html += "<table><tr><td/><td>"+a.answerText+"</td><td/></tr>";
|
||||||
|
html += "<div id='"+calid+"'></div>";
|
||||||
|
html += "<input name='"+a.Survey_answerId+"' id='"+a.Survey_answerId+"' type=text></input>";
|
||||||
|
html += "<span id='"+a.Survey_answerId+"button'></span>";
|
||||||
|
html += "</span>"+verte;
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
var c = new YAHOO.widget.Calendar(calid,{title:'Choose a date:', close:true});
|
||||||
|
c.selectEvent.subscribe(this.selectCalendar,[c,a.Survey_answerId],true);
|
||||||
|
c.render();
|
||||||
|
c.hide();
|
||||||
|
var b = new YAHOO.widget.Button({ label:"Select Date", id:"pushbutton"+a.Survey_answerId, container:a.Survey_answerId+'button' });
|
||||||
|
b.on("click", this.showCalendar,[c]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(fileUpload[q.questionType]){
|
||||||
|
for(var x = 0; x < q.answers.length; x++){
|
||||||
|
var a = q.answers[x];
|
||||||
|
html += verts+"<span class=answer>";
|
||||||
|
html += "<input type='file' name='"+a.Survey_answerId+"' id='"+a.Survey_answerId+"' size='50'>";
|
||||||
|
html += "</span>"+verte;
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
files.push(a.Survey_answerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(slider[q.questionType]){
|
||||||
|
//First run through and put up the span placeholders and find the max value for an answer, to know how big the allocation points will be.
|
||||||
|
var max = 0;
|
||||||
|
if(q.questionType == 'Dual Slider - Range'){
|
||||||
|
var a1 = q.answers[0];
|
||||||
|
var a2 = q.answers[1];
|
||||||
|
html += "<input type=hidden id='"+a1.Survey_answerId+"' name='"+a1.Survey_answerId+"' value=0>";
|
||||||
|
html += "<input type=hidden id='"+a2.Survey_answerId+"' name='"+a2.Survey_answerId+"' value="+a1.max+">";
|
||||||
|
|
||||||
|
html += verts+"<span class=answer>";
|
||||||
|
html += "<p><table><tr><td>";
|
||||||
|
html += "<span id='"+a1.Survey_answerId+"show'>0</span>";
|
||||||
|
html += "</td><td></td><td>";
|
||||||
|
html += "<span id='"+a2.Survey_answerId+"show'>"+a2.max+"</span>";
|
||||||
|
html += "</td></tr>";
|
||||||
|
html += "<tr><td>0 </td><td>";
|
||||||
|
html += "<div id='"+q.Survey_questionId+"slider-bg' tabindex='-1' title='Slider' class=slider-bg>";
|
||||||
|
html += "<div id='"+a1.Survey_answerId+"slider-min-thumb' class=slider-min-thumb>\
|
||||||
|
<img src='/extras/wobject/Survey/thumb-n.gif'></div>\
|
||||||
|
<div id='"+a2.Survey_answerId+"slider-max-thumb' class=slider-max-thumb>\
|
||||||
|
<img src='/extras/wobject/Survey/thumb-n.gif'></div>";
|
||||||
|
|
||||||
|
html += " </div>\
|
||||||
|
</div>";
|
||||||
|
html += "<td>"+a1.max+"</td><td>";
|
||||||
|
html += "</table>";
|
||||||
|
|
||||||
|
html += "</span>"+verte;
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
new this.dualSliders(q);
|
||||||
|
}else{
|
||||||
|
for(var i in q.answers){
|
||||||
|
var a = q.answers[i];
|
||||||
|
html += verts+"<span class=answer>";
|
||||||
|
html += "<p><table><tr><td></td><td>";
|
||||||
|
html += a.answerText+" ";
|
||||||
|
html += "<span id='"+a.Survey_answerId+"show'>0</span>";
|
||||||
|
html += "<input type=hidden id='"+a.Survey_answerId+"' name='"+a.Survey_answerId+"'>";
|
||||||
|
html += "</td><td></td></tr>";
|
||||||
|
html += "<tr><td>0 </td><td>";
|
||||||
|
html += "<div id='"+a.Survey_answerId+"slider-bg' tabindex='-1' title='Slider' class=slider-bg>";
|
||||||
|
if(q.questionType == 'Dual Slider - Range'){
|
||||||
|
html += "<div id='"+a.Survey_answerId+"slider-min-thumb' class=slider-min-thumb>\
|
||||||
|
<img src='/extras/wobject/Survey/thumb-n.gif'>\
|
||||||
|
<div id='"+a.Survey_answerId+"slider-max-thumb' class=slider-max-thumb>\
|
||||||
|
<img src='/extras/wobject/Survey/thumb-n.gif'>";
|
||||||
|
|
||||||
|
}else{
|
||||||
|
html += "<div id='"+a.Survey_answerId+"slider-thumb' class=slider-thumb>\
|
||||||
|
<img src='/extras/wobject/Survey/thumb-n.gif'>";
|
||||||
|
}
|
||||||
|
html += " </div>\
|
||||||
|
</div>";
|
||||||
|
html += "<td>"+a.max+"</td><td>";
|
||||||
|
html += "</table>";
|
||||||
|
|
||||||
|
html += "</span>"+verte;
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
if(a.max - a.min > max){max = a.max - a.min;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(q.questionType == 'Multi Slider - Allocate'){
|
||||||
|
//sliderManagers[sliderManagers.length] = new this.sliderManager(q,max);
|
||||||
|
new this.sliderManager(q,max);
|
||||||
|
}
|
||||||
|
else if(q.questionType == 'Slider'){
|
||||||
|
new this.sliders(q);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(hidden[q.questionType]){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html += "<hr><input type=button id=submit value=submit></input>";
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
document.getElementById('footer').innerHTML = "<hr>You are |---| close to being done.";
|
||||||
|
// var submit = function() {alert(YAHOO.util.Connect.setForm('surveyForm'));}
|
||||||
|
YAHOO.util.Event.addListener("submit", "click", this.submit);
|
||||||
|
}
|
||||||
|
this.submit = function(){
|
||||||
|
var butts = new Array();
|
||||||
|
for(var i in buttons){
|
||||||
|
if(buttons[i].get('checked')){
|
||||||
|
butts.push([buttons[i].get('id'),buttons[i].get('value')]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(var i in files){
|
||||||
|
console.log(files[i]);
|
||||||
|
console.log(document.getElementById(files[i]).value);
|
||||||
|
}
|
||||||
|
Survey.Comm.callServer(s,'submitQuestions');
|
||||||
|
}
|
||||||
|
this.dualSliders = function(q){
|
||||||
|
var total = 200;
|
||||||
|
var sliders = new Array();
|
||||||
|
var a1 = q.answers[0];
|
||||||
|
var a2 = q.answers[1];
|
||||||
|
var scale = 200/a1.max;
|
||||||
|
console.log(scale);
|
||||||
|
|
||||||
|
var id = q.Survey_questionId;
|
||||||
|
var a1id = a1.Survey_answerId;
|
||||||
|
var a2id = a2.Survey_answerId;
|
||||||
|
|
||||||
|
var a1h = document.getElementById(a1id);
|
||||||
|
var a2h = document.getElementById(a2id);
|
||||||
|
var a1s = document.getElementById(a1id+'show');
|
||||||
|
var a2s = document.getElementById(a2id+'show');
|
||||||
|
var s = YAHOO.widget.Slider.getHorizDualSlider(id+'slider-bg',
|
||||||
|
a1id+"slider-min-thumb", a2id+"slider-max-thumb",
|
||||||
|
200, 1*scale, [1,200]);
|
||||||
|
|
||||||
|
s.minRange = 4;
|
||||||
|
var updateUI = function () {
|
||||||
|
var min = Math.round(s.minVal/scale),
|
||||||
|
max = Math.round(s.maxVal/scale);
|
||||||
|
a1h.value = min;
|
||||||
|
a1s.innerHTML = min;
|
||||||
|
a2h.value = max;
|
||||||
|
a2s.innerHTML = max;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Subscribe to the dual thumb slider's change and ready events to
|
||||||
|
// report the state.
|
||||||
|
// s.subscribe('ready', updateUI);
|
||||||
|
s.subscribe('change', updateUI);
|
||||||
|
}
|
||||||
|
this.sliders = function(q){
|
||||||
|
var total = 200;
|
||||||
|
var sliders = new Array();
|
||||||
|
for(var i in q.answers){
|
||||||
|
var a = q.answers[i];
|
||||||
|
var step = q.answers[i].step;
|
||||||
|
var scale = 200/q.answers[i].max;
|
||||||
|
var Event = YAHOO.util.Event;
|
||||||
|
var lang = YAHOO.lang;
|
||||||
|
var id = a.Survey_answerId+'slider-bg';
|
||||||
|
var s = YAHOO.widget.Slider.getHorizSlider(id, a.Survey_answerId+'slider-thumb',
|
||||||
|
0, 200, (scale*step));
|
||||||
|
s.max = a.max*scale;
|
||||||
|
s.input = a.Survey_answerId;
|
||||||
|
s.scale = scale;
|
||||||
|
var check = function() {
|
||||||
|
var t = document.getElementById(this.input);
|
||||||
|
var tshow = document.getElementById(this.input+'show');
|
||||||
|
t.value = this.getRealValue();
|
||||||
|
tshow.innerHTML = this.getRealValue();
|
||||||
|
};
|
||||||
|
s.getRealValue = function() {
|
||||||
|
return this.getValue() / this.scale;
|
||||||
|
}
|
||||||
|
s.subscribe("slideEnd", check);
|
||||||
|
s.subscribe("change", check);
|
||||||
|
sliders.push(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//an object which creates sliders for allocation type questions and then manages their events and keeps them from overallocating
|
||||||
|
this.sliderManager = function(q,t){
|
||||||
|
var total = 200;
|
||||||
|
var step = q.answers[0].step;
|
||||||
|
var scale = 200/q.answers[0].max;
|
||||||
|
var sliders = new Array();
|
||||||
|
|
||||||
|
for(var i in q.answers){
|
||||||
|
var a = q.answers[i];
|
||||||
|
var Event = YAHOO.util.Event;
|
||||||
|
var lang = YAHOO.lang;
|
||||||
|
var id = a.Survey_answerId+'slider-bg';
|
||||||
|
var s = YAHOO.widget.Slider.getHorizSlider(id, a.Survey_answerId+'slider-thumb',
|
||||||
|
0, 200, scale*step);
|
||||||
|
s.input = a.Survey_answerId;
|
||||||
|
s.lastValue = 0;
|
||||||
|
//console.log(s);
|
||||||
|
var check = function() {
|
||||||
|
var t = 0;
|
||||||
|
for(var x in sliders){
|
||||||
|
t+= sliders[x].getValue();
|
||||||
|
}
|
||||||
|
if(t > total){
|
||||||
|
this.setValue(this.lastValue);
|
||||||
|
}else{
|
||||||
|
this.lastValue = this.getValue();
|
||||||
|
// alert("Setting "+this.input+" to "+this.getRealValue());
|
||||||
|
document.getElementById(this.input).value = this.getRealValue();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
s.subscribe("slideEnd", check);
|
||||||
|
s.subscribe("change", check);
|
||||||
|
var manualEntry = function(e){
|
||||||
|
// set the value when the 'return' key is detected
|
||||||
|
if (Event.getCharCode(e) === 13 || e.type == 'blur') {
|
||||||
|
var v = parseFloat(this.value, 10);
|
||||||
|
v = (lang.isNumber(v)) ? v : 0;
|
||||||
|
v *= scale;
|
||||||
|
|
||||||
|
// convert the real value into a pixel offset
|
||||||
|
for(var sl in sliders){
|
||||||
|
if(sliders[sl].input == this.id){
|
||||||
|
sliders[sl].setValue(Math.round(v));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event.on(document.getElementById(s.input), "keydown", manualEntry);
|
||||||
|
Event.on(document.getElementById(s.input), "blur", manualEntry);
|
||||||
|
|
||||||
|
s.getRealValue = function() {
|
||||||
|
return Math.round(this.getValue() / scale);
|
||||||
|
}
|
||||||
|
sliders.push(s);
|
||||||
|
document.getElementById(s.input).value = s.getRealValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selectCalendar = function(event,args,obj){
|
||||||
|
var id = obj[1];
|
||||||
|
var selected = args[0];
|
||||||
|
var date = selected[0];
|
||||||
|
var year = date[0], month = date[1], day = date[2];
|
||||||
|
var input = document.getElementById(id);
|
||||||
|
input.value = month + "/" + day + "/" + year;
|
||||||
|
obj[0].hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.showCalendar = function(event,objs){
|
||||||
|
//console.log('showing '+objs[0].id);
|
||||||
|
objs[0].show();
|
||||||
|
}
|
||||||
|
this.buttonChanged = function(event,objs){
|
||||||
|
var b = objs[0];
|
||||||
|
var qid = objs[1];
|
||||||
|
var maxA = objs[2];
|
||||||
|
var butts = objs[3];
|
||||||
|
max = parseInt(max);
|
||||||
|
if(maxA == 1){
|
||||||
|
for(var i in butts){
|
||||||
|
butts[i].set('checked',false);
|
||||||
|
}
|
||||||
|
b.set('checked',true);
|
||||||
|
}
|
||||||
|
else if(b.get('checked')){
|
||||||
|
var max = parseInt(document.getElementById(qid+'max').innerHTML);
|
||||||
|
if(max == 0){
|
||||||
|
b.set('checked',false);
|
||||||
|
//warn that options used up
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
document.getElementById(qid+'max').innerHTML = parseInt(max-1);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
var max = parseInt(document.getElementById(qid+'max').innerHTML);
|
||||||
|
document.getElementById(qid+'max').innerHTML = parseInt(max+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Initialize survey
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
Survey.OnLoad = new function() {
|
||||||
|
var e = YAHOO.util.Event;
|
||||||
|
this.init = function() {
|
||||||
|
e.onDOMReady(this.initHandler);
|
||||||
|
}
|
||||||
|
this.initHandler = function(){
|
||||||
|
Survey.Comm.setUrl('/'+document.getElementById('assetPath').value);
|
||||||
|
Survey.Comm.callServer('','loadQuestions');
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
Survey.OnLoad.init();
|
||||||
408
www/extras/wobject/Survey/administersurvey.js.backup1
Normal file
408
www/extras/wobject/Survey/administersurvey.js.backup1
Normal file
|
|
@ -0,0 +1,408 @@
|
||||||
|
if (typeof Survey == "undefined") {
|
||||||
|
var Survey = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Survey.Form = new function() {
|
||||||
|
|
||||||
|
var sliders;
|
||||||
|
var dSliders;
|
||||||
|
var texts;
|
||||||
|
var buttons;
|
||||||
|
var cals;
|
||||||
|
var files;
|
||||||
|
|
||||||
|
var multipleChoice = {'Multiple Choice':1,'Gender':1,'Yes/No':1,'True/False':1,'Agree/Disagree':1,'Oppose/Support':1,'Importance':1,
|
||||||
|
'Likelihood':1,'Certainty':1,'Satisfaction':1,'Confidence':1,'Effectiveness':1,'Concern':1,'Risk':1,'Threat':1,'Security':1,'Ideology':1,
|
||||||
|
'Race':1,'Party':1,'Education':1};
|
||||||
|
var text = {'Text':1, 'Email':1, 'Phone Number':1, 'Text Date':1, 'Currency':1};
|
||||||
|
var slider = {'Slider':1, 'Dual Slider - Range':1, 'Multi Slider - Allocate':1};
|
||||||
|
var dateType = {'Date':1,'Date Range':1};
|
||||||
|
var fileUpload = {'File Upload':1};
|
||||||
|
var hidden = {'Hidden':1};
|
||||||
|
|
||||||
|
this.displayQuestions = function(params){
|
||||||
|
sliders = new Array();
|
||||||
|
dSliders = new Array();
|
||||||
|
texts = new Array();
|
||||||
|
buttons = new Array();
|
||||||
|
cals = new Array();
|
||||||
|
files = new Array();
|
||||||
|
|
||||||
|
var section = params.section;
|
||||||
|
var questions = params.questions;
|
||||||
|
document.getElementById('headertitle').innerHTML = "Section: "+section.sequenceNumber+" "+section.sectionName + "<hr>";
|
||||||
|
|
||||||
|
if(section.questionsOnSectionPage){
|
||||||
|
document.getElementById('headertext').innerHTML = section.sectionText;
|
||||||
|
}
|
||||||
|
|
||||||
|
var qs = params.questions;
|
||||||
|
var s = params.survey;
|
||||||
|
var html = "";
|
||||||
|
|
||||||
|
// html = '<form id=surveyForm>';
|
||||||
|
document.getElementById('survey').innerHTML = html;html = '';
|
||||||
|
for(var i = 0; i < qs.length; i++){
|
||||||
|
var q = qs[i];
|
||||||
|
var verts = '';
|
||||||
|
var verte = '';
|
||||||
|
for(var x in q.answers){
|
||||||
|
for(var y in q.answers[x]){
|
||||||
|
if(q.answers[x][y] == undefined){q.answers[x][y] = '';}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(q.verticalDisplay != 0){
|
||||||
|
verts = "<p>";
|
||||||
|
verte = "</p>";
|
||||||
|
}
|
||||||
|
|
||||||
|
html += "<hr>";
|
||||||
|
html += "<div class='question'>Q"+q.sequenceNumber+": "+q.questionText+"</div>";
|
||||||
|
|
||||||
|
if(multipleChoice[q.questionType]){
|
||||||
|
if(q.maxAnswers > 1){
|
||||||
|
html += "<div class='"+q.Survey_questionId+"qmessage'>Selections left: <span id='"+q.Survey_questionId+"max'>"+q.maxAnswers+"</span></div>";
|
||||||
|
}
|
||||||
|
var butts = new Array();
|
||||||
|
for(var x = 0; x < q.answers.length; x++){
|
||||||
|
var a = q.answers[x];
|
||||||
|
html += verts+"<span class=answer id="+a.Survey_answerId+"container></span>"+verte;
|
||||||
|
// html += verts+"<input type=checkbox id="+a.Survey_answerId+" name="+a.Survey_answerId+" value=1></input>"+verte;
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
var b = new YAHOO.widget.Button({ type: "checkbox", label: a.answerText, id: a.Survey_answerId, name: a.Survey_answerId, value: a.Survey_answerId,
|
||||||
|
container: a.Survey_answerId+"container", checked: false });
|
||||||
|
b.on("click", this.buttonChanged,[b,a.Survey_questionId,q.maxAnswers,butts]);
|
||||||
|
butts.push(b);
|
||||||
|
buttons.push(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(text[q.questionType]){
|
||||||
|
for(var x = 0; x < q.answers.length; x++){
|
||||||
|
var a = q.answers[x];
|
||||||
|
html += verts+"<span class=answer>";
|
||||||
|
|
||||||
|
if(q.questionType == 'Text'){
|
||||||
|
html += "<textarea name="+a.Survey_answerId+"></textarea>";
|
||||||
|
}else if(q.questionType == 'Email'){
|
||||||
|
html += "<input type=text name="+a.Survey_answerId+"></input>";
|
||||||
|
}else if(q.questionType == 'Phone Number'){
|
||||||
|
html += "<input type=text name="+a.Survey_answerId+"></input>";
|
||||||
|
}else if(q.questionType == 'Text Date'){
|
||||||
|
html += "<input type=text name="+a.Survey_answerId+"></input>";
|
||||||
|
}else if(q.questionType == 'Currency'){
|
||||||
|
html += "<input type=text name="+a.Survey_answerId+"></input>";
|
||||||
|
}
|
||||||
|
html += "</span>"+verte;
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(dateType[q.questionType]){
|
||||||
|
for(var x = 0; x < q.answers.length; x++){
|
||||||
|
var a = q.answers[x];
|
||||||
|
var calid = a.Survey_answerId+'container';
|
||||||
|
html += verts+"<span class=dateanswer>";
|
||||||
|
html += "<table><tr><td/><td>"+a.answerText+"</td><td/></tr>";
|
||||||
|
html += "<div id='"+calid+"'></div>";
|
||||||
|
html += "<input name='"+a.Survey_answerId+"' id='"+a.Survey_answerId+"' type=text></input>";
|
||||||
|
html += "<span id='"+a.Survey_answerId+"button'></span>";
|
||||||
|
html += "</span>"+verte;
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
var c = new YAHOO.widget.Calendar(calid,{title:'Choose a date:', close:true});
|
||||||
|
c.selectEvent.subscribe(this.selectCalendar,[c,a.Survey_answerId],true);
|
||||||
|
c.render();
|
||||||
|
c.hide();
|
||||||
|
var b = new YAHOO.widget.Button({ label:"Select Date", id:"pushbutton"+a.Survey_answerId, container:a.Survey_answerId+'button' });
|
||||||
|
b.on("click", this.showCalendar,[c]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(fileUpload[q.questionType]){
|
||||||
|
for(var x = 0; x < q.answers.length; x++){
|
||||||
|
var a = q.answers[x];
|
||||||
|
html += verts+"<span class=answer>";
|
||||||
|
html += "<input type='file' name='"+a.Survey_answerId+"' id='"+a.Survey_answerId+"' size='50' />";
|
||||||
|
html += "</span>"+verte;
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
files.push(a.Survey_answerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(slider[q.questionType]){
|
||||||
|
//First run through and put up the span placeholders and find the max value for an answer, to know how big the allocation points will be.
|
||||||
|
var max = 0;
|
||||||
|
if(q.questionType == 'Dual Slider - Range'){
|
||||||
|
var a1 = q.answers[0];
|
||||||
|
var a2 = q.answers[1];
|
||||||
|
html += "<input type=hidden id='"+a1.Survey_answerId+"' name='"+a1.Survey_answerId+"' value=0>";
|
||||||
|
html += "<input type=hidden id='"+a2.Survey_answerId+"' name='"+a2.Survey_answerId+"' value="+a1.max+">";
|
||||||
|
|
||||||
|
html += verts+"<span class=answer>";
|
||||||
|
html += "<p><table><tr><td>";
|
||||||
|
html += "<span id='"+a1.Survey_answerId+"show'>0</span>";
|
||||||
|
html += "</td><td></td><td>";
|
||||||
|
html += "<span id='"+a2.Survey_answerId+"show'>"+a2.max+"</span>";
|
||||||
|
html += "</td></tr>";
|
||||||
|
html += "<tr><td>0 </td><td>";
|
||||||
|
html += "<div id='"+q.Survey_questionId+"slider-bg' tabindex='-1' title='Slider' class=slider-bg>";
|
||||||
|
html += "<div id='"+a1.Survey_answerId+"slider-min-thumb' class=slider-min-thumb>\
|
||||||
|
<img src='/extras/wobject/Survey/thumb-n.gif'></div>\
|
||||||
|
<div id='"+a2.Survey_answerId+"slider-max-thumb' class=slider-max-thumb>\
|
||||||
|
<img src='/extras/wobject/Survey/thumb-n.gif'></div>";
|
||||||
|
|
||||||
|
html += " </div>\
|
||||||
|
</div>";
|
||||||
|
html += "<td>"+a1.max+"</td><td>";
|
||||||
|
html += "</table>";
|
||||||
|
|
||||||
|
html += "</span>"+verte;
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
new this.dualSliders(q);
|
||||||
|
}else{
|
||||||
|
for(var i in q.answers){
|
||||||
|
var a = q.answers[i];
|
||||||
|
html += verts+"<span class=answer>";
|
||||||
|
html += "<p><table><tr><td></td><td>";
|
||||||
|
html += a.answerText+" ";
|
||||||
|
html += "<span id='"+a.Survey_answerId+"show'>0</span>";
|
||||||
|
html += "<input type=hidden id='"+a.Survey_answerId+"' name='"+a.Survey_answerId+"'>";
|
||||||
|
html += "</td><td></td></tr>";
|
||||||
|
html += "<tr><td>0 </td><td>";
|
||||||
|
html += "<div id='"+a.Survey_answerId+"slider-bg' tabindex='-1' title='Slider' class=slider-bg>";
|
||||||
|
if(q.questionType == 'Dual Slider - Range'){
|
||||||
|
html += "<div id='"+a.Survey_answerId+"slider-min-thumb' class=slider-min-thumb>\
|
||||||
|
<img src='/extras/wobject/Survey/thumb-n.gif'>\
|
||||||
|
<div id='"+a.Survey_answerId+"slider-max-thumb' class=slider-max-thumb>\
|
||||||
|
<img src='/extras/wobject/Survey/thumb-n.gif'>";
|
||||||
|
|
||||||
|
}else{
|
||||||
|
html += "<div id='"+a.Survey_answerId+"slider-thumb' class=slider-thumb>\
|
||||||
|
<img src='/extras/wobject/Survey/thumb-n.gif'>";
|
||||||
|
}
|
||||||
|
html += " </div>\
|
||||||
|
</div>";
|
||||||
|
html += "<td>"+a.max+"</td><td>";
|
||||||
|
html += "</table>";
|
||||||
|
|
||||||
|
html += "</span>"+verte;
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
if(a.max - a.min > max){max = a.max - a.min;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(q.questionType == 'Multi Slider - Allocate'){
|
||||||
|
//sliderManagers[sliderManagers.length] = new this.sliderManager(q,max);
|
||||||
|
new this.sliderManager(q,max);
|
||||||
|
}
|
||||||
|
else if(q.questionType == 'Slider'){
|
||||||
|
new this.sliders(q);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(hidden[q.questionType]){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html += "<hr><input type=button id=submit value=submit></input>";
|
||||||
|
document.getElementById('survey').innerHTML += html;html = '';
|
||||||
|
document.getElementById('footer').innerHTML = "<hr>You are |---| close to being done.";
|
||||||
|
YAHOO.util.Event.addListener("submit", "click", this.submit);
|
||||||
|
YAHOO.util.Event.addListener("testSubmit", "click", this.tsubmit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.tsubmit = function(){
|
||||||
|
// console.log(YAHOO.util.Connect.setForm('surveyForm',1));
|
||||||
|
var t = document.getElementById('surveyTest');
|
||||||
|
// Survey.Comm.callServer('','submitQuestions',document.getElementById('surveyTest'));
|
||||||
|
Survey.Comm.callServer('','submitQuestions','surveyTest');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.submit = function(){
|
||||||
|
// console.log(YAHOO.util.Connect.setForm('surveyForm',1));
|
||||||
|
Survey.Comm.callServer('','submitQuestions','surveyForm');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.dualSliders = function(q){
|
||||||
|
var total = 200;
|
||||||
|
var sliders = new Array();
|
||||||
|
var a1 = q.answers[0];
|
||||||
|
var a2 = q.answers[1];
|
||||||
|
var scale = 200/a1.max;
|
||||||
|
//console.log(scale);
|
||||||
|
|
||||||
|
var id = q.Survey_questionId;
|
||||||
|
var a1id = a1.Survey_answerId;
|
||||||
|
var a2id = a2.Survey_answerId;
|
||||||
|
|
||||||
|
var a1h = document.getElementById(a1id);
|
||||||
|
var a2h = document.getElementById(a2id);
|
||||||
|
var a1s = document.getElementById(a1id+'show');
|
||||||
|
var a2s = document.getElementById(a2id+'show');
|
||||||
|
var s = YAHOO.widget.Slider.getHorizDualSlider(id+'slider-bg',
|
||||||
|
a1id+"slider-min-thumb", a2id+"slider-max-thumb",
|
||||||
|
200, 1*scale, [1,200]);
|
||||||
|
|
||||||
|
s.minRange = 4;
|
||||||
|
var updateUI = function () {
|
||||||
|
var min = Math.round(s.minVal/scale),
|
||||||
|
max = Math.round(s.maxVal/scale);
|
||||||
|
a1h.value = min;
|
||||||
|
a1s.innerHTML = min;
|
||||||
|
a2h.value = max;
|
||||||
|
a2s.innerHTML = max;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Subscribe to the dual thumb slider's change and ready events to
|
||||||
|
// report the state.
|
||||||
|
// s.subscribe('ready', updateUI);
|
||||||
|
s.subscribe('change', updateUI);
|
||||||
|
}
|
||||||
|
this.sliders = function(q){
|
||||||
|
var total = 200;
|
||||||
|
var sliders = new Array();
|
||||||
|
for(var i in q.answers){
|
||||||
|
var a = q.answers[i];
|
||||||
|
var step = q.answers[i].step;
|
||||||
|
var scale = 200/q.answers[i].max;
|
||||||
|
var Event = YAHOO.util.Event;
|
||||||
|
var lang = YAHOO.lang;
|
||||||
|
var id = a.Survey_answerId+'slider-bg';
|
||||||
|
var s = YAHOO.widget.Slider.getHorizSlider(id, a.Survey_answerId+'slider-thumb',
|
||||||
|
0, 200, (scale*step));
|
||||||
|
s.max = a.max*scale;
|
||||||
|
s.input = a.Survey_answerId;
|
||||||
|
s.scale = scale;
|
||||||
|
var check = function() {
|
||||||
|
var t = document.getElementById(this.input);
|
||||||
|
var tshow = document.getElementById(this.input+'show');
|
||||||
|
t.value = this.getRealValue();
|
||||||
|
tshow.innerHTML = this.getRealValue();
|
||||||
|
};
|
||||||
|
s.getRealValue = function() {
|
||||||
|
return this.getValue() / this.scale;
|
||||||
|
}
|
||||||
|
s.subscribe("slideEnd", check);
|
||||||
|
s.subscribe("change", check);
|
||||||
|
sliders.push(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//an object which creates sliders for allocation type questions and then manages their events and keeps them from overallocating
|
||||||
|
this.sliderManager = function(q,t){
|
||||||
|
var total = 200;
|
||||||
|
var step = q.answers[0].step;
|
||||||
|
var scale = 200/q.answers[0].max;
|
||||||
|
var sliders = new Array();
|
||||||
|
|
||||||
|
for(var i in q.answers){
|
||||||
|
var a = q.answers[i];
|
||||||
|
var Event = YAHOO.util.Event;
|
||||||
|
var lang = YAHOO.lang;
|
||||||
|
var id = a.Survey_answerId+'slider-bg';
|
||||||
|
var s = YAHOO.widget.Slider.getHorizSlider(id, a.Survey_answerId+'slider-thumb',
|
||||||
|
0, 200, scale*step);
|
||||||
|
s.input = a.Survey_answerId;
|
||||||
|
s.lastValue = 0;
|
||||||
|
//console.log(s);
|
||||||
|
var check = function() {
|
||||||
|
var t = 0;
|
||||||
|
for(var x in sliders){
|
||||||
|
t+= sliders[x].getValue();
|
||||||
|
}
|
||||||
|
if(t > total){
|
||||||
|
this.setValue(this.lastValue);
|
||||||
|
}else{
|
||||||
|
this.lastValue = this.getValue();
|
||||||
|
// alert("Setting "+this.input+" to "+this.getRealValue());
|
||||||
|
document.getElementById(this.input).value = this.getRealValue();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
s.subscribe("slideEnd", check);
|
||||||
|
s.subscribe("change", check);
|
||||||
|
var manualEntry = function(e){
|
||||||
|
// set the value when the 'return' key is detected
|
||||||
|
if (Event.getCharCode(e) === 13 || e.type == 'blur') {
|
||||||
|
var v = parseFloat(this.value, 10);
|
||||||
|
v = (lang.isNumber(v)) ? v : 0;
|
||||||
|
v *= scale;
|
||||||
|
|
||||||
|
// convert the real value into a pixel offset
|
||||||
|
for(var sl in sliders){
|
||||||
|
if(sliders[sl].input == this.id){
|
||||||
|
sliders[sl].setValue(Math.round(v));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event.on(document.getElementById(s.input), "keydown", manualEntry);
|
||||||
|
Event.on(document.getElementById(s.input), "blur", manualEntry);
|
||||||
|
|
||||||
|
s.getRealValue = function() {
|
||||||
|
return Math.round(this.getValue() / scale);
|
||||||
|
}
|
||||||
|
sliders.push(s);
|
||||||
|
document.getElementById(s.input).value = s.getRealValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selectCalendar = function(event,args,obj){
|
||||||
|
var id = obj[1];
|
||||||
|
var selected = args[0];
|
||||||
|
var date = selected[0];
|
||||||
|
var year = date[0], month = date[1], day = date[2];
|
||||||
|
var input = document.getElementById(id);
|
||||||
|
input.value = month + "/" + day + "/" + year;
|
||||||
|
obj[0].hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.showCalendar = function(event,objs){
|
||||||
|
//console.log('showing '+objs[0].id);
|
||||||
|
objs[0].show();
|
||||||
|
}
|
||||||
|
this.buttonChanged = function(event,objs){
|
||||||
|
var b = objs[0];
|
||||||
|
var qid = objs[1];
|
||||||
|
var maxA = objs[2];
|
||||||
|
var butts = objs[3];
|
||||||
|
max = parseInt(max);
|
||||||
|
if(maxA == 1){
|
||||||
|
for(var i in butts){
|
||||||
|
butts[i].set('checked',false);
|
||||||
|
}
|
||||||
|
b.set('checked',true);
|
||||||
|
}
|
||||||
|
else if(b.get('checked')){
|
||||||
|
var max = parseInt(document.getElementById(qid+'max').innerHTML);
|
||||||
|
if(max == 0){
|
||||||
|
b.set('checked',false);
|
||||||
|
//warn that options used up
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
document.getElementById(qid+'max').innerHTML = parseInt(max-1);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
var max = parseInt(document.getElementById(qid+'max').innerHTML);
|
||||||
|
document.getElementById(qid+'max').innerHTML = parseInt(max+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Initialize survey
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
Survey.OnLoad = new function() {
|
||||||
|
var e = YAHOO.util.Event;
|
||||||
|
this.init = function() {
|
||||||
|
e.onDOMReady(this.initHandler);
|
||||||
|
}
|
||||||
|
this.initHandler = function(){
|
||||||
|
Survey.Comm.setUrl('/'+document.getElementById('assetPath').value);
|
||||||
|
Survey.Comm.callServer('','loadQuestions');
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
Survey.OnLoad.init();
|
||||||
64
www/extras/wobject/Survey/administersurvey/comm.js
Normal file
64
www/extras/wobject/Survey/administersurvey/comm.js
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
if (typeof Survey == "undefined") {
|
||||||
|
var Survey = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Survey.Comm= new function(){
|
||||||
|
|
||||||
|
|
||||||
|
this.url = '';
|
||||||
|
this.setUrl = function(u){this.url = u;}
|
||||||
|
|
||||||
|
var request = function(sUrl,callback,postData,form, hasFile){
|
||||||
|
if(form != undefined){
|
||||||
|
if(hasFile){
|
||||||
|
YAHOO.util.Connect.setForm(form,true);
|
||||||
|
//console.log('set file was true');
|
||||||
|
}else{
|
||||||
|
//console.log('set file was false');
|
||||||
|
YAHOO.util.Connect.setForm(form);
|
||||||
|
}
|
||||||
|
//console.log('setForm was true');
|
||||||
|
}
|
||||||
|
YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.callback = {
|
||||||
|
upload:function(o){
|
||||||
|
Survey.Comm.callServer('','loadQuestions');
|
||||||
|
},
|
||||||
|
success:function(o){
|
||||||
|
var response = '';
|
||||||
|
response = YAHOO.lang.JSON.parse(o.responseText);
|
||||||
|
if(response.type == 'displayquestions'){
|
||||||
|
Survey.Form.displayQuestions(response);
|
||||||
|
}else if(response.type == 'forward'){
|
||||||
|
//console.log("going to "+response.url);
|
||||||
|
location.href=response.url;
|
||||||
|
}else{
|
||||||
|
alert("bad response");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
failure: function(o){
|
||||||
|
if(o.status == -1){
|
||||||
|
alert("Last request timed out, please try again");
|
||||||
|
}else{
|
||||||
|
alert("Last request failed "+o.statusText);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
timeout: 15000
|
||||||
|
};
|
||||||
|
|
||||||
|
this.callServer = function(data,functionName,form,hasFile){
|
||||||
|
var postData;
|
||||||
|
if(form == undefined){
|
||||||
|
postData = "data="+YAHOO.lang.JSON.stringify(data,data);
|
||||||
|
//console.log(postData);
|
||||||
|
}
|
||||||
|
var sUrl = this.url + "?func="+functionName;
|
||||||
|
request(sUrl,this.callback,postData,form,hasFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}();
|
||||||
BIN
www/extras/wobject/Survey/bg-fader.gif
Normal file
BIN
www/extras/wobject/Survey/bg-fader.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 433 B |
125
www/extras/wobject/Survey/dd.js
Normal file
125
www/extras/wobject/Survey/dd.js
Normal file
|
|
@ -0,0 +1,125 @@
|
||||||
|
if (typeof Survey == "undefined") {
|
||||||
|
var Survey = {};
|
||||||
|
}
|
||||||
|
var Dom = YAHOO.util.Dom;
|
||||||
|
var Event = YAHOO.util.Event;
|
||||||
|
var DDM = YAHOO.util.DragDropMgr;
|
||||||
|
|
||||||
|
Survey.DDList = function(id, sGroup, config) {
|
||||||
|
|
||||||
|
Survey.DDList.superclass.constructor.call(this, id, sGroup, config);
|
||||||
|
|
||||||
|
this.logger = this.logger || YAHOO;
|
||||||
|
var el = this.getDragEl();
|
||||||
|
Dom.setStyle(el, "opacity", 0.67); // The proxy is slightly transparent
|
||||||
|
|
||||||
|
this.goingUp = false;
|
||||||
|
this.lastY = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
YAHOO.extend(Survey.DDList, YAHOO.util.DDProxy, {
|
||||||
|
|
||||||
|
startDrag: function(x, y) {
|
||||||
|
this.logger.log(this.id + " startDrag");
|
||||||
|
|
||||||
|
// make the proxy look like the source element
|
||||||
|
var dragEl = this.getDragEl();
|
||||||
|
var clickEl = this.getEl();
|
||||||
|
Dom.setStyle(clickEl, "visibility", "hidden");
|
||||||
|
|
||||||
|
dragEl.innerHTML = clickEl.innerHTML;
|
||||||
|
|
||||||
|
Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
|
||||||
|
Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor"));
|
||||||
|
Dom.setStyle(dragEl, "border", "2px solid gray");
|
||||||
|
},
|
||||||
|
|
||||||
|
endDrag: function(e) {
|
||||||
|
|
||||||
|
var srcEl = this.getEl();
|
||||||
|
var proxy = this.getDragEl();
|
||||||
|
|
||||||
|
// Show the proxy element and animate it to the src element's location
|
||||||
|
Dom.setStyle(proxy, "visibility", "");
|
||||||
|
var a = new YAHOO.util.Motion(
|
||||||
|
proxy, {
|
||||||
|
points: {
|
||||||
|
to: Dom.getXY(srcEl)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
0.2,
|
||||||
|
YAHOO.util.Easing.easeOut
|
||||||
|
)
|
||||||
|
var proxyid = proxy.id;
|
||||||
|
var thisid = this.id;
|
||||||
|
|
||||||
|
// Hide the proxy and show the source element when finished with the animation
|
||||||
|
a.onComplete.subscribe(function() {
|
||||||
|
Dom.setStyle(proxyid, "visibility", "hidden");
|
||||||
|
Dom.setStyle(thisid, "visibility", "");
|
||||||
|
});
|
||||||
|
a.animate();
|
||||||
|
},
|
||||||
|
|
||||||
|
onDragDrop: function(e, id) {
|
||||||
|
|
||||||
|
// If there is one drop interaction, the li was dropped either on the list,
|
||||||
|
// or it was dropped on the current location of the source element.
|
||||||
|
if (DDM.interactionInfo.drop.length === 1) {
|
||||||
|
|
||||||
|
// The position of the cursor at the time of the drop (YAHOO.util.Point)
|
||||||
|
var pt = DDM.interactionInfo.point;
|
||||||
|
|
||||||
|
// The region occupied by the source element at the time of the drop
|
||||||
|
var region = DDM.interactionInfo.sourceRegion;
|
||||||
|
|
||||||
|
// Check to see if we are over the source element's location. We will
|
||||||
|
// append to the bottom of the list once we are sure it was a drop in
|
||||||
|
// the negative space (the area of the list without any list items)
|
||||||
|
if (!region.intersect(pt)) {
|
||||||
|
var destEl = Dom.get(id);
|
||||||
|
var destDD = DDM.getDDById(id);
|
||||||
|
destEl.appendChild(this.getEl());
|
||||||
|
destDD.isEmpty = false;
|
||||||
|
DDM.refreshCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Survey.Data.dragDrop(this.getEl());
|
||||||
|
},
|
||||||
|
|
||||||
|
onDrag: function(e) {
|
||||||
|
|
||||||
|
// Keep track of the direction of the drag for use during onDragOver
|
||||||
|
var y = Event.getPageY(e);
|
||||||
|
|
||||||
|
if (y < this.lastY) {
|
||||||
|
this.goingUp = true;
|
||||||
|
} else if (y > this.lastY) {
|
||||||
|
this.goingUp = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lastY = y;
|
||||||
|
},
|
||||||
|
|
||||||
|
onDragOver: function(e, id) {
|
||||||
|
|
||||||
|
var srcEl = this.getEl();
|
||||||
|
var destEl = Dom.get(id);
|
||||||
|
|
||||||
|
// We are only concerned with list items, we ignore the dragover
|
||||||
|
// notifications for the list.
|
||||||
|
if (destEl.nodeName.toLowerCase() == "li") {
|
||||||
|
var orig_p = srcEl.parentNode;
|
||||||
|
var p = destEl.parentNode;
|
||||||
|
|
||||||
|
if (this.goingUp) {
|
||||||
|
p.insertBefore(srcEl, destEl); // insert above
|
||||||
|
} else {
|
||||||
|
p.insertBefore(srcEl, destEl.nextSibling); // insert below
|
||||||
|
}
|
||||||
|
|
||||||
|
DDM.refreshCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
232
www/extras/wobject/Survey/editsurvey.js
Normal file
232
www/extras/wobject/Survey/editsurvey.js
Normal file
|
|
@ -0,0 +1,232 @@
|
||||||
|
if (typeof Survey == "undefined") {
|
||||||
|
var Survey = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Survey.Data = new function(){
|
||||||
|
var lastDataSet = {};
|
||||||
|
var focus;
|
||||||
|
|
||||||
|
|
||||||
|
this.dragDrop = function(did){
|
||||||
|
var type;
|
||||||
|
|
||||||
|
if(did.className.match("section")){type = 'section';}
|
||||||
|
else if(did.className.match("question")){type = 'question';}
|
||||||
|
else{ type = 'answer';}
|
||||||
|
|
||||||
|
var first = {id:did.id,type:type};
|
||||||
|
var before = document.getElementById(did.id).previousSibling;
|
||||||
|
|
||||||
|
while(1){
|
||||||
|
if( before == undefined || (before.id != undefined && before.id != '') ){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var before = before.previousSibling;
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = {id:'',type:''};
|
||||||
|
|
||||||
|
if(before != undefined && before.id != undefined && before.id != ''){
|
||||||
|
if(before.className.match("section")){type = 'section';}
|
||||||
|
else if(before.className.match("question")){type = 'question';}
|
||||||
|
else{ type = 'answer';}
|
||||||
|
data = {id:before.id,type:type};
|
||||||
|
}
|
||||||
|
|
||||||
|
Survey.Comm.dragDrop(first,data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.clicked = function(){
|
||||||
|
Survey.Comm.loadSurvey(this.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.loadData = function(d){
|
||||||
|
focus = d.focus;//What is the current highlighted item.
|
||||||
|
var lastType = '';//What was the last type created.
|
||||||
|
var lastId = {'section': '', 'question': '', 'answer': ''};//what is the last id of each type placed, so we know a child's parent.
|
||||||
|
var buttons = {'question':0,'answer':0,'section':0}; //array of bools on if buttons put down
|
||||||
|
document.getElementById('sections').innerHTML='';
|
||||||
|
var scount = 1;
|
||||||
|
var qcount = 1;
|
||||||
|
var acount = 1;
|
||||||
|
for(var x in d.data){
|
||||||
|
//Now check to see if this is where an add button goes.
|
||||||
|
//Add addAnswer when we go from answer to question or section or end
|
||||||
|
//Add addQuestion when we go from question to section or end
|
||||||
|
|
||||||
|
if(lastType == 'answer' && d.data[x].type == 'question'){
|
||||||
|
this.addAnswerButton(lastId['section'],lastId['question']);
|
||||||
|
buttons['answer'] = 1;
|
||||||
|
acount = 1;
|
||||||
|
}
|
||||||
|
else if(lastType == 'answer' && d.data[x].type == 'section'){
|
||||||
|
this.addAnswerButton(lastId['section'],lastId['question']);
|
||||||
|
buttons['answer'] = 1;
|
||||||
|
this.addQuestionButton(lastId['section']);
|
||||||
|
buttons['question'] = 1;
|
||||||
|
acount = 1;
|
||||||
|
qcount = 1;
|
||||||
|
}
|
||||||
|
else if(lastType == 'question' && d.data[x].type == 'section'){
|
||||||
|
if(!buttons['answer']){
|
||||||
|
this.addAnswerButton(lastId['section'],lastId['question']);
|
||||||
|
buttons['answer']=1;
|
||||||
|
}
|
||||||
|
this.addQuestionButton(lastId['section']);
|
||||||
|
buttons['question'] = 1;
|
||||||
|
acount = 1;
|
||||||
|
qcount = 1;
|
||||||
|
}
|
||||||
|
else if(d.data[x].type == 'section' && lastType == 'section' && lastId['section'] == focus){
|
||||||
|
this.addQuestionButton(lastId['section']);
|
||||||
|
buttons['question'] = 1;
|
||||||
|
acount = 1;
|
||||||
|
qcount = 1;
|
||||||
|
}
|
||||||
|
else if(d.data[x].type != 'answer' && lastType == 'question' && lastId['section'] + '||||'+ lastId['question'] == focus){
|
||||||
|
this.addAnswerButton(lastId['section'],lastId['question']);
|
||||||
|
buttons['answer']=1;
|
||||||
|
acount = 1;
|
||||||
|
qcount = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var node = document.createElement('li');
|
||||||
|
if(focus != undefined && focus.indexOf(d.data[x].id) > -1){
|
||||||
|
node.className = "s"+d.data[x].type;
|
||||||
|
}else{
|
||||||
|
node.className = d.data[x].type;
|
||||||
|
}
|
||||||
|
if(d.data[x].text == undefined){//== 'null'){
|
||||||
|
d.data[x].text = '<empty>';
|
||||||
|
}
|
||||||
|
var id = '';
|
||||||
|
var delim = "||||";
|
||||||
|
var pre;
|
||||||
|
if(d.data[x].type == 'section'){
|
||||||
|
pre = 'S'+ scount++ +':';
|
||||||
|
id = d.data[x].id;
|
||||||
|
}
|
||||||
|
else if(d.data[x].type == 'question'){
|
||||||
|
pre = 'Q'+ qcount++ +':';
|
||||||
|
id = lastId['section'] + delim + d.data[x].id;
|
||||||
|
}
|
||||||
|
else if(d.data[x].type == 'answer'){
|
||||||
|
if(d.data[x].recordedAnswers != null){
|
||||||
|
}
|
||||||
|
pre = 'A'+ acount++ +':';
|
||||||
|
id = lastId['section'] + delim + lastId['question'] + delim + d.data[x].id;
|
||||||
|
}
|
||||||
|
node.innerHTML = pre + ' ' + d.data[x].text;
|
||||||
|
node.id = id;
|
||||||
|
new Survey.DDList(node.id,"sections");
|
||||||
|
document.getElementById('sections').appendChild(node);
|
||||||
|
YAHOO.util.Event.addListener(id, "click", this.clicked);
|
||||||
|
|
||||||
|
lastType = d.data[x].type;
|
||||||
|
lastId[d.data[x].type] = d.data[x].id;
|
||||||
|
}
|
||||||
|
if(lastType == 'answer' && ! buttons['answer']){
|
||||||
|
this.addAnswerButton(lastId['section'],lastId['question']);
|
||||||
|
this.addQuestionButton(lastId['section']);
|
||||||
|
}
|
||||||
|
if(lastType == 'question' && ! buttons['question']){
|
||||||
|
this.addAnswerButton(lastId['section'],lastId['question']);
|
||||||
|
}
|
||||||
|
if(lastType == 'question' || lastType == 'section' && ! buttons['question']){
|
||||||
|
this.addQuestionButton(lastId['section']);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addSectionButton();
|
||||||
|
|
||||||
|
this.loadObjectEdit(d.edit);
|
||||||
|
lastDataSet = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.addSection = function(){
|
||||||
|
Survey.Comm.newSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.addQuestion = function(e,sid){
|
||||||
|
Survey.Comm.newQuestion(sid);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addAnswer = function(e,ids){
|
||||||
|
Survey.Comm.newAnswer(ids[0],ids[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.addSectionButton = function(){
|
||||||
|
var node = document.createElement('li');
|
||||||
|
node.innerHTML = "<span id='newSection'></span>";
|
||||||
|
document.getElementById('sections').appendChild(node);
|
||||||
|
var button = new YAHOO.widget.Button({ label:"Add Section", id:"addsection", container:"newSection" });
|
||||||
|
button.on("click", this.addSection);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.addQuestionButton = function(sid){
|
||||||
|
var node = document.createElement('li');
|
||||||
|
node.className = 'newQuestion';
|
||||||
|
node.innerHTML = "<span id='newQuestion'></span>";
|
||||||
|
document.getElementById('sections').appendChild(node);
|
||||||
|
var button = new YAHOO.widget.Button({ label:"Add Question", id:'addquestion', container:"newQuestion"});//, onclick:{fn:this.addQuestion} });
|
||||||
|
button.on("click", this.addQuestion,sid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.addAnswerButton = function(sid,qid){
|
||||||
|
var node = document.createElement('li');
|
||||||
|
node.id = 'newAnswer';
|
||||||
|
node.className = 'newAnswer';
|
||||||
|
document.getElementById('sections').appendChild(node);
|
||||||
|
var button = new YAHOO.widget.Button({ label:"Add Answer", id:'addanswer', container:"newAnswer" });
|
||||||
|
button.on("click", this.addAnswer,[sid,qid]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.loadObjectEdit = function(edit){
|
||||||
|
if(edit){
|
||||||
|
if(edit.type == "loadSection"){
|
||||||
|
Survey.SectionTemplate.loadSection(edit.params);
|
||||||
|
}
|
||||||
|
else if(edit.type == "loadQuestion"){
|
||||||
|
Survey.QuestionTemplate.loadQuestion(edit.params);
|
||||||
|
}
|
||||||
|
else if(edit.type == "loadAnswer"){
|
||||||
|
Survey.AnswerTemplate.loadAnswer(edit.params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.loadLast = function(){
|
||||||
|
this.loadData(lastDataSet);
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Initialize survey
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
Survey.OnLoad = function() {
|
||||||
|
var e = YAHOO.util.Event;
|
||||||
|
return {
|
||||||
|
init: function() {
|
||||||
|
e.onDOMReady(this.initHandler);
|
||||||
|
},
|
||||||
|
initHandler: function(){
|
||||||
|
new YAHOO.util.DDTarget("sections","sections");
|
||||||
|
Survey.Comm.loadSurvey();
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
Survey.OnLoad.init();
|
||||||
988
www/extras/wobject/Survey/editsurvey.js.backup
Normal file
988
www/extras/wobject/Survey/editsurvey.js.backup
Normal file
|
|
@ -0,0 +1,988 @@
|
||||||
|
// vim:ft=javascript
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Initialize namespace
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
if (typeof WebGUI == "undefined") {
|
||||||
|
var WebGUI = {};
|
||||||
|
}
|
||||||
|
var Survey = {};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Global Params
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
var objects = new Array();
|
||||||
|
objects[0] = undefined;
|
||||||
|
var slength = 1;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// List Super Object
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//function listObject(type){
|
||||||
|
Survey.listObject = function(type){
|
||||||
|
var loType = type;
|
||||||
|
this.dom;
|
||||||
|
this.toggleOn = function(){
|
||||||
|
if(loType == 'section'){
|
||||||
|
this.dom.className="sselected";
|
||||||
|
}else if(loType == 'question'){
|
||||||
|
this.dom.className="qselected";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.toggleOff = function(){
|
||||||
|
this.dom.className=loType;
|
||||||
|
}
|
||||||
|
this.getType = function(){return loType;}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Section definition
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//function section(text,s,randomize){
|
||||||
|
Survey.Section = function(text,s,randomize){
|
||||||
|
//inheritence
|
||||||
|
this.inherit= Survey.listObject;
|
||||||
|
this.inherit("section");
|
||||||
|
|
||||||
|
var sectionUL = document.getElementById('sections');
|
||||||
|
|
||||||
|
this.text = text;
|
||||||
|
this.sId = "S"+(slength++);
|
||||||
|
this.id = s.toString();
|
||||||
|
this.randomize = randomize;
|
||||||
|
this.questions = new Array();
|
||||||
|
this.dd;
|
||||||
|
this.ddt;
|
||||||
|
this.addThyself = function(){
|
||||||
|
if(this.dom != undefined){alert("dom already defined");return}
|
||||||
|
this.dom = document.createElement('li');
|
||||||
|
this.dom.id=this.id;//use slice to get just the number. Q used to protect namespace from A numbered objects
|
||||||
|
this.updateHTML();
|
||||||
|
// this.className = this.getType();
|
||||||
|
|
||||||
|
var holder = document.createElement('ul');
|
||||||
|
holder.className = "questionList";
|
||||||
|
holder.id = this.id + "QL";
|
||||||
|
holder.innerHTML = "<li></li>";
|
||||||
|
|
||||||
|
|
||||||
|
var pli = document.createElement('li');//parent li, containter to hold section li and question ul.
|
||||||
|
pli.id = this.id+"div";
|
||||||
|
pli.className = this.getType();
|
||||||
|
sectionUL.appendChild(pli);
|
||||||
|
pli.appendChild(this.dom);
|
||||||
|
pli.appendChild(holder);
|
||||||
|
|
||||||
|
this.ddt = new YAHOO.util.DDTarget(this.id+"QL","questions");
|
||||||
|
|
||||||
|
this.dd = new WebGUI.DDList(this.id+"div","sections");
|
||||||
|
this.dd.isTarget = false;
|
||||||
|
this.dd.addToGroup("trashcan");
|
||||||
|
this.dd.setHandleElId(this.id);
|
||||||
|
|
||||||
|
YAHOO.util.Event.addListener(this.id, "click", WebGUI.SectionHandler.clicked);
|
||||||
|
}
|
||||||
|
this.updateHTML = function(){
|
||||||
|
this.dom.innerHTML="<b>["+this.sId+"]</b>"+ " " + this.text.substr(0,25) + " ...";
|
||||||
|
}
|
||||||
|
this.updateLoc = function(loc){
|
||||||
|
this.sId = "S"+loc;
|
||||||
|
this.updateHTML();
|
||||||
|
}
|
||||||
|
this.removeQuestion = function(id){
|
||||||
|
for(var i = 0; i <= this.questions.length; i++){
|
||||||
|
if(this.questions[i] == id){
|
||||||
|
this.questions.splice(i,1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.addThyself();
|
||||||
|
|
||||||
|
this.noDrag = function(){
|
||||||
|
this.dd.lock();
|
||||||
|
},
|
||||||
|
|
||||||
|
this.removeThyself = function(){
|
||||||
|
if(this.dom == undefined){ alert("dom is not defined"); return; }
|
||||||
|
YAHOO.util.Event.removeListener(this.id, "click");
|
||||||
|
this.dd.setHandleElId(undefined);
|
||||||
|
this.dd.unreg();
|
||||||
|
this.dd = undefined;
|
||||||
|
var p = this.dom.parentNode;
|
||||||
|
p.removeChild(this.dom.nextSibling);
|
||||||
|
p.removeChild(this.dom);
|
||||||
|
p.parentNode.removeChild(p);
|
||||||
|
this.dom = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.showThyself = function(){
|
||||||
|
document.getElementById("sid").innerHTML = this.sId;
|
||||||
|
document.getElementById("sectioninputtext").value = this.text;
|
||||||
|
var menu = WebGUI.Menu.getsMenu();
|
||||||
|
menu.getItem(0).cfg.setProperty("checked",this.randomize);
|
||||||
|
}
|
||||||
|
this.update = function(text,randomize){
|
||||||
|
this.text = text;
|
||||||
|
this.randomize = randomize;
|
||||||
|
this.updateHTML();
|
||||||
|
}
|
||||||
|
this.DESTROY = function(){
|
||||||
|
for(var q in this.questions){
|
||||||
|
objects[this.questions[q]].DESTROY();
|
||||||
|
}
|
||||||
|
this.removeThyself();
|
||||||
|
slength--;
|
||||||
|
objects[this.id] = undefined;
|
||||||
|
WebGUI.Menu.newS();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Notes, use previousSibling,nextSibling to get ids of siblings, and insertBefore or appendChild to add elements.
|
||||||
|
WebGUI.SectionHandler = function(){
|
||||||
|
return{
|
||||||
|
clicked: function() {//new section event button, prompts the new section menu
|
||||||
|
WebGUI.DM.showThis(this.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Answer definition
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
Survey.Answer = function(id,qid){
|
||||||
|
//inheritence
|
||||||
|
this.inherit= Survey.listObject;
|
||||||
|
this.inherit("answer");
|
||||||
|
this.avalues = [{'atext':"",'ameta':""}]; //array of associative arrays. Array maps to answer types. associate arrays map to all possible responses
|
||||||
|
this.qId = qid;
|
||||||
|
this.id = id;
|
||||||
|
this.aId = "A"+objects[this.qId].answers.length;
|
||||||
|
var answerUL = document.getElementById("answers");
|
||||||
|
objects[this.qId].answers[objects[this.qId].answers.length] = this.id;
|
||||||
|
this.addThyself = function(){
|
||||||
|
if(this.dom != undefined){alert("dom already defined");return}
|
||||||
|
this.dom = document.createElement('li');
|
||||||
|
this.dom.id=this.id;//use slice to get just the number. Q used to protect namespace from A numbered objects
|
||||||
|
this.dom.className = this.getType();
|
||||||
|
this.updateHTML();
|
||||||
|
answerUL.appendChild(this.dom);
|
||||||
|
this.dd = new WebGUI.DDList(this.id.toString(),"answers");
|
||||||
|
this.dd.addToGroup("trashcan");
|
||||||
|
YAHOO.util.Event.addListener(this.id.toString(), "click", WebGUI.AnswerHandler.clicked);
|
||||||
|
}
|
||||||
|
this.updateHTML = function(){
|
||||||
|
this.dom.innerHTML="<b>["+this.aId+"]</b>";
|
||||||
|
}
|
||||||
|
this.showThyself = function(){
|
||||||
|
document.getElementById('asid').innerHTML = objects[this.sId].sId;
|
||||||
|
document.getElementById('aqid').innerHTML = objects[this.qId].qId;
|
||||||
|
document.getElementById('aid').innerHTML = this.aId;
|
||||||
|
}
|
||||||
|
this.hide = function(){
|
||||||
|
}
|
||||||
|
this.show = function(){
|
||||||
|
}
|
||||||
|
this.DESTROY = function(){
|
||||||
|
if(this.dom == undefined){ alert("dom is not defined"); return; }
|
||||||
|
YAHOO.util.Event.removeListener(this.id, "click");
|
||||||
|
this.dom.parentNode.removeChild(this.dom);
|
||||||
|
this.dom = undefined;
|
||||||
|
this.dd.unreg();
|
||||||
|
objects[this.id] = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WebGUI.AnswerHandler = function(){
|
||||||
|
return{
|
||||||
|
clicked: function() {//new section event button, prompts the new section menu
|
||||||
|
alert('click');
|
||||||
|
// WebGUI.DM.showThis(this.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Question definition
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//function question(qid,type,typeName,text,options,toptions,sid){
|
||||||
|
Survey.Question = function(qid,type,typeName,text,options,toptions,sid){
|
||||||
|
//inheritence
|
||||||
|
this.inherit= Survey.listObject;
|
||||||
|
this.inherit("question");
|
||||||
|
this.type = type; //index to the qMenu YUI menu containing this question type
|
||||||
|
this.typeName = typeName;
|
||||||
|
this.text = text; //Question text
|
||||||
|
this.id = qid;
|
||||||
|
this.sId = sid; //Section parent node id attribute
|
||||||
|
objects[sid].questions[objects[sid].questions.length] = qid;
|
||||||
|
this.qId = "Q"+ objects[this.sId].questions.length //Nodes id attribute
|
||||||
|
this.options = options; //indexes to the oMenu YUI menu
|
||||||
|
this.textOptions = toptions; //strings indexed by the ids of the option input fields
|
||||||
|
this.answers = new Array();
|
||||||
|
this.answersRef = new Array(); //2D array of [qid][aid] which point at this qid. Used for updating answers when this question is reordered/deleted
|
||||||
|
|
||||||
|
var questionUL = document.getElementById(this.sId.toString()+"QL");
|
||||||
|
|
||||||
|
this.loc;
|
||||||
|
|
||||||
|
this.addThyself = function(){
|
||||||
|
this.dom = document.createElement('li'); //reference to this questions dom object
|
||||||
|
this.dom.className = this.getType();
|
||||||
|
this.dom.id = this.id.toString();
|
||||||
|
this.updateHTML();
|
||||||
|
questionUL.appendChild(this.dom);
|
||||||
|
this.dd = new WebGUI.DDList(this.id.toString(),"questions");
|
||||||
|
this.dd.addToGroup("trashcan");
|
||||||
|
YAHOO.util.Event.addListener(this.id.toString(), "click", WebGUI.QuestionHandler.clicked);
|
||||||
|
}
|
||||||
|
this.updateHTML = function(){
|
||||||
|
this.dom.innerHTML="<b>["+this.qId+ " "+ this.typeName+"]</b> " + this.text.substr(0,25) + " ...";
|
||||||
|
}
|
||||||
|
this.addThyself();
|
||||||
|
|
||||||
|
this.index = function(){
|
||||||
|
var t = this.qId.split("-");
|
||||||
|
return (t[1].slice(1)-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.removeThyself = function(){
|
||||||
|
if(this.dom == undefined){ alert("dom is not defined"); return; }
|
||||||
|
YAHOO.util.Event.removeListener(this.id.toString(), "click");
|
||||||
|
this.dom.parentNode.removeChild(this.dom);
|
||||||
|
this.dom = undefined;
|
||||||
|
this.dd.unreg();
|
||||||
|
objects[this.sId].removeQuestion(this.id);
|
||||||
|
}
|
||||||
|
this.showThyself = function(){
|
||||||
|
document.getElementById("qid").innerHTML = this.qId;
|
||||||
|
document.getElementById("qsid").innerHTML = objects[this.sId].sId;
|
||||||
|
document.getElementById("questioninputtext").value = this.text;
|
||||||
|
WebGUI.Menu.clearMenus();
|
||||||
|
var menu = WebGUI.Menu.getqMenu();
|
||||||
|
menu.getItem(this.type).cfg.setProperty("checked",true);
|
||||||
|
//WebGUI.Menu.qTypeClick(null,[null,qMenu.getItem(q['type'])],null);
|
||||||
|
WebGUI.Menu.loadOMenu(this.type);
|
||||||
|
var oMenu = WebGUI.Menu.getoMenu();
|
||||||
|
for(var i in this.options){
|
||||||
|
oMenu.getItem(this.options[i]).cfg.setProperty("checked",true);
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
document.getElementById('max').value = q['max'];
|
||||||
|
}catch(e){}
|
||||||
|
try{
|
||||||
|
document.getElementById('min').value = q['min'];
|
||||||
|
}catch(e){}
|
||||||
|
try{
|
||||||
|
document.getElementById('step').value = q['step'];
|
||||||
|
}catch(e){}
|
||||||
|
|
||||||
|
}
|
||||||
|
this.update = function(type, typeName,text,options,toptions){
|
||||||
|
this.type=type;
|
||||||
|
this.typeName = typeName;
|
||||||
|
this.text = text;
|
||||||
|
this.options = options;
|
||||||
|
this.textOptions = toptions;
|
||||||
|
this.updateHTML();
|
||||||
|
}
|
||||||
|
this.updateLoc = function(sid,loc){
|
||||||
|
this.sId = sid;
|
||||||
|
this.qId = "Q"+loc;
|
||||||
|
this.updateHTML();
|
||||||
|
}
|
||||||
|
this.DESTROY = function(){
|
||||||
|
//remove event handler, dom, answerRefs, question, and answers
|
||||||
|
for(var i in this.answers){
|
||||||
|
this.answers[i].DESTROY();
|
||||||
|
}
|
||||||
|
for(var i in this.answersRef){
|
||||||
|
this.answersRef[i].unlink();
|
||||||
|
}
|
||||||
|
this.removeThyself();
|
||||||
|
objects[this.id] = undefined;
|
||||||
|
WebGUI.Menu.newQ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WebGUI.QuestionHandler = function(){
|
||||||
|
return{
|
||||||
|
clicked: function() {//new question event button, prompts the new question menu
|
||||||
|
WebGUI.DM.showThis(this.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Display Manager
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
WebGUI.DM = function(){
|
||||||
|
var lastObject;//Current Question
|
||||||
|
return{
|
||||||
|
updateSectionDOMLists: function(){
|
||||||
|
//Loop through sections ul then answer ul and make sure everything is in the right place.
|
||||||
|
var q = document.getElementById('sections');
|
||||||
|
var loc = 1;
|
||||||
|
var tsections = new Array();
|
||||||
|
var start = q.firstChild;//the li which contains the a ul which contains the current section li and
|
||||||
|
while(start){
|
||||||
|
var section = start.firstChild.id;
|
||||||
|
start = start.nextSibling;
|
||||||
|
objects[section].updateLoc(loc++);
|
||||||
|
objects[section].questions = new Array();
|
||||||
|
this.updateQuestionDOMList(section,section+"QL");
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
updateQuestionDOMList: function(sid, parent){
|
||||||
|
var q = document.getElementById(parent);
|
||||||
|
var start = q.firstChild;
|
||||||
|
var loc = 1;
|
||||||
|
while(start){
|
||||||
|
var section = start.id;
|
||||||
|
if(! start.id){
|
||||||
|
start = start.nextSibling;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
start = start.nextSibling;
|
||||||
|
objects[section].updateLoc(sid,loc++);
|
||||||
|
objects[sid].questions[objects[sid].questions.length] = section;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
updateAnswerDOMLists: function(){
|
||||||
|
},
|
||||||
|
showThis: function(Id) {
|
||||||
|
this.clearLast();
|
||||||
|
lastObject = Id;
|
||||||
|
try{
|
||||||
|
objects[lastObject].toggleOn();
|
||||||
|
WebGUI.Menu.sselected(lastObject);
|
||||||
|
WebGUI.Menu.showEditSection();
|
||||||
|
}catch(e){}
|
||||||
|
try{
|
||||||
|
objects[objects[lastObject].sId].toggleOn();
|
||||||
|
WebGUI.Menu.sselected(objects[objects[lastObject].sId].id);
|
||||||
|
WebGUI.Menu.qselected(lastObject);
|
||||||
|
WebGUI.Menu.showEditQuestion();
|
||||||
|
}catch(e){}
|
||||||
|
try{
|
||||||
|
objects[objects[objects[lastObject].qId].sId].toggleOn();
|
||||||
|
WebGUI.Menu.sselected(objects[objects[objects[lastObject].qId].sId].id);
|
||||||
|
WebGUI.Menu.qselected(objects[objects[lastObject].qId].id);
|
||||||
|
WebGUI.Menu.aselected(lastObject);
|
||||||
|
WebGUI.Menu.showEditAnswer();
|
||||||
|
}catch(e){}
|
||||||
|
objects[lastObject].showThyself();
|
||||||
|
},
|
||||||
|
clearLast: function(){
|
||||||
|
try{
|
||||||
|
objects[lastObject].toggleOff();
|
||||||
|
}catch(e){}
|
||||||
|
try{
|
||||||
|
objects[objects[lastObject].sId].toggleOff();
|
||||||
|
}catch(e){}
|
||||||
|
try{
|
||||||
|
objects[objects[objects[lastObject].qId].sId].toggleOff();
|
||||||
|
}catch(e){}
|
||||||
|
lastObject = undefined;
|
||||||
|
WebGUI.Menu.sselected(undefined);
|
||||||
|
WebGUI.Menu.qselected(undefined);
|
||||||
|
WebGUI.Menu.aselected(undefined);
|
||||||
|
},
|
||||||
|
getLastSection: function(){
|
||||||
|
var q = document.getElementById('sections');
|
||||||
|
try{
|
||||||
|
return (parseInt(q.lastChild.firstChild.id))//the li which contains the a ul which contains the current section li and
|
||||||
|
}catch(e){}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Menu definition
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
WebGUI.Menu = function(){
|
||||||
|
var qMenu = new YAHOO.widget.Menu("qmenu",{position: "static", hidedelay: 750, lazyload: true});
|
||||||
|
var oMenu = new YAHOO.widget.Menu("omenu",{position: "static", hidedelay: 750, lazyload: true});
|
||||||
|
var sMenu = new YAHOO.widget.Menu("smenu",{position: "static", hidedelay: 750, lazyload: true});
|
||||||
|
var aMenu = new YAHOO.widget.Menu("amenu",{position: "static", hidedelay: 750, lazyload: true});
|
||||||
|
|
||||||
|
var last = -1;//Last qMenu option selected, keep track so we can unselect on next click
|
||||||
|
var qselected = 0;//Currently selected qMenu item.
|
||||||
|
var sselected = 'S1';
|
||||||
|
|
||||||
|
return{
|
||||||
|
sselected: function(i){ sselected = i; },
|
||||||
|
qselected: function(i){ qselected = i; },
|
||||||
|
aselected: function(i){ aselected = i; },
|
||||||
|
|
||||||
|
init: function() {
|
||||||
|
document.getElementById("questiontext").innerHTML="<textarea id=questioninputtext maxlength=2056 cols=30 rows=5></textarea>";
|
||||||
|
WebGUI.Menu.clearMenus();
|
||||||
|
qMenu.subscribe("click", this.qTypeClick);
|
||||||
|
oMenu.subscribe("click", this.oTypeClick);
|
||||||
|
|
||||||
|
sMenu.addItems([ "Randomly Ordered" ] );
|
||||||
|
sMenu.render("sectionmenu");
|
||||||
|
sMenu.subscribe("click", this.sTypeClick);
|
||||||
|
|
||||||
|
document.getElementById("qsubmitbutton").style.display="none";
|
||||||
|
WebGUI.Menu.showEditSection();
|
||||||
|
new YAHOO.widget.Button({ type: "button", label: "Submit Question", container: "qsubmitbutton",
|
||||||
|
onclick: {fn: WebGUI.Menu.addQ} });
|
||||||
|
new YAHOO.widget.Button({ type: "button", label: "Submit Section", container: "ssubmitbutton",
|
||||||
|
onclick: {fn: WebGUI.Menu.addS} });
|
||||||
|
new YAHOO.widget.Button({ type: "button", label: "Submit Answer", container: "asubmitbutton",
|
||||||
|
onclick: {fn: WebGUI.Menu.addA} });
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
getsMenu: function(){ return sMenu; },
|
||||||
|
getqMenu: function(){ return qMenu; },
|
||||||
|
getoMenu: function(){ return oMenu; },
|
||||||
|
getaMenu: function(){ return aMenu; },
|
||||||
|
|
||||||
|
addQ: function() {
|
||||||
|
// var id = document.getElementById("qid").innerHTML;
|
||||||
|
var text = document.getElementById('questioninputtext').value;
|
||||||
|
var options = new Array();
|
||||||
|
|
||||||
|
var qindex;
|
||||||
|
var qtype;
|
||||||
|
var temp = qMenu.getItems();
|
||||||
|
for(var i in temp){
|
||||||
|
if(temp[i].cfg.getProperty("checked")){
|
||||||
|
qtype = temp[i].value;
|
||||||
|
qindex = temp[i].index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
temp = oMenu.getItems();
|
||||||
|
for(var i in temp){
|
||||||
|
if(temp[i].cfg.getProperty("checked")){
|
||||||
|
options[options.length] = temp[i].index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var toptions = new Array();
|
||||||
|
var sid = sselected;
|
||||||
|
|
||||||
|
try{toptions['max'] = document.getElementById('max').value;}catch(err){}
|
||||||
|
try{toptions['min'] = document.getElementById('min').value;}catch(err){}
|
||||||
|
try{toptions['step'] = document.getElementById('step').value;}catch(err){}
|
||||||
|
|
||||||
|
if(qselected != undefined){
|
||||||
|
objects[qselected].update(qindex,qtype,text,options,toptions);
|
||||||
|
}else{
|
||||||
|
objects[objects.length] = new Survey.Question(objects.length,qindex,qtype,text,options,toptions,sselected);
|
||||||
|
}
|
||||||
|
WebGUI.Menu.newQ();
|
||||||
|
},
|
||||||
|
addS: function(){
|
||||||
|
var id;
|
||||||
|
if(sselected){
|
||||||
|
id = sselected;
|
||||||
|
}else{
|
||||||
|
id = objects.length;
|
||||||
|
}
|
||||||
|
var text = document.getElementById('sectioninputtext').value;
|
||||||
|
var checked = sMenu.getItem(0).cfg.getProperty("checked");
|
||||||
|
if(objects[id] != undefined){//editing an existing section which knows how to update itself
|
||||||
|
objects[id].update(text,checked);
|
||||||
|
}else{
|
||||||
|
objects[id] = new Survey.Section(text,id,checked);
|
||||||
|
}
|
||||||
|
WebGUI.Menu.newS();
|
||||||
|
},
|
||||||
|
addA: function(){
|
||||||
|
var qtype = objects[qselected].type;
|
||||||
|
var id;
|
||||||
|
if(aselected){
|
||||||
|
id = sselected;
|
||||||
|
}else{
|
||||||
|
id = objects.length;
|
||||||
|
}
|
||||||
|
if(objects[id] == undefined){//editing an existing answer which knows how to update itself
|
||||||
|
objects[id] = new Survey.Answer(id,qselected)
|
||||||
|
}
|
||||||
|
for(var q in objects[id].avalues[qtype]){
|
||||||
|
objects[id].avalues[qtype][q] = document.getElementById(q).value;
|
||||||
|
}
|
||||||
|
objects[id].addThyself();
|
||||||
|
WebGUI.Menu.newA();
|
||||||
|
},
|
||||||
|
|
||||||
|
newS: function() {//new section event button, prompts the new section menu
|
||||||
|
sselected = undefined;
|
||||||
|
qselected = undefined;
|
||||||
|
aselected = undefined;
|
||||||
|
WebGUI.DM.clearLast();
|
||||||
|
WebGUI.Menu.showEditSection();
|
||||||
|
document.getElementById('sectioninputtext').value = '';
|
||||||
|
document.getElementById('sid').innerHTML = "S"+(slength);
|
||||||
|
sMenu.getItem(0).cfg.setProperty("checked",false);
|
||||||
|
},
|
||||||
|
|
||||||
|
newA: function() {
|
||||||
|
aselected = undefined;
|
||||||
|
if(!sselected){
|
||||||
|
sselected = WebGUI.DM.getLastSection();
|
||||||
|
}
|
||||||
|
if(!qselected){
|
||||||
|
qselected = objects[sselected].questions[objects[sselected].questions.length-1];
|
||||||
|
}
|
||||||
|
if(!qselected){
|
||||||
|
alert("At least one question must be selected to add an answer.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
document.getElementById('asid').innerHTML = objects[sselected].sId;
|
||||||
|
document.getElementById('aqid').innerHTML = objects[qselected].qId;
|
||||||
|
document.getElementById('aid').innerHTML = "A"+(objects[qselected].answers.length + 1);
|
||||||
|
WebGUI.DM.showThis(qselected);
|
||||||
|
WebGUI.Menu.showEditAnswer();
|
||||||
|
WebGUI.Menu.clearOMenus();
|
||||||
|
var input = document.getElementById("answerinput");
|
||||||
|
input.innerHTML="";
|
||||||
|
var qtype = objects[qselected].type;
|
||||||
|
if(qtype == 0){//multiple choice
|
||||||
|
input.innerHTML = "Please enter the text: <input type='text' id='atext'><br>"+
|
||||||
|
"Please enter the meta tag: <input type='text' id='ameta'>";
|
||||||
|
}else if(qtype == 1){//Text
|
||||||
|
alert("Answers can not be added to a text type");
|
||||||
|
WebGUI.Menu.newQ();
|
||||||
|
}else if(qtype == 2){//Slider
|
||||||
|
}else if(qtype == 3){//Date
|
||||||
|
}else if(qtype == 4){//True/False
|
||||||
|
}
|
||||||
|
},
|
||||||
|
newQ: function() {
|
||||||
|
qselected = undefined;
|
||||||
|
aselected = undefined;
|
||||||
|
if(!sselected){
|
||||||
|
sselected = WebGUI.DM.getLastSection();
|
||||||
|
}
|
||||||
|
if(!sselected){
|
||||||
|
alert("At least one section must be selected to add an answer.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WebGUI.DM.showThis(sselected);
|
||||||
|
WebGUI.Menu.showEditQuestion();
|
||||||
|
WebGUI.Menu.clearMenus();
|
||||||
|
document.getElementById('qsid').innerHTML = objects[sselected].sId;
|
||||||
|
var nextQ = objects[sselected].questions.length;
|
||||||
|
document.getElementById('qid').innerHTML = "Q"+ (nextQ + 1);
|
||||||
|
document.getElementById("questioninputtext").value = "";
|
||||||
|
WebGUI.Menu.loadOMenu(0);
|
||||||
|
},
|
||||||
|
clearOMenus: function(){
|
||||||
|
aMenu.clearContent();
|
||||||
|
},
|
||||||
|
|
||||||
|
clearMenus: function() {
|
||||||
|
qMenu.clearContent();
|
||||||
|
qMenu.addItems([
|
||||||
|
{text: "Multiple Choice",value: "Multiple Choice"},
|
||||||
|
{text: "Text",value: "Text"},
|
||||||
|
{text: "Slider",value: "Slider"},
|
||||||
|
{text: "Date",value: "Date"},
|
||||||
|
{text: "True/False",value: "True/False"},
|
||||||
|
] );
|
||||||
|
qMenu.render("questionmenu");
|
||||||
|
oMenu.clearContent();
|
||||||
|
document.getElementById("qsubmitbutton").style.display="none";
|
||||||
|
document.getElementById("qoptionmenu").style.display="none";
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
loadQ: function(e) {
|
||||||
|
WebGUI.Menu.clearMenus();
|
||||||
|
var q = questions[ this.id.slice(1) - 1 ];
|
||||||
|
document.getElementById('qid').innerHTML = "Q"+q['id']+":";
|
||||||
|
document.getElementById('questioninputtext').value = q['text'];
|
||||||
|
qMenu.getItem(q['type']).cfg.setProperty("checked");
|
||||||
|
//WebGUI.Menu.qTypeClick(null,[null,qMenu.getItem(q['type'])],null);
|
||||||
|
WebGUI.Menu.loadOMenu(qMenu.getItem(q['type']).index);
|
||||||
|
for(var i in q['moptions']){
|
||||||
|
oMenu.getItem(q['moptions'][i]).cfg.setProperty("checked",true);
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
document.getElementById('max').value = q['max'];
|
||||||
|
}catch(e){}
|
||||||
|
try{
|
||||||
|
document.getElementById('min').value = q['min'];
|
||||||
|
}catch(e){}
|
||||||
|
try{
|
||||||
|
document.getElementById('step').value = q['step'];
|
||||||
|
}catch(e){}
|
||||||
|
},
|
||||||
|
|
||||||
|
showEditQuestion: function() {
|
||||||
|
document.getElementById("editquestion").style.display="inline";
|
||||||
|
document.getElementById("editanswer").style.display="none";
|
||||||
|
document.getElementById("editsection").style.display="none";
|
||||||
|
},
|
||||||
|
showEditAnswer: function() {
|
||||||
|
document.getElementById("editquestion").style.display="none";
|
||||||
|
document.getElementById("editanswer").style.display="inline";
|
||||||
|
document.getElementById("editsection").style.display="none";
|
||||||
|
},
|
||||||
|
showEditSection: function() {
|
||||||
|
document.getElementById("editquestion").style.display="none";
|
||||||
|
document.getElementById("editanswer").style.display="none";
|
||||||
|
document.getElementById("editsection").style.display="inline";
|
||||||
|
},
|
||||||
|
|
||||||
|
sTypeClick: function(p_sType, p_aArgs, p_oValue) {
|
||||||
|
if(p_aArgs[1].cfg.getProperty("checked")){
|
||||||
|
p_aArgs[1].cfg.setProperty("checked", false);
|
||||||
|
}else{
|
||||||
|
p_aArgs[1].cfg.setProperty("checked", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
oTypeClick: function(p_sType, p_aArgs, p_oValue) {
|
||||||
|
var checked = p_aArgs[1].cfg.getProperty("checked");
|
||||||
|
var index = p_aArgs[1].index;
|
||||||
|
if(qselected == 1 && index >= 0 && index < 4){
|
||||||
|
for(var i=0; i<=3; i++){
|
||||||
|
oMenu.getItem(i).cfg.setProperty("checked",false);
|
||||||
|
}
|
||||||
|
p_aArgs[1].cfg.setProperty("checked",checked);
|
||||||
|
}
|
||||||
|
else if(qselected == 4 && index >= 0 && index <= 1){
|
||||||
|
for(var i=0; i<=1; i++){
|
||||||
|
oMenu.getItem(i).cfg.setProperty("checked",false);
|
||||||
|
}
|
||||||
|
p_aArgs[1].cfg.setProperty("checked",checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p_aArgs[1].cfg.getProperty("checked")){
|
||||||
|
p_aArgs[1].cfg.setProperty("checked", false);
|
||||||
|
}else{
|
||||||
|
p_aArgs[1].cfg.setProperty("checked", true);
|
||||||
|
}
|
||||||
|
if(qselected == 0 && index == 1 && p_aArgs[1].cfg.getProperty("checked") == false){
|
||||||
|
document.getElementById('max').value = 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
validateMultipleMax: function(){
|
||||||
|
var v = this.value;
|
||||||
|
if (v != parseInt(v) || v < 1){
|
||||||
|
this.value = 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
qTypeClick: function(p_sType, p_aArgs, p_oValue) {
|
||||||
|
var index = p_aArgs[1].index;
|
||||||
|
|
||||||
|
WebGUI.Menu.showEditQuestion();
|
||||||
|
|
||||||
|
WebGUI.Menu.loadOMenu(index);
|
||||||
|
},
|
||||||
|
|
||||||
|
loadOMenu: function(index) {
|
||||||
|
|
||||||
|
if(last > -1){
|
||||||
|
qMenu.getItem(last).cfg.setProperty("checked",false);
|
||||||
|
}
|
||||||
|
qMenu.getItem(index).cfg.setProperty("checked",true);
|
||||||
|
last = index;
|
||||||
|
|
||||||
|
oMenu.clearContent();
|
||||||
|
|
||||||
|
document.getElementById("qsubmitbutton").style.display="inline";
|
||||||
|
document.getElementById("qoptionmenu").style.display="inline";
|
||||||
|
document.getElementById("textoptions").innerHTML="";
|
||||||
|
|
||||||
|
var temp = document.createElement("div");
|
||||||
|
|
||||||
|
if(index == 0){//Multipe choice options
|
||||||
|
try{
|
||||||
|
YAHOO.util.Event.removeListener("max", "click");
|
||||||
|
}catch(e){}
|
||||||
|
YAHOO.util.Event.addListener("max", "blur", WebGUI.Menu.validateMultipleMax);
|
||||||
|
temp.innerHTML = "Max Answers: <input id=max type=text value=1 size=2><br/>";
|
||||||
|
oMenu.addItems([
|
||||||
|
"Randomize",
|
||||||
|
"Horizontal display",
|
||||||
|
"Multiple Answers",
|
||||||
|
"Comment Box",
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
else if(index == 1){//Text options
|
||||||
|
temp.innerHTML = "Max length <input type=text value=50 size=4 id=max><br/>";
|
||||||
|
oMenu.addItems([
|
||||||
|
"Multi-Line",
|
||||||
|
"Numerical",
|
||||||
|
"Phone Number",
|
||||||
|
"Currency Amount",
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
else if(index == 2){//Slider options
|
||||||
|
temp.innerHTML = "Start Value: <input type=text value=0 size=2 id=min><br/> End Value: <input id=max type=text value=10 size=2><br/> Step Value: <input id=step type=text value=2 size=2><br/>";
|
||||||
|
}
|
||||||
|
else if(index == 3){//Date options
|
||||||
|
oMenu.addItems([
|
||||||
|
"Range",
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
else if(index == 4){//True/False options
|
||||||
|
oMenu.addItems([
|
||||||
|
"Yes/No",
|
||||||
|
"Male/Female",
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
document.getElementById("textoptions").appendChild(temp);
|
||||||
|
oMenu.addItems(["Optional"]);
|
||||||
|
oMenu.render("qoptionmenu");
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Initialize survey
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
WebGUI.OnLoad = function() {
|
||||||
|
var e = YAHOO.util.Event;
|
||||||
|
return {
|
||||||
|
init: function() {
|
||||||
|
//e.onDOMReady(this.initHandler, "The onDOMReady event fired. The DOM is now safe to modify via script.");
|
||||||
|
e.onDOMReady(this.initHandler);
|
||||||
|
},
|
||||||
|
initHandler: function(){
|
||||||
|
new YAHOO.widget.Button({ type: "button", label: "New Question", container: "addqbutton",
|
||||||
|
onclick: {fn: WebGUI.Menu.newQ} });
|
||||||
|
new YAHOO.widget.Button({ type: "button", label: "New Answer", container: "addabutton",
|
||||||
|
onclick: {fn: WebGUI.Menu.newA} });
|
||||||
|
new YAHOO.widget.Button({ type: "button", label: "New Section", container: "addsbutton",
|
||||||
|
onclick: {fn: WebGUI.Menu.newS} });
|
||||||
|
|
||||||
|
WebGUI.Menu.init();
|
||||||
|
|
||||||
|
document.getElementById("editanswer").style.display="none";
|
||||||
|
objects[objects.length] = new Survey.Section("First Section",objects.length,false);
|
||||||
|
WebGUI.DM.showThis(objects.length-1);
|
||||||
|
WebGUI.Menu.newQ();
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
WebGUI.OnLoad.init();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var Dom = YAHOO.util.Dom;
|
||||||
|
var Event = YAHOO.util.Event;
|
||||||
|
var DDM = YAHOO.util.DragDropMgr;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// example app
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//YAHOO.example.DDApp = {
|
||||||
|
WebGUI.DD = {
|
||||||
|
init: function() {
|
||||||
|
|
||||||
|
new YAHOO.util.DDTarget("sections","sections");
|
||||||
|
new YAHOO.util.DDTarget("answers","answers");
|
||||||
|
new YAHOO.util.DDTarget("trashcan","trashcan");
|
||||||
|
|
||||||
|
Event.on("showButton", "click", this.showOrder);
|
||||||
|
Event.on("switchButton", "click", this.switchStyles);
|
||||||
|
},
|
||||||
|
|
||||||
|
showOrder: function() {
|
||||||
|
var parseList = function(ul, title) {
|
||||||
|
var items = ul.getElementsByTagName("li");
|
||||||
|
var out = title + ": ";
|
||||||
|
for (i=0;i<items.length;i=i+1) {
|
||||||
|
out += items[i].id + " ";
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
};
|
||||||
|
|
||||||
|
var ul1=Dom.get("ul1"), ul2=Dom.get("ul2");
|
||||||
|
alert(parseList(ul1, "List 1") + "\n" + parseList(ul2, "List 2"));
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
switchStyles: function() {
|
||||||
|
Dom.get("ul1").className = "draglist_alt";
|
||||||
|
Dom.get("ul2").className = "draglist_alt";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// custom drag and drop implementation
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
WebGUI.DDList = function(id, sGroup, config) {
|
||||||
|
WebGUI.DDList.superclass.constructor.call(this, id, sGroup, config);
|
||||||
|
|
||||||
|
this.logger = this.logger || YAHOO;
|
||||||
|
var el = this.getDragEl();
|
||||||
|
Dom.setStyle(el, "opacity", 0.3); // The proxy is slightly transparent
|
||||||
|
|
||||||
|
this.goingUp = false;
|
||||||
|
this.lastY = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
YAHOO.extend(WebGUI.DDList, YAHOO.util.DDProxy, {
|
||||||
|
|
||||||
|
startDrag: function(x, y) {
|
||||||
|
this.logger.log(this.id + " startDrag");
|
||||||
|
|
||||||
|
// make the proxy look like the source element
|
||||||
|
var dragEl = this.getDragEl();
|
||||||
|
var clickEl = this.getEl();
|
||||||
|
Dom.setStyle(clickEl, "visibility", "hidden");
|
||||||
|
|
||||||
|
dragEl.innerHTML = clickEl.innerHTML;
|
||||||
|
|
||||||
|
Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
|
||||||
|
Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor"));
|
||||||
|
Dom.setStyle(dragEl, "border", "2px solid gray");
|
||||||
|
},
|
||||||
|
|
||||||
|
endDrag: function(e) {
|
||||||
|
|
||||||
|
var srcEl = this.getEl();
|
||||||
|
var proxy = this.getDragEl();
|
||||||
|
|
||||||
|
// Show the proxy element and animate it to the src element's location
|
||||||
|
Dom.setStyle(proxy, "visibility", "");
|
||||||
|
var a = new YAHOO.util.Motion(
|
||||||
|
proxy, {
|
||||||
|
points: {
|
||||||
|
to: Dom.getXY(srcEl)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
0.2,
|
||||||
|
YAHOO.util.Easing.easeOut
|
||||||
|
)
|
||||||
|
var proxyid = proxy.id;
|
||||||
|
var thisid = this.id;
|
||||||
|
|
||||||
|
// Hide the proxy and show the source element when finished with the animation
|
||||||
|
a.onComplete.subscribe(function() {
|
||||||
|
Dom.setStyle(proxyid, "visibility", "hidden");
|
||||||
|
Dom.setStyle(thisid, "visibility", "");
|
||||||
|
});
|
||||||
|
a.animate();
|
||||||
|
|
||||||
|
//call appropriate update function depending on the element type moved.
|
||||||
|
var t = this.getEl().id;
|
||||||
|
t = t.replace(/[a-zA-Z]/g,"");
|
||||||
|
if(document.getElementById(this.id).parentNode.id == 'trashcan' || document.getElementById(this.id).parentNode.parentNode.id == 'trashcan'){
|
||||||
|
WebGUI.DM.updateAnswerDOMLists();
|
||||||
|
WebGUI.DM.updateSectionDOMLists();
|
||||||
|
objects[t].DESTROY();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(objects[t].constructor == Survey.Answer){
|
||||||
|
WebGUI.DM.updateAnswerDOMLists();
|
||||||
|
}else{
|
||||||
|
WebGUI.DM.updateSectionDOMLists();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onDragDrop: function(e, id) {
|
||||||
|
|
||||||
|
// If there is one drop interaction, the li was dropped either on the list,
|
||||||
|
// or it was dropped on the current location of the source element.
|
||||||
|
if (DDM.interactionInfo.drop.length === 1) {
|
||||||
|
|
||||||
|
// The position of the cursor at the time of the drop (YAHOO.util.Point)
|
||||||
|
var pt = DDM.interactionInfo.point;
|
||||||
|
|
||||||
|
// The region occupied by the source element at the time of the drop
|
||||||
|
var region = DDM.interactionInfo.sourceRegion;
|
||||||
|
|
||||||
|
// Check to see if we are over the source element's location. We will
|
||||||
|
// append to the bottom of the list once we are sure it was a drop in
|
||||||
|
// the negative space (the area of the list without any list items)
|
||||||
|
if (!region.intersect(pt)) {
|
||||||
|
var destEl = Dom.get(id);
|
||||||
|
var destDD = DDM.getDDById(id);
|
||||||
|
destEl.appendChild(this.getEl());
|
||||||
|
destDD.isEmpty = false;
|
||||||
|
DDM.refreshCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onDrag: function(e) {
|
||||||
|
|
||||||
|
// Keep track of the direction of the drag for use during onDragOver
|
||||||
|
var y = Event.getPageY(e);
|
||||||
|
|
||||||
|
if (y < this.lastY) {
|
||||||
|
this.goingUp = true;
|
||||||
|
} else if (y > this.lastY) {
|
||||||
|
this.goingUp = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lastY = y;
|
||||||
|
},
|
||||||
|
|
||||||
|
onDragOver: function(e, id) {
|
||||||
|
|
||||||
|
var srcEl = this.getEl();
|
||||||
|
var destEl = Dom.get(id);
|
||||||
|
|
||||||
|
// We are only concerned with list items, we ignore the dragover
|
||||||
|
// notifications for the list.
|
||||||
|
document.getElementById('log1').innerHTML = srcEl.className;
|
||||||
|
document.getElementById('log2').innerHTML = destEl.className;
|
||||||
|
document.getElementById('log').innerHTML = destEl.nodeName;
|
||||||
|
|
||||||
|
if ( destEl.nodeName.toLowerCase() == "li" )
|
||||||
|
{
|
||||||
|
//destEl.className == "questionList" || destEl.className == "question" || destEl.className == "qselected")
|
||||||
|
var orig_p = srcEl.parentNode;
|
||||||
|
var p = destEl.parentNode;
|
||||||
|
|
||||||
|
if (this.goingUp) {
|
||||||
|
p.insertBefore(srcEl, destEl); // insert above
|
||||||
|
} else {
|
||||||
|
p.insertBefore(srcEl, destEl.nextSibling); // insert below
|
||||||
|
}
|
||||||
|
|
||||||
|
DDM.refreshCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Event.onDOMReady(YAHOO.example.DDApp.init, YAHOO.example.DDApp, true);
|
||||||
|
Event.onDOMReady(WebGUI.DD.init, WebGUI.DD, true);
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
337
www/extras/wobject/Survey/editsurvey.js.backup.newer
Normal file
337
www/extras/wobject/Survey/editsurvey.js.backup.newer
Normal file
|
|
@ -0,0 +1,337 @@
|
||||||
|
if (typeof Survey == "undefined") {
|
||||||
|
var Survey = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Survey.Data = new function(){
|
||||||
|
var lastDataSet = {};
|
||||||
|
var focus;
|
||||||
|
|
||||||
|
this.dragDrop = function(did){
|
||||||
|
var type;
|
||||||
|
|
||||||
|
if(did.className.match("section")){type = 'section';}
|
||||||
|
else if(did.className.match("question")){type = 'question';}
|
||||||
|
else{ type = 'answer';}
|
||||||
|
|
||||||
|
var first = {id:did.id,type:type};
|
||||||
|
var before = document.getElementById(did.id).previousSibling;
|
||||||
|
|
||||||
|
while(1){
|
||||||
|
if( before == undefined || (before.id != undefined && before.id != '') ){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var before = before.previousSibling;
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = {id:'',type:''};
|
||||||
|
|
||||||
|
if(before != undefined && before.id != undefined && before.id != ''){
|
||||||
|
if(before.className.match("section")){type = 'section';}
|
||||||
|
else if(before.className.match("question")){type = 'question';}
|
||||||
|
else{ type = 'answer';}
|
||||||
|
data = {id:before.id,type:type};
|
||||||
|
}
|
||||||
|
|
||||||
|
Survey.Comm.dragDrop(first,data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.clicked = function(){
|
||||||
|
Survey.Comm.loadSurvey(this.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.loadData = function(d){
|
||||||
|
focus = d.focus;//What is the current highlighted item.
|
||||||
|
var lastType = '';//What was the last type created.
|
||||||
|
var lastId = {'section': '', 'question': '', 'answer': ''};//what is the last id of each type placed, so we know a child's parent.
|
||||||
|
var buttons = {'question':0,'answer':0,'section':0}; //array of bools on if buttons put down
|
||||||
|
document.getElementById('sections').innerHTML='';
|
||||||
|
|
||||||
|
for(var x in d.data){
|
||||||
|
//Now check to see if this is where an add button goes.
|
||||||
|
//Add addAnswer when we go from answer to question or section or end
|
||||||
|
//Add addQuestion when we go from question to section or end
|
||||||
|
|
||||||
|
if(lastType == 'answer' && (d.data[x].type == 'question' || d.data[x].type == 'section')){
|
||||||
|
this.addAnswerButton(lastId['question']);
|
||||||
|
buttons['answer'] = 1;
|
||||||
|
}
|
||||||
|
else if(lastType == 'question' && d.data[x].type == 'section'){
|
||||||
|
this.addQuestionButton(lastId['section']);
|
||||||
|
buttons['question'] = 1;
|
||||||
|
}
|
||||||
|
else if(d.data[x].type == 'section' && lastType == 'section' && lastId['section'] == focus){
|
||||||
|
this.addQuestionButton(lastId['section']);
|
||||||
|
buttons['question'] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var node = document.createElement('li');
|
||||||
|
|
||||||
|
if(d.data[x].id == focus){
|
||||||
|
node.className = "s"+d.data[x].type;
|
||||||
|
}else{
|
||||||
|
node.className = d.data[x].type;
|
||||||
|
}
|
||||||
|
|
||||||
|
node.innerHTML = d.data[x].text;
|
||||||
|
node.id = d.data[x].id;
|
||||||
|
new Survey.DDList(node.id,"sections");
|
||||||
|
document.getElementById('sections').appendChild(node);
|
||||||
|
YAHOO.util.Event.addListener(d.data[x].id, "click", this.clicked);
|
||||||
|
|
||||||
|
lastType = d.data[x].type;
|
||||||
|
lastId[d.data[x].type] = d.data[x].id;
|
||||||
|
}
|
||||||
|
if(lastType == 'answer' && ! buttons['answer']){
|
||||||
|
this.addAnswerButton(lastId['question']);
|
||||||
|
this.addQuestionButton(lastId['section']);
|
||||||
|
}else if(lastType == 'question' || lastType == 'section' && ! buttons['question']){
|
||||||
|
this.addQuestionButton(lastId['section']);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addSectionButton();
|
||||||
|
|
||||||
|
this.loadObjectEdit(d.edit);
|
||||||
|
lastDataSet = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.addSection = function(){
|
||||||
|
Survey.Comm.newSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.addQuestion = function(e,sid){
|
||||||
|
Survey.Comm.newQuestion(sid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.addSectionButton = function(){
|
||||||
|
var node = document.createElement('li');
|
||||||
|
node.innerHTML = "<span id='newSection'></span>";
|
||||||
|
document.getElementById('sections').appendChild(node);
|
||||||
|
var button = new YAHOO.widget.Button({ label:"Add Section", id:"addsection", container:"newSection" });
|
||||||
|
button.on("click", this.addSection);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.addQuestionButton = function(qid){
|
||||||
|
var node = document.createElement('li');
|
||||||
|
node.className = 'newQuestion';
|
||||||
|
node.innerHTML = "<span id='newQuestion'></span>";
|
||||||
|
document.getElementById('sections').appendChild(node);
|
||||||
|
var button = new YAHOO.widget.Button({ label:"Add Question", id:'addquestion', container:"newQuestion"});//, onclick:{fn:this.addQuestion} });
|
||||||
|
button.on("click", this.addQuestion,qid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.addAnswerButton = function(aid){
|
||||||
|
var node = document.createElement('li');
|
||||||
|
node.id = 'newAnswer';
|
||||||
|
node.className = 'newAnswer';
|
||||||
|
document.getElementById('sections').appendChild(node);
|
||||||
|
var button = new YAHOO.widget.Button({ label:"Add Answer", id:aid, container:"newAnswer" });
|
||||||
|
button.on("click", this.addAnswer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.loadObjectEdit = function(edit){
|
||||||
|
if(edit){
|
||||||
|
console.log('was an edit'+edit.type);
|
||||||
|
if(edit.type == "loadSection"){
|
||||||
|
console.log('loadsection');
|
||||||
|
Survey.SectionTemplate.loadSection(edit.params);
|
||||||
|
}
|
||||||
|
else if(edit.type == "loadQuestion"){
|
||||||
|
console.log('loadquestion');
|
||||||
|
Survey.QuestionTemplate.loadQuestion(edit.params);
|
||||||
|
}
|
||||||
|
else if(edit.type == "loadAnswer"){
|
||||||
|
Survey.AnswerTemplate.loadAnswer(edit.params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.loadLast = function(){
|
||||||
|
this.loadData(lastDataSet);
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
/*Survey.SectionTemplate = new function(){
|
||||||
|
this.qpp;
|
||||||
|
this.randomizeQuestions;
|
||||||
|
this.questionsOnSectionPage;
|
||||||
|
|
||||||
|
this.returnData = function(){
|
||||||
|
var data = {};
|
||||||
|
data['type'] = "section";
|
||||||
|
data["sectionText"] = document.getElementById('text').value;
|
||||||
|
data['sectionName'] = document.getElementById('sectionName').value;
|
||||||
|
data['questionsPerPage'] = this.qpp.get('label');
|
||||||
|
data['randomizeQuestions'] = this.randomizeQuestions.get('checkedButton').get('value');
|
||||||
|
data['questionsOnSectionPage'] = this.questionsOnSectionPage.get('checkedButton').get('value');
|
||||||
|
data['Survey_sectionId'] = document.getElementById('Survey_sectionId').value;
|
||||||
|
Survey.Comm.submitEdit(data);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
this.qppClick = function(p_sType, p_aArgs, p_oItem) {
|
||||||
|
Survey.SectionTemplate.qpp.set("label", p_oItem.cfg.getProperty("text"));
|
||||||
|
}
|
||||||
|
this.loadSection = function(params){
|
||||||
|
document.getElementById('edit').innerHTML = "\
|
||||||
|
<p>Section Number: "+params.sequenceNumber + "\
|
||||||
|
<input type='hidden' id='Survey_sectionId' value='"+params.Survey_sectionId+"'>\
|
||||||
|
<p>Section Name: <input id='sectionName' value='"+params.sectionName + "' type=text>\
|
||||||
|
<hr>\
|
||||||
|
<p>Randomize Questions: <span id='randomQuestions'></span>\
|
||||||
|
<p>Question per Page: <span id='questionsPerPage'></span>\
|
||||||
|
<p>Questions on Section Page: <span id='questionsOnSectionPage'></span>\
|
||||||
|
<hr>\
|
||||||
|
<p>Section Text:</p> <textarea id=text maxlength=2056 cols=30 rows=5>"+ params.sectionText +"</textarea>\
|
||||||
|
<p><input type='button' onclick='Survey.SectionTemplate.returnData()' value='Save Section'>\
|
||||||
|
";
|
||||||
|
|
||||||
|
this.randomizeQuestions = new YAHOO.widget.ButtonGroup({
|
||||||
|
id: "randomizeQuestions",
|
||||||
|
name: "randomizeQuestions",
|
||||||
|
container: "randomQuestions" });
|
||||||
|
|
||||||
|
this.randomizeQuestions.addButtons([
|
||||||
|
{ label: "Yes", value: "1" },
|
||||||
|
{ label: "No", value: "0" }
|
||||||
|
]);
|
||||||
|
|
||||||
|
if(params['randomizeQuestions'] == 1){this.randomizeQuestions.check(0);}
|
||||||
|
else{this.randomizeQuestions.check(1);}
|
||||||
|
|
||||||
|
var qppList = [];
|
||||||
|
|
||||||
|
for(var i = 1; i <= 10; i++){
|
||||||
|
qppList.push({ text: i.toString(), onclick: { fn: Survey.SectionTemplate.qppClick } });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.qpp = new YAHOO.widget.Button({
|
||||||
|
type: "menu",
|
||||||
|
label: "1",
|
||||||
|
name: "mymenubutton",
|
||||||
|
menu: qppList,
|
||||||
|
container: "questionsPerPage" });
|
||||||
|
this.qpp.set("label", params['questionsPerPage']);
|
||||||
|
|
||||||
|
|
||||||
|
this.questionsOnSectionPage = new YAHOO.widget.ButtonGroup({
|
||||||
|
id: "questionsOnSectionPage",
|
||||||
|
name: "questionsOnSectionpage",
|
||||||
|
container: "questionsOnSectionPage" });
|
||||||
|
this.questionsOnSectionPage.addButtons([
|
||||||
|
{ label: "Yes", value: "1" },
|
||||||
|
{ label: "No", value: "0" }
|
||||||
|
]);
|
||||||
|
if(params['questionsOnSectionPage'] == 1){this.questionsOnSectionPage.check(0);}
|
||||||
|
else{this.questionsOnSectionPage.check(1);}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
*/
|
||||||
|
/*Survey.QuestionTemplate = new function(){
|
||||||
|
this.loadQuestion = function(params){
|
||||||
|
for(var i in params){
|
||||||
|
console.log(i+' '+params[i]);
|
||||||
|
}
|
||||||
|
document.getElementById('edit').innerHTML = "\
|
||||||
|
<p>Question Number: "+params.sequenceNumber + "\
|
||||||
|
<input type='hidden' id='Survey_sectionId' value='"+params.Survey_sectionId+"'>\
|
||||||
|
<input type='hidden' id='Survey_questionId' value='"+params.Survey_questionId+"'>\
|
||||||
|
|
||||||
|
<p>Randomize Questions: <span id='randomAnswers'></span>\
|
||||||
|
<p>Question per Page: <span id='questionsPerPage'></span>\
|
||||||
|
<p>Questions on Section Page: <span id='questionsOnSectionPage'></span>\
|
||||||
|
<hr>\
|
||||||
|
<p>Section Text:</p> <textarea id=text maxlength=2056 cols=30 rows=5>"+ params.sectionText +"</textarea>\
|
||||||
|
<p><input type='button' onclick='Survey.SectionTemplate.returnData()' value='Save Section'>\
|
||||||
|
";
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
*/
|
||||||
|
Survey.AnswerTemplate = new function(){
|
||||||
|
this.loadAnswer = function(){
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------
|
||||||
|
|
||||||
|
Survey.Comm = new function(){
|
||||||
|
|
||||||
|
//p is a string that contains the id of the Survey that is of interest. To get Section 2 Question 3 Answer 4 pass '2-3-4'.
|
||||||
|
var request = function(sUrl,callback,postData){
|
||||||
|
YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
|
||||||
|
}
|
||||||
|
var callback = {
|
||||||
|
success:function(o){
|
||||||
|
Survey.Data.loadData(YAHOO.lang.JSON.parse(o.responseText));
|
||||||
|
},
|
||||||
|
failure: function(o){
|
||||||
|
alert("Last request failed");
|
||||||
|
Survey.Data.loadLast();
|
||||||
|
},
|
||||||
|
argument:["what","is","this","for"],
|
||||||
|
timeout: 1000
|
||||||
|
};
|
||||||
|
this.loadSurvey = function(p){
|
||||||
|
var postData = "data="+p;
|
||||||
|
var sUrl = "?func=loadSurvey";
|
||||||
|
request(sUrl,callback,postData);
|
||||||
|
}
|
||||||
|
this.dragDrop = function(target,before){
|
||||||
|
var p = {};
|
||||||
|
p['target'] = target;
|
||||||
|
p['before'] = before;
|
||||||
|
var postData = "data="+YAHOO.lang.JSON.stringify(p);
|
||||||
|
var sUrl = "?func=dragDrop";
|
||||||
|
request(sUrl,callback,postData);
|
||||||
|
}
|
||||||
|
this.submitEdit = function(p){
|
||||||
|
var postData = "data="+YAHOO.lang.JSON.stringify(p);
|
||||||
|
var sUrl = "?func=submitEdit";
|
||||||
|
request(sUrl,callback,postData);
|
||||||
|
}
|
||||||
|
this.newSection = function(){
|
||||||
|
var sUrl = "?func=newSection";
|
||||||
|
request(sUrl,callback);
|
||||||
|
}
|
||||||
|
this.newQuestion = function(sid){
|
||||||
|
var postData = "data="+sid;
|
||||||
|
var sUrl = "?func=newQuestion";
|
||||||
|
request(sUrl,callback,postData);
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Initialize survey
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------
|
||||||
|
Survey.OnLoad = function() {
|
||||||
|
var e = YAHOO.util.Event;
|
||||||
|
return {
|
||||||
|
init: function() {
|
||||||
|
//e.onDOMReady(this.initHandler, "The onDOMReady event fired. The DOM is now safe to modify via script.");
|
||||||
|
e.onDOMReady(this.initHandler);
|
||||||
|
},
|
||||||
|
initHandler: function(){
|
||||||
|
new YAHOO.util.DDTarget("sections","sections");
|
||||||
|
Survey.Comm.loadSurvey();
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
Survey.OnLoad.init();
|
||||||
67
www/extras/wobject/Survey/editsurvey/answer.js
Normal file
67
www/extras/wobject/Survey/editsurvey/answer.js
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
if (typeof Survey == "undefined") {
|
||||||
|
var Survey = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Survey.AnswerTemplate = new function(){
|
||||||
|
this.params;
|
||||||
|
this.loadAnswer = function(params){
|
||||||
|
for(var p in params){
|
||||||
|
if(params[p] == undefined){params[p] = '';}
|
||||||
|
}
|
||||||
|
|
||||||
|
var html = "\
|
||||||
|
<div id='answer'>\
|
||||||
|
<div class='hd'>Please enter answer information</div>\
|
||||||
|
<div class='bd'>\
|
||||||
|
\
|
||||||
|
<form name='form' method='POST' action='?func=submitAnswerEdit'>\
|
||||||
|
\
|
||||||
|
<p>Answer Number: "+params.sequenceNumber + "\
|
||||||
|
\
|
||||||
|
<input type='hidden' name='Survey_sectionId' value='"+params.Survey_sectionId+"'>\
|
||||||
|
<input type='hidden' name='Survey_questionId' value='"+params.Survey_questionId+"'>\
|
||||||
|
<input type='hidden' name='Survey_answerId' value='"+params.Survey_answerId+"'>";
|
||||||
|
html = html + "<p>Answer Text:\n<textarea name='answerText'>"+params.answerText+"</textArea>\n";
|
||||||
|
html = html + "<p>Recorded Answer\n<textarea name='recordedAnswer'>"+params.recordedAnswer+"</textArea>\n";
|
||||||
|
html = html + "<p>Jump to Question:<input type=text value='"+params.gotoQuestion+"' name=gotoQuestion size=4>";
|
||||||
|
html = html + "<p>Is this the correct answer:\n" +
|
||||||
|
this.makeRadio('isCorrect',[{text:'Yes',value:1},{text:'No',value:0}],params.isCorrect);
|
||||||
|
html = html + "<p>Min:<input type=text value='"+params.min+"' name=min size=2>";
|
||||||
|
html = html + "<p>Max:<input type=text value='"+params.max+"' name=max size=2>";
|
||||||
|
html = html + "<p>Step:<input type=text value='"+params.step+"' name=step size=2>";
|
||||||
|
html = html + "<p>Verbatim:\n" +
|
||||||
|
this.makeRadio('verbatim',[{text:'Yes',value:1},{text:'No',value:0}],params.verbatim);
|
||||||
|
document.getElementById('edit').innerHTML = html;
|
||||||
|
|
||||||
|
var butts = [{ text:"Submit", handler:function(){this.submit();}, isDefault:true },{ text:"Cancel", handler:function(){this.cancel();}} ];
|
||||||
|
if(params.Survey_answerId != ''){
|
||||||
|
butts[2] = { text:"Delete", handler:function(){Survey.Comm.deleteAnswer(Survey.AnswerTemplate.params.Survey_answerId);}};
|
||||||
|
}
|
||||||
|
|
||||||
|
var form = new YAHOO.widget.Dialog("answer",
|
||||||
|
{ width : "300px",
|
||||||
|
fixedcenter : true,
|
||||||
|
visible : false,
|
||||||
|
constraintoviewport : true,
|
||||||
|
buttons : butts
|
||||||
|
});
|
||||||
|
|
||||||
|
form.callback = Survey.Comm.callback;
|
||||||
|
form.render();
|
||||||
|
form.show();
|
||||||
|
this.params = params;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.makeRadio = function(name,values,checked){
|
||||||
|
var html = '';
|
||||||
|
for(var i in values){
|
||||||
|
if(checked == values[i]['value']){
|
||||||
|
html = html+ "<input type='radio' name='" + name + "' value='" + values[i]['value'] + "' checked>" + values[i]['text'];
|
||||||
|
}else{
|
||||||
|
html = html+ "<input type='radio' name='" + name + "' value='" + values[i]['value'] + "' >" + values[i]['text'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html = html + "\n";
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
}();
|
||||||
67
www/extras/wobject/Survey/editsurvey/comm.js
Normal file
67
www/extras/wobject/Survey/editsurvey/comm.js
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
if (typeof Survey == "undefined") {
|
||||||
|
var Survey = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Survey.Comm = new function(){
|
||||||
|
|
||||||
|
var request = function(sUrl,callback,postData){
|
||||||
|
YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
|
||||||
|
}
|
||||||
|
this.callback = {
|
||||||
|
success:function(o){
|
||||||
|
Survey.Data.loadData(YAHOO.lang.JSON.parse(o.responseText));
|
||||||
|
},
|
||||||
|
failure: function(o){
|
||||||
|
alert("Last request failed");
|
||||||
|
Survey.Data.loadLast();
|
||||||
|
},
|
||||||
|
timeout: 1000
|
||||||
|
};
|
||||||
|
this.loadSurvey = function(p){
|
||||||
|
var postData = "data="+p;
|
||||||
|
var sUrl = "?func=loadSurvey";
|
||||||
|
request(sUrl,this.callback,postData);
|
||||||
|
}
|
||||||
|
this.dragDrop = function(target,before){
|
||||||
|
var p = {};
|
||||||
|
p['target'] = target;
|
||||||
|
p['before'] = before;
|
||||||
|
var postData = "data="+YAHOO.lang.JSON.stringify(p);
|
||||||
|
var sUrl = "?func=dragDrop";
|
||||||
|
request(sUrl,this.callback,postData);
|
||||||
|
}
|
||||||
|
this.submitEdit = function(p){
|
||||||
|
var postData = "data="+YAHOO.lang.JSON.stringify(p);
|
||||||
|
var sUrl = "?func=submitEdit";
|
||||||
|
request(sUrl,this.callback,postData);
|
||||||
|
}
|
||||||
|
this.newSection = function(){
|
||||||
|
var sUrl = "?func=newSection";
|
||||||
|
request(sUrl,this.callback);
|
||||||
|
}
|
||||||
|
this.newQuestion = function(sid){
|
||||||
|
var postData = "data="+sid;
|
||||||
|
var sUrl = "?func=newQuestion";
|
||||||
|
request(sUrl,this.callback,postData);
|
||||||
|
}
|
||||||
|
this.newAnswer = function(sid,qid){
|
||||||
|
var postData = "data="+YAHOO.lang.JSON.stringify([sid,qid]);
|
||||||
|
var sUrl = "?func=newAnswer";
|
||||||
|
request(sUrl,this.callback,postData);
|
||||||
|
}
|
||||||
|
this.deleteAnswer = function(id){
|
||||||
|
var postData = "data="+id;
|
||||||
|
var sUrl = "?func=deleteAnswer";
|
||||||
|
request(sUrl,this.callback,postData);
|
||||||
|
}
|
||||||
|
this.deleteQuestion = function(id){
|
||||||
|
var postData = "data="+id;
|
||||||
|
var sUrl = "?func=deleteQuestion";
|
||||||
|
request(sUrl,this.callback,postData);
|
||||||
|
}
|
||||||
|
this.deleteSection = function(id){
|
||||||
|
var postData = "data="+id;
|
||||||
|
var sUrl = "?func=deleteSection";
|
||||||
|
request(sUrl,this.callback,postData);
|
||||||
|
}
|
||||||
|
}();
|
||||||
107
www/extras/wobject/Survey/editsurvey/question.js
Normal file
107
www/extras/wobject/Survey/editsurvey/question.js
Normal file
|
|
@ -0,0 +1,107 @@
|
||||||
|
if (typeof Survey == "undefined") {
|
||||||
|
var Survey = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Survey.QuestionTemplate = new function(){
|
||||||
|
|
||||||
|
this.loadQuestion = function(params){
|
||||||
|
|
||||||
|
for(var p in params){
|
||||||
|
if(params[p] == undefined){params[p] = '';}
|
||||||
|
}
|
||||||
|
|
||||||
|
var html = "\
|
||||||
|
<div id='question'>\
|
||||||
|
<div class='hd'>Please enter question information</div>\
|
||||||
|
<div class='bd'>\
|
||||||
|
\
|
||||||
|
<form name='form' method='POST' action='?func=submitQuestionEdit'>\
|
||||||
|
<p>Question Number: "+params.sequenceNumber + "\
|
||||||
|
\
|
||||||
|
<input type='hidden' name='Survey_sectionId' value='"+params.Survey_sectionId+"'>\
|
||||||
|
<input type='hidden' name='Survey_questionId' value='"+params.Survey_questionId+"'>\
|
||||||
|
<p>Question Text:\n";
|
||||||
|
if(params.questionText == ''){
|
||||||
|
html = html + "<textarea name='questionText'>Enter Text Here</textArea>\n";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
html = html + "<textarea name='questionText'>"+params.questionText+"</textArea>\n";
|
||||||
|
}
|
||||||
|
html = html + "<p>Question custom variable name:<input maxlength=35 size=10 type=text value='"+ params.questionVariable +"' name=questionVariable size=2>";
|
||||||
|
html = html + "<p>Randomize answers:";
|
||||||
|
|
||||||
|
html = html+ this.makeRadio('randomizeAnswers',[{text:'Yes',value:1},{text:'No',value:0}],params.randomizeAnswers);
|
||||||
|
html = html + "<p>Previous answers to display:<textarea name='previousAnswerWords' cols=4 rows=2>"+params.previousAnswerWords+"</textarea>";
|
||||||
|
html = html + "<p>Question type:";
|
||||||
|
|
||||||
|
var questions = ['Multiple Choice','Gender','Yes/No','True/False','Agree/Disagree','Oppose/Support','Importance','Likelihood','Certainty','Satisfaction',
|
||||||
|
'Confidence','Effectiveness','Concern','Risk','Threat','Security','Ideology','Race','Party','Education',
|
||||||
|
'Text', 'Email', 'Phone Number', 'Text Date', 'Currency',
|
||||||
|
'Slider','Dual Slider - Range','Multi Slider - Allocate', 'Date','Date Range', 'File Upload','Hidden'];
|
||||||
|
|
||||||
|
html = html + this.makeMenu('questionType',questions,questions,params.questionType);
|
||||||
|
|
||||||
|
html = html + "\
|
||||||
|
<p>Randomized words:\
|
||||||
|
<textarea name=randomizedWords>"+params.randomizedWords+"</textArea>\
|
||||||
|
<p>Vertical display:";
|
||||||
|
|
||||||
|
html = html+ this.makeRadio('verticalDisplay',[{text:'Yes',value:1},{text:'No',value:0}],params.verticalDisplay);
|
||||||
|
html = html + "<p>Allow comment:";
|
||||||
|
html = html+ this.makeRadio('allowComment',[{text:'Yes',value:1},{text:'No',value:0}],params.allowComment);
|
||||||
|
html = html + "<p>Maximum number of answers:<input type=text value='"+params.maxAnswers+"' name=maxAnswers size=2>";
|
||||||
|
html = html + "<p>Required:";
|
||||||
|
html = html+ this.makeRadio('required',[{text:'Yes',value:1},{text:'No',value:0}],params.required);
|
||||||
|
html = html + "\
|
||||||
|
</form>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
";
|
||||||
|
|
||||||
|
document.getElementById('edit').innerHTML = html;
|
||||||
|
|
||||||
|
|
||||||
|
var butts = [ { text:"Submit", handler:function(){this.submit();}, isDefault:true }, { text:"Cancel", handler:function(){this.cancel();}} ];
|
||||||
|
if(params.Survey_questionId != ''){
|
||||||
|
butts[2] = {text:"Delete", handler:function(){Survey.Comm.deleteQuestion(params.Survey_questionId);}};
|
||||||
|
}
|
||||||
|
|
||||||
|
var form = new YAHOO.widget.Dialog("question",
|
||||||
|
{ width : "315px",
|
||||||
|
fixedcenter : true,
|
||||||
|
visible : false,
|
||||||
|
constraintoviewport : true,
|
||||||
|
buttons : butts
|
||||||
|
} );
|
||||||
|
|
||||||
|
form.callback = Survey.Comm.callback;
|
||||||
|
form.render();
|
||||||
|
form.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
this.makeMenu = function(name,values,text,selected){
|
||||||
|
var html = "<select name='"+name+"'>\n";
|
||||||
|
for(var i in values){
|
||||||
|
if(values[i] == selected){
|
||||||
|
html = html + "<option value='"+values[i]+"' selected>"+text[i]+"</option>\n";
|
||||||
|
}else{
|
||||||
|
html = html + "<option value='"+values[i]+"' >"+text[i]+"</option>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html = html + "</select>\n";
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
this.makeRadio = function(name,values,checked){
|
||||||
|
var html = '';
|
||||||
|
for(var i in values){
|
||||||
|
if(checked == values[i]['value']){
|
||||||
|
html = html+ "<input type='radio' name='" + name + "' value='" + values[i]['value'] + "' checked>" + values[i]['text'];
|
||||||
|
}else{
|
||||||
|
html = html+ "<input type='radio' name='" + name + "' value='" + values[i]['value'] + "' >" + values[i]['text'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html = html + "\n";
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
}();
|
||||||
93
www/extras/wobject/Survey/editsurvey/section.js
Normal file
93
www/extras/wobject/Survey/editsurvey/section.js
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
if (typeof Survey == "undefined") {
|
||||||
|
var Survey = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Survey.SectionTemplate = new function(){
|
||||||
|
|
||||||
|
this.loadSection = function(params){
|
||||||
|
|
||||||
|
for(var p in params){
|
||||||
|
if(params[p] == undefined){params[p] = '';}
|
||||||
|
}
|
||||||
|
|
||||||
|
var html = "\
|
||||||
|
<div id='section'>\
|
||||||
|
<div class='hd'>Please enter section formation</div>\
|
||||||
|
<div class='bd'>\
|
||||||
|
<form name='form' method='POST' action='?func=submitSectionEdit'>\
|
||||||
|
<p>Section Number: "+params.sequenceNumber + "\
|
||||||
|
<input type='hidden' name='Survey_sectionId' value='"+params.Survey_sectionId+"'>\
|
||||||
|
<p>Section Name: <input name='sectionName' value='"+params.sectionName + "' type=text>\
|
||||||
|
<hr>\
|
||||||
|
<p>Randomize Questions:";
|
||||||
|
if(params.randomizeQuestions == 1){
|
||||||
|
html = html+ "\
|
||||||
|
<input type='radio' name='randomizeQuestions' value=1 checked>Yes\
|
||||||
|
<input type='radio' name='randomizeQuestions' value=0>No";
|
||||||
|
}else{
|
||||||
|
html = html+ "\
|
||||||
|
<input type='radio' name='randomizeQuestions' value=1>Yes\
|
||||||
|
<input type='radio' name='randomizeQuestions' value=0 checked>No";
|
||||||
|
}
|
||||||
|
html = html + "\
|
||||||
|
<p>Question per Page:\
|
||||||
|
<select name='questionsPerPage'>";
|
||||||
|
for(var i=1;i<=10;i++){
|
||||||
|
if(i == params.questionsPerPage){
|
||||||
|
html = html + "<option value='"+i+"' selected>"+i+"</option>";
|
||||||
|
}else{
|
||||||
|
html = html + "<option value='"+i+"'/>"+i+"</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html = html + "</select>\
|
||||||
|
<p>Questions on Section Page: <span id='questionsOnSectionPage'></span>";
|
||||||
|
if(params.questionsOnSectionPage == 1){
|
||||||
|
html = html+ "\
|
||||||
|
<input type='radio' name='questionsOnSectionPage' value=1 checked>Yes\
|
||||||
|
<input type='radio' name='questionsOnSectionPage' value=0>No";
|
||||||
|
}else{
|
||||||
|
html = html+ "\
|
||||||
|
<input type='radio' name='questionsOnSectionPage' value=1>Yes\
|
||||||
|
<input type='radio' name='questionsOnSectionPage' value=0 checked>No";
|
||||||
|
}
|
||||||
|
html = html + "\
|
||||||
|
<hr>\
|
||||||
|
<p>Section Text:</p> <textarea name=sectionText maxlength=2056 cols=30 rows=5>"+ params.sectionText +"</textarea>\
|
||||||
|
";
|
||||||
|
html = html + "<p>Title on every page: " + this.makeRadio('everyPageTitle',[{text:'Yes',value:1},{text:'No',value:0}],params.everyPageTitle);
|
||||||
|
html = html + "<p>Text on every page: " + this.makeRadio('everyPageText',[{text:'Yes',value:1},{text:'No',value:0}],params.everyPageText);
|
||||||
|
html = html + "<p>Terminal section: " + this.makeRadio('terminal',[{text:'Yes',value:1},{text:'No',value:0}],params.terminal);
|
||||||
|
html = html + "<p> Terminal section URL: <input type=text name=terminalURL value='"+params.terminalURL+"'>";
|
||||||
|
document.getElementById('edit').innerHTML = html;
|
||||||
|
|
||||||
|
var butts = [ { text:"Submit", handler:function(){this.submit();}, isDefault:true }, { text:"Cancel", handler:function(){this.cancel();}} ];
|
||||||
|
if(params.Survey_sectionId != ''){
|
||||||
|
butts[2] = {text:"Delete", handler:function(){Survey.Comm.deleteSection(params.Survey_sectionId);}};
|
||||||
|
}
|
||||||
|
|
||||||
|
var form = new YAHOO.widget.Dialog("section",
|
||||||
|
{ width : "300px",
|
||||||
|
fixedcenter : true,
|
||||||
|
visible : false,
|
||||||
|
constraintoviewport : true,
|
||||||
|
buttons : butts
|
||||||
|
} );
|
||||||
|
|
||||||
|
form.callback = Survey.Comm.callback;
|
||||||
|
form.render();
|
||||||
|
form.show();
|
||||||
|
}
|
||||||
|
this.makeRadio = function(name,values,checked){
|
||||||
|
var html = '';
|
||||||
|
for(var i in values){
|
||||||
|
if(checked == values[i]['value']){
|
||||||
|
html = html+ "<input type='radio' name='" + name + "' value='" + values[i]['value'] + "' checked>" + values[i]['text'];
|
||||||
|
}else{
|
||||||
|
html = html+ "<input type='radio' name='" + name + "' value='" + values[i]['value'] + "' >" + values[i]['text'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html = html + "\n";
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
15
www/extras/wobject/Survey/loadTemplate.pl
Executable file
15
www/extras/wobject/Survey/loadTemplate.pl
Executable file
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
use DBI;
|
||||||
|
use File::Slurp;
|
||||||
|
my $dbh = DBI->connect("DBI:mysql:database=www_norman_com;host=localhost;port=3306", "webgui", "webgui", { RaiseError => 1, AutoCommit => 1 }) or die $!;
|
||||||
|
|
||||||
|
my $file = read_file("template.html");
|
||||||
|
|
||||||
|
my $sth = $dbh->prepare(qq{ UPDATE template SET template = ?,revisionDate = ? WHERE assetid = ? });
|
||||||
|
$sth->execute($file, time(),"M3RkJY763xgE1SLYQ4pBqA");
|
||||||
|
$dbh->disconnect();
|
||||||
|
|
||||||
34
www/extras/wobject/Survey/survey.css
Normal file
34
www/extras/wobject/Survey/survey.css
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
div.dateanswer {
|
||||||
|
min-height: 250px;
|
||||||
|
}
|
||||||
|
div.slider-bg {
|
||||||
|
position: relative;
|
||||||
|
background:url(/extras/wobject/Survey/bg-fader.gif) 5px 0 no-repeat;
|
||||||
|
height:28px;
|
||||||
|
width:228px;
|
||||||
|
}
|
||||||
|
div.slider-thumb {
|
||||||
|
cursor:default;
|
||||||
|
position: absolute;
|
||||||
|
top: 4px;
|
||||||
|
}
|
||||||
|
div.slider-min-thumb {
|
||||||
|
cursor:default;
|
||||||
|
position: absolute;
|
||||||
|
top: 4px;
|
||||||
|
}
|
||||||
|
div.slider-max-thumb {
|
||||||
|
cursor:default;
|
||||||
|
position: absolute;
|
||||||
|
top: 4px;
|
||||||
|
}
|
||||||
|
#headertitle {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#headertext {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#questions {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
97
www/extras/wobject/Survey/survey.css.backup
Normal file
97
www/extras/wobject/Survey/survey.css.backup
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
|
||||||
|
div.trashcan {
|
||||||
|
border: 1px solid gray;
|
||||||
|
width: 175px;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
div.workarea {
|
||||||
|
padding:10px;
|
||||||
|
padding-top:40px;
|
||||||
|
float:left
|
||||||
|
}
|
||||||
|
|
||||||
|
div.editarea {
|
||||||
|
margin-top:40px;
|
||||||
|
padding:10px;
|
||||||
|
float:left;
|
||||||
|
border: 1px solid gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.editquestion {
|
||||||
|
padding:10px;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
div.editanswer {
|
||||||
|
padding:10px;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#submitbutton { padding:20px; }
|
||||||
|
|
||||||
|
div.entry {
|
||||||
|
padding-bottom:10px;
|
||||||
|
padding-left:10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.draglist {
|
||||||
|
position: relative;
|
||||||
|
width: 300px;
|
||||||
|
background: #f7f7f7;
|
||||||
|
border: 1px solid gray;
|
||||||
|
list-style: none;
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
padding-bottom:20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.draglist li {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.questionList {
|
||||||
|
position: relative;
|
||||||
|
background: #f7f7f7;
|
||||||
|
border: 1px solid gray;
|
||||||
|
list-style: none;
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
min-height: 40px
|
||||||
|
}
|
||||||
|
|
||||||
|
li.section {
|
||||||
|
background-color: #CCCCFF;
|
||||||
|
border:1px solid #7EA6B2;
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.sselected {
|
||||||
|
background-color: #E76300;
|
||||||
|
border:1px solid #7EA6B2;
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.qselected {
|
||||||
|
background-color: #CC6600;
|
||||||
|
border:1px solid #7EA6B2;
|
||||||
|
cursor: move;
|
||||||
|
padding-left:15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.question {
|
||||||
|
background-color: #D1E6EC;
|
||||||
|
border:1px solid #7EA6B2;
|
||||||
|
padding-left:15px;
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.answer {
|
||||||
|
background-color: #D1E6EC;
|
||||||
|
border:1px solid #7EA6B2;
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
|
li.aselected {
|
||||||
|
background-color: #CC6600;
|
||||||
|
border:1px solid #7EA6B2;
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
|
|
||||||
132
www/extras/wobject/Survey/surveyedit.css
Normal file
132
www/extras/wobject/Survey/surveyedit.css
Normal file
|
|
@ -0,0 +1,132 @@
|
||||||
|
|
||||||
|
div.testarea {
|
||||||
|
width: 200px;
|
||||||
|
height: 100px;
|
||||||
|
z-index: 999;
|
||||||
|
border: 1px solid gray;
|
||||||
|
background: #f7f7f7;
|
||||||
|
position: absolute;
|
||||||
|
top: 5%;
|
||||||
|
left:5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.trashcan {
|
||||||
|
border: 1px solid gray;
|
||||||
|
width: 175px;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
div.workarea {
|
||||||
|
padding:10px;
|
||||||
|
padding-top:40px;
|
||||||
|
float:left
|
||||||
|
}
|
||||||
|
|
||||||
|
div.editarea {
|
||||||
|
margin-top:40px;
|
||||||
|
padding:10px;
|
||||||
|
float:left;
|
||||||
|
border: 1px solid gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.editquestion {
|
||||||
|
padding:10px;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
div.editanswer {
|
||||||
|
padding:10px;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#submitbutton { padding:20px; }
|
||||||
|
|
||||||
|
div.entry {
|
||||||
|
padding-bottom:10px;
|
||||||
|
padding-left:10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.draglist {
|
||||||
|
position: relative;
|
||||||
|
width: 300px;
|
||||||
|
background: #f7f7f7;
|
||||||
|
border: 1px solid gray;
|
||||||
|
list-style: none;
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
padding-bottom:20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.draglist li {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.questionList {
|
||||||
|
position: relative;
|
||||||
|
background: #f7f7f7;
|
||||||
|
border: 1px solid gray;
|
||||||
|
list-style: none;
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
min-height: 40px
|
||||||
|
}
|
||||||
|
|
||||||
|
li.section {
|
||||||
|
background-color: #CCCCFF;
|
||||||
|
border:1px solid #7EA6B2;
|
||||||
|
cursor: move;
|
||||||
|
min-height: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.ssection {
|
||||||
|
background-color: #E76300;
|
||||||
|
border:1px solid #7EA6B2;
|
||||||
|
cursor: move;
|
||||||
|
min-height: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.squestion {
|
||||||
|
background-color: #CC6600;
|
||||||
|
border:1px solid #7EA6B2;
|
||||||
|
cursor: move;
|
||||||
|
padding-left:15px;
|
||||||
|
width: 80%;
|
||||||
|
min-height: 10px;
|
||||||
|
}
|
||||||
|
li.newQuestion {
|
||||||
|
# background-color: #D1E6EC;
|
||||||
|
# border:1px solid #7EA6B2;
|
||||||
|
# cursor: move;
|
||||||
|
padding-left:25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.question {
|
||||||
|
background-color: #D1E6EC;
|
||||||
|
border:1px solid #7EA6B2;
|
||||||
|
cursor: move;
|
||||||
|
padding-left:15px;
|
||||||
|
width:80%;
|
||||||
|
min-height: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.answer {
|
||||||
|
background-color: #D1E6EC;
|
||||||
|
border:1px solid #7EA6B2;
|
||||||
|
cursor: move;
|
||||||
|
padding-left:50px;
|
||||||
|
width:60%;
|
||||||
|
min-height: 10px;
|
||||||
|
}
|
||||||
|
li.sanswer {
|
||||||
|
background-color: #CC6600;
|
||||||
|
border:1px solid #7EA6B2;
|
||||||
|
cursor: move;
|
||||||
|
padding-left:50px;
|
||||||
|
width:60%;
|
||||||
|
min-height: 10px;
|
||||||
|
}
|
||||||
|
li.newAnswer {
|
||||||
|
# background-color: #D1E6EC;
|
||||||
|
# border:1px solid #7EA6B2;
|
||||||
|
padding-left:50px;
|
||||||
|
# cursor: move;
|
||||||
|
}
|
||||||
|
|
||||||
159
www/extras/wobject/Survey/template.html.backup
Normal file
159
www/extras/wobject/Survey/template.html.backup
Normal file
|
|
@ -0,0 +1,159 @@
|
||||||
|
<title>WebGUI Survey Alpha I ROCK A LOT!!!</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
body { margin:0; padding:0; }
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="extras/yui/build/menu/assets/skins/sam/menu.css" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="extras/yui/build/fonts/fonts-min.css" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="extras/yui/build/button/assets/skins/sam/button.css" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript" src="extras/yui/build/utilities/utilities.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="extras/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="extras/yui/build/container/container_core.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="extras/yui/build/button/button.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="extras/yui/build/menu/menu.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript" src="extras/wobject/Survey/editsurvey.js"></script>
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="extras/wobject/Survey/survey.css" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<body class=" yui-skin-sam">
|
||||||
|
|
||||||
|
<div class="workarea">
|
||||||
|
|
||||||
|
<h3>Questions</h3>
|
||||||
|
|
||||||
|
<div id=addqbutton></div>
|
||||||
|
|
||||||
|
<div id = "addsbutton"></div>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<ul id="sections" class="draglist"></ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="workarea">
|
||||||
|
|
||||||
|
<h3>Answers</h3>
|
||||||
|
|
||||||
|
<div id=addabutton></div>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<ul id="answers" class="draglist">
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="editarea">
|
||||||
|
|
||||||
|
<div class="trashcan" id="trashcan">TrashCan.img</div>
|
||||||
|
|
||||||
|
<div id="editsection">
|
||||||
|
|
||||||
|
<h2>Edit Section</h3>
|
||||||
|
|
||||||
|
<h3 id=sid></h3>
|
||||||
|
|
||||||
|
<h4>Displayed Text:</h4>
|
||||||
|
|
||||||
|
<textarea id=sectioninputtext maxlength=2056 cols=30 rows=5></textarea>
|
||||||
|
|
||||||
|
<div id="sectionmenu"></div>
|
||||||
|
|
||||||
|
<div id="soptionmenu"></div>
|
||||||
|
|
||||||
|
<div id="ssubmitbutton"></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="editquestion">
|
||||||
|
|
||||||
|
<h2>Edit Question</h3>
|
||||||
|
|
||||||
|
<h3 id=qsid></h3>
|
||||||
|
|
||||||
|
<h3 id=qid></h3>
|
||||||
|
|
||||||
|
<h4>Question Text: </h4>
|
||||||
|
|
||||||
|
<div class=entry id="questiontext"></div>
|
||||||
|
|
||||||
|
<h4>Question Type:</h4>
|
||||||
|
|
||||||
|
<div id="questionmenu"></div>
|
||||||
|
|
||||||
|
<div id="qoptionmenu">
|
||||||
|
|
||||||
|
<h4>Options:</h4><div id="textoptions"></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="qsubmitbutton"></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="editanswer">
|
||||||
|
|
||||||
|
<h2>Edit Answer</h3>
|
||||||
|
|
||||||
|
<h3 id=asid></h3>
|
||||||
|
|
||||||
|
<h3 id=aqid></h3>
|
||||||
|
|
||||||
|
<h3 id=aid></h3>
|
||||||
|
|
||||||
|
<div id="answermenu"></div>
|
||||||
|
|
||||||
|
<div id="answerinput"></div>
|
||||||
|
|
||||||
|
<div id="asubmitbutton"></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class"area">
|
||||||
|
|
||||||
|
<div id=log></div>
|
||||||
|
|
||||||
|
<div id=log1></div>
|
||||||
|
|
||||||
|
<div id=log2></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
6
www/extras/wobject/Survey/templates/buttonHTML.txt
Normal file
6
www/extras/wobject/Survey/templates/buttonHTML.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<tmpl_loop name=answers>
|
||||||
|
<tmpl_var name='verts'>
|
||||||
|
<span class=answer id="<tmpl_var name='Survey_answerId'>container"></span>
|
||||||
|
<tmpl_var name='verte'>
|
||||||
|
<input type=hidden name=<tmpl_var name='Survey_answerId'> id=<tmpl_var name='Survey_answerId'>>
|
||||||
|
</tmpl_loop>
|
||||||
7
www/extras/wobject/Survey/templates/fileLoaderHTML.txt
Normal file
7
www/extras/wobject/Survey/templates/fileLoaderHTML.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<tmpl_loop name='answers>
|
||||||
|
<tmpl_var name='verts'>
|
||||||
|
<span class=answer>
|
||||||
|
<input type='file' name='<tmpl_var name=Survey_answerId>' id='<tmpl_var name=Survey_answerId>' size='50' />
|
||||||
|
</span>
|
||||||
|
<tmpl_var name='verte'>
|
||||||
|
</tmpl_loop>
|
||||||
151
www/extras/wobject/Survey/templates/takeSurvey.html
Normal file
151
www/extras/wobject/Survey/templates/takeSurvey.html
Normal file
|
|
@ -0,0 +1,151 @@
|
||||||
|
<div id="header">
|
||||||
|
<div id=headertitle><tmpl_var name='sectionName'></div>
|
||||||
|
<div id=headertext><tmpl_var name='sectionText'></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id='questions'>
|
||||||
|
|
||||||
|
<form name='surveyForm'>
|
||||||
|
|
||||||
|
<input type='hidden' name='section' value='<tmpl_var name='Survey_sectionId'>'>
|
||||||
|
|
||||||
|
<tmpl_loop name='questions'>
|
||||||
|
<hr>
|
||||||
|
<div class='question'>Q<tmpl_var name='sequenceNumber'>: <tmpl_var name='questionText'></div>
|
||||||
|
|
||||||
|
<tmpl_if name='multipleChoice'>
|
||||||
|
<tmpl_if name='maxMoreOne'>
|
||||||
|
<div>selections left: <span id='<tmpl_var name='Survey_questionId'>max'><tmpl_var name='maxAnswers'></div>
|
||||||
|
</tmpl_if>
|
||||||
|
</tmpl_if>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<tmpl_if name='fileLoader'>
|
||||||
|
<tmpl_loop name='answers'>
|
||||||
|
<tmpl_var name='verts'>
|
||||||
|
<span class=answer>
|
||||||
|
<input type='file' name='<tmpl_var name="Survey_answerId">' id='<tmpl_var name=Survey_answerId>' size='50' />
|
||||||
|
</span>
|
||||||
|
<tmpl_if name='verbatim'>
|
||||||
|
<span> <input type=text name= '<tmpl_var name='Survey_answerId'>verbatim' ></span>
|
||||||
|
</tmpl_if>
|
||||||
|
<tmpl_var name='verte'>
|
||||||
|
</tmpl_loop>
|
||||||
|
</tmpl_if>
|
||||||
|
|
||||||
|
<tmpl_if name='text'>
|
||||||
|
<tmpl_loop name=answers>
|
||||||
|
<tmpl_var name='verts'>
|
||||||
|
<span class=answer>
|
||||||
|
<textarea name="<tmpl_var name="Survey_answerId">"></textarea>
|
||||||
|
</span>
|
||||||
|
<tmpl_if name='verbatim'>
|
||||||
|
<span><input type=text name='<tmpl_var name='Survey_answerId'>verbatim'></span>
|
||||||
|
</tmpl_if>
|
||||||
|
<tmpl_var name='verte'>
|
||||||
|
</tmpl_loop>
|
||||||
|
</tmpl_if>
|
||||||
|
|
||||||
|
<tmpl_if name='multipleChoice'>
|
||||||
|
<tmpl_loop name=answers>
|
||||||
|
<tmpl_var name='verts'>
|
||||||
|
<span class=answer id="<tmpl_var name='Survey_answerId'>container"></span>
|
||||||
|
<tmpl_if name='verbatim'>
|
||||||
|
<span><input type=text name='<tmpl_var name='Survey_answerId'>verbatim'></span>
|
||||||
|
</tmpl_if>
|
||||||
|
<tmpl_var name='verte'>
|
||||||
|
<input type=hidden name=<tmpl_var name='Survey_answerId'> id=<tmpl_var name='Survey_answerId'>>
|
||||||
|
</tmpl_loop>
|
||||||
|
</tmpl_if>
|
||||||
|
|
||||||
|
<tmpl_if name='dateType'>
|
||||||
|
<tmpl_loop name=answers>
|
||||||
|
<tmpl_var name='verts'>
|
||||||
|
<span class=dateanswer>
|
||||||
|
<table><tr><td/><td><tmpl_var name='answerText'></td><td/></tr>
|
||||||
|
<div id='<tmpl_var name='Survey_answerId'>container'></div>
|
||||||
|
<input name='<tmpl_var name='Survey_answerId'>' id='<tmpl_var name='Survey_answerId'>' type=text></input>
|
||||||
|
<span id='<tmpl_var name='Survey_answerId'>button'></span>
|
||||||
|
<tmpl_if name='verbatim'>
|
||||||
|
<span><input type=text name='<tmpl_var name='Survey_answerId'>verbatim'></span>
|
||||||
|
</tmpl_if>
|
||||||
|
<tmpl_var name='verte'>
|
||||||
|
</tmpl_loop>
|
||||||
|
</tmpl_if>
|
||||||
|
|
||||||
|
<tmpl_if name='slider'>
|
||||||
|
<tmpl_if name='dualSlider'>
|
||||||
|
|
||||||
|
<tmpl_loop name='a1'>
|
||||||
|
<input type=hidden id='<tmpl_var name='Survey_answerId'>' name='<tmpl_var name='Survey_answerId'>' value=0>
|
||||||
|
</tmpl_loop>
|
||||||
|
<tmpl_loop name='a2'>
|
||||||
|
<input type=hidden id='<tmpl_var name='Survey_answerId'>' name='<tmpl_var name='Survey_answerId'>' value="<tmpl_var name='max'>">
|
||||||
|
</tmpl_loop>
|
||||||
|
|
||||||
|
<span class=answer>
|
||||||
|
<p><table><tr><td>
|
||||||
|
<tmpl_loop name='a1'>
|
||||||
|
<span id='<tmpl_var name='Survey_answerId'>show'>0</span>
|
||||||
|
</tmpl_loop>
|
||||||
|
</td><td></td><td>
|
||||||
|
<tmpl_loop name='a2'>
|
||||||
|
<span id='<tmpl_var name='Survey_answerId'>show'><tmpl_var name='max'></span>
|
||||||
|
</tmpl_loop>
|
||||||
|
</td></tr>
|
||||||
|
<tr><td>0 </td><td>
|
||||||
|
<div id='<tmpl_var name='Survey_questionId'>slider-bg' tabindex='-1' title='Slider' class=slider-bg>
|
||||||
|
<tmpl_loop name='a1'>
|
||||||
|
<div id='<tmpl_var name='Survey_answerId'>slider-min-thumb' class=slider-min-thumb>
|
||||||
|
</tmpl_loop>
|
||||||
|
<img src='/extras/wobject/Survey/thumb-n.gif'></div>
|
||||||
|
<tmpl_loop name='a2'>
|
||||||
|
<div id='<tmpl_var name='Survey_answerId'>slider-max-thumb' class=slider-max-thumb>
|
||||||
|
</tmpl_loop>
|
||||||
|
<img src='/extras/wobject/Survey/thumb-n.gif'></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<tmpl_loop name='a2'>
|
||||||
|
<td><tmpl_var name='max'></td><td>
|
||||||
|
</tmpl_loop>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<tmpl_else>
|
||||||
|
<tmpl_loop name=answers>
|
||||||
|
<tmpl_var name='verts'>
|
||||||
|
|
||||||
|
<span class=answer>
|
||||||
|
<p><table><tr><td></td><td>
|
||||||
|
<tmpl_var name='answerText'>
|
||||||
|
<span id='<tmpl_var name='Survey_answerId'>show'>0</span>
|
||||||
|
<input type=hidden id='<tmpl_var name='Survey_answerId'>' name='<tmpl_var name='Survey_answerId'>'>
|
||||||
|
</td><td></td></tr>
|
||||||
|
<tr><td>0 </td><td>
|
||||||
|
<div id='<tmpl_var name='Survey_answerId'>slider-bg' tabindex='-1' title='Slider' class=slider-bg>
|
||||||
|
<div id='<tmpl_var name='Survey_answerId'>slider-thumb' class=slider-thumb>
|
||||||
|
<img src='/extras/wobject/Survey/thumb-n.gif'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<td><tmpl_var name='max'></td><td>
|
||||||
|
</table>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<tmpl_var name='verte'>
|
||||||
|
</tmpl_loop>
|
||||||
|
</tmpl_if>
|
||||||
|
</tmpl_if>
|
||||||
|
|
||||||
|
</tmpl_loop>
|
||||||
|
<hr><input type=button id=submitbutton value=submitbutton></input>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="footer"></div>
|
||||||
|
|
||||||
|
|
||||||
7
www/extras/wobject/Survey/templates/textHTML.txt
Normal file
7
www/extras/wobject/Survey/templates/textHTML.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<tmpl_loop name=answers>
|
||||||
|
<tmpl_var name='verts'>
|
||||||
|
<span class=answer>
|
||||||
|
<textarea name="<tmpl_var name=Survey_answerId">></textarea>
|
||||||
|
</span>
|
||||||
|
<tmpl_var name='verte'>
|
||||||
|
</tmpl_loop>
|
||||||
BIN
www/extras/wobject/Survey/thumb-n.gif
Normal file
BIN
www/extras/wobject/Survey/thumb-n.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 612 B |
Loading…
Add table
Add a link
Reference in a new issue