// utility functions function get_offset( el, up_steps ) { var _x = 0 , _y = 0 , iterations = 1 ; while( ( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) && ( iterations <= up_steps ) ) { _x += el.offsetLeft - el.scrollLeft; _y += el.offsetTop - el.scrollTop; el = el.offsetParent; // console.log("offset iteration: "+iterations+" x offset: "+_x) ; iterations++ ; } return { top: _y, left: _x }; } String.prototype.toSentenceCase = function() { return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase() } function log(text) { console.log(text) ; } function log_o(text,object) { console.log(text) ; console.dir(object) ; } function log_s(vars) { // f.k.a. log_string var str = '' , i = 0 ; str += '\' • '+vars[i]+':|\'+'+vars[i]+'+\'|\'' ; for ( i = 1 ; i < vars.length ; i++ ) { str += '+\' • '+vars[i]+':|\'+'+vars[i]+'+\'|\'' ; } return str ; } function log_ts() { var ts = Date.now()+'' ; return ts.substring(0,1)+','+ts.substring(1,4)+','+ts.substring(4,7)+','+ts.substring(7,10)+'.'+ts.substring(10) ; } function pad(number,digits) { number +='' ; while ( number.length < digits ) { number = '0'+number ; } return number ; } // pad function pF(number_string) { return parseFloat(number_string) ; } function pI(number_string) { return parseInt(number_string) ; } function is_defined( the_variable ) { // this one for use in the js context return ( the_variable != undefined ) ; } function replace_all(what_string,with_string,the_string) { var what_pos = the_string.indexOf(what_string) ; while ( what_pos != -1 ) { the_string = the_string.substring(0,what_pos)+with_string+the_string.substring(what_pos+what_string.length) ; what_pos = the_string.indexOf(what_string) ; } ; // while there's still a what found in string return the_string ; } ; function digits_only(txt) { var output = '' , i = 0 ; for ( var i = 0 ; i < txt.length ; i++ ) { if ( ( txt.charCodeAt(i) >= 48 ) && ( txt.charCodeAt(i) <= 57 ) ) { output = output + txt.charAt(i) ; } } // console.log('digits_only input|'+txt+'| output|'+output+'|') ; return output ; } function js2mf(t) { // t is a time object return t.getFullYear()+'.'+pad((1+t.getMonth()),2)+'.'+pad(t.getDate(),2)+' '+pad(t.getHours(),2)+':'+pad(t.getMinutes(),2)+':'+pad(t.getSeconds(),2) ; } // js2mf function js2hmsd(t) { // t is a time object return pad(t.getHours(),2)+':'+pad(t.getMinutes(),2)+':'+pad(t.getSeconds(),2)+'.'+(pad(t.getMilliseconds(),3)).substring(0,2) ; } // js2mf function js2mfdate(t) { // t is a time object return t.getFullYear()+'.'+pad((1+t.getMonth()),2)+'.'+pad(t.getDate(),2) ; } // js2mf function touch_device() { var msTouchEnabled = window.navigator.msMaxTouchPoints , generalTouchEnabled = "ontouchstart" in document.createElement("div") ; if (msTouchEnabled || generalTouchEnabled) { return true; } else { return false; } ; } function is_an_e_mail(e_mail) { var e_regex = "\\w+([a-zA-Z0-9!#$%&‘*+-/=?^`.{|}~]?)*\\w+@\\w+([a-zA-Z0-9-]?)*\\w+.\\w{2,6}(.\\w{2,6})*" , match_output = e_mail.match(e_regex) ; if ( match_output ) { // need to double-check that there's at least one period after the @, since the stupid match function's not producting the right results here var at_pos = match_output[0].indexOf('@') , domain = match_output[0].substring(at_pos+1) , dot_pos = domain.indexOf('.') , dot_pos_correct = ( dot_pos > 1) && ( dot_pos <= ( domain.length - 1 - 2 ) ) ; // console.log("domain: "+domain+" length: "+domain.length+" dot_pos: "+dot_pos) ; return ( ( e_mail == match_output[0] ) && dot_pos_correct ) ; } else { return false ; } } // is_e_mail_valid function domain(e_mail) { var at_pos = e_mail.indexOf('@') ; if ( at_pos != -1 ) { return e_mail.substring(at_pos+1) } else { return '' ; } } function convert_base( no, fb, tb ) { if ( fb == tb ) { return no ; } var Lf = fb.length , Lt = tb.length , Ln = no.length , r = '' , b10 = '' ; if ( tb == '0123456789' ) { r = 0 ; for ( var i = 0 ; i < Ln ; i++ ) { r = r + parseInt( fb.indexOf( no.charAt( i ) ) ) * Math.pow( Lf, Ln - ( i + 1 ) ) ; } return r ; } ; if ( fb != '0123456789') b10 = convert_base( no , fb , '0123456789' ); else b10 = no ; if ( b10 < Lt ) return tb.charAt( b10 ); while( b10 != '0') { r = tb.charAt( b10 % Lt ) + r; b10 = Math.floor( b10/Lt ); } ; return r ; } var recent_ids = [] ; function new_id() { var p1 = '' + convert_base( Math.round( 4000 + ( ( 199999 - 4000) * Math.random() ) ) , '0123456789' , '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ) , t = new Date() , ts = '' + t.getTime() , p2 = '' + convert_base( ts , '0123456789' , '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ) , next_id = p1 + p2 , unique = true ; for ( var i = 0 ; i < recent_ids.length ; i++ ) { unique = unique && ( next_id != recent_ids[i] ) ; } if ( unique ) { recent_ids.push( next_id ) ; if ( recent_ids.length > 50 ) { recent_ids.shift() ; } return next_id ; } else { return new_id() ; } } // new_id function id_ts(id) { var ts_part = id.substring(3,10) ; return convert_base( ts_part , '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' , '0123456789' ) ; } // id_ts function sort_array_on ($scope,the_array,the_property) { the_array.sort ( function (a, b) { // console.dir($scope.OID[a.OIDref]); // console.log("a = |"+a.OIDref+"| |"+the_property+"| : |"+$scope.OID[a.OIDref][the_property]+"| b = |"+b.OIDref+"| |"+the_property+"| : |"+$scope.OID[b.OIDref][the_property]+"|"); // console.log("ab"); console.log("a=b"); if (parseInt($scope.OID[a.OIDref][the_property]) < parseInt($scope.OID[b.OIDref][the_property])) { return -1; } else if (parseInt($scope.OID[a.OIDref][the_property]) > parseInt($scope.OID[b.OIDref][the_property])) { return 1; } else { return 0; } } ); } // sort_array_on // variable page layout function get_CSS_rule(rule_name) { rule_name = rule_name.toLowerCase() ; if (document.styleSheets) { for ( var i = 0 ; i < document.styleSheets.length ; i++ ) { var styleSheet = document.styleSheets[i] , ii = 0 , cssRule = false ; do { if ( styleSheet.cssRules ) { cssRule = styleSheet.cssRules[ii] ; // Yes --Mozilla Style } else { cssRule = styleSheet.rules[ii] ; // Yes IE style. }; if ( cssRule ) { if ( cssRule.selectorText ) { if ( cssRule.selectorText.toLowerCase() == rule_name ) { //console.log("found rule "+rule_name) ; return cssRule; }; }; }; ii++ ; } while ( cssRule ) ; } ; } ; return false; }; function get_y_position(the_object) { if ( the_object ) { // log('get_y_position. the_object == truthy ') ; var current_top = 0; if (the_object.offsetParent) { do { current_top += the_object.offsetTop ; } while (the_object = the_object.offsetParent) ; // log('get_y_position. current_top: '+current_top ) ; return current_top; } ; } else { // log('get_y_position. the_object == falsy ') ; return 0 ; } } function set_up_dep_img_list(s) { s.m.dep_img_list = [] ; var i = 0 , img_count = 38 , next_no = 0 , next_no_ok = false , usage = [] , usage_template = { check : 0 } , dep_img_template = { img_no : '' } ; for ( i = 0 ; i < img_count ; i++ ) { usage.push( angular.copy( usage_template ) ) ; s.m.dep_img_list.push( angular.copy( dep_img_template ) ) ; } for ( i = 0 ; i < img_count ; i++ ) { next_no_ok = false ; while ( ! next_no_ok ) { next_no = Math.round( img_count * Math.random() ) ; if ( next_no < img_count ) { // is valid reference into usage array? if ( usage[next_no].check == 0 ) { // is not already used? usage[next_no].check = 1 ; next_no_ok = true ; } } } s.m.dep_img_list[i].img_no = pad( next_no , 3 ) ; // log('img_list: '+pad(i,2)+' '+s.m.dep_img_list[i].img_no) ; } } function set_m(s) { // called by catchresize and the check-width functions var m = s.m , h = window.innerHeight, // px w = document.getElementById( 'visible_width_div' ).offsetWidth, // px content_bottom = pI( get_y_position( document.getElementById( 'content_bottom' ) ) ) , min_h = 300, max_content_width = s.m.mcw , mcw = max_content_width , side_blank = Math.ceil( Math.max(0,w-(max_content_width)) / 2 ) , w100to50 = 0 , page_pad_max = 30 , page_pad_bp = 600 ; s.m.h = h; s.m.w = w; // log( 'in set_m, s.m.h='+s.m.h ) ; // log('set_m. content_bottom: '+content_bottom ) ; if (h>w) { min_h = 740; s.m.orientation = "portrait"; s.m.portrait = true ; if ( (h<740) || (w<420) ) { s.m.device = "mobile"; s.m.portrait_mobile = true ; } else { s.m.device = "not_mobile"; s.m.portrait_mobile = false ; }; } else { min_h = 420; s.m.orientation = "landscape"; s.m.portrait = false ; s.m.portrait_mobile = false ; if (h<420) { s.m.device = "mobile"; } else { s.m.device = "not_mobile"; }; }; s.m.max_content_width = max_content_width ; s.m.ww = 0 ; if ( w < page_pad_bp ) { s.m.page_pad = 0 ; s.m.ww = w ; } else { s.m.page_pad = ( w <= ( page_pad_bp + 2*page_pad_max ) ? ( 0.5 * (w - page_pad_bp) ) : page_pad_max ) ; s.m.ww = Math.min(w,mcw) - 2*s.m.page_pad ; } // s.m.ww = Math.min( w - 2*s.m.page_pad , mcw + 2*page_pad_max ) ; // working width // w100to50 width scales smoothly from 100% for portrait mobile down to 50% for max page width // w100to50 = Math.round(Math.min(100,Math.max(50,(100-((50/850)*(w-400)))))) ; s.m.w100to50.width = (s.w(s.m.w,500,650))+'px' ; // form layout and other parametric CSS rules var bp = 420 , maxlp = 100 * ( 120 + 16 ) / bp , // lp = length in percent ? unfortunately the drawing is lost on this one... minlp = 100 * ( 190 + 16 ) / mcw , dlp = minlp - maxlp , dw = mcw - bp , ml = dlp / dw , yl = maxlp + ml * ( w - bp ) , lp = Math.round( Math.min( maxlp , Math.max( minlp , yl ) ) ) , mintp = 70 , mt = ( mintp - 100 ) / dw , yt = 100 + mt * ( w - bp ) , ip = Math.round( Math.min ( 100 , Math.max( mintp , yt ))) - lp , w100to70 = Math.round(Math.min(w,mcw)*0.01*Math.min(100,Math.max(mintp,yt))) ; s.m.w100to70 = w100to70 ; s.m.gtfbp = ( w >= 600 ) ; // greater than (or equal to) form breakpoint s.m.ltfbp = ( w < 600 ) ; // less than form breakpoint if ( w < 600 ) { // put labels on top of inputs s.m.flp.textAlign = 'left' ; s.m.flp.fontSize = '0.95em' ; s.m.flp.paddingLeft = '0px' ; s.m.flp.marginBottom = '-2px' ; s.m.fid.clear = 'both' ; s.m.fi.width = s.w(w,420,500)+'px' ; s.m.fw.width = s.w(w,620,820)+"px" ; s.m.fld.width = w+'px' ; s.m.fire = s.w(w,420,500) ; // form input right end } else { // put labels to the left of inputs s.m.fld_width = s.w(w,420,175) ; s.m.fld.width = s.m.fld_width+'px' ; s.m.flp.textAlign = 'right' ; s.m.flp.fontSize = '1.0em' ; s.m.flp.paddingLeft = '0px' ; s.m.flp.marginBottom = '3px' ; s.m.fid.clear = 'none' ; s.m.fi_width = s.w(w,420,500) ; s.m.fi.width = s.m.fi_width+'px' ; s.m.fw.width = s.w(w,620,820)+"px" ; s.m.fire = s.w(w,420,175) + s.w(w,420,500) ; } ; s.m.fiw.width = s.w(w,420,500)+"px" ; // 280 r col width s.m.r300.width = ( s.m.ww < 600 ? s.m.ww : ( s.m.ww - (300 + 2) ) )+'px' ; s.m.r300.paddingLeft = ( s.m.ww < 600 ? 0 : '12px' ) ; // console.log("lp: "+lp+" ip: "+ip+ " sum: "+(lp+ip)+" yt: "+yt+" w100to70: "+w100to70) ; // derive left offset for l3 menu to line up with l2 selection, as necessary if ( s.show_menu ) { if ( s.yah_l2_i != '' ) { s.m.l3_abs_offset = get_offset( document.getElementById(s.menu[s.yah_l1_i].children[s.yah_l2_i].path_end) , 3 ).left ; } else { s.m.l3_abs_offset = '-1' ; } if ( s.m.l3_abs_offset > 10) { s.m.l3_rel_offset = s.m.l3_abs_offset - side_blank - s.m.page_pad ; } else { s.m.l3_rel_offset = 0 ; } if ( s.m.l3_rel_offset > 0 ) { s.m.l3_margin_left = s.m.l3_rel_offset -0 ; } else { s.m.l3_margin_left = 0 ; } } // derive deployment-pic tile count, size, if used s.m.H2O_h = ( s.m.dpics == 2 ? Math.min( 0.4*m.h , 0.33*m.w ) : Math.min( 0.25*m.h , 0.25*m.w ) ) ; if ( content_bottom > 0 ) { s.m.content_bottom = content_bottom ; var dep_tile = {} ; s.m.footer_offset = 27 ; s.m.max_dep_tile_w = 400 ; dep_tile.min = ( s.m.dpics == 2 ? 120 : 60 ) ; dep_tile.pad = 15.0 ; dep_tile.space = h - content_bottom - s.m.footer_offset ; dep_tile.max = ( s.m.dpics == 2 ? Math.min( s.m.max_dep_tile_w , dep_tile.space - s.m.m ) : 90 ) ; dep_tile.count = 1 ; dep_tile.ww = ( s.m.ww - ( 2 * s.m.m ) + dep_tile.pad ) ; dep_tile.count = Math.max( 2 , ( ( dep_tile.min > dep_tile.max ) ? Math.floor( dep_tile.ww / ( dep_tile.min + dep_tile.pad ) ) : Math.ceil( dep_tile.ww / ( dep_tile.max + dep_tile.pad ) ) ) ) ; dep_tile.w = ( dep_tile.ww / dep_tile.count ) - dep_tile.pad ; s.m.dep_tile_count = dep_tile.count ; s.m.dep_tile_w = dep_tile.w ; s.m.dep_tile_pad = dep_tile.pad ; s.m.dep_tile_offset = Math.max( s.m.m , ( dep_tile.space - dep_tile.w - ( 2*dep_tile.pad ) ) ) ; s.m.dep_tile = [] ; dep_tile_template = { img : '' } ; for ( var i = 0 ; i < dep_tile.count ; i++ ) { s.m.dep_tile.push( angular.copy( dep_tile_template ) ) ; // assign pics from array set up on page load from pics in db, in random order } // log_o('s.m.dep_tile:', s.m.dep_tile ) ; // log_o('dep_tile:' , dep_tile ) ; } // call page-specific dynamic formatting function, if extant if ( s.p ) { if ( s.p.set_m ) { s.p.set_m() ; } } } log('in serve_js.php, about to define theApp') ; var theApp = angular.module('theApp', [] ); // ['ngTouch'] log('theApp = '+( theApp ? 'true' : 'false' ) ) ; if ( theApp ) { log_o( 'theApp',theApp ) ; } theApp.controller('theController', function($scope, $sce, $http) { log('in theApp.controller') ; var s = $scope ; // metrics for parametric page rendering s.m = { m : 16 , // standard margin, in px mcw : 1250 , // max content width page_pad : 0 , w100to50 : get_CSS_rule(".w100to50").style , w100to70 : get_CSS_rule(".w100to70").style , fld : get_CSS_rule(".fld").style , flp : get_CSS_rule(".flp").style , fid : get_CSS_rule(".fid").style , fip : get_CSS_rule(".fip").style , fi : get_CSS_rule(".fi").style , fw : get_CSS_rule(".fw").style , fiw : get_CSS_rule(".fiw").style , r300 : get_CSS_rule(".r300").style , dpics_layout_ready : false } // variables common to all pages s.c = { cookies_enabled : true , user_agent : '' , user : '' , pass_min : '' , u0 : { e_mail : '' , user_class : 0 , group : '' , ent_id : '' , ent_class : '' , ent_name : '' } , u1 : { e_mail : '' , user_class : 0 , group : '' , ent_id : '' , ent_class : '' , ent_name : '' } , ent_class_index : { // retrieve ent and user classes from master definition in 2ls.php browser : 0 , prospect : 1 , customer : 2 , named_account : 3 , integrator : 4 , integrator_c : 5 , reseller : 6 , reseller_c : 7 , vad : 8 , vad_c : 9 , distributor : 10 , strat_partner : 11 , strat_partner_c : 12 , Tarana : 13 } , ent_classes : [ { class : 'browser' , disp : 'browser' } ,{ class : 'prospect' , disp : 'prospect' } ,{ class : 'customer' , disp : 'customer' } ,{ class : 'named_account' , disp : 'named account' } ,{ class : 'integrator' , disp : 'integrator' } ,{ class : 'integrator_c' , disp : 'integrator, certified' } ,{ class : 'reseller' , disp : 'reseller' } ,{ class : 'reseller_c' , disp : 'reseller, certified' } ,{ class : 'vad' , disp : 'VAD' } ,{ class : 'vad_c' , disp : 'VAD, certified' } ,{ class : 'distributor' , disp : 'distributor' } ,{ class : 'strat_partner' , disp : 'strategic partner' } ,{ class : 'strat_partner_c' , disp : 'strategic partner, certified' } ,{ class : 'Tarana' , disp : 'Tarana' } ] , ent_classes_count : 14 , ent_class_abbrv : { // for cross-referencing between long-form entity class to abbreviated form browser : 'b' ,prospect : 'p' ,customer : 'c' ,named_account : 'na' ,integrator : 'iu' ,integrator_c : 'ic' ,reseller : 'ru' ,reseller_c : 'rc' ,vad : 'vu' ,vad_c : 'vc' ,distributor : 'd' ,strat_partner : 'su' ,strat_partner_c : 'sc' ,Tarana : 'T' } , user_classes : [ { class : 1 , disp : 'individual' } ,{ class : 2 , disp : 'manager1' } ,{ class : 3 , disp : 'manager2' } ,{ class : 4 , disp : 'admin' } ,{ class : 5 , disp : 'wheel' } ] , user_classes_count : 5 , user_class_rb_index : 5 , // was ent_classes, which seems wrong file_classes : [ { class : 'release' , disp : 'release' , icon : 'i_release.svg' } ,{ class : 'image' , disp : 'image' , icon : 'i_image.svg' } ,{ class : 'video' , disp : 'video' , icon : 'i_video.svg' } ,{ class : 'collateral' , disp : 'collateral' , icon : 'i_collateral.svg' } ,{ class : 'page' , disp : 'page' , icon : 'i_page.svg' } ,{ class : 'other' , disp : 'other' , icon : 'i_other.svg' } ] , file_classes_count : 6 , release_subclasses : [ { class : 'sys_release' , disp : 'sys release' , icon : 'i_sys_release.svg' } ,{ class : 'release_note' , disp : 'release note' , icon : 'i_release_note.svg' } ,{ class : 'docs_segment' , disp : 'docs segment' , icon : 'i_docs_segment.svg' } ,{ class : 'docs_bundle' , disp : 'docs bundle' , icon : 'i_docs_bundle.svg' } ] , release_subclasses_count : 4 , collateral_subclasses : [ { class : 'presentation' , disp : 'presentation' , icon : 'i_presentation.svg' } ,{ class : 'white_paper' , disp : 'white paper' , icon : 'i_white_paper.svg' } ,{ class : 'datasheet' , disp : 'datasheet' , icon : 'i_datasheet.svg' } ,{ class : 'app_note' , disp : 'app note' , icon : 'i_app_note.svg' } ,{ class : 'report' , disp : 'report' , icon : 'i_report.svg' } ,{ class : 'other' , disp : 'other' , icon : 'i_other.svg' } ] , release_subclasses_count : 4 , get_u_tbl : true , u_tbl : [ ] , // users table for u1 ent_id, array form for ng-repeat use as necessary u_ix : { } , // index to users table, to map from an e_mail (user id) to u_tbl array index text_check : false , print_view : false , show_debug : false , call_p_set_m : false , eval_response : ' ', exp_to_eval : '' , show_current_ua_info : false , show_confirm_dialog : false , confirm_case : '' } s.a = { return_caught : false } ; // required for the keyBind directives // utility functions s.min = function(a,b) { return Math.min(a,b) ; } s.max = function(a,b) { return Math.max(a,b) ; } s.rcol = function(bp,lcol) { // right column width in px given a left column width and a window width breakpoint if ( s.m.w < bp ) { return s.m.ww ; } else // s.m.ww == working width { return s.m.ww - lcol ; } } // rcol s.w = function(x,bp,max) { // delivers width in px for the three-line model from breakpoint < max <= max_content_width var a = x - 2 * s.m.m , b0 = bp - 2 * s.m.m , b = b0 + ( x - bp ) * ( ( ( max - 2 * s.m.m ) - b0 ) / ( s.m.mcw - bp ) ) , c = max - 2 * s.m.m ; if ( max > bp ) { return Math.round(Math.min(a,b,c)) ; } else { return Math.round(Math.min(a,c)) ; } } // w s.check_w = function() { // console.log("check_w called, $scope.m.w = "+$scope.m.w); // log( 'check_w, before setTimeout '+log_ts() ) ; setTimeout( function() { var new_w = document.getElementById("visible_width_div").offsetWidth ; // console.log("check_w: "+new_w); $scope.handle_window_resize(); $scope.$apply() ; // log( 'check_w, inside setTimeout '+log_ts() ) ; } , 50 ) ; }; s.in = function( the_thing , the_array ) { var is_in = false , l = the_array.length , i = 0 ; while ( ( ! is_in ) && ( i < l ) ) { is_in = ( the_array[i] == the_thing ) ; i++ ; } return is_in ; } s.is_defined = function( the_variable ) { // this one for use in the html context return ( the_variable != undefined ) ; } s.second_hand = function() { var deg = 0 , dpt = 10 , // degrees per tick spt = 1 , // seconds per tick interval = spt * 1000 ; setInterval(function(){ deg = ( deg == (360 - dpt) ) ? 0 : ( deg + dpt ) ; s.m.second_hand = deg ; s.$apply() ; }, interval ) ; } s.startup_this_page = function() { } // overwritten by individual pages as required s.rb_trustAsHtml = function(rb_obj) { if ( rb_obj ) { if ( rb_obj.options[0] ) { log( 'rb_tAH, rb_obj.options[0].option = '+rb_obj.options[0].option ) ; } else { log( 'rb_tAH, rb_obj.option[0] non-object' ) ; } } else { log( 'rb_tAH, rb_obj non-object' ) ; } log('rb_trustAsHtml for '+rb_obj.options[0].option ) ; for ( var i = 0 ; i < rb_obj.options.length ; i++ ) { rb_obj.options[i].option = $sce.trustAsHtml( rb_obj.options[i].option ) ; } } // rb_trust s.rb_set = function(rb_obj,num) { for ( var i = 0 ; i < rb_obj.options.length ; i++ ) { rb_obj.options[i].selected = ( i == num ) ; } rb_obj.selection = num ; } // rb_set s.rb_clear = function(rb_obj) { for ( var i = 0 ; i < rb_obj.options.length ; i++ ) { rb_obj.options[i].selected = false ; } rb_obj.selection = '' ; } s.apply_list_filter = function(list,field,filter) { var lc_filter = filter.toLowerCase() , filter_size = lc_filter.length , left_chars = '' , this_row = {} ; // log('apply_list_filter'+eval(log_s(['filter','filter_size']))) ; for ( var i = 0 ; i < list.length ; i++ ) { this_row = list[i] ; if ( filter_size > 0 ) { // log('filter size > 0') ; left_chars = this_row[field].substring(0,filter_size) ; left_chars = left_chars.toLowerCase() ; this_row.filter = ( left_chars == lc_filter ) ; } else { // log('filter size !> 0') ; this_row.filter = true ; } } } // apply_list_filter s.ua_profile = function() { var ua = { ec : '' , ei : '' , en : '' , uc : '' , u1 : '' } ; if ( s.c.u1.ent_class != s.c.u0.ent_class ) { ua.ec = s.c.u1.ent_class ; } if ( s.c.u1.ent_id != s.c.u0.ent_id ) { ua.ei = s.c.u1.ent_id ; ua.en = s.c.u1.ent_name ; } if ( s.c.u1.user_class != s.c.u0.user_class ) { ua.uc = s.c.u1.user_class ; } if ( s.c.u1.e_mail != s.c.u0.e_mail ) { ua.u1 = s.c.u1.e_mail ; } return ua ; } // build_ua_entry s.nop = function() { // } // do nothing // common view response & page logistics s.cookies_enabled_check = function() { if ( s.cc_code != "NOP" ) { var http_string = "ajax/cookies_enabled.php?p1="+s.cc_code ; // console.log("cookie_check called, query = "+http_string) ; $http.get(http_string) .success(function(data,status) { s.c.cookies_enabled = data[0].cookies_enabled ; s.cc_msg = data[0].msg ; // console.log("cookie_check success. cookies_enabled = "+s.cookie_check+" msg = "+s.cc_msg) ; }) .error(function(data,status) { // console.log("cookie_check failed") ; }) ; } else { // console.log("cookies_enabled_check, cc_code = NOP") ; s.c.cookies_enabled = true ; s.cc_msg = "cc_code = NOP" ; } } // function cookie_check s.get_location_from_IP = function() { log('getting session location from IP') ; var http_string = "ajax/get_session_location_from_IP.php" ; $http.get(http_string) .success(function(data,status) { }) .error(function(data,status) { }) ; s.get_location = false ; } // function cookie_check s.log_action = function(action,content_class,content_id) { // log('logging action'+eval(log_s(['action','content_class','content_id']))) ; var ua = ( s.c.spoofing ? JSON.stringify(s.ua_profile()) : '' ) ; var http_string = "ajax/log_action.php?" + "u=" + s.c.u0.e_mail +"&"+ "ua=" + ua +"&"+ "a=" + action +"&"+ "cc=" + content_class +"&"+ "ci=" + content_id ; $http.get(http_string) .success(function(data,status) { // log('logged action'+eval(log_s(['action','content_class','content_id']))) ; }) .error(function(data,status) { }) ; } // function log_action s.log_page_load = function() { if ( s.c.spoofing ) { // need to retrieve ent_name for using-as object var http_string = "ajax/get_json_from_mtable.php?t=entities&w=ent_id %3d '" + s.c.u1.ent_id + "'" ; // console.log(http_string) $http.get(http_string) .success(function(data,status) { if ( data.length > 0 ) { // console.dir(data) ; s.c.u1.ent_name = data[0].name ; } s.log_action('loaded','page','/'+s.requested_path) ; }) .error(function(data,status) { }) ; } else { s.log_action('loaded','page','/'+s.requested_path) ; } }// log_page_load s.log_download = function(content_class,content_id) { // log('log_download: '+content_class+', '+content_id) ; setTimeout( function() { s.log_action('downloaded',content_class,content_id) ; } , 1000 ) ; // console.log('post log_action') ; } // log_download s.log_out = function() { var http_string = "ajax/end_session.php?u="+s.c.u0.e_mail ; $http.get(http_string) .success(function(data,status) { // console.log("msg: "+data[0].msg) ; window.location = "/private" ; }) .error(function(data,status) { }) ; } s.reload_requested_path = function() { if ( s.requested_path.length == 0 ) { s.requested_path = 'private' ; } window.location = s.requested_path ; } s.build_users_table = function() { var c = s.c , ent_id = c.u1.ent_id , where_clause = "ent_id \= \'"+ent_id+"\' order by f_name, l_name" , http_string = "ajax/get_json_from_mtable.php?t=users&w="+where_clause ; // log("where clause: "+where_clause) ; $http.get(http_string) .success(function(data,status) { if ( data.length > 0 ) { c.u_tbl = angular.copy(data) ; var dupe_count = 0 ; for ( var i = 0 ; i < c.u_tbl.length ; i++ ) { // set disp_name for each user if ( i == 0 ) { c.u_tbl[i].disp_name = c.u_tbl[i].f_name ; } else { if ( c.u_tbl[i].f_name == c.u_tbl[i-1].f_name ) { if ( c.u_tbl[i].l_name.charAt(0) == c.u_tbl[i-1].l_name.charAt(0) ) { dupe_count++ ; c.u_tbl[i].disp_name = c.u_tbl[i].f_name + ' ' + c.u_tbl[i].l_name.charAt(0) + ( dupe_count > 1 ? ' ' + dupe_count : '' ) ; } else { dupe_count = 0 ; c.u_tbl[i].disp_name = c.u_tbl[i].f_name + ' ' + c.u_tbl[i].l_name.charAt(0) ; } // else where last initials are not dupes } else { dupe_count = 0 ; c.u_tbl[i].disp_name = c.u_tbl[i].f_name ; } // else where f_name not dupe } // else where i > 0 // set index c.u_ix[c.u_tbl[i].user] = i ; } // for i < u_tbl.length // log_o('c.u_tbl:',c.u_tbl) ; // log_o('c.u_ix:',c.u_ix) ; s.finish_common_startup() ; } else { s.finish_common_startup() ; }// if data.length > 0 }) .error(function(data,status) { log( 'error in build_users_table http.get response. status: '+status ) ; s.finish_common_startup() ; }) ; } // build_users_table s.do_confirm_dialog = function(the_case) { s.c.confirm_case = the_case ; s.c.show_confirm_dialog = true ; } // forms, tables, and action-button automation s.handle_form_input = function( form_name , field_i , opt_i ) { var form = s.p[form_name] , fields = form.fields , field = fields[field_i] ; switch ( field.ui_type ) { case 'input' : break ; case 'radio buttons' : var opts = field.options ; for ( var i = 0 ; i < opts.length ; i++ ) { opts[i].sel = ( i == opt_i ) ; } field.curr_sel = opt_i ; field.new_val = opts[opt_i].val ; break ; case 'checkbox' : field.new_val = ( field.new_val == 1 ? 0 : 1 ) ; break ; case 'pick list' : if ( opt_i == -1 ) { // flag that filter has changed s.apply_list_filter( field.list , 'val' , field.filter ) ; } else { var list = field.list ; for ( var i = 0 ; i < list.length ; i++ ) { list[i].sel = ( i == opt_i ) ; } field.curr_sel = opt_i ; field.new_val = list[opt_i].val ; } break ; case 'sfdc pick object' : switch ( opt_i ) { case -1 : // flag that filter has changed s.apply_list_filter( field.list , 'val' , field.filter ) ; break ; case -2 : // flag that user has x'd (cancelled) the selected entry field.curr_sel = '' ; field.new_val = '' ; field.filter = '' ; var list = field.list ; s.apply_list_filter( list , 'val' , field.filter ) ; for ( var i = 0 ; i < list.length ; i++ ) { list[i].sel = false ; } break ; default : var list = field.list ; for ( var i = 0 ; i < list.length ; i++ ) { list[i].sel = ( i == opt_i ) ; } setTimeout( function() { field.curr_sel = opt_i ; field.new_val = list[opt_i].val ; log('sfdc pick object selection made '+eval(log_s(['opt_i','field.curr_sel']))) ; s.$apply() ; } , 500 ) ; } break ; case 'textarea' : break ; } // update changed form.changed = false ; for ( var i = 0 ; i < fields.length ; i++ ) { form.changed = form.changed || ( fields[i].new_val != fields[i].old_val ) ; } // call page-specific handler as required // log('handle_input'+eval(log_s(['form_name','field_i','opt_i','field.db_name','field.new_val']))) ; if ( field.p_handler ) { s.p.handle_input( form_name , field_i , opt_i ) ; } } // handle_input s.set_table_rpp = function( table_name ) { var table = s.p[table_name] , offset_top = pI( get_y_position( document.getElementById( table_name ) ) ) , offset_bottom = 0 , caption = ( ( table.caption || table.cap_comment || table.rpp ) ? 31 : 0 ) , header = ( table.headers ? 33 : 0 ) , table_footer = ( table.footer ? 23 : 0 ) + ( ( table.refresh_button || ( table.data_age != undefined ) ) ? 23 : 0 ) , window_footer = 23 , working_height = 20 + s.m.h - offset_top - ( caption + header + table_footer + window_footer ) ; if ( table.actions_name ) { var actions_elem = document.getElementById(table.actions_name) ; offset_bottom = 20 + ( actions_elem ? actions_elem.offsetHeight : 0 ) ; // including some margin working_height -= offset_bottom ; } table.rpp = Math.max( ( table.min_rows ? table.min_rows : 5 ) , Math.floor( working_height / 33 ) ) ; // table rows per page if ( table.selection != undefined ) { table.selection = 0 ; } table.page = 1 ; table.pages = Math.ceil( ( table.rows.length - 1 ) / table.rpp ) ; // correct for dummy entry at index 0 // log('set_table_rpp'+eval(log_s(['s.p[table_name].rpp']))) ; } s.tbl_page_change = function( table_name , which_direction ) { var table = s.p[table_name] ; switch ( which_direction ) { case 'next' : table.page++ ; break; case 'previous' : table.page-- ; break; } if ( table.selection != undefined ) { table.selection = 0 ; } // reset to the dummy entry at index 0 } s.handle_table_input = function( table_name , row_i ) { s.p[table_name].selection = row_i ; } // common database interactions and related UI bits s.apply_ent_filter = function() { var lc_filter = s.p.ent_filter.toLowerCase() , filter_size = lc_filter.length ; for ( var i = 0 ; i < s.p.entities.length ; i++ ) { if ( filter_size > 0 ) { var left_chars = s.p.entities[i].name.substring(0,filter_size) ; left_chars = left_chars.toLowerCase() ; s.p.entities[i].filter = ( left_chars == lc_filter ) ; } else { s.p.entities[i].filter = true ; } } } // apply_ent_filter s.get_entity_list = function() { s.p.getting_entities = true ; var selected_class = s.p.ent_class_rb.options[s.p.ent_class_rb.selection].val , where_clause = "ent_class \= \'"+selected_class+"\' order by name" , http_string = "ajax/get_json_from_mtable.php?t=entities&w="+where_clause ; // console.log("where clause: "+where_clause) ; $http.get(http_string) .success(function(data,status) { if ( data.length > 0 ) { if ( selected_class == s.p.ent_class_rb.options[s.p.ent_class_rb.selection].val ) { // if user hasn't changed mind within http cycle time s.p.entities = angular.copy(data) ; s.apply_ent_filter() ; s.p.getting_entities = false ; // console.dir(s.p.entities) ; } } else { s.p.entities = [] ; } }) .error(function(data,status) { }) ; } // get_entity_list // dev s.exp_eval = function() { s.c.eval_response = JSON.stringify( eval( s.c.exp_to_eval ) ) ; } s.finish_common_startup = function() { log('finish_common_startup') ; s.m.home = ( !s.new_session ) && ( ( s.requested_path == '' ) || ( s.requested_path == 'private' ) ) ; s.startup_this_page() ; } // finish styling/layout variable setup set_m(s) ; set_up_dep_img_list(s) ; setTimeout( function() { $scope.$apply( s.m.dpics_layout_ready = true ) ; } , 30 ) ; // stall to prevent flash of unfinished page layout on first load //=== page-specific variable/object and function definitions, loaded as js fragment from inc directory s.p = { //state show_welcome : true , show_intro_form : false , show_intro_e_mail : false , login_e_mail_valid : false , show_simple_request_reset_msg : false , auth_fail : false , reset_sent : false , get_passes : '' , just_pass : '' , passes_short : '' , passes_ok : '' , get_member_info : '' , categorize_new : '' , get_prospect_info : '' , get_new_info : '' , member_info_ok : '' , new_info_ok : '' , prospect_info_ok : '' , e_mail_confirm_sent : '' , post_submit_disable : '' , accessing : false , //form inputs and other data e_mail1 : '' , e_mail2 : '' , pass1 : '' , pass2 : '' , f_name : '' , l_name : '' , title : '' , ent_id : '' , // passed back by check_new_e_mail ajax org_name : '' , // likewise, in the member-org case city : '' , country : '' , phone : '' , aff_rb : { "options" : [ { "option":$sce.trustAsHtml("new indirect customer
(please mention your product source below)") , "selected":false , "short_aff":"new customer" }, { "option":$sce.trustAsHtml("supporting a current Tarana customer") , "selected":false , "short_aff":"customer aff" }, { "option":$sce.trustAsHtml("working with a current Tarana partner") , "selected":false , "short_aff":"partner aff" }, { "option":$sce.trustAsHtml("other (described below)") , "selected":false , "short_aff":"see msg" } ] , "selection" : "" } , serial : '' , msg : '' , //messages e_mail_notice : $sce.trustAsHtml(' ') , post_cat_msg : $sce.trustAsHtml(' ') , password_notice : $sce.trustAsHtml(' ') , plain_link_message : 'One last step:  We\'ve sent you a confirmation link in e-mail; just click on that to finish the process.  (Note that your e-mail client may have put it in your spam folder.)' , post_new_user_submit_notice : '' , new_cat_rb : { options : [ { option : $sce.trustAsHtml('just browsing, and interested in a little more detail about AbsoluteAir 2') , cat : 'browser' , selected : false } , { option : $sce.trustAsHtml('looking for a solution to a current enterprise or radio backhaul connectivity problem') , cat : 'prospect' , selected : false } , { option : $sce.trustAsHtml('working with Tarana equipment and need access to resources or support') , cat : 'cust_part' , selected : false } ] , selection : '' } , test_var : 'hello, world' } log( 's.p defined in new_session.js, s.p.test_var = ' + s.p.test_var ) ; log( 'new_cat_rb is '+ ( s.p.new_cat_rb ? 'defined' : 'undefined' ) ) ; s.set_post_e_mail_view_defaults = function() { s.p.e_mail_notice = $sce.trustAsHtml(' ') ; s.p.get_passes = false ; s.p.just_pass = false ; s.p.passes_short = false ; s.p.passes_ok = false ; s.p.get_member_info = false ; s.p.categorize_new = false ; s.p.get_prospect_info = false ; s.p.get_new_info = false ; s.p.member_info_ok = false ; s.p.new_info_ok = false ; s.p.e_mail_confirm_sent = false ; s.p.post_submit_disable = false ; s.rb_clear(s.p.aff_rb) ; s.rb_clear(s.p.new_cat_rb) ; } s.validate_login_e_mail = function() { s.p.login_e_mail_valid = is_an_e_mail(s.c.u0.e_mail) ; } // validate_e_mail s.check_credentials = function() { if ( ( s.c.u0.e_mail.length > 0 ) && ( s.p.password.length > 0 ) ) { s.p.accessing = true ; console.log('checking credentials') ; s.p.auth_fail = false ; s.p.reset_sent = false ; var http_string = "ajax/check_credentials.php?u="+s.c.u0.e_mail+"&p="+s.p.password ; // console.log("checking credentials, httpget: "+http_string) ; $http.get(http_string) .success(function(data,status) { log_o('check_credentials, success, data:',data) ; s.p.auth_fail = ( data[0].authed == false ) ; s.auth_msg = data[0].msg ; if ( ! s.p.auth_fail ) { s.log_action('logged in','user_agent',s.c.user_agent) ; console.log("auth success, s.requested_path (before): "+s.requested_path) ; if ( ( s.requested_path == '' ) || ( s.params[1] == 'login' ) ) { s.requested_path = '/private' ; } else { s.requested_path = '/'+s.requested_path ; } // console.log("auth success, s.requested_path (after): "+s.requested_path) ; setTimeout( function () { window.location = s.requested_path ; }, 100 ) ; } else { s.log_action("login failure","","") ; s.p.accessing = false ; } }) .error(function(data,status) { s.p.auth_fail = true ; s.auth_msg = "check_credentials.php failed to respond" ; }) ; } // if neither u nor p is an empty string } s.send_pass_reset = function() { var http_string = "ajax/send_pass_reset.php?u="+s.c.u0.e_mail ; $http.get(http_string) .success(function(data,status) { s.p.show_simple_request_reset_msg = false ; // hides this, if shown s.p.auth_fail = false ; // hides the auth fail message, if shown s.p.reset_sent = true ; // console.log("reset code: "+data[0].reset_code+" length: "+data[0].reset_code.length+" msg: "+data[0].msg) ; }) .error(function(data,status) { s.p.reset_sent = false ; }) ; } s.start_introduction = function() { s.p.show_welcome = false ; s.p.show_intro_form = true ; s.p.show_intro_e_mail = true ; } s.check_new_e_mail = function() { s.set_post_e_mail_view_defaults(); if ( ( s.p.e_mail1 == s.p.e_mail2 ) && ( s.p.e_mail1.length > 0 ) ) { if ( ! is_an_e_mail( s.p.e_mail1 ) ) { s.p.e_mail_notice = $sce.trustAsHtml('Please enter a valid e-mail address.') ; } else { s.p.e_mail_notice = $sce.trustAsHtml(' ') ; var at_pos = s.p.e_mail1.indexOf('@') , domain = s.p.e_mail1.substring(at_pos+1) ; domain = domain.toLowerCase() ; // find out which branch we're in var http_string = "ajax/check_new_e_mail.php?d="+domain+"&e="+s.p.e_mail1 ; $http.get(http_string) .success(function(data,status) { var msg = '' ; switch (data[0].case) { case 'duplicate' : msg = 'This e-mail address is already on our list.  If it\'s yours, please try using it to log in.  Otherwise, you may want to contact your team\'s e-mail account administrator.' ; break ; case 'Tarana' : msg = "Thanks.  For Taranans, we just need a password and you're good to go." ; s.p.get_passes = true ; s.p.just_pass = true ; // enable submit button when passes match and are sufficiently long break ; case 'member' : msg = "Thanks.  We're pleased to welcome a new member from the "+data[0].name+" team.  We need you to set a password and provide a little more info:" ; s.p.get_passes = true ; s.p.get_member_info = true ; s.p.ent_id = data[0].ent_id ; s.p.org_name = data[0].name ; break ; case 'new' : msg = "Thanks.  Looks like we don't have your company or organization on our list, based on your e-mail domain.  Please choose the description below that fits you best:" ; s.p.categorize_new = true ; // Our Private site resources are reserved for our customers and partners.  If you need access to support a customer, or if you are a new customer who purchased your Tarana equipment indirectly, please share with us the info below, and we'll get back to you promptly." ; // s.p.get_new_info = true ; break ; case 'disallowed' : msg = "Thanks for your interest.  Our Private site is reserved for interested professionals, customers, and partners.  Please feel free to browse our public site." ; break ; } s.p.e_mail_notice = $sce.trustAsHtml(msg) ; }) .error(function(data,status) { s.p.reset_sent = false ; }) ; } } } // check_new_e_mail s.passes_check = function() { var passes_match = ( s.p.pass1 == s.p.pass2 ) && ( s.p.pass1.length > 0 ) ; if ( passes_match ) { s.p.passes_short = s.p.pass1.length < s.c.pass_min ; } else { s.p.passes_short = false ; } s.p.passes_ok = passes_match && !s.p.passes_short ; } // passes_check s.submit_pass = function() { // applies to the Tarana and browser cases -- sends confirm e-mail as well var Taranan = ( domain(s.p.e_mail1) == 'taranawireless.com' ) , ajax_filename = ( Taranan ? 'add_Taranan' : 'add_browser') ; if ( s.p.passes_ok && !s.p.post_submit_disable ) { // catches premature use of the "enter" key, and prevents resubmission var at_pos = s.p.e_mail1.indexOf('@') , sentenced = s.p.e_mail1.toSentenceCase() , f_name = sentenced.substring(0,at_pos) , http_string = 'ajax/'+ajax_filename+'.php?u='+s.p.e_mail1+"&p="+s.p.pass1+"&f="+f_name ; s.p.post_submit_disable = true ; //console.log("submit_pass, http_string: "+http_string+" at_pos: "+at_pos+" sentenced: "+sentenced ) ; $http.get(http_string) .success(function(data,status) { s.p.e_mail_confirm_sent = true ; s.p.show_intro_e_mail = false ; s.p.get_passes = false ; if ( !data[0].sent ) s.p.post_new_user_submit_notice = $sce.trustAsHtml('This e-mail address is already on our list.  If it\'s yours, please try using it to log in.') ; }) .error(function(data,status) { console.log("save_pass_send_e_confirm.php error") ; }) ; } } // submit_pass s.member_info_check = function() { s.p.member_info_ok = s.p.passes_ok && s.p.f_name.length > 0 && s.p.l_name.length > 0 && s.p.city.length > 0 && s.p.country.length > 0 ; } //aff_info_check s.submit_member_ee_info = function() { if ( s.p.member_info_ok ) { var http_string = "ajax/add_member_ee.php?"; http_string += 'u=' + s.p.e_mail1 + '&p=' + s.p.pass1 + '&fn=' + s.p.f_name + '&ln=' + s.p.l_name + '&ei=' + s.p.ent_id + '&en=' + s.p.org_name + '&ci=' + s.p.city + '&co=' + s.p.country ; s.p.post_submit_disable = true ; $http.get(http_string) .success(function(data,status) { s.p.e_mail_confirm_sent = true ; s.p.post_new_user_submit_notice = $sce.trustAsHtml('You\'re on our list now.  '+s.p.plain_link_message) ; s.p.show_intro_e_mail = false ; s.p.get_passes = false ; s.p.get_member_info = false ; }) .error(function(data,status) { }) ; } } // submit member ee info s.new_info_check = function() { // console.log('fn: '+s.p.f_name.length+'ln: '+s.p.l_name.length+' ti: '+s.p.title.length+' en: '+s.p.org_name.length+' ci: '+s.p.city.length+ // ' co: '+s.p.country.length+' af: |'+s.p.aff_rb.selection+'| se: '+s.p.serial.length+' me: '+s.p.msg.length) ; s.p.new_info_ok = s.p.f_name.length > 0 && s.p.l_name.length > 0 && s.p.title.length > 0 && s.p.org_name.length > 0 && s.p.city.length > 0 && s.p.country.length > 0 && s.p.aff_rb.selection.length != '' && s.p.serial.length > 0 && s.p.msg.length > 0 ; } //new_info_check s.prospect_info_check = function() { s.p.prospect_info_ok = s.p.f_name.length > 0 && s.p.l_name.length > 0 && s.p.title.length > 0 && s.p.org_name.length > 0 && s.p.msg.length > 0 ; } //new_info_check s.submit_prospect_info = function() { if ( s.p.prospect_info_ok && s.p.passes_ok ) { var http_string = "ajax/add_prospect.php?"; // adds to db, sends e-mail conf, sends profile to wheel for approval http_string += 'u=' + s.p.e_mail1 + '&p=' + s.p.pass1 + '&fn=' + s.p.f_name + '&ln=' + s.p.l_name + '&ti=' + s.p.title + '&en=' + s.p.org_name + '&me=' + s.p.msg ; s.p.post_submit_disable = true ; $http.get(http_string) .success(function(data,status) { s.p.e_mail_confirm_sent = true ; s.p.post_new_user_submit_notice = $sce.trustAsHtml(s.p.plain_link_message+'  You\'ll have access to baseline product information as soon as your e-mail address is confirmed.

We\'ll review your info promptly and send you another note when we\'ve upgraded you to full pre-sales access, including our complete link gallery, network planning guidance, product specs, and high-level pricing.') ; s.p.show_intro_e_mail = false ; s.p.get_prospect_info = false ; s.p.get_passes = false ; }) .error(function(data,status) { }) ; } } // submit new info s.submit_new_info = function() { if ( s.p.new_info_ok ) { var http_string = "ajax/add_new_aff.php?"; http_string += 'u=' + s.p.e_mail1 + '&fn=' + s.p.f_name + '&ln=' + s.p.l_name + '&ti=' + s.p.title + '&en=' + s.p.org_name + '&ci=' + s.p.city + '&co=' + s.p.country + '&af=' + s.p.aff_rb.options[s.p.aff_rb.selection].short_aff + '&se=' + s.p.serial + '&me=' + s.p.msg ; s.p.post_submit_disable = true ; $http.get(http_string) .success(function(data,status) { s.p.e_mail_confirm_sent = true ; s.p.post_new_user_submit_notice = $sce.trustAsHtml('...for your information. We\'ll get back to you promptly.') ; s.p.show_intro_e_mail = false ; s.p.get_new_info = false ; }) .error(function(data,status) { }) ; } } // submit new info s.e_mail_test = function() { s.p.e_val = is_an_e_mail(s.p.e_mail1) ; } s.take_new_category_action = function( i ) { var msg = 'Great.  ' ; s.rb_set(s.p.new_cat_rb,i) ; s.p.get_passes = s.p.just_pass = s.p.get_prospect_info = s.p.get_new_info = false ; // reset everything switch ( i ) { case 0 : // just browsing msg += 'We just need you to choose a password and you\'re good to go.' ; s.p.get_passes = true ; s.p.just_pass = true ; break ; case 1 : // prospect msg += 'Please tell us a little more about yourself and your application:' ; s.p.get_passes = true ; s.p.get_prospect_info = true ; break ; case 2 : // current customer/partner, but domain not registered msg += 'Please share with us the info below, and we\'ll get back to you promptly.' ; s.p.get_new_info = true ; break ; } s.p.post_cat_msg = $sce.trustAsHtml(msg) ; } s.startup_this_page = function() { // log('startup_this_page called for new_session.js') ; // s.rb_trustAsHtml(s.p.aff_rb) ; // s.rb_trustAsHtml(s.p.new_cat_rb) ; if ( ( s.params[1] == 'intro' ) || ( s.params[1] == 'register' ) ) { // route to third html block in new_sessions.html s.p.show_welcome = false ; s.p.show_intro_form = true ; s.p.show_intro_e_mail = true ; } if ( s.params[2] == 'reset' ) { s.p.show_simple_request_reset_msg = true ; } if ( s.params[1] == 'login' ) { if ( s.params[2].length > 0 ) { s.c.u0.e_mail = s.params[2] ; } } s.p.post_new_user_submit_notice = $sce.trustAsHtml(s.p.plain_link_message) ; s.set_post_e_mail_view_defaults(); s.second_hand() ; } // startup_this_page //=== startup steps for every page // log('taking startup steps') ; s.check_w() ; php_handoff(s,$http) ; s.cookies_enabled_check() ; if ( s.get_location ) { s.get_location_from_IP() ; } if ( ! s.new_session ) s.log_page_load() ; if ( s.c.get_u_tbl ) { s.build_users_table() ; // calls s.finish_common_startup when successful -- can turn off on individual pages if not required } else { s.finish_common_startup() ; } } ) ; // theApp.controller //=== custom directives theApp.constant('keyCodes', { esc: 27, space: 32, enter: 13, tab: 9, backspace: 8, shift: 16, ctrl: 17, alt: 18, capslock: 20, numlock: 144 }); theApp.directive('keyBind', ['keyCodes', function (keyCodes) { // usage example: function map(obj) { var mapped = {}; for (var key in obj) { var action = obj[key]; if (keyCodes.hasOwnProperty(key)) { mapped[keyCodes[key]] = action; } } return mapped; } return function ($scope, element, attrs) { var bindings = map($scope.$eval(attrs.keyBind)); element.bind("keydown keypress", function (event) { if (bindings.hasOwnProperty(event.which)) { if ( ! $scope.a.return_caught ) { $scope.a.return_caught = true ; log('keyBind directive. event.which = '+event.which+' bindings[event.which]='+bindings[event.which]); $scope.$apply(function() { $scope.$eval(bindings[event.which]); }); } else { $scope.a.return_caught = false ; } ; } // if relevant event }); }; }]); theApp.directive('catchload', function($window) { return function($scope) { $scope.handle_window_load = function() { set_m($scope); // console.log("window load") ; // setTimeout(function() { draw_canvases($scope); }, 10); return true; }; // $scope.handle_window_load(); return angular.element($window).bind('load', function() { $scope.handle_window_load(); return $scope.$apply(); }); }; }); theApp.directive('catchresize', function($window) { return function($scope) { $scope.handle_window_resize = function() { set_m($scope); // console.log("window resize") ; // setTimeout(function() { draw_canvases($scope); }, 10); return true; }; $scope.handle_window_resize(); return angular.element($window).bind('resize', function() { $scope.handle_window_resize(); return $scope.$apply(); }); }; }); //=== standalone script content (not inserted in scope of common controller as above) // no standalone js required