Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

combining js code

Signed-off-by: Lok Cheung <lokarithm@gmail.com>
  • Loading branch information...
commit 7abfd18c7ed3b3354b314d7414744487abcd790f 1 parent 5590ba5
@lokarithm lokarithm authored
View
82 webapp/Scripts/draw-lead.js
@@ -212,7 +212,7 @@ function DrawLead6(c,date) {
}
// Author: Lok Cheung
-// Purpose: Listen for the user to click or touch the screen, then draw the drill down display
+// Purpose: Listen for the user to click or touch the drill down display, then close it
$(document).ready(function () {
// if user clicked on button, the overlay layer or the dialogbox, close the dialog
$('#dialog-overlay, #dialog-box').bind("touchstart click", function () {
@@ -229,27 +229,6 @@ $(document).ready(function () {
});
});
-// Name: popup
-// Author: Lok Cheung
-// Purpose: Uses quadratic curves to draw a colorful figure with labeled sections. Each section's height is relative to its weighted value.
-// Arguments: Pump_In_Sale(html_message);
-function popup(message) {
- // get the screen height and width
- var maskHeight = $(document).height();
- var maskWidth = $(window).width();
-
- // calculate the values for center alignment
- var dialogTop = (maskHeight/3) - ($('#dialog-box').height());
- var dialogLeft = (maskWidth/2) - ($('#dialog-box').width()/2);
-
- // assign values to the overlay and dialog box
- $('#dialog-overlay').css({height:maskHeight, width:maskWidth}).show();
- $('#dialog-box').css({top:dialogTop, left:dialogLeft}).show();
-
- // display the message
- $('#dialog-message').html(message);
-}
-
$("#myCanvas").swiperight(function(event, result) {
event.stopImmediatePropagation();
wipeStatus("Right",result,3);
@@ -260,15 +239,16 @@ $("#myCanvas").swipeleft(function(event, result) {
wipeStatus("Left",result,3);
});
-
+// Author: Lok Cheung
+// Purpose: Listen for the user to click or touch the elements on the canvas, then call the popup function
$('#myCanvas').bind("touchstart click", function(event){
var heightFactor=1;
for(var i=0;i <trendArray.length;i++ )
{
- //check if touching the element location
+ //check if user is touching the area within the element
if(event.pageX>trendArray[i][1] && event.pageX<(trendArray[i][1]+trendArray[i][3]) && event.pageY>trendArray[i][2] && event.pageY <(trendArray[i][2]+trendArray[i][4])) {
event.preventDefault();
- //y position of the dialog box
+ //change the y position of the dialog box according to which element is touched
if(trendArray[i][0]=="Number of Leads" || trendArray[i][0]=="New 3PL Leads" || trendArray[i][0]=="Close Rate" || trendArray[i][0]=="Prospect Count"){
document.getElementById('dialog-box').style.cssText = "margin-top: 800px";
}
@@ -283,34 +263,34 @@ $('#myCanvas').bind("touchstart click", function(event){
'<td>'+trendArray[i][6]+'</td>'+
'</tr>'+
'</table>');
-
- if(trendArray[i][0]=="Number of Leads"){
- heightFactor=0.3;
- for(var j=0;j<trendArray[i][5].length;j++) {
- drawLineGraph("trendGraph",trendArray[i][5][j][2],trendArray[i][5][j][0],trendArray[i][5][j][1], j,heightFactor,true);
- }
- }else if(trendArray[i][0]=="New 3PL Leads"){
- heightFactor=2.5;
- for(var j=0;j<trendArray[i][5].length;j++) {
- drawLineGraph("trendGraph",trendArray[i][5][j][2],trendArray[i][5][j][0],trendArray[i][5][j][1], j,heightFactor,false);
- }
- }else{
- if(trendArray[i][0]=="Response by Mail" || trendArray[i][0]=="Unique Customers" || trendArray[i][0]=="Prospect Count"){
- heightFactor=0.1;
- }
- if(trendArray[i][0]=="Response by Phone"){
- heightFactor=0.2;
- }
- if(trendArray[i][0]=="New Sales From Leads" || trendArray[i][0]=="Used Sales From Leads" || trendArray[i][0]=="Lost Sales From Leads"){
- heightFactor=5;
- }
- if(trendArray[i][0]=="Close Rate"){
- heightFactor=2200;
- }
- drawTrend(trendArray[i][5],heightFactor);
+ //changing the height factor of each element
+ if(trendArray[i][0]=="Number of Leads"){
+ heightFactor=0.3;
+ for(var j=0;j<trendArray[i][5].length;j++) {
+ drawLineGraph("trendGraph",trendArray[i][5][j][2],trendArray[i][5][j][0],trendArray[i][5][j][1], j,heightFactor,true);
+ }
+ }else if(trendArray[i][0]=="New 3PL Leads"){
+ heightFactor=2.5;
+ for(var j=0;j<trendArray[i][5].length;j++) {
+ drawLineGraph("trendGraph",trendArray[i][5][j][2],trendArray[i][5][j][0],trendArray[i][5][j][1], j,heightFactor,false);
+ }
+ }else{
+ if(trendArray[i][0]=="Response by Mail" || trendArray[i][0]=="Unique Customers" || trendArray[i][0]=="Prospect Count"){
+ heightFactor=0.1;
+ }
+ if(trendArray[i][0]=="Response by Phone"){
+ heightFactor=0.2;
}
+ if(trendArray[i][0]=="New Sales From Leads" || trendArray[i][0]=="Used Sales From Leads" || trendArray[i][0]=="Lost Sales From Leads"){
+ heightFactor=5;
+ }
+ if(trendArray[i][0]=="Close Rate"){
+ heightFactor=2200;
+ }
+ drawTrend(trendArray[i][5],heightFactor);
+ }
- //draw x, y axis
+ //draw x, y axis of the chart
var canvas = document.getElementById("trendGraph");
var context = canvas.getContext("2d");
context.save();
View
24 webapp/Scripts/draw-sales.js
@@ -292,23 +292,6 @@ $(document).ready(function () {
});
});
-function popup(message) {
- // get the screen height and width
- var maskHeight = $(document).height();
- var maskWidth = $(window).width();
-
- // calculate the values for center alignment
- var dialogTop = (maskHeight/3) - ($('#dialog-box').height());
- var dialogLeft = (maskWidth/2) - ($('#dialog-box').width()/2);
-
- // assign values to the overlay and dialog box
- $('#dialog-overlay').css({height:maskHeight, width:maskWidth}).show();
- $('#dialog-box').css({top:dialogTop, left:dialogLeft}).show();
-
- // display the message
- $('#dialog-message').html(message);
-}
-
$("#myCanvas").swiperight(function(event, result) {
event.stopImmediatePropagation();
wipeStatus("Right",result,1);
@@ -320,7 +303,7 @@ $("#myCanvas").swipeleft(function(event, result) {
});
$('#myCanvas').bind("touchstart click", function(event){
- var heightFactor;
+ var heightFactor=1;
for(var i=0;i <trendArray.length;i++ )
{
//check if touching the element location
@@ -344,11 +327,10 @@ $('#myCanvas').bind("touchstart click", function(event){
'<td>'+trendArray[i][6]+'</td>'+
'</tr>'+
'</table>');
+ //changing the height factor of each element
if(trendArray[i][0]=="Pump In Sale" || trendArray[i][0]=="Competitive Segment Sale") {
if(trendArray[i][0]=="Competitive Segment Sale")
heightFactor=5;
- if(trendArray[i][0]=="Pump In Sale")
- heightFactor=1;
for(var j=0;j<trendArray[i][5].length;j++) {
drawLineGraph("trendGraph",trendArray[i][5][j][2],trendArray[i][5][j][0],trendArray[i][5][j][1], j,heightFactor);
}
@@ -368,7 +350,7 @@ $('#myCanvas').bind("touchstart click", function(event){
drawTrend(trendArray[i][5],heightFactor);
}
- //draw x, y axis
+ //draw x, y axis of the chart
var canvas = document.getElementById("trendGraph");
var context = canvas.getContext("2d");
context.save();
View
18 webapp/Scripts/draw-service.js
@@ -214,24 +214,6 @@ $(document).ready(function () {
});
});
-function popup(message) {
- // get the screen height and width
- var maskHeight = $(document).height();
- var maskWidth = $(window).width();
-
- // calculate the values for center alignment
- var dialogTop = (maskHeight/3) - ($('#dialog-box').height());
- var dialogLeft = (maskWidth/2) - ($('#dialog-box').width()/2);
-
- // assign values to the overlay and dialog box
- $('#dialog-overlay').css({height:maskHeight, width:maskWidth}).show();
- $('#dialog-box').css({top:dialogTop, left:dialogLeft}).show();
-
- // display the message
- $('#dialog-message').html(message);
-}
-
-
$("#myCanvas").swiperight(function(event, result) {
event.stopImmediatePropagation();
wipeStatus("Right",result,2);
Please sign in to comment.
Something went wrong with that request. Please try again.