1;(function ( $, window, document, undefined ) { 2 3 "use strict"; 4 5 /** Create the defaults once **/ 6 var pluginName = "pmsresults", 7 defaults = { 8 style : {}, 9 datas : [] 10 }, 11 dataKey = "plugin_" + pluginName; 12 13/** The actual plugin constructor **/ 14function Plugin ( element, options ) { 15 this.element = element; 16 this.settings = $.extend( {}, defaults, options ); 17 this._defaults = defaults; 18 this._name = pluginName; 19 this.init(); 20} 21 22/** Avoid Plugin.prototype conflicts **/ 23$.extend( Plugin.prototype, { 24 init: function () { 25 var msChartSData = [], labs = [], dset = [], dset2 = [], msChartData = {}, msChartOptions = {}, bgcolors, advcolors = [], mschartelem, pwpChart = {}; 26 var fillColor = '', fillColor2 = '', strokeColor = '', strokeColor2 = '', highlightFill = '', highlightFill2 = '', highlightStroke = '', highlightStroke2 = '', element = '', style = '', lng = {}, elementstyle = this.settings.style.style, counter, msChartType, afillColor = [], astrokeColor = [], ahighlightFill = [], ahighlightStroke = [], thismax = 0, arfillColor = [], arstrokeColor = [], arhighlightFill = [], arstrokeColor2 = []; 27 if ( this.settings.style.bgcolor == undefined ) { 28 this.settings.style.bgcolor = ""; 29 } 30 this.settings.style.aftertag = ""; 31 if ( this.settings.style.percentage != undefined ) { 32 if ( this.settings.style.percentage == "true" ) { 33 this.settings.style.aftertag = "%"; 34 } 35 } 36 if ( this.settings.style.after != undefined ) { 37 if ( this.settings.style.after != "" ) { 38 this.settings.style.aftertag = this.settings.style.after; 39 } 40 } 41 if ( this.settings.style.legend != undefined ) { 42 if ( this.settings.style.legend != "" ) { 43 this.settings.style.legend = this.settings.style.legend; 44 } 45 } 46 if ( ( bgcolors == "" || bgcolors == undefined ) && this.settings.style.bgcolor != "" ) { 47 bgcolors = this.settings.style.bgcolor.replace(/\s/g, '').split( "," ); 48 } 49 if ( this.settings.style.style == "progressbar" || this.settings.style.style == "linebar" ) { 50 jQuery( '#' + jQuery( this.element ).attr( 'id' ) + " .survey_global_percent" ).each( function( index ) { 51 element = jQuery(this); 52 if ( elementstyle == "linebar" ) { 53 element.css( "width", parseInt( element.closest( ".lineprocess" ).find( ".hiddenperc" ).val() ) + "%" ); 54 incNumbers( 0, element.closest( ".lineprocess" ).find( ".hiddenperc" ).val(), element.parent().children( ".perc" ), 16 ); 55 } 56 else { 57 element.css( "width", parseInt( element.closest( ".process" ).find( ".hiddenperc" ).val() ) + "%" ); 58 } 59 }) 60 } 61 function incNumbers( start, end, jqstr, speed ) { 62 var clr = null; 63 var ele = jQuery( jqstr ); 64 var rand = start; 65 var res = ""; 66 if ( arguments.length < 3 ) { 67 throw "missing required parameters"; 68 } 69 function loop() { 70 clearTimeout( clr ); 71 function inloop() { 72 res = rand += 1; 73 ele.html( res + "%" ); 74 if ( !( rand < end ) ) { 75 ele.html( end + "%" ); 76 return; 77 } 78 clr = setTimeout( inloop, ( speed || 32 ) ); 79 }; 80 inloop(); 81 // setTimeout(loop, 2500); //Increment Loop TIme 82 }; 83 loop(); 84 } 85 Object.size = function( obj ) { 86 var size = 0, key; 87 for ( key in obj ) { 88 if ( obj.hasOwnProperty( key ) ) { 89 size++; 90 } 91 } 92 return size; 93 }; 94 95 element = this.element; 96 style = this.settings.style; 97 if ( this.settings.style.lng != undefined ) { 98 lng = this.settings.style.lng; 99 } 100 else { 101 lng.label1 = ""; 102 lng.label2 = ""; 103 } 104 if ( style.style == "barchart" || style.style == "linechart" || style.style == "radarchart" || style.style == "piechart" || style.style == "doughnutchart" || style.style == "polarchart" || style.style == "bubblechart" || style.style == "horizontalbarchart" ) { 105 var thisdatas = this.settings.datas[ 0 ]; 106 var thisdatassize = 0; 107 if ( thisdatas != undefined ) { 108 if ( thisdatas.length == undefined ) { 109 thisdatassize = Object.size( thisdatas ); 110 } 111 else { 112 thisdatassize = thisdatas.length; 113 } 114 } 115 if ( bgcolors == undefined && thisdatas != undefined ) { 116 for (var i = 0; i < thisdatassize; i++ ) { 117 advcolors.push( [ getFromHex( get_random_color(), 0.7 ), getFromHex( get_random_color(), 0.7 ), getFromHex( get_random_color(), 0.7 ), getFromHex( get_random_color(), 0.7 ) ] ); 118 } 119 } 120 else { 121 jQuery.each( bgcolors, function ( a, bs ) { 122 if ( a == undefined ) { 123 a = 0; 124 } 125 advcolors[ a ] = bs.split( ":" ); 126 }) 127 for (var c = 0; c < thisdatassize; c++ ) { 128 if ( advcolors[ c ] == undefined ) { 129 if ( advcolors[ c - 1 ] != undefined ) { 130 advcolors[ c ] = advcolors[ c - 1 ]; 131 } 132 else { 133 advcolors[ c ] = [ getFromHex( get_random_color(), 0.7 ), getFromHex( get_random_color(), 0.7 ), getFromHex( get_random_color(), 0.7 ), getFromHex( get_random_color(), 0.7 ) ]; 134 } 135 } 136 } 137 } 138 for ( var s = 0; s < thisdatassize; s++ ) { 139 for (var c = 0; c < 4; c++ ) { 140 if ( advcolors[ s ] == undefined ) { 141 advcolors[ s ] = new Array(); 142 } 143 if ( advcolors[ s ][ c ] == undefined || advcolors[ s ][ c ] == "random" ) { 144 advcolors[ s ][ c ] = getFromHex( get_random_color(), 0.7 ); 145 } 146 } 147 } 148 149 jQuery.each( this.settings.datas, function ( i, elem ) { 150 dset = [];dset2 = []; 151 fillColor = ( advcolors[ 1 ] != undefined && advcolors[ 1 ] != '' ) ? getFromHex( advcolors[ 1 ], 0.5 ) : getFromHex( get_random_color(), 0.7 ), 152 strokeColor = ( advcolors[ 2 ] != undefined && advcolors[ 2 ] != '' ) ? getFromHex( advcolors[ 2 ], 0.5 ) : getFromHex( get_random_color(), 0.7 ), 153 highlightFill = ( advcolors[ 3 ] != undefined && advcolors[ 3 ] != '' ) ? getFromHex( advcolors[ 3 ], 0.5 ) : getFromHex( get_random_color(), 0.7 ), 154 highlightStroke = ( advcolors[ 4 ] != undefined && advcolors[ 4 ] != '' ) ? getFromHex( advcolors[ 4 ], 0.5 ) : getFromHex( get_random_color(), 0.7 ); 155 labs = []; 156 thismax = 0; 157 jQuery.each(elem, function (e, el) { 158 if ( elementstyle == "bubblechart" ) { 159 labs.push( el.answer ); 160 var splcount = el.count.toString().split(":"); 161 if ( splcount[ 0 ] == undefined ) { 162 splcount[ 0 ] = 0; 163 } 164 if ( splcount[ 1 ] == undefined ) { 165 splcount[ 1 ] = 0; 166 } 167 if ( splcount[ 2 ] == undefined ) { 168 splcount[ 2 ] = 0; 169 } 170 dset.push( { x: parseInt( splcount[ 0 ] ), y: parseInt( splcount[ 1 ] ), r: parseInt( splcount[ 2 ] ) } ); 171 } 172 else { 173 labs.push( el.answer ); 174 dset.push( el.count ); 175 } 176 if ( el.gcount != undefined ) { 177 dset2.push( el.gcount ); 178 } 179 if ( bgcolors == "" ) { 180 afillColor.push( getFromHex( get_random_color(), 0.7 ) ); 181 //astrokeColor.push( get_random_color() ); 182 ahighlightFill.push( getFromHex( get_random_color(), 0.7 ) ); 183 //ahighlightStroke.push( get_random_color() ); 184 } 185 }); 186 thismax = Math.max.apply(Math,dset); 187 if ( bgcolors == "" ) { 188 fillColor = afillColor; 189 strokeColor = "rgba(0, 0, 0, 0.1)"; 190 highlightFill = ahighlightFill; 191 highlightStroke = "rgba(0, 0, 0, 0.2)"; 192 } 193 if ( ! jQuery.isEmptyObject( dset2 ) ) { 194 if ( fillColor[ 1 ] != undefined ) { 195 if ( fillColor[ 1 ].substring( 0, 3 ) == 'rgb' ) { 196 highlightFill = getFromRGB( fillColor[ 1 ], 0.6 ); 197 fillColor = getFromRGB( fillColor[ 1 ], 0.8 ); 198 } else { 199 highlightFill = getFromHex( fillColor[ 1 ], 0.6 ); 200 fillColor = getFromHex( fillColor[ 1 ], 0.8 ); 201 } 202 } 203 else { 204 fillColor = afillColor; 205 highlightFill = ahighlightFill; 206 } 207 if ( fillColor[ 1 ] != undefined ) { 208 if ( strokeColor[ 1 ].substring( 0, 3 ) == 'rgb' ) { 209 strokeColor = getFromRGB( strokeColor[ 1 ], 0.8 ); 210 } else { 211 strokeColor = getFromHex( strokeColor[ 1 ], 0.8 ); 212 } 213 } 214 else { 215 strokeColor = "rgba(0, 0, 0, 0.1)"; 216 highlightStroke = "rgba(0, 0, 0, 0.2)"; 217 } 218 } 219 jQuery.each( advcolors, function ( i, ar ) { 220 jQuery.each( advcolors[ i ], function (e, el) { 221 advcolors[ i ][ e ] = getFromHex( el, 0.8 ); 222 } ) 223 arfillColor.push( advcolors[ i ][ 0 ] ); 224 arstrokeColor.push( advcolors[ i ][ 1 ] ); 225 arhighlightFill.push( advcolors[ i ][ 2 ] ); 226 arstrokeColor2.push( advcolors[ i ][ 3 ] ); 227 } ) 228 if ( elementstyle == "radarchart" || elementstyle == "linechart" ) { 229 if ( typeof arfillcolor != 'undefined' ) { 230 var sarfillcolor = arfillcolor[ 0 ]; 231 } 232 if ( arstrokeColor != undefined ) { 233 var sarstrokeColor = arstrokeColor[ 0 ]; 234 } 235 if ( arhighlightFill != undefined ) { 236 var sarhighlightFill = arhighlightFill[ 0 ]; 237 } 238 if ( arstrokeColor2 != undefined ) { 239 var sarstrokeColor2 = arstrokeColor2[ 0 ]; 240 } 241 if ( fillColor != undefined ) { 242 var sfillColor = fillColor[ 0 ]; 243 } 244 if ( strokeColor != undefined ) { 245 var sstrokeColor = strokeColor[ 0 ]; 246 } 247 if ( highlightFill != undefined ) { 248 var shighlightFill = highlightFill[ 0 ]; 249 } 250 if ( strokeColor != undefined ) { 251 var sstrokeColor = strokeColor[ 0 ]; 252 } 253 msChartData = { 254 labels : labs, 255 datasets : [ 256 { 257 label: lng.label1, 258 backgroundColor : ( typeof sarfillColor != 'undefined' ) ? sarfillColor : sfillColor, 259 borderColor : ( typeof sarstrokeColor != 'undefined' ) ? sarstrokeColor : sstrokeColor,
260 hoverBackgroundColor: ( typeof sarhighlightFill != 'undefined' ) ? sarhighlightFill : shighlightFill, 261 hoverBorderColor: ( typeof sarstrokeColor2 != 'undefined' ) ? sarstrokeColor2 : sstrokeColor, 262 pointBackgroundColor: "rgba(0, 0, 0, 0.2)", 263 pointBorderColor: "rgba(0, 0, 0, 0.2)", 264 pointHoverBackgroundColor: "rgba(0, 0, 0, 0.2)", 265 pointHoverBorderColor: "rgba(0, 0, 0, 0.2)", 266 data : dset 267 } 268 ] 269 270 } 271 } 272 else { 273 msChartData = { 274 labels : labs, 275 datasets : [ 276 { 277 label: lng.label1, 278 backgroundColor : ( arfillColor != undefined ) ? arfillColor : fillColor, 279 borderColor : ( arstrokeColor != undefined ) ? arstrokeColor : strokeColor, 280 hoverBackgroundColor: ( arhighlightFill != undefined ) ? arhighlightFill : highlightFill, 281 hoverBorderColor: ( arstrokeColor2 != undefined ) ? arstrokeColor2 : strokeColor, 282 pointBackgroundColor: "rgba(0, 0, 0, 0.2)", 283 pointBorderColor: "rgba(0, 0, 0, 0.2)", 284 pointHoverBackgroundColor: "rgba(0, 0, 0, 0.2)", 285 pointHoverBorderColor: "rgba(0, 0, 0, 0.2)", 286 data : dset 287 } 288 ] 289 290 } 291 } 292 if ( ! jQuery.isEmptyObject( dset2 ) ) { 293 fillColor2 = getFromHex( get_random_color(), 0.7 ), 294 strokeColor2 = getFromHex( get_random_color(), 0.7 ), 295 highlightFill2 = getFromHex( get_random_color(), 0.7 ), 296 highlightStroke2 = getFromHex( get_random_color(), 0.7 ); 297 msChartData.datasets.push({ 298 label: lng.label2, 299 backgroundColor : fillColor2, 300 borderColor : strokeColor2, 301 hoverBackgroundColor: highlightFill2, 302 hoverBorderColor: strokeColor2,
303 pointBackgroundColor: fillColor2, 304 pointBorderColor: strokeColor2, 305 pointHoverBackgroundColor: highlightFill2, 306 pointHoverBorderColor: strokeColor2, 307 data : dset2 308 }) 309 } 310 msChartOptions.tooltipTemplate = "<%if (label){%><%=label%>: <%}%><%= value %>" + style.aftertag; 311 msChartOptions.multiTooltipTemplate = "<%= datasetLabel %><%= value %>" + style.aftertag; 312 msChartOptions.barStrokeWidth = 1; 313 if ( style.legend == "true" ) { 314 msChartOptions.legend = { 315 display: true 316 } 317 } 318 else { 319 msChartOptions.legend = { 320 display: false 321 } 322 } 323 if ( elementstyle == "barchart" ) { 324 msChartType = 'bar'; 325 if ( style.max > 0 ) { 326 msChartOptions.scales = { 327 yAxes: [{ 328 ticks: { 329 max: parseInt( style.max ), 330 stepSize: Math.ceil( style.max / 10 ), 331 beginAtZero: true 332 } 333 }] 334 } 335 } 336 else { 337 msChartOptions.scales = { 338 yAxes: [{ 339 ticks: { 340 stepSize: Math.ceil( thismax / 10 ), 341 beginAtZero: true 342 } 343 }] 344 } 345 } 346 } 347 if ( elementstyle == "horizontalbarchart" ) { 348 msChartType = 'horizontalBar'; 349 if ( style.max > 0 ) { 350 msChartOptions.scales = { 351 yAxes: [{ 352 ticks: { 353 max: parseInt( style.max ), 354 stepSize: Math.ceil( style.max / 10 ), 355 beginAtZero: true 356 } 357 }], 358 xAxes: [{ 359 ticks: { 360 autoSkip: false, 361 beginAtZero: true 362 } 363 }] 364 } 365 } 366 else { 367 msChartOptions.scales = { 368 yAxes: [{ 369 ticks: { 370 stepSize: Math.ceil( thismax / 10 ), 371 beginAtZero: true 372 } 373 }], 374 xAxes: [{ 375 ticks: { 376 autoSkip: false, 377 beginAtZero: true 378 } 379 }] 380 } 381 } 382 } 383 if ( elementstyle == "linechart" ) { 384 msChartType = 'line'; 385 if ( style.max > 0 ) { 386 msChartOptions.scales = { 387 yAxes: [{ 388 ticks: { 389 max: parseInt( style.max ), 390 min: 0, 391 stepSize: Math.ceil( style.max / 10 ), 392 beginAtZero: true 393 } 394 }] 395 } 396 } 397 else { 398 msChartOptions.scales = { 399 yAxes: [{ 400 ticks: { 401 min: 0, 402 stepSize: Math.ceil( thismax / 10 ), 403 beginAtZero: true 404 } 405 }] 406 } 407 } 408 } 409 if ( elementstyle == "bubblechart" ) { 410 msChartType = 'bubble'; 411 if ( style.max > 0 ) { 412 msChartOptions.scales = { 413 yAxes: [{ 414 ticks: { 415 max: parseInt( style.max ), 416 min: 0, 417 stepSize: Math.ceil( style.max / 10 ), 418 beginAtZero: true 419 } 420 }], 421 xAxes: [{ 422 ticks: { 423 min: 0, 424 stepSize: Math.ceil( thismax / 10 ), 425 beginAtZero: true 426 } 427 }] 428 } 429 } 430 else { 431 msChartOptions.scales = { 432 yAxes: [{ 433 ticks: { 434 min: 0, 435 stepSize: Math.ceil( thismax / 10 ), 436 beginAtZero: true 437 } 438 }], 439 xAxes: [{ 440 ticks: { 441 min: 0, 442 stepSize: Math.ceil( thismax / 10 ), 443 beginAtZero: true 444 } 445 }] 446 } 447 } 448 } 449 if ( elementstyle == "radarchart" ) { 450 msChartType = 'radar'; 451 if ( style.max > 0 ) { 452 msChartOptions.scale = { 453 ticks: { 454 max: parseInt( style.max ), 455 beginAtZero: true 456 } 457 } 458 } 459 else { 460 msChartOptions.scale = { 461 ticks: { 462 beginAtZero: true 463 } 464 } 465 } 466 } 467 if ( elementstyle == "piechart" ) { 468 msChartType = 'pie'; 469 } 470 if ( elementstyle == "doughnutchart" ) { 471 msChartType = 'doughnut'; 472 } 473 if ( elementstyle == "polarchart" ) { 474 msChartType = 'polarArea'; 475 if ( style.max > 0 ) { 476 msChartOptions.scale = { 477 ticks: { 478 max: parseInt( style.max ),
479 stepSize: Math.ceil( style.max / 10 ), 480 beginAtZero: true 481 } 482 } 483 } 484 else { 485 msChartOptions.scale = { 486 ticks: { 487 stepSize: Math.ceil( thismax / 10 ), 488 beginAtZero: true 489 } 490 } 491 } 492 } 493 if ( elementstyle != "" ) { 494 //set charts to full width 495 if ( style.legend != "true" ) { 496 var newheight = jQuery( "#" + jQuery( element ).attr( 'id' ) + " canvas" ).width() * 0.6; 497 if ( newheight != 0 ) { 498 jQuery( "#" + jQuery( element ).attr( 'id' ) + " canvas" ).attr( "height", parseInt( newheight ) + "px" ); 499 } 500 } 501 else { 502 var newheight = jQuery( "#" + jQuery( element ).attr( 'id' ) + " canvas" ).width() * 0.6; 503 if ( newheight != 0 ) { 504 jQuery( "#" + jQuery( element ).attr( 'id' ) + " canvas" ).attr( "height", parseInt( newheight ) + "px" ); 505 } 506 } 507 mschartelem = jQuery( "#" + jQuery( element ).attr( 'id' ) + " canvas" )[ 0 ].getContext( "2d" ); 508 msChartOptions.responsive = true; 509 msChartOptions.maintainAspectRatio = false; 510 pwpChart = new Chart( 511 mschartelem, 512 { 513 type: msChartType, 514 data: msChartData, 515 options: msChartOptions 516 } 517 ); 518 } 519 }); 520 } 521 522 function colourNameToHex( colour ) { 523 var colours = {"aliceblue":"#f0f8ff","antiquewhite":"#faebd7","aqua":"#00ffff","aquamarine":"#7fffd4","azure":"#f0ffff", 524 "beige":"#f5f5dc","bisque":"#ffe4c4","black":"#000000","blanchedalmond":"#ffebcd","blue":"#0000ff","blueviolet":"#8a2be2","brown":"#a52a2a","burlywood":"#deb887", 525 "cadetblue":"#5f9ea0","chartreuse":"#7fff00","chocolate":"#d2691e","coral":"#ff7f50","cornflowerblue":"#6495ed","cornsilk":"#fff8dc","crimson":"#dc143c","cyan":"#00ffff", 526 "darkblue":"#00008b","darkcyan":"#008b8b","darkgoldenrod":"#b8860b","darkgray":"#a9a9a9","darkgreen":"#006400","darkkhaki":"#bdb76b","darkmagenta":"#8b008b","darkolivegreen":"#556b2f", 527 "darkorange":"#ff8c00","darkorchid":"#9932cc","darkred":"#8b0000","darksalmon":"#e9967a","darkseagreen":"#8fbc8f","darkslateblue":"#483d8b","darkslategray":"#2f4f4f","darkturquoise":"#00ced1", 528 "darkviolet":"#9400d3","deeppink":"#ff1493","deepskyblue":"#00bfff","dimgray":"#696969","dodgerblue":"#1e90ff", 529 "firebrick":"#b22222","floralwhite":"#fffaf0","forestgreen":"#228b22","fuchsia":"#ff00ff", 530 "gainsboro":"#dcdcdc","ghostwhite":"#f8f8ff","gold":"#ffd700","goldenrod":"#daa520","gray":"#808080","grey":"#808080","green":"#008000","greenyellow":"#adff2f", 531 "honeydew":"#f0fff0","hotpink":"#ff69b4", 532 "indianred ":"#cd5c5c","indigo":"#4b0082","ivory":"#fffff0","khaki":"#f0e68c", 533 "lavender":"#e6e6fa","lavenderblush":"#fff0f5","lawngreen":"#7cfc00","lemonchiffon":"#fffacd","lightblue":"#add8e6","lightcoral":"#f08080","lightcyan":"#e0ffff","lightgoldenrodyellow":"#fafad2", 534 "lightgrey":"#d3d3d3","lightgreen":"#90ee90","lightpink":"#ffb6c1","lightsalmon":"#ffa07a","lightseagreen":"#20b2aa","lightskyblue":"#87cefa","lightslategray":"#778899","lightsteelblue":"#b0c4de", 535 "lightyellow":"#ffffe0","lime":"#00ff00","limegreen":"#32cd32","linen":"#faf0e6", 536 "magenta":"#ff00ff","maroon":"#800000","mediumaquamarine":"#66cdaa","mediumblue":"#0000cd","mediumorchid":"#ba55d3","mediumpurple":"#9370d8","mediumseagreen":"#3cb371","mediumslateblue":"#7b68ee", 537 "mediumspringgreen":"#00fa9a","mediumturquoise":"#48d1cc","mediumvioletred":"#c71585","midnightblue":"#191970","mintcream":"#f5fffa","mistyrose":"#ffe4e1","moccasin":"#ffe4b5", 538 "navajowhite":"#ffdead","navy":"#000080", 539 "oldlace":"#fdf5e6","olive":"#808000","olivedrab":"#6b8e23","orange":"#ffa500","orangered":"#ff4500","orchid":"#da70d6", 540 "palegoldenrod":"#eee8aa","palegreen":"#98fb98","paleturquoise":"#afeeee","palevioletred":"#d87093","papayawhip":"#ffefd5","peachpuff":"#ffdab9","peru":"#cd853f","pink":"#ffc0cb","plum":"#dda0dd","powderblue":"#b0e0e6","purple":"#800080", 541 "red":"#ff0000","rosybrown":"#bc8f8f","royalblue":"#4169e1", 542 "saddlebrown":"#8b4513","salmon":"#fa8072","sandybrown":"#f4a460","seagreen":"#2e8b57","seashell":"#fff5ee","sienna":"#a0522d","silver":"#c0c0c0","skyblue":"#87ceeb","slateblue":"#6a5acd","slategray":"#708090","snow":"#fffafa","springgreen":"#00ff7f","steelblue":"#4682b4", 543 "tan":"#d2b48c","teal":"#008080","thistle":"#d8bfd8","tomato":"#ff6347","turquoise"
543:"#40e0d0", 544 "violet":"#ee82ee", 545 "wheat":"#f5deb3","white":"#ffffff","whitesmoke":"#f5f5f5", 546 "yellow":"#ffff00","yellowgreen":"#9acd32"}; 547 548 if (typeof colours[colour.toLowerCase()] != 'undefined') 549 return colours[colour.trim().toLowerCase()]; 550 551 return "#808080"; 552 } 553 function getFromRGB( color, transparency ) { 554 var result = ""; 555 if ( color.indexOf( 'a' ) == -1 ){ 556 result = color.replace( ')', ', ' + transparency + ' )').replace( 'rgb', 'rgba' ); 557 } 558 return result; 559 } 560 561 function getFromHex( color, transparency ) { 562 var searchrgba = new RegExp( "rgba" );; 563 if ( searchrgba.test( color ) == false ) { 564 if ( typeof color === 'string' ) { 565 var patt = /^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/; 566 var matches = patt.exec( color.trim() ); 567 if ( matches == null && searchrgba.test( color ) == false ) { 568 var matches = patt.exec( colourNameToHex( color.trim() ) ); 569 } 570 var rgba = "rgba(" + parseInt( matches[ 1 ], 16 ) + "," + parseInt( matches[ 2 ], 16 ) + "," + parseInt( matches[ 3 ], 16 ) + ", " + transparency + ")"; 571 return rgba; 572 } 573 else { 574 var colorcodes = []; 575 jQuery.each( color, function ( i, elem ) { 576 var patt = /^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/; 577 var matches = patt.exec( elem.trim() ); 578 if ( matches == null && searchrgba.test( color ) == false ) { 579 var matches = patt.exec( colourNameToHex( elem.trim() ) ); 580 } 581 colorcodes[ i ] = "rgba(" + parseInt( matches[ 1 ], 16 ) + "," + parseInt( matches[ 2 ], 16 ) + "," + parseInt( matches[ 3 ], 16 ) + ", " + transparency + ")"; 582 }) 583 return colorcodes; 584 } 585 } 586 else { 587 return color; 588 } 589 } 590 function get_random_color() { 591 var letters = '0123456789ABCDEF'.split(''); 592 var color = '#'; 593 for (var i = 0; i < 6; i++ ) { 594 color += letters[Math.round(Math.random() * 15)]; 595 } 596 return color; 597 } 598 }, 599 destroy: function() { 600 } 601}); 602 $.fn[ pluginName ] = function ( options ) { 603 var plugin = this.data(dataKey); 604 // has plugin instantiated ? 605 if (plugin instanceof Plugin) { 606 // if have options arguments, call plugin.init() again 607 if (typeof options !== 'undefined') { 608 plugin.init(options); 609 } 610 } else { 611 plugin = new Plugin(this, options); 612 this.data(dataKey, plugin); 613 } 614 return plugin; 615 }; 616})( jQuery, window, document );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.