diff --git a/www/extras/wobject/Survey/administersurvey.js.backup b/www/extras/wobject/Survey/administersurvey.js.backup deleted file mode 100644 index 87ec877aa..000000000 --- a/www/extras/wobject/Survey/administersurvey.js.backup +++ /dev/null @@ -1,404 +0,0 @@ -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 deleted file mode 100644 index 4df16790c..000000000 --- a/www/extras/wobject/Survey/administersurvey.js.backup1 +++ /dev/null @@ -1,408 +0,0 @@ -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/editsurvey.js.backup b/www/extras/wobject/Survey/editsurvey.js.backup deleted file mode 100644 index 7a36bca33..000000000 --- a/www/extras/wobject/Survey/editsurvey.js.backup +++ /dev/null @@ -1,988 +0,0 @@ -// 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 deleted file mode 100644 index 78fc93177..000000000 --- a/www/extras/wobject/Survey/editsurvey.js.backup.newer +++ /dev/null @@ -1,337 +0,0 @@ -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/template.html.backup b/www/extras/wobject/Survey/template.html.backup deleted file mode 100644 index 627a01672..000000000 --- a/www/extras/wobject/Survey/template.html.backup +++ /dev/null @@ -1,159 +0,0 @@ -WebGUI Survey Alpha I ROCK A LOT!!! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    - -

    Questions

    - -
    - -
    - -
    - -
      - -
      - - - -
      - -

      Answers

      - -
      - -
      - -
        - -
      - -
      - - - -
      - -
      TrashCan.img
      - -
      - -

      Edit Section

      - -

      - -

      Displayed Text:

      - - - -
      - -
      - -
      - -
      - -
      - -

      Edit Question

      - -

      - -

      - -

      Question Text:

      - -
      - -

      Question Type:

      - -
      - -
      - -

      Options:

      - -
      - -
      - -
      - -
      - -

      Edit Answer

      - -

      - -

      - -

      - -
      - -
      - -
      - -
      - -
      - - - -
      - -
      - -
      - -
      - -
      - -