diff --git a/www/extras/wobject/Survey/administersurvey.js b/www/extras/wobject/Survey/administersurvey.js new file mode 100644 index 000000000..f52f732d8 --- /dev/null +++ b/www/extras/wobject/Survey/administersurvey.js @@ -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 = ""; +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 = ""; + 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 += "
"; + html += "
Q"+q.sequenceNumber+": "+q.questionText+"
"; + + 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(); diff --git a/www/extras/wobject/Survey/administersurvey.js.backup b/www/extras/wobject/Survey/administersurvey.js.backup new file mode 100644 index 000000000..87ec877aa --- /dev/null +++ b/www/extras/wobject/Survey/administersurvey.js.backup @@ -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 + "
"; + + if(section.questionsOnSectionPage){ + document.getElementById('headertext').innerHTML = section.sectionText; + } + + var qs = params.questions; + var s = params.survey; + var html = ""; + +// html = '
'; + 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 = "

"; + verte = "

"; + } + + html += "
"; + html += "
Q"+q.sequenceNumber+": "+q.questionText+"
"; + + if(multipleChoice[q.questionType]){ + if(q.maxAnswers > 1){ + html += "
Selections left: "+q.maxAnswers+"
"; + } + var butts = new Array(); + for(var x = 0; x < q.answers.length; x++){ + var a = q.answers[x]; + html += verts+""+verte; +// html += verts+""+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+""; + + if(q.questionType == 'Text'){ + html += ""; + }else if(q.questionType == 'Email'){ + html += ""; + }else if(q.questionType == 'Phone Number'){ + html += ""; + }else if(q.questionType == 'Text Date'){ + html += ""; + }else if(q.questionType == 'Currency'){ + html += ""; + } + html += ""+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+""; + html += ""; + html += "
"; + html += ""; + html += ""; + html += ""+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+""; + html += ""; + html += ""+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 += ""; + html += ""; + + html += verts+""; + html += "

"+a.answerText+"
"; + html += "
"; + html += "0"; + html += ""; + html += ""+a2.max+""; + html += "
0  "; + html += "
"; + html += "
\ +
\ +
\ +
"; + + html += "
\ + "; + html += "
"+a1.max+""; + html += "
"; + + html += "
"+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+""; + html += "

"; + html += "
"; + html += a.answerText+" "; + html += "0"; + html += ""; + html += "
0  "; + html += "
"; + if(q.questionType == 'Dual Slider - Range'){ + html += "
\ + \ +
\ + "; + + }else{ + html += "
\ + "; + } + html += "
\ +
"; + html += "
"+a.max+""; + html += "
"; + + html += ""+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 += "


"; + document.getElementById('survey').innerHTML += html;html = ''; + document.getElementById('footer').innerHTML = "
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(); diff --git a/www/extras/wobject/Survey/administersurvey.js.backup1 b/www/extras/wobject/Survey/administersurvey.js.backup1 new file mode 100644 index 000000000..4df16790c --- /dev/null +++ b/www/extras/wobject/Survey/administersurvey.js.backup1 @@ -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 + "
"; + + if(section.questionsOnSectionPage){ + document.getElementById('headertext').innerHTML = section.sectionText; + } + + var qs = params.questions; + var s = params.survey; + var html = ""; + +// html = ''; + 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 = "

"; + verte = "

"; + } + + html += "
"; + html += "
Q"+q.sequenceNumber+": "+q.questionText+"
"; + + if(multipleChoice[q.questionType]){ + if(q.maxAnswers > 1){ + html += "
Selections left: "+q.maxAnswers+"
"; + } + var butts = new Array(); + for(var x = 0; x < q.answers.length; x++){ + var a = q.answers[x]; + html += verts+""+verte; +// html += verts+""+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+""; + + if(q.questionType == 'Text'){ + html += ""; + }else if(q.questionType == 'Email'){ + html += ""; + }else if(q.questionType == 'Phone Number'){ + html += ""; + }else if(q.questionType == 'Text Date'){ + html += ""; + }else if(q.questionType == 'Currency'){ + html += ""; + } + html += ""+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+""; + html += ""; + html += "
"; + html += ""; + html += ""; + html += ""+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+""; + html += ""; + html += ""+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 += ""; + html += ""; + + html += verts+""; + html += "

"+a.answerText+"
"; + html += "
"; + html += "0"; + html += ""; + html += ""+a2.max+""; + html += "
0  "; + html += "
"; + html += "
\ +
\ +
\ +
"; + + html += "
\ + "; + html += "
"+a1.max+""; + html += "
"; + + html += "
"+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+""; + html += "

"; + html += "
"; + html += a.answerText+" "; + html += "0"; + html += ""; + html += "
0  "; + html += "
"; + if(q.questionType == 'Dual Slider - Range'){ + html += "
\ + \ +
\ + "; + + }else{ + html += "
\ + "; + } + html += "
\ +
"; + html += "
"+a.max+""; + html += "
"; + + html += ""+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 += "


"; + document.getElementById('survey').innerHTML += html;html = ''; + document.getElementById('footer').innerHTML = "
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(); diff --git a/www/extras/wobject/Survey/administersurvey/comm.js b/www/extras/wobject/Survey/administersurvey/comm.js new file mode 100644 index 000000000..33dae620d --- /dev/null +++ b/www/extras/wobject/Survey/administersurvey/comm.js @@ -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); + } + + + +}(); diff --git a/www/extras/wobject/Survey/bg-fader.gif b/www/extras/wobject/Survey/bg-fader.gif new file mode 100644 index 000000000..7db8eb72c Binary files /dev/null and b/www/extras/wobject/Survey/bg-fader.gif differ diff --git a/www/extras/wobject/Survey/dd.js b/www/extras/wobject/Survey/dd.js new file mode 100644 index 000000000..86559ebba --- /dev/null +++ b/www/extras/wobject/Survey/dd.js @@ -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(); + } + } +}); diff --git a/www/extras/wobject/Survey/editsurvey.js b/www/extras/wobject/Survey/editsurvey.js new file mode 100644 index 000000000..788ef12e5 --- /dev/null +++ b/www/extras/wobject/Survey/editsurvey.js @@ -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 = ''; + } + 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 = ""; + 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 = ""; + 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(); diff --git a/www/extras/wobject/Survey/editsurvey.js.backup b/www/extras/wobject/Survey/editsurvey.js.backup new file mode 100644 index 000000000..7a36bca33 --- /dev/null +++ b/www/extras/wobject/Survey/editsurvey.js.backup @@ -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 = "
  • "; + + + 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="["+this.sId+"]"+ " " + 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="["+this.aId+"]"; + } + 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="["+this.qId+ " "+ this.typeName+"] " + 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=""; + 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:
    "+ + "Please enter the meta tag: "; + }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:
    "; + oMenu.addItems([ + "Randomize", + "Horizontal display", + "Multiple Answers", + "Comment Box", + ] ); + } + else if(index == 1){//Text options + temp.innerHTML = "Max length
    "; + oMenu.addItems([ + "Multi-Line", + "Numerical", + "Phone Number", + "Currency Amount", + ] ); + } + else if(index == 2){//Slider options + temp.innerHTML = "Start Value:
    End Value:
    Step Value:
    "; + } + 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 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); + +})(); + diff --git a/www/extras/wobject/Survey/editsurvey.js.backup.newer b/www/extras/wobject/Survey/editsurvey.js.backup.newer new file mode 100644 index 000000000..78fc93177 --- /dev/null +++ b/www/extras/wobject/Survey/editsurvey.js.backup.newer @@ -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 = ""; + 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 = ""; + 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 = "\ +

    Section Number: "+params.sequenceNumber + "\ + \ +

    Section Name: \ +


    \ +

    Randomize Questions: \ +

    Question per Page: \ +

    Questions on Section Page: \ +


    \ +

    Section Text:

    \ +

    \ + "; + + 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 = "\ +

    Question Number: "+params.sequenceNumber + "\ + \ + \ + +

    Randomize Questions: \ +

    Question per Page: \ +

    Questions on Section Page: \ +


    \ +

    Section Text:

    \ +

    \ + "; + } +}(); +*/ +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(); diff --git a/www/extras/wobject/Survey/editsurvey/answer.js b/www/extras/wobject/Survey/editsurvey/answer.js new file mode 100644 index 000000000..7db2d7910 --- /dev/null +++ b/www/extras/wobject/Survey/editsurvey/answer.js @@ -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 = "\ +

    \ +
    Please enter answer information
    \ +
    \ +\ + \ +\ +

    Answer Number: "+params.sequenceNumber + "\ +\ + \ + \ + "; + html = html + "

    Answer Text:\n\n"; + html = html + "

    Recorded Answer\n\n"; + html = html + "

    Jump to Question:"; + html = html + "

    Is this the correct answer:\n" + + this.makeRadio('isCorrect',[{text:'Yes',value:1},{text:'No',value:0}],params.isCorrect); + html = html + "

    Min:"; + html = html + "

    Max:"; + html = html + "

    Step:"; + html = html + "

    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+ "" + values[i]['text']; + }else{ + html = html+ "" + values[i]['text']; + } + } + html = html + "\n"; + return html; + } +}(); diff --git a/www/extras/wobject/Survey/editsurvey/comm.js b/www/extras/wobject/Survey/editsurvey/comm.js new file mode 100644 index 000000000..76f19cfcd --- /dev/null +++ b/www/extras/wobject/Survey/editsurvey/comm.js @@ -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); + } +}(); diff --git a/www/extras/wobject/Survey/editsurvey/question.js b/www/extras/wobject/Survey/editsurvey/question.js new file mode 100644 index 000000000..49990a482 --- /dev/null +++ b/www/extras/wobject/Survey/editsurvey/question.js @@ -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 = "\ +

    \ +
    Please enter question information
    \ +
    \ +\ + \ +

    Question Number: "+params.sequenceNumber + "\ +\ + \ + \ +

    Question Text:\n"; + if(params.questionText == ''){ + html = html + "\n"; + } + else{ + html = html + "\n"; + } + html = html + "

    Question custom variable name:"; + html = html + "

    Randomize answers:"; + + html = html+ this.makeRadio('randomizeAnswers',[{text:'Yes',value:1},{text:'No',value:0}],params.randomizeAnswers); + html = html + "

    Previous answers to display:"; + html = html + "

    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 + "\ +

    Randomized words:\ + \ +

    Vertical display:"; + + html = html+ this.makeRadio('verticalDisplay',[{text:'Yes',value:1},{text:'No',value:0}],params.verticalDisplay); + html = html + "

    Allow comment:"; + html = html+ this.makeRadio('allowComment',[{text:'Yes',value:1},{text:'No',value:0}],params.allowComment); + html = html + "

    Maximum number of answers:"; + html = html + "

    Required:"; + html = html+ this.makeRadio('required',[{text:'Yes',value:1},{text:'No',value:0}],params.required); + html = html + "\ +

    \ +
    \ +
    \ + "; + + 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 = "\n"; + return html; + } + this.makeRadio = function(name,values,checked){ + var html = ''; + for(var i in values){ + if(checked == values[i]['value']){ + html = html+ "" + values[i]['text']; + }else{ + html = html+ "" + values[i]['text']; + } + } + html = html + "\n"; + return html; + } + +}(); diff --git a/www/extras/wobject/Survey/editsurvey/section.js b/www/extras/wobject/Survey/editsurvey/section.js new file mode 100644 index 000000000..d95ce86a7 --- /dev/null +++ b/www/extras/wobject/Survey/editsurvey/section.js @@ -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 = "\ +
    \ +
    Please enter section formation
    \ +
    \ +
    \ +

    Section Number: "+params.sequenceNumber + "\ + \ +

    Section Name: \ +


    \ +

    Randomize Questions:"; + if(params.randomizeQuestions == 1){ + html = html+ "\ + Yes\ + No"; + }else{ + html = html+ "\ + Yes\ + No"; + } + html = html + "\ +

    Question per Page:\ + \ +

    Questions on Section Page: "; + if(params.questionsOnSectionPage == 1){ + html = html+ "\ + Yes\ + No"; + }else{ + html = html+ "\ + Yes\ + No"; + } + html = html + "\ +


    \ +

    Section Text:

    \ + "; + html = html + "

    Title on every page: " + this.makeRadio('everyPageTitle',[{text:'Yes',value:1},{text:'No',value:0}],params.everyPageTitle); + html = html + "

    Text on every page: " + this.makeRadio('everyPageText',[{text:'Yes',value:1},{text:'No',value:0}],params.everyPageText); + html = html + "

    Terminal section: " + this.makeRadio('terminal',[{text:'Yes',value:1},{text:'No',value:0}],params.terminal); + html = html + "

    Terminal section URL: "; + 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+ "" + values[i]['text']; + }else{ + html = html+ "" + values[i]['text']; + } + } + html = html + "\n"; + return html; + } +}(); + diff --git a/www/extras/wobject/Survey/loadTemplate.pl b/www/extras/wobject/Survey/loadTemplate.pl new file mode 100755 index 000000000..3501b0076 --- /dev/null +++ b/www/extras/wobject/Survey/loadTemplate.pl @@ -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(); + diff --git a/www/extras/wobject/Survey/survey.css b/www/extras/wobject/Survey/survey.css new file mode 100644 index 000000000..bae7b65b3 --- /dev/null +++ b/www/extras/wobject/Survey/survey.css @@ -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; +} + diff --git a/www/extras/wobject/Survey/survey.css.backup b/www/extras/wobject/Survey/survey.css.backup new file mode 100644 index 000000000..e0e1e3327 --- /dev/null +++ b/www/extras/wobject/Survey/survey.css.backup @@ -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; +} + diff --git a/www/extras/wobject/Survey/surveyedit.css b/www/extras/wobject/Survey/surveyedit.css new file mode 100644 index 000000000..1d6d48e21 --- /dev/null +++ b/www/extras/wobject/Survey/surveyedit.css @@ -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; +} + diff --git a/www/extras/wobject/Survey/template.html.backup b/www/extras/wobject/Survey/template.html.backup new file mode 100644 index 000000000..627a01672 --- /dev/null +++ b/www/extras/wobject/Survey/template.html.backup @@ -0,0 +1,159 @@ +WebGUI Survey Alpha I ROCK A LOT!!! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    + +

    Questions

    + +
    + +
    + +
    + +
      + +
      + + + +
      + +

      Answers

      + +
      + +
      + +
        + +
      + +
      + + + +
      + +
      TrashCan.img
      + +
      + +

      Edit Section

      + +

      + +

      Displayed Text:

      + + + +
      + +
      + +
      + +
      + +
      + +

      Edit Question

      + +

      + +

      + +

      Question Text:

      + +
      + +

      Question Type:

      + +
      + +
      + +

      Options:

      + +
      + +
      + +
      + +
      + +

      Edit Answer

      + +

      + +

      + +

      + +
      + +
      + +
      + +
      + +
      + + + +
      + +
      + +
      + +
      + +
      + + diff --git a/www/extras/wobject/Survey/templates/buttonHTML.txt b/www/extras/wobject/Survey/templates/buttonHTML.txt new file mode 100644 index 000000000..3d11c5a24 --- /dev/null +++ b/www/extras/wobject/Survey/templates/buttonHTML.txt @@ -0,0 +1,6 @@ + + + + + id=> + diff --git a/www/extras/wobject/Survey/templates/fileLoaderHTML.txt b/www/extras/wobject/Survey/templates/fileLoaderHTML.txt new file mode 100644 index 000000000..a23e89784 --- /dev/null +++ b/www/extras/wobject/Survey/templates/fileLoaderHTML.txt @@ -0,0 +1,7 @@ + + + + + + diff --git a/www/extras/wobject/Survey/templates/takeSurvey.html b/www/extras/wobject/Survey/templates/takeSurvey.html new file mode 100644 index 000000000..c5ab9f306 --- /dev/null +++ b/www/extras/wobject/Survey/templates/takeSurvey.html @@ -0,0 +1,151 @@ + + +
      + + + +'> + + +
      +
      Q:
      + + + +
      selections left: max'>
      +
      +
      + + + + + + + + + + + + + verbatim' > + + + + + + + + + + + + + verbatim'> + + + + + + + + + + + verbatim'> + + + id=> + + + + + + + + +
      container'>
      + ' id='' type=text> + button'> + + verbatim'> + + + + + + + + + + ' name='' value=0> + + + ' name='' value=""> + + + +

      +
      + + show'>0 + + + + show'> + +
      0   +
      slider-bg' tabindex='-1' title='Slider' class=slider-bg> + +
      slider-min-thumb' class=slider-min-thumb> + +
      + +
      slider-max-thumb' class=slider-max-thumb> + +
      +
      + + +
      + +
      + +
      + + + + + + +

      +
      +   + show'>0 + ' name=''> +
      0   +
      slider-bg' tabindex='-1' title='Slider' class=slider-bg> +
      slider-thumb' class=slider-thumb> + +
      +
      +
      +
      + + + + + + + + +


      + + +
      + + + + diff --git a/www/extras/wobject/Survey/templates/textHTML.txt b/www/extras/wobject/Survey/templates/textHTML.txt new file mode 100644 index 000000000..80605e73d --- /dev/null +++ b/www/extras/wobject/Survey/templates/textHTML.txt @@ -0,0 +1,7 @@ + + + + + + + diff --git a/www/extras/wobject/Survey/thumb-n.gif b/www/extras/wobject/Survey/thumb-n.gif new file mode 100644 index 000000000..c91a33293 Binary files /dev/null and b/www/extras/wobject/Survey/thumb-n.gif differ