$.ccio.tm=function(x,d,z,user){ var tmp='';if(!d){d={}}; var k={} if(d&&d.user){ user=d.user } if(!user){ user=$user } if(d.id&&!d.mid){d.mid=d.id;} switch(x){ case 0://video var url = $.ccio.init('videoUrlBuild',d) href = 'href="'+url+'"' // if(!d.filename){d.filename=$.ccio.init('tf',d.time)+'.'+d.ext;} d.dlname=d.mid+'-'+d.filename; d.startMoment=$.ccio.timeObject(d.time), d.endMoment=$.ccio.timeObject(d.end), d.hr=parseInt(d.startMoment.format('HH')), d.per=parseInt(d.hr/24*100); d.circle='
'+d.hr+'
' tmp+='
  • '+d.circle+'
    '+lang.Start+' : '+d.startMoment.format('h:mm:ss , MMMM Do YYYY')+'
    '+lang.End+' : '+d.endMoment.format('h:mm:ss , MMMM Do YYYY')+'
    '+(parseInt(d.size)/1000000).toFixed(2)+'mb
    ' if($.ccio.DropboxAppKey){ tmp+='' } tmp+='
  • '; $(z).each(function(n,v){ v=$(v); if(v.find('.video-item').length>10){v.find('.video-item:last').remove()} }) break; case 1://monitor icon d.src=placeholder.getData(placeholder.plcimg({bgcolor:'#b57d00',text:'...'})); tmp+='
    '+d.name+'
    '+d.mid+'
    '+lang['Save as']+' : '+d.ext+'
    Status : '+d.status+'
    ' tmp+='
    ' var buttons = { "Pop": { "label": "Pop", "attr": "monitor=\"pop\"", "class": "default", "icon": "external-link" }, "Power Viewer": { "label": "Power Viewer", "attr": "monitor=\"powerview\"", "class": "default", "icon": "map-marker" }, "Videos List": { "label": "Videos List", "attr": "monitor=\"videos_table\"", "class": "default", "icon": "film" }, "Monitor Settings": { "label": "Monitor Settings", "attr": "monitor=\"edit\"", "class": "default", "icon": "wrench" } } if(!$.ccio.permissionCheck('video_view',d.mid)){ delete(buttons["Videos List"]) delete(buttons["Power Viewer"]) } if(!$.ccio.permissionCheck('monitor_edit',d.mid)){ delete(buttons["Monitor Settings"]) } $.each(buttons,function(n,v){ tmp+='' }) tmp+='
    \
    '; delete(d.src); break; case 2://monitor stream try{k.d=JSON.parse(d.details);}catch(er){k.d=d.details;} k.mode=$.ccio.init('humanReadMode',d.mode); var dataTarget = '.monitor_item[mid=\''+d.mid+'\'][ke=\''+d.ke+'\'][auth=\''+user.auth_token+'\']'; tmp+='
    '; tmp+='
    ' tmp+='
    '; tmp+='
    '; tmp+='
    '; tmp+='
    '+d.name+', '+lang['Recording FPS']+' : '+d.fps+'
    '; tmp+='
    '; tmp+='
    '//start of btn list var buttons = { "Snapshot": { "label": "Snapshot", "attr": "monitor=\"snapshot\"", "class": "primary", "icon": "camera" }, "Show Logs": { "label": "Show Logs", "attr": "monitor=\"show_data\"", "class": "warning", "icon": "exclamation-triangle" }, "Control": { "label": "Control", "attr": "monitor=\"control_toggle\"", "class": "default arrows", "icon": "arrows" }, "Status Indicator": { "label": "Status Indicator", "attr": "monitor=\"watch_on\"", "class": "success signal", "icon": "plug" }, "Pop": { "label": "Pop", "attr": "monitor=\"pop\"", "class": "default", "icon": "external-link" }, "Calendar": { "label": "Calendar", "attr": "monitor=\"calendar\"", "class": "default ", "icon": "calendar" }, "Power Viewer": { "label": "Power Viewer", "attr": "monitor=\"powerview\"", "class": "default", "icon": "map-marker" }, "Time-lapse": { "label": "Time-lapse", "attr": "monitor=\"timelapse\"", "class": "default", "icon": "angle-double-right" }, "Video Grid": { "label": "Video Grid", "attr": "monitor=\"video_grid\"", "class": "default", "icon": "th" }, "Videos List": { "label": "Videos List", "attr": "monitor=\"videos_table\"", "class": "default", "icon": "film" }, "Monitor Settings": { "label": "Monitor Settings", "attr": "monitor=\"edit\"", "class": "default", "icon": "wrench" }, "Fullscreen": { "label": "Fullscreen", "attr": "monitor=\"fullscreen\"", "class": "default", "icon": "arrows-alt" }, "Close": { "label": "Close", "attr": "monitor=\"watch_off\"", "class": "danger", "icon": "times" } } if(!$.ccio.permissionCheck('video_view',d.mid)){ delete(buttons["Videos List"]) delete(buttons["Time-lapse"]) delete(buttons["Power Viewer"]) delete(buttons["Calendar"]) } if(!$.ccio.permissionCheck('monitor_edit',d.mid)){ delete(buttons["Monitor Settings"]) } $.each(buttons,function(n,v){ tmp+='' }) tmp+='
    ';//end of btn list tmp+='
    ';//.stream-block tmp+='
    '; tmp+='
    '; tmp+='
      '; tmp+='
      '; tmp+='
      '; tmp+='
      ';//.mdl-data_window tmp+='
      ';//.grid-stack-content tmp+='';//#monitor_live_... break; case 3://api key row tmp+=''+d.code+''+d.ip+''+d.time+'  '; break; case 4://log row, draw to global and monitor if(!d.time){d.time=$.ccio.init('t')} tmp+='
    • ' tmp+='' tmp+='
      '+d.ke+' : '+d.mid+'
      ' tmp+=''+d.log.type+' ' tmp+='' tmp+='
      ' tmp+='
      ' tmp+=$.ccio.init('jsontoblock',d.log.msg); tmp+='
      ' tmp+='
    • '; $(z).each(function(n,v){ v=$(v); if(v.find('.log-item').length>10){v.find('.log-item:last').remove()} }) break; case 6://notification row if(!d.time){d.time=$.ccio.init('t')} if(!d.note.class){d.note.class=''} tmp+='
    • ' tmp+='' tmp+='
      '+d.ke+' : '+d.id+'
      ' tmp+=''+d.note.type+' ' tmp+='' tmp+='
      ' tmp+='
      ' tmp+=d.note.msg tmp+='
      ' tmp+='
    • '; break; case'option': var selected = '' if(d.selected === true){selected = ' selected'} tmp+='' break; case'stream-element': try{k.d=JSON.parse(d.details);}catch(er){k.d=d.details} if($.ccio.mon[d.ke+d.mid+user.auth_token]&&$.ccio.mon[d.ke+d.mid+user.auth_token].previousStreamType===k.d.stream_type){ return; } k.e=$('#monitor_live_'+d.mid+user.auth_token+' .stream-block'); k.e.find('.stream-element').remove(); if($.ccio.op().jpeg_on===true){ tmp+=''; }else{ switch(k.d.stream_type){ case'hls':case'flv':case'mp4': tmp+=''; break; case'mjpeg': tmp+=''; break; case'jpeg': tmp+=''; break; default://base64//h265 tmp+=''; break; } } k.e.append(tmp).find('.stream-element').resize(); if($.ccio.op().switches.monitorMuteAudio === 1){ k.e.find('video').each(function(n,el){ el.muted = "muted" }) } break; case'user-row': d.e=$('.user-row[uid="'+d.uid+'"][ke="'+d.ke+'"]') if(d.e.length===0){ tmp+='
    • '; tmp+='
      '+d.mail+' : '+d.uid+'
      Logged in
      '; tmp+='
    • '; }else{ d.e.find('.mail').text(d.mail) d.e.find('.time').livestamp('destroy').toggleClass('livestamped livestamp').text(d.logged_in_at) } $.ccio.init('ls') break; case'detector-filters-where': if(!d)d={}; d.id=$('#filters_where .row').length; if(!d.p1){d.p1='indifference'} if(!d.p2){d.p2='='} if(!d.p3){d.p3=''} if(!d.p4){d.p4='&&'} tmp+='
      ' tmp+='
      ' tmp+=' ' tmp+='
      ' tmp+='
      ' tmp+=' ' tmp+='
      ' tmp+='
      ' tmp+=' ' tmp+='
      ' tmp+='
      ' tmp+=' ' tmp+='
      ' tmp+='
      ' break; case'filters-where': if(!d)d={}; d.id=$('#filters_where .row').length; if(!d.p1){d.p1='mid'} if(!d.p2){d.p2='='} if(!d.p3){d.p3=''} tmp+='
      '; tmp+='
      '; tmp+=' '; tmp+='
      '; tmp+='
      '; tmp+=' '; tmp+='
      '; tmp+='
      '; tmp+=' '; tmp+='
      '; tmp+='
      '; break; case 'link-set'://Link Shinobi - 1 set if(!d.host){d.host=''} if(!d.ke){d.ke=''} if(!d.api){d.api=''} if(!d.secure){d.secure="0"} tmp+='
      ' tmp+='

      '+d.host+' '+d.ke+' 

      ' tmp+='
      ' tmp+='
      ' tmp+='
      ' tmp+='
      ' tmp+='
      '; break; case 'form-group'://Input Map Selector var fields = [] if(d.fields){ if(d.fields instanceof Object){ fields = [d] }else{ fields = d } } $.each(fields,function(n,v){ var value,hidden if(!v.attribute)v.attribute=''; if(!v.placeholder)v.placeholder=''; if(!v.class)v.class=''; if(!v.inputType)v.inputType='value'; if(v.hidden){hidden='style="display:none"'}else{hidden=''}; if(v.value){value='value=""'}else{value=''}; tmp+='
      ' tmp+=' ' tmp+='
      ' }) break; case 'input-map-selector'://Input Map Selector if(!d.map){d.map=''} tmp+='
      ' tmp+=' ' tmp+='
      ' break; case 'input-map'://Input Map Options var tempID = $.ccio.gid(); if(!d.channel){ var numberOfChannelsDrawn = $('#monSectionInputMaps .input-map').length d.channel=numberOfChannelsDrawn+1 } var fields = [ // { // name:'', // class:'', // placeholder:'', // default:'', // attribute:'', // type:'text', // }, { name:'type', label:lang['Input Type'], default:'h264', attribute:'selector="h_i_'+tempID+'"', type:'selector', choices:[ {label:lang['H.264 / H.265 / H.265+'],value:'h264'}, {label:lang['JPEG'],value:'jpeg'}, {label:lang['MJPEG'],value:'mjpeg'}, {label:lang['HLS (.m3u8)'],value:'hls'}, {label:lang['MPEG-4 (.mp4 / .ts)'],value:'mp4'}, {label:lang['Local'],value:'local'}, {label:lang['Raw'],value:'raw'}, ] }, { name:'fulladdress', label:lang['Full URL Path'], placeholder:'Example : rtsp://admin:password@123.123.123.123/stream/1', type:'text', }, { name:'sfps', label:lang['Monitor Capture Rate'], placeholder:'', type:'text', }, { name:'aduration', label:lang['Analyzation Duration'], placeholder:'Example : 1000000', type:'text', }, { name:'probesize', label:lang['Probe Size'], placeholder:'Example : 1000000', type:'text', }, { name:'stream_loop', label:lang['Loop Stream'], class:'h_i_'+tempID+'_input h_i_'+tempID+'_mp4 h_i_'+tempID+'_raw', hidden:true, default:'0', type:'selector', choices:[ {label:'No',value:'0'}, {label:'Yes',value:'1'} ] }, { name:'rtsp_transport', label:lang['RTSP Transport'], class:'h_i_'+tempID+'_input h_i_'+tempID+'_h264', default:'0', type:'selector', choices:[ {label:'Auto',value:''}, {label:'TCP',value:'tcp'}, {label:'UDP',value:'udp'} ] }, { name:'accelerator', label:lang['Accelerator'], attribute:'selector="h_accel_'+tempID+'"', default:'0', type:'selector', choices:[ {label:'No',value:'0'}, {label:'Yes',value:'1'}, ] }, { name:'hwaccel', label:lang['hwaccel'], class:'h_accel_'+tempID+'_input h_accel_'+tempID+'_1', hidden:true, default:'', type:'selector', choices: $.ccio.HWAccelChoices }, { name:'hwaccel_vcodec', label:lang['hwaccel_vcodec'], class:'h_accel_'+tempID+'_input h_accel_'+tempID+'_1', hidden:true, default:'auto', type:'selector', choices:[ {label:lang['Auto'],value:'auto'}, {label:lang['h264_cuvid'],value:'h264_cuvid',group:'NVIDIA'}, {label:lang['hevc_cuvid'],value:'hevc_cuvid',group:'NVIDIA'}, {label:lang['mjpeg_cuvid'],value:'mjpeg_cuvid',group:'NVIDIA'}, {label:lang['mpeg4_cuvid'],value:'mpeg4_cuvid',group:'NVIDIA'}, {label:lang['h264_qsv'],value:'h264_qsv',group:'Quick Sync Video'}, {label:lang['hevc_qsv'],value:'hevc_qsv',group:'Quick Sync Video'}, {label:lang['mpeg2_qsv'],value:'mpeg2_qsv',group:'Quick Sync Video'}, {label:lang['h264_mmal'],value:'h264_mmal',group:'Raspberry Pi'}, {label:lang['mpeg2_mmal'],value:'mpeg2_mmal',group:'Raspberry Pi'}, {label:lang['mpeg4_mmal'],value:'mpeg4_mmal',group:'Raspberry Pi'}, ] }, { name:'hwaccel_device', label:lang['hwaccel_device'], class:'h_accel_'+tempID+'_input h_accel_'+tempID+'_1', hidden:true, placeholder:'Example : /dev/dri/video0', type:'text', }, ]; tmp+='
      ' tmp+='

      '+lang["Input"]+' '+lang["Map"]+' : '+d.channel+'' tmp+='
      ' tmp+='

      ' $.each(fields,function(n,v){ if(!v.attribute)v.attribute=''; if(!v.placeholder)v.placeholder=''; if(!v.class)v.class=''; if(v.hidden){v.hidden='style="display:none"'}else{v.hidden=''}; tmp+='
      ' tmp+=' ' tmp+='
      ' }) tmp+='
      ' break; case 'stream-channel'://Stream Channel var tempID = $.ccio.gid(); if(!d.channel){ var numberOfChannelsDrawn = $('#monSectionStreamChannels .stream-channel').length d.channel=numberOfChannelsDrawn } tmp+='
      ' tmp+='

      '+lang["Stream Channel"]+' '+d.channel+'' tmp+='
      ' tmp+='

      ' // tmp+='
      ' // tmp+=' ' // tmp+='
      ' tmp+='
      ' tmp+='

      '+lang['Input Feed'] tmp+='
      ' tmp+=' ' tmp+='
      ' tmp+='

      ' tmp+='
      ' tmp+='
      ' tmp+='
      ' tmp+=' ' tmp+='
      ' tmp+='
      ' tmp+='
      ' tmp+=' ' tmp+='
      ' tmp+='
      ' tmp+=' ' tmp+='
      ' tmp+='
      ' tmp+=' ' tmp+='
      ' tmp+='
      ' tmp+=' ' tmp+='
      ' tmp+='
      ' tmp+=' ' tmp+='
      ' tmp+='
      ' tmp+='
      ' tmp+=' ' tmp+='
      ' tmp+=' ' tmp+=' ' tmp+='
      ' break; } if(z && x !== 2){ $(z).prepend(tmp) } switch(x){ case 1: z='#monitors_list .link-monitors-list[auth="'+user.auth_token+'"][ke="'+d.ke+'"]' if($('.link-monitors-list[auth="'+user.auth_token+'"][ke="'+d.ke+'"]').length===0){ $("#monitors_list").append('') var options = { cellHeight: 80, verticalMargin: 10, }; //monitor="watch_off" $(z).gridstack(options); $(z).on('change', function(event, ui) { var monitors = {} $.grid.e.find(" .monitor_item").each(function(n,v){ var el = $(v) var item = {} item.ke = el.attr('ke') item.mid = el.attr('mid') item.x = el.attr('data-gs-x') item.y = el.attr('data-gs-y') item.height = el.attr('data-gs-height') item.width = el.attr('data-gs-width') monitors[item.ke+item.mid] = item }) user.details.monitorOrder=monitors; $.ccio.cx({f:'monitorOrder',monitorOrder:monitors},user) }); } $(z).prepend(tmp) componentHandler.upgradeAllRegistered() break; case 0:case 4: $.ccio.init('ls'); break; case 2: var x = 0; var y = 0; var width = $.grid.getMonitorsPerRow() var height = width; if(user.details && user.details.monitorOrder && user.details.monitorOrder[d.ke+d.mid]){ var saved = user.details.monitorOrder[d.ke+d.mid]; x = saved.x; y = saved.y; width = saved.width; height = saved.height; } var autoPlacement = false if($.ccio.op().switches.monitorOrder !== 1){ autoPlacement = true } $(z).data('gridstack').addWidget($(tmp), x, y, width, height, autoPlacement); k.e=$('#monitor_live_'+d.mid+user.auth_token); try{ if(JSON.parse(d.details).control=="1"){ k.e.find('[monitor="control_toggle"]').show() }else{ k.e.find('.pad').remove(); k.e.find('[monitor="control_toggle"]').hide() } $.ccio.tm('stream-element',d,null,user) }catch(re){$.ccio.log(re)} k.mid=d.mid k.mon=$.ccio.mon[d.ke+d.mid+user.auth_token] $.ccio.init('monitorInfo',k) break; case'detector-filters-where': $('#detector_filters_where').append(tmp); $('#detector_filters_where .row [where="p4"][disabled]').prop('disabled',false) $('#detector_filters_where .row:last [where="p1"]').val(d.p1) $('#detector_filters_where .row:last [where="p2"]').val(d.p2) $('#detector_filters_where .row:last [where="p3"]').val(d.p3) $('#detector_filters_where .row:last [where="p4"]').val(d.p4).prop('disabled',true) break; case'filters-where': $('#filters_where').append(tmp); $('#filters_where .row:last [where="p1"]').val(d.p1) $('#filters_where .row:last [where="p2"]').val(d.p2) $('#filters_where .row:last [where="p3"]').val(d.p3) break; case'input-map': var mapsList = $.aM.maps mapsList.append(tmp) mapsList.find('.input-map').last().find('[map-detail="aduration"]').change() return tempID; break; case'stream-channel': var channeList = $.aM.channels channeList.append(tmp) channeList.find('.stream-channel').last().find('[channel-detail="stream_vcodec"]').change() return tempID; break; case'link-set': $('[links="'+d.host+'"] [link="secure"]').val(d.secure).change() break; } return tmp; } $.ccio.pm=function(x,d,z,user){ var tmp='';if(!d){d={}}; if(!user){ user=$user } switch(x){ case 0: d.mon=$.ccio.mon[d.ke+d.mid+user.auth_token]; d.ev='.glM'+d.mid+user.auth_token+'.videos_list ul,.glM'+d.mid+user.auth_token+'.videos_monitor_list ul';d.fr=$.ccio.fr.find(d.ev),d.tmp=''; if(d.fr.length===0){$.ccio.fr.append('

      '+d.mon.name+'

      ')} if(d.videos&&d.videos.length>0){ $.each(d.videos,function(n,v){ if(v.status!==0){ tmp+=$.ccio.tm(0,v,null,user) } }) }else{ $('.glM'+d.mid+user.auth_token+'.videos_list,.glM'+d.mid+user.auth_token+'.videos_monitor_list').appendTo($.ccio.fr) tmp+='
    • No videos
    • '; } $(d.ev).html(tmp); $.ccio.init('ls'); break; case 3: z='#api_list'; $(z).empty(); $.each(d,function(n,v){ tmp+=$.ccio.tm(3,v,null,user); }) break; case'option': $.each(d,function(n,v){ tmp+=$.ccio.tm('option',v,null,user); }) break; case'user-row': $.each(d,function(n,v){ tmp+=$.ccio.tm('user-row',v,null,user); }) z='#users_online' break; case'link-set': $.sM.links.empty() $.each(d,function(n,v){ tmp+=$.ccio.tm('link-set',v,'#linkShinobi',user) }) break; } if(z){ $(z).prepend(tmp) } return tmp; }