All The Javascript So it is searchable.
Get |
|
1 |   |
2 | function slideDownTo(key){ |
3 |    var node = getNode(key); |
4 |    dispatchOver(node); |
5 | }  |
6 |   |
7 |  function displaySlideNamed(aName){ |
8 |      pinned = null; |
9 |      var node = getNode(aName); |
10 |     dispatchOver(node); |
11 | |
12 |  } |
13 |   |
14 |  function getNode(nodeName){ |
15 |       return view.graph.nodes(nodeName); |
16 |  } |
17 | |
18 |  function setRatio(node,score){ |
19 |      node.data.ratio = score; |
20 |  } |
21 |       |
22 |  function getConferenceKey(slide){ |
23 |     return slide.conference.id; |
24 | } |
25 | |
26 |  function getConference(slide){ |
27 |     return slide.conference; |
28 | } |
29 | |
30 | function localRebuild(){ |
31 |      return true; |
32 |   } |
33 | |
34 | |
35 | |
36 | |
37 |   function getConferenceName(node){ |
38 |       if (getClass(node)== 'Conference'){ |
39 |           return node.title; |
40 |       } |
41 |       return node.conference.title; |
42 |   } |
43 |    |
44 | function isRoot(node){ |
45 |     if (! ('parent' in node) || |
46 |        (node.parent === null)){ |
47 |         return true; |
48 |     } |
49 |     return false; |
50 | } |
51 | |
52 | |
53 | |
54 |       |
55 |   function getTitle(item){ |
56 |       return item.title; |
57 |   } |
58 |    |
59 |   function getBranchSize(item){ |
60 |       return item.branchSize; |
61 |   } |
62 |    |
63 |    |
64 |    function getDescription(item){ |
65 |       return item.description; |
66 |   } |
67 |      function getUpVotes(item){ |
68 |       return item.upVotes; |
69 |   } |
70 |      function getDownVotes(item){ |
71 |       return item.downVotes; |
72 |   } |
73 |    |
74 |   function getClass(slide){ |
75 |       return slide.class; |
76 |   } |
77 |    |
78 |    |
79 |   |
80 |  function addChildArray (item,index){ |
81 |      item.children = []; |
82 |  } |
83 |   |
84 |  function getKey(item,array){ |
85 |      return item.id; |
86 |  } |
87 |   function getClass(item,array){ |
88 |      return item.class; |
89 |  } |
90 |   |
Move Commands For Destkopt |
|
91 |  function moveUp(){ |
92 |             moveTo(homeNode.parent); |
93 | } |
94 | |
95 | function moveDown(childIndex){ |
96 |         moveTo (homeNode.children[childIndex]); |
97 | } |
98 | |
99 | function moveToLast(numberOfSiblings){ |
100 |         moveTo (homeNode.parent.children[numberOfSiblings -1]); |
101 | } |
102 | |
103 | function moveToFirst(){ |
104 |     moveTo (homeNode.preant.children[0]);  |
105 | } |
106 | |
107 | function moveRight(offset){ |
108 |         moveTo (homeNode.parent.children[offset+1]);  |
109 | } |
110 | |
111 | function moveLeft(offset){ |
112 |      moveTo (homeNode.parent.children[offset-1]); |
113 | } |
addDescription |
|
114 |    |
115 |   /* |
116 |   function addDescription (description){ |
117 |      $('#description').remove(); |
118 |      var result =' <span id = "description" style= "position:absolute; bottom:10px;'   + |
119 |      'z-index: -1; left: 33%; padding: 20px; ">'+ |
120 |      description +  |
121 |      '</span>'; |
122 |   |
123 |      $('#graph-container').append(result); |
124 |  } |
125 |  */ |
addList |
|
126 |   function renderList(node){ |
127 |       if (node.children.length ===0){ |
128 |           return ''; |
129 |       } |
130 |       result = '<center>'; |
131 |       result +='<b>SubCategories:</b><br>'; |
132 |       for (var i = 0  i< node.children.length; i++){ |
133 |           result +=  node.children[i].title + "<br>"; |
134 |       } |
135 |       result += '</center>'; |
136 |       return result; |
137 |   } |
138 |    |
139 |     function renderList2(node){ |
140 |       result ='<ul>'; |
141 |       for (var i = 0  i< node.children.length; i++){ |
142 |           result += "<li>" + node.children[i].title + "</li>"; |
143 |       } |
144 |       result += "</ul>"; |
145 |       return result; |
146 |   } |
147 |   /* |
148 |   function deleteNodePlusChildren(){ |
149 |            $('#NodePlusChildren').remove(); |
150 |   } |
151 |   function renderNodePlusChildren (node){ |
152 |      var result ='<div id = "NodePlusChildren" ' + |
153 |      'style= "position:fixed;'+ |
154 |      'bottom:' + node.children.length + 'em;  '   + |
155 |      'left: 30%; z-index: -1;">' + |
156 |      "<p>" + node.title + "</p>"+  |
157 |       renderList(node)+ |
158 |      '</div>'; |
159 |      $('#graph-container').append(result); |
160 |  } |
161 |  */ |
camera |
|
162 |  var baseX = 0; |
163 |  var baseY = -($('#graph-container')[0].clientWidth)/4 |
164 | ; |
165 |   function cameraGoToOrigin(){ |
166 |  view.cameras[0].goTo({x:baseX, y: baseY, ratio:1, angle: 1.55}); |
167 |  } |
168 |   |
169 |  //NOT WORKING |
170 |  function cameraGoToNode(node){ |
171 |       view.cameras[0].goTo({x:node.x , y: node.y ,  angle:node.angle}); |
172 |       |
173 |  } |
174 | |
childFunctions |
|
175 |   |
176 | |
177 | function getChildIndex(node){ |
178 |    var childIndex = 0;     |
179 |           if ('previousChildIndex' in node){ |
180 |              childIndex = node.previousChildIndex; |
181 |            } |
182 |    return childIndex; |
183 | } |
184 |   |
185 |       |
first |
|
186 |   var view; |
187 |   var homeNode; |
188 |   var root; |
189 |   var landingPage; |
190 |   var lastHover = null; |
191 |   isMobile = false; |
192 | |
193 | |
194 | |
195 | |
196 | |
197 | |
198 |  var mySettings =  { |
199 |        animationsTime: 500, |
200 |      drawLabels: true, |
201 |      drawEdgeLabels: true, |
202 |       zoomMax : 4, |
203 |       singleHover: false, |
204 |     doubleClickEnabled: false, |
205 |     enableNodeHovering: true, |
206 |         labelSizeRatio: 0, |
207 |     labelThreshold: 1, |
208 |     minNodeSize: 1, |
209 |     maxNodeSize: 4 |
210 |   }; |
211 |    |
212 |  function myCallback(arg){ |
213 |      view  = arg; |
214 |      var nodes = view.graph.nodes(); |
215 |      nodes.forEach(addChildArray); |
216 |      nodes.forEach (setParent); |
217 |      nodes.forEach(zeroPosition); |
218 |      //nodes.forEach(setLabels); |
219 |      //MUST BE AFTER SET PARENT |
220 |      nodes.forEach(setConferences); |
221 |     |
222 |    |
223 |   |
224 | |
225 |       |
226 |       |
227 |      root = getNode(rootName); |
228 |      root.x=0;  |
229 |      root.y=0; |
230 |      root.share = 2*Math.PI; |
231 |      root.angle = 0; |
232 |    |
233 | |
234 |      var row = root.children; |
235 |      var radius = 1; |
236 |       |
237 |      while (row.length > 0){ |
238 |           |
239 |          calculateChildPositions(row,radius );  |
240 |          row = rowItems(row); |
241 |          radius ++ |
242 |       } |
243 |       cameraGoToOrigin(); |
244 | view.bind('overNode', overNode); |
245 |     view.bind('outNode', outNode); |
246 | view.bind('overNodes', overNodes); |
247 |     view.bind('outNodes', outNodes); |
248 |     view.bind('clickNode', clickNode); |
249 |      |
250 |      view.refresh(); |
251 |           |
252 |         homeNode= getNode(homeNodeKey); |
253 |        landingPage = homeNode; |
254 |     dispatchOver(homeNode); |
255 |          pinned = homeNode; |
256 | |
257 |  } //END OF CALLBACK |
258 | |
259 | |
260 |  sigma.parsers.json(deskTopJson, { |
261 |   container: 'graph-container', |
262 |   settings: mySettings |
263 | }, |
264 |   myCallback); |
265 |   |
266 |   |
267 | |
hasChildren |
|
268 |  function hasChildren(node){ |
269 |      if (node.children.length > 0){ |
270 |          return true; |
271 |      } |
272 |      return false; |
273 |       |
274 |  } |
hover |
|
275 | var pinned = null; |
276 | |
277 | function deletePin(node){ |
278 |     delete pinned.data.pinned; |
279 |     pinned = null; |
280 | } |
281 | |
282 |     |
283 |  function leavePinnedNode(){ |
284 |       var pin = pinned; |
285 |          deletePin (pin); |
286 |          outNodeCore(pin); |
287 |          view.refresh(); |
288 |  }   |
289 |   |
290 |  function clickNode(e){ |
291 |       var node = e.data.node; |
292 |       clickNodeCore(node); |
293 |  } |
294 |  function clickNodeCore (node){ |
295 |       //Clicking on Pinned Node |
296 |      if (node == pinned){ |
297 |        deletePin(pinned); |
298 |          node.label = node.title; |
299 |         newHomeNode(e.node); |
300 |          view.refresh(); |
301 |      } |
302 |      // CLICKING ON A DIFFERENT NODE |
303 |      else if (pinned){ |
304 |          leavePinnedNode(); |
305 |      } |
306 |      else{ |
307 |          overNodeCore(node); |
308 |          pinned = node; |
309 |          node.data.pinned = true; |
310 |          node.label = 'PINNED: '+ node.title; |
311 |          view.refresh(); |
312 |      } |
313 |       |
314 |  } |
315 |   |
316 |   |
317 |   |
318 |  var hoverNodes= {}; |
319 | |
320 |  function overNode(e) { |
321 |            if (pinned){ |
322 |             return; |
323 |         } |
324 |         var node = e.data.node; |
325 |         overNodeCore(node); |
326 |  } |
327 |   |
328 | function overNodes(e){ |
329 |           if (pinned){ |
330 |             return; |
331 |         } |
332 |     for (var i = 0; i < e.data.nodes.length; i++){ |
333 |         var node = e.data.nodes [i]; |
334 |         overNodeCore(node); |
335 |  } |
336 | } |
337 | |
338 | function deleteOldHovers(){ |
339 |          for (var key in hoverNodes){ |
340 |              var item = hoverNodes[key]; |
341 |               hideLabel(item); |
342 |               if (item.conference){ |
343 |                   hideLabel(item.conference); |
344 |               } |
345 |             delete hoverNodes[key]; |
346 |        } |
347 | } |
348 | var lastOverNode=null; |
349 | var lastOutNode = null; |
350 | var lastNodeEvent=null; |
351 | function  overNodeCore(node){ |
352 |    |
353 |         showLabel (node); |
354 |        if ((lastOverNode== node)&& |
355 |            (lastNodeEvent =="overNode")){ |
356 |                return; |
357 |            } |
358 |         //if (lastOverNode){ |
359 |         //hideLabel(lastOverNode); |
360 |        //} |
361 |         lastOverNode = node; |
362 |         lastNodeEvent = "overNode"; |
363 |             deleteOldHovers(); |
364 | |
365 |         showLabel (node); |
366 |         newHomeNode(node); |
367 |         possiblyLoadContent(node); |
368 |         hoverNodes [node.id]= node; |
369 | } |
370 |   |
371 |  function outNode(e){ |
372 |             if (pinned){ |
373 |             return; |
374 |         } |
375 |          var node = e.data.node; |
376 |       outNodeCore(node); |
377 | } |
378 | |
379 | function outNodes(e){ |
380 |        if (pinned){ |
381 |             return; |
382 |         } |
383 |     for (var i = 0; i < e.data.nodes.length; i++){ |
384 |          var node = e.data.nodes [i]; |
385 |         outNodeCore (node); |
386 |     } |
387 | } |
388 | |
389 | function outNodeCore(node){ |
390 | |
391 |            if ((lastOutNode== node)&& |
392 |            (lastNodeEvent =="outNode")){ |
393 |                return; |
394 |            } |
395 |            hideLabel(node); |
396 |           view.refresh(); |
397 |         //deleteOldHovers(); |
398 |         if (node.conference){ |
399 |                   hideLabel(node.conference); |
400 |               } |
401 |         lastOutNode = node; |
402 |         lastNodeEvent = "outNode"; |
403 |     |
404 |  } |
405 |   |
406 |   |
initialize |
|
407 |     |
408 |  function setParent(item,index){ |
409 |      item.data= {}; |
410 |      var parent = item.parent; |
411 |      if (item.id == rootName){ |
412 |          item.parent = null; |
413 |          return; |
414 |      } |
415 |      parent = getNode (item.parent); |
416 |      item.parent = parent; |
417 |      item.parent.children.push (item); |
418 |     view.graph.addEdge({source:parent.id,  |
419 |                    target:item.id, |
420 |                    label:"Hello", |
421 |               id:(item.id + parent.id), size: 1}); |
422 |     if (item.class == 'Conference'){ |
423 |         item.data.talks = []; |
424 |     } |
425 |  } |
426 |  function setConferences(node,index){ |
427 |      if (getClass(node) == 'Video'){ |
428 |         node.conference = getNode(node.conference); |
429 |         node.conference.data.talks.push(node); |
430 |         /* |
431 |         if (node.parent != node.conference){ |
432 |             view.graph.addEdge({source:node.id,  |
433 |                       target:node.conference.id,  |
434 |                       id:(node.id + node.conference.id),  |
435 |                       size: 1, |
436 |                       hidden:true |
437 |         }); |
438 |         |
439 |         } |
440 |         */ |
441 | |
442 |     } |
443 | }     |
444 |  function setLabels(item,index){ |
445 |    //  item.label = item.title; |
446 |  } |
447 |   |
loadContent |
|
448 | function possiblyLoadContent(node){ |
449 |          lastHover = node; |
450 |    setTimeout (maybeLoadContent,400,node); |
451 | } |
452 | |
453 | function maybeLoadContent(node){ |
454 |      if (lastHover == node){ |
455 |         addLinks(node); |
456 |        loadRemoteContent(node); |
457 |         return; |
458 |     } |
459 | } |
460 | |
461 | var oldVideoNode=null; |
462 | var oldConferenceNode = null; |
463 | function addLinks(node){ |
464 |     //if ('talks' in node){ |
465 |     //    addConferenceLinks(node); |
466 |     //} |
467 |     if ('conference' in node){ |
468 |        addVideoLink (node);                     |
469 |     } |
470 |     view.refresh(); |
471 | } |
472 |   |
473 | function addConferenceLinks(node){ |
474 |         dropConferenceLinks (oldVideoNode); |
475 |         oldConferenceNode = node; |
476 |         node.data.hasConferenceLink = true; |
477 | |
478 |         for (var i = 0  i < node.talks.length; i++){ |
479 |             var talk = node.talks[i]; |
480 |             var name = node.id + talk.id; |
481 |             if (!view.graph.edges(name)){ |
482 |                view.graph.addEdge({source:node.id,  |
483 |                             target:talk.id,  |
484 |                            id:name,  |
485 |                            size: 1}); |
486 |         }  |
487 |         } |
488 | }  |
489 | |
490 | function addVideoLink(node){ |
491 |         dropVideoLink (oldVideoNode); |
492 |         oldVideoNode = node; |
493 |         var name = node.id + node.conference.id; |
494 |         if (!view.graph.edges(name)){ |
495 |            node.data.hasVideoLink = true; |
496 |            //showLabel(node.conference); |
497 |            view.graph.addEdge({source:node.id,  |
498 |                             target:node.conference.id,  |
499 |                            id:name, size: 1}); |
500 |         }       |
501 | }  |
502 | |
503 | function dropConferenceLink(conference){ |
504 |     if (! conference){ |
505 |         return; |
506 |     } |
507 |     if (conference.data.hasConferenceLink){ |
508 |         node.data.hasConferenceLink = false;   |
509 |         for (var i=0; i<conference.talks.length; i++ ){ |
510 |            var name = conference.id + conference.talks[i]; |
511 |            view.graph.dropEdge(name); |
512 |         } |
513 |         view.refresh(); |
514 | |
515 |     } |
516 | } |
517 | |
518 | |
519 | function dropVideoLink(node){ |
520 | |
521 |     if (! node){ |
522 |         return; |
523 |     } |
524 |     if (node.data.hasVideoLink){ |
525 |         node.data.hasVideoLink = false;    |
526 |         var name = node.id + node.conference.id; |
527 |         view.graph.dropEdge(name); |
528 |         view.refresh(); |
529 | |
530 |     } |
531 | } |
532 | |
533 | function newHomeNode (node){ |
534 |        homeNode = node; |
535 |        showLabel(node); |
536 |     saveCurrentURL(); |
537 |    // $("#arrows").html(arrows(node)); |
538 |     $("#text").html(renderSlide(node)); |
539 |     //postRender(); |
540 | |
541 | } |
542 |       |
543 |           |
544 | |
545 |  function errorF( jqXHR, textStatus, errorThrown ){ |
546 |     console.log ("AJAX ERROR", jqXHR, textStatus, errorThrown ); |
547 | } |
548 | |
549 | //after slide load |
550 | function loadRemoteContent(node){ |
551 |     var url = "/" + getKey(node) + "/content"; |
552 |     divName = "#" + getKey(node) + "-content"; |
553 |       $.ajax({url: url, cache: false,  |
554 |       error: errorF, |
555 |       success: function(result){ |
556 |         $(divName).html(result); |
557 |         resizeVideos(0,0,"#text"); |
558 |     } |
559 |       }); |
560 |      |
561 | } |
562 |   |
563 | |
564 |     |
moveTo |
|
565 |  var currentNode=null; |
566 | function moveTo(node){ |
567 |     pinned = null; |
568 |     |
569 |     if (currentNode){ |
570 |             dispatchOut (currentNode); |
571 |     } |
572 |     dispatchOver(node); |
573 | } |
574 | |
575 | function hideLabel(node){ |
576 |          node.label = ""; |
577 | } |
578 | function dispatchOut(node){ |
579 |         var data = {}; |
580 |         data.node = currentNode; |
581 |        view.renderers[0].dispatchEvent('outNode',data); |
582 | } |
583 | function showLabel(node){ |
584 |         node.label=node.title; |
585 | } |
586 | function dispatchOver(node){ |
587 |        view.renderers[0].dispatchEvent('overNode',{node}); |
588 | } |
positions |
|
589 |    |
590 |  function nextItem(array,index){ |
591 |      if (index == array.length -1){ |
592 |          return array[0]; |
593 |      } |
594 |      return array[index+1]; |
595 |  } |
596 |  function previousItem(array,index){ |
597 |      if (index === 0){ |
598 |          return array [array.length -1]; |
599 |      } |
600 |      return array [index-1]; |
601 | } |
602 | |
603 | function average (angle1, angle2,radius){ |
604 |         if ((angle1 - angle2) > Math.PI){ |
605 |           |
606 |            angle2=angle2 + 2*Math.PI; |
607 |            //return angle1; |
608 |            return average (angle1, angle2, radius); |
609 |         }  |
610 |          |
611 |         if ((angle1 - angle2) > 1){ |
612 |            return angle1 - (0.333/radius); |
613 |         }   |
614 |          |
615 |         if ((angle2 - angle1) > Math.PI){ |
616 |             |
617 |              angle2= angle2 - 2*Math.PI; |
618 |              return average (angle1, angle2, radius);       |
619 |         } |
620 |         if ((angle2 - angle1) > 1){ |
621 |            return angle1 + (0.3333/radius); |
622 |     } |
623 |     return (angle1 + angle2 ) /2.0; |
624 | } |
625 | |
626 |  function calculateChildPositions (row,radius){ |
627 |      var i, item, arent, siblings, length, offset, share; |
628 |      var angle, parentAngle,itemIndex,  delta; |
629 |      var first, last, previous, previousAngle, next, nextAngle; |
630 |      var j, ratio; |
631 |      var rowLength= row.length; |
632 |      var maxDelta = 0; |
633 |      var minDelta = 0; |
634 |      for (i = 0  i<rowLength;i ++ ){ |
635 |           item = row [i];  |
636 |           parentAngle= item.parent.angle; |
637 |           siblings = item.parent.children; |
638 |           length = siblings.length; |
639 |           offset = length /2; |
640 |           share =  item.parent.share/length; |
641 |           item.share = share; |
642 |           itemIndex = siblings.indexOf(item); |
643 |           delta = (itemIndex -offset) * share |
644 |           angle = parentAngle + delta; |
645 |           onePosition(item, angle, radius); |
646 |          } |
647 |            |
648 |          if (radius < 2) { |
649 |            return; |
650 |        } |
651 |         |
652 |       for (i = 0  i<rowLength;i ++ ){ |
653 |               item = row [i];  |
654 |               siblings = item.parent.children; |
655 |               length= siblings.length; |
656 |               itemIndex = siblings.indexOf(item);   |
657 | |
658 |               if (itemIndex === 0){ |
659 |                   previous = previousItem (row,i); |
660 |                   previousAngle = previous.angle; |
661 |                   first = average (item.angle, previousAngle,radius); |
662 | |
663 |               } |
664 |               if (itemIndex == siblings.length -1 ){ |
665 |                   next = nextItem(row,i); |
666 |                   nextAngle = next.angle; |
667 |                   last = average (item.angle, nextAngle,radius);  |
668 |                |
669 | |
670 |                   for (j=0 j< length; j++){ |
671 |                       item = siblings [j]; |
672 |                       delta = last - first; |
673 |                       offset = length /2; |
674 |                       ratio = (j) /length; |
675 |                       if (length ==1){ |
676 |                           ratio = 0.5; |
677 |                       } |
678 |                       angle = first + (delta * ratio); |
679 |                     onePosition(item, angle, radius); |
680 |                   } |
681 |               } |
682 | |
683 |       } |
684 | |
685 |            |
686 | } |
687 | |
688 |   function onePosition( item,angle,radius) { |
689 |      item.angle = angle; |
690 |     item.x=radius * Math.cos(angle); |
691 |     item.y=  radius * Math.sin(angle); |
692 |  }  |
693 |   |
694 |   |
695 |  function randomPosition(item, index) { |
696 |     item.x=Math.random () +1; |
697 |     item.y=Math.random () +1; |
698 |  } |
699 |  function zeroPosition(item, index) { |
700 |     item.x=0; |
701 |     item.y=0; |
702 |  } |
renderSearchButton |
|
703 |  function renderSearchOption(node){ |
704 |           if (! isMobile){ |
705 |           return "" + |
706 |             lili('<a href="https://PythonLinks.info/search">Search</a>'); |
707 |           } |
708 |           else{  |
709 |               return lili('<a onclick ="showSearch()">Search</a>'); |
710 |          |
711 |            } |
712 |             |
713 |  } |
714 |   |
showsearch |
|
715 |   function showSearch(){} |
traverse |
|
716 | |
717 |   |
718 |  function rowItems(rowArray){ |
719 |      var result = []; |
720 |      for (var i=0  i<rowArray.length;i++){ |
721 |          result = result.concat(rowArray[i].children); |
722 |      } |
723 |      return result; |
724 |  }  |
ChildFunctions |
|
725 |     |
726 |   |
727 |  function getChildIndex(homeNode){ |
728 |    var childIndex = 0;     |
729 |           if (homeNode.hasOwnProperty('previousChildIndex')){ |
730 |              childIndex = homeNode.previousChildIndex; |
731 |            } |
732 |    return childIndex;            |
733 |  }            |
SlideUpOrDown |
|
734 |   |
735 |    function hideDivLater(){ |
736 |     $.fn.fullpage.destroy('all'); |
737 | }    |
738 | |
739 |  function showSearch(){   |
740 |      loadOneSlide(); |
741 |      $("#searchDiv").slideDown(400); |
742 |          $("#browse").slideUp(400); |
743 |      setTimeout(hideDivLater,400); |
744 |      $('body').scrollTop(0); |
745 |     if (homeNode.data.class == 'Conference'){ |
746 |          oldSearchString="asdfasdfkjhae"; |
747 |          currentSearchString="asdfasdfkjhae"; |
748 |          $("input[name=search]").val(homeNode.data.title); |
749 |          myKeyUpCore(homeNode.data.title); |
750 |  }  |
751 |   |
752 |       |
753 |  } |
754 |   |
755 |     |
756 |   function resetHeight(){ |
757 |      searchDiv.style.height="auto" |
758 | } |
759 |   |
760 |    function showBrowser(){ |
761 |     $("#browse").slideDown(400); |
762 |     $("#searchDiv").slideUp(400); |
763 |      setTimeout (resetHeight,400); |
764 |     $('#fullpage').fullpage(fullPageArguments); |
765 |     setTimeout(reload,1000); |
766 | |
767 |       |
768 |  } |
769 |   |
770 |    function searchClick(aNode){ |
771 |        var duration = 400; |
772 |          $("#browse").slideDown(duration); |
773 |     $("#searchDiv").slideUp(duration); |
774 |      homeNode = aNode; |
775 |       saveCurrentURL(); |
776 |      displaySlide(homeNode); |
777 |      //setTimeout(reload,duration); |
778 |  } |
779 |   |
780 | |
781 |        |
782 | |
783 |        |
784 |   |
createSlides |
|
785 | function renderVerticalSlides(){ |
786 |      |
787 |             var i,slide;   |
788 |             var result = ""; |
789 |             for (i = 0  i < verticalSlides.length; i++){ |
790 |                     slide =renderVerticalSlide (verticalSlides[i],i); |
791 |                      result += slide; |
792 |             } |
793 |             return result; |
794 |              |
795 | }    |
796 | |
797 | function renderHorizontalSlides(){ |
798 |       |
799 |             var j;      |
800 |             var result = "";  |
801 |             for (j = 0  j < horizontalSlides.length; j++){ |
802 |                       slide =renderHorizontalSlide (horizontalSlides[j],j); |
803 |                       result += slide; |
804 |                     } |
805 |             return result;             |
806 |      |
807 |             } |
808 |              |
809 | |
renderSlides |
|
810 |  function goToChat(item){ |
811 |        |
812 |     var href = "/" + item + "/chat"; |
813 |           window.open(href); |
814 | |
815 |  } |
816 |   |
817 |   |
818 |   |
819 | |
renderVerticalSlide |
|
820 |  function renderHorizontalSlide(slide,index){  |
821 |     var result = ""; |
822 |     result += "<div " + |
823 |     " id = \"slide " + slide.key + "\" "+ |
824 |     "class=\"slide"; |
825 |     if (slide == homeNode)  { |
826 |             result +=" active"; |
827 |         } |
828 | |
829 |     result +="\">"; |
830 |     result += '<div style="width: calc(100% - 20px);"' + |
831 |               'id="' + slide.key + "-page" + '">'; |
832 |                |
833 |     result += renderSlide(slide,index); |
834 |     result += "</div>"; |
835 |     result += "</div>"; |
836 |     return result; |
837 |  } |
838 |   |
839 |   |
840 |  function renderVerticalSlide(slide, index){ |
841 |         var result = ""; |
842 |         result += "<div class=\"section "; |
843 |         if (slide == homeNode)  { |
844 |             result +="active "; |
845 |         } |
846 |        //       result += " style=\"background-color:" + |
847 |        //   (parents(slide).length & 1) ? '#ccc': '#fff'+ ";\""; |
848 |         result +="\">"; |
849 |            if (slide == homeNode)  { |
850 |             result += renderHorizontalSlides();   |
851 |          } |
852 |          else { |
853 |             result += renderSlide(slide,0); |
854 |          } |
855 |        |
856 |         result += "</div>"; |
857 |         return result; |
858 |  } |
859 |   |
clickNode |
|
860 |   function clickNode(webPageName){ |
861 |      var key = webPageName.key; |
862 |       homeNode=tree.getNodeByKey(key); |
863 |      popSlides(homeNode); |
864 |  } |
865 |   |
866 |   window.addEventListener('popstate', function(event) { |
867 | clickNode(event.state); |
868 |    |
869 | }); |
get |
|
870 | function slideDownTo(key){ |
871 |     var nextNode=tree.getNodeByKey(key); |
872 |     var index = homeNode.children.indexOf(nextNode); |
873 |     homeNode.previousChildIndex=index; |
874 |    goDown(); |
875 | }  |
876 | |
877 |  function setRatio(node,score){ |
878 |      node.data.ratio = score; |
879 |  } |
880 |       |
881 |  function getConferenceKey(slide){ |
882 |     return slide.data.conference; |
883 | } |
884 | |
885 |  function getConference(slide){ |
886 |     return getNode(slide.data.conference); |
887 | } |
888 | |
889 | function localRebuild(){ |
890 |        $.fn.fullpage.reBuild(); |
891 |      return true; |
892 |   } |
893 | |
894 | |
895 | function getNode(key){ |
896 |        return tree.getNodeByKey(key); |
897 | } |
898 | |
899 |   function getConferenceName(node){ |
900 |       return node.data.conference; |
901 |   } |
902 |    |
903 | function isRoot(node){ |
904 |     if (getKey(node)==rootName){ |
905 |         return true; |
906 |     } |
907 |     return false; |
908 | } |
909 |       |
910 |   function getTitle(item){ |
911 |       return item.data.title; |
912 |   } |
913 |    |
914 |   function getBranchSize(item){ |
915 |       return item.data.branchSize; |
916 |   } |
917 |    |
918 |    |
919 |    function getDescription(item){ |
920 |       return item.data.description; |
921 |   } |
922 |      function getUpVotes(item){ |
923 |       return item.data.upVotes; |
924 |   } |
925 |      function getDownVotes(item){ |
926 |       return item.data.downVotes; |
927 |   } |
928 |    |
929 |   function getClass(slide){ |
930 |       return slide.data.class; |
931 |   } |
932 |    |
933 | |
934 |   |
935 |  function getKey(item,array){ |
936 |      return item.key; |
937 |  } |
938 |   function getClass(item,array){ |
939 |      return item.data.class; |
940 |  } |
941 |    |
getHorizontalAndVerticalSlides |
|
942 | var horizontalSlides, verticalSlides;  |
943 |     var verticalIndex; |
944 | var horizontalIndex; |
945 | |
946 | function setSlides(aNode){ |
947 |     setSingleSlide(); |
948 | }     |
949 | |
950 | function setSingleSlide(){ |
951 |     verticalSlides = [homeNode]; |
952 |     horizontalSlides = [homeNode]; |
953 |      verticalIndex = 0; |
954 |     horizontalIndex = 0; |
955 | } |
956 | function setUpSlides(){ |
957 |     verticalSlides = [homeNode.parent,homeNode]; |
958 |     horizontalSlides = [homeNode]; |
959 |      verticalIndex = 1; |
960 |     horizontalIndex = 0; |
961 | } |
962 | function setDownSlides(){ |
963 |     var childIndex = getChildIndex(homeNode); |
964 |     verticalSlides = [homeNode,homeNode.children[childIndex]]; |
965 |     horizontalSlides = [homeNode]; |
966 |      verticalIndex = 0; |
967 |     horizontalIndex = 0; |
968 | } |
969 | function setRightSlides(){ |
970 |     var hIndex = homeNode.parent.children.indexOf(homeNode); |
971 |     verticalSlides = [homeNode]; |
972 |     horizontalSlides = [homeNode, homeNode.parent.children[hIndex+1]]; |
973 |      verticalIndex = 0; |
974 |     horizontalIndex = 0; |
975 | } |
976 | function setLeftSlides(){ |
977 |     var hIndex = homeNode.parent.children.indexOf(homeNode); |
978 |     verticalSlides = [homeNode]; |
979 |     horizontalSlides = [homeNode.parent.children[hIndex-1],homeNode]; |
980 |      verticalIndex = 0; |
981 |     horizontalIndex = 1; |
982 | } |
983 | |
984 | |
985 | /* |
986 | THis was the old one.  |
987 | function setSlides(aNode){ |
988 |     verticalSlides = listOfVerticalSlides(aNode); |
989 |     horizontalSlides = listOfHorizontalSlides(aNode); |
990 |   |
991 |     verticalIndex = verticalSlides.indexOf(homeNode); |
992 |     horizontalIndex = horizontalSlides.indexOf(homeNode); |
993 | } |
994 | */ |
995 | |
996 | function listOfVerticalSlides(homeNode){ |
997 |     var result = []; |
998 |     if (homeNode.parent.parent !== null){ |
999 |         result.push (homeNode.parent); |
1000 |     } |
1001 |     result.push (homeNode); |
1002 |      |
1003 |     if (hasChildren(homeNode)){ |
1004 |           var childIndex = getChildIndex(homeNode); |
1005 |           var child=homeNode.children[childIndex]; |
1006 |            result.push(child); |
1007 |     } |
1008 |     return result; |
1009 |  } |
1010 |   |
1011 |   |
1012 |  function listOfHorizontalSlides(aNode){ |
1013 |      var children = aNode.parent.children; |
1014 |      var index =children.indexOf(aNode); |
1015 |      var result = []; |
1016 |      if (index >0){ |
1017 |          result.push (children[index-1]); |
1018 |      } |
1019 |    |
1020 |      result.push (aNode); |
1021 |      |
1022 |      if (index < children.length -1){ |
1023 |          result.push (children[index + 1]); |
1024 |      } |
1025 |      return result; |
1026 |  } |
1027 |   |
1028 | |
getPage |
|
1029 |  function getPage(){ |
1030 |      handle = ''; |
1031 |      var result = $('#' + homeNode.key + "-page" ).html(); |
1032 |      handle = 'lozinski'; |
1033 |      return result; |
1034 |  } |
hasChildren |
|
1035 |    |
1036 |  function hasChildren(homeNode){ |
1037 |     |
1038 |     if (homeNode.hasOwnProperty ('children') && |
1039 |          (homeNode.children !== null) && |
1040 |         (homeNode.children.length > 0)){ |
1041 |             return true; |
1042 |         } |
1043 |      return false;     |
1044 |  } |
1045 |       |
initialize |
|
1046 | var landingPage = null; |
1047 | |
1048 | var  parameters =    { |
1049 |        extensions: ["filter"], |
1050 | quicksearch: true, |
1051 | |
1052 | filter: { |
1053 | autoApply: true,  // Re-apply last filter if lazy data is loaded |
1054 | counter: true,  // Show a badge with number of matching child nodes near parent icons |
1055 | fuzzy: false,  // Match single characters in order, e.g. 'fb' will match 'FooBar' |
1056 | hideExpandedCounter: true,  // Hide counter badge, when parent is expanded |
1057 | highlight: true,  // Highlight matches by wrapping inside <mark> tags |
1058 | mode: "hide",  // Grayout unmatched nodes (pass "hide" to remove unmatched node instead) |
1059 | autoExpand: true, |
1060 | leavesOnly:false |
1061 | }, |
1062 | |
1063 | |
1064 | treeInit: function(ctx){ |
1065 |              this._superApply(ctx); |
1066 |          }, |
1067 |   |
1068 |        init:  function(arg1,arg2) { |
1069 |            |
1070 |              tree=  arg2.tree; |
1071 |  homeNode=arg2.tree.getNodeByKey(webPageName); |
1072 |  tree.homeNode=homeNode; |
1073 |  landingPage = homeNode; |
1074 |  root=arg2.tree.getRootNode().children[0]; |
1075 |  saveCurrentURLAndSearch(); |
1076 |      displaySlide(homeNode); |
1077 |        }, |
1078 |   |
1079 |         source: $.ajax({ |
1080 |             url: mobileJson, |
1081 |             dataType: "json" |
1082 |          }), |
1083 |           |
1084 |           |
1085 |           click: function(event, data) { |
1086 |                var aNode = data.node; |
1087 |                 searchClick(aNode); |
1088 |          return false; |
1089 |           |
1090 |          }, |
1091 |  }; |
1092 |   |
1093 | $("#tree").fancytree(parameters); |
1094 | |
initializeslides |
|
1095 | function pleaseLoadContent (anchorLink, index, slideAnchor, slideIndex){ |
1096 |     loadContent (); |
1097 | } |
1098 | function smallLoadContent (anchorLink, index, slideAnchor, slideIndex){ |
1099 |     loadContent (); |
1100 | } |
1101 | |
1102 | function reloadSection(anchorLink, index){ |
1103 |     if (mayLoad){ |
1104 |         mayLoad = false; |
1105 |         reload(); |
1106 |     } |
1107 | } |
1108 | |
1109 | function reloadSlide(anchorLink, index, slideAnchor, slideIndex){ |
1110 |     if (mayLoad){ |
1111 |         mayLoad = false; |
1112 |         reload(); |
1113 |     } |
1114 | } |
1115 | |
1116 | var fullPageArguments=     { |
1117 |   verticalCentered: false, |
1118 |   //CHROME |
1119 | scrollOverflow:true, |
1120 | scrollBar: false, |
1121 | loopHorizontal: false, |
1122 | touchSensitivity: 10, |
1123 |         afterResize: resizeVideos,  |
1124 | css3:false, //JQUERY UI required by Fancytree breaks it |
1125 |       afterRender:pleaseLoadContent, |
1126 |  afterLoad: reloadSection,  |
1127 |  afterSlideLoad: reloadSlide, |
1128 |  onLeave:  leaveSection, |
1129 |    onSlideLeave:  leaveSlide |
1130 | |
1131 | }; |
leave |
|
1132 | |
1133 | var mayLoad=false; |
1134 | |
1135 |  //OLD VERSIONS |
1136 | function leaveSection (index,nextIndex,direction){ |
1137 |         if (! allowScrolling){ |
1138 |         return false; |
1139 |     } |
1140 |     mayLoad= true; |
1141 |     homeNode = verticalSlides [nextIndex-1]; |
1142 |     saveCurrentURL(); |
1143 |     return true; |
1144 | } |
1145 | |
1146 | |
1147 | function leaveSlide(anchorLink, index, slideIndex, direction, nextSlideIndex){ |
1148 |     if (! allowScrolling){ |
1149 |         return false; |
1150 |     } |
1151 |     mayLoad= true; |
1152 |     homeNode = horizontalSlides [nextSlideIndex]; |
1153 |      saveCurrentURL(); |
1154 | |
1155 |     return true; |
1156 | |
1157 | } |
1158 | |
1159 | |
1160 | |
1161 | function popSlides(aNode){ |
1162 |      setSlides(aNode); |
1163 |      reload(); |
1164 | } |
1165 | |
1166 | function displaySlideNamed(key){ |
1167 |     displaySlide(tree.getNodeByKey(key)); |
1168 |     saveCurrentURL(); |
1169 | }  |
1170 | |
1171 | function displaySlide(aNode){ |
1172 |     homeNode = aNode; |
1173 |      setSlides(aNode); |
1174 |      reload(); |
1175 | } |
moveMoveCommands |
|
1176 | function buildFullPage(){ |
1177 |           $('#fullpage').fullpage(fullPageArguments); |
1178 | } |
1179 | |
1180 | function moveDown(){ |
1181 |     setDownSlides(); |
1182 |     restartFullPage(); |
1183 |     reloadCore(); |
1184 |     $.fn.fullpage.moveSectionDown(); |
1185 | } |
1186 | |
1187 |  function moveUp(){ |
1188 |      setUpSlides(); |
1189 |    restartFullPage(); |
1190 |     reloadCore(); |
1191 |     $.fn.fullpage.moveSectionUp(); |
1192 |       |
1193 | |
1194 |  } |
1195 | |
1196 | |
1197 | |
1198 | function moveToLast(numberOfSiblings){ |
1199 |      return; |
1200 | } |
1201 | |
1202 | function moveToFirst(){ |
1203 | return |
1204 |      |
1205 | } |
1206 | |
1207 | function moveRight(){ |
1208 |     setRightSlides(); |
1209 |    restartFullPage(); |
1210 |     reloadCore(); |
1211 |     $.fn.fullpage.moveSlideRight(); |
1212 | |
1213 | } |
1214 | |
1215 | function moveLeft(){ |
1216 |      setLeftSlides(); |
1217 |    restartFullPage(); |
1218 |     reloadCore(); |
1219 |     $.fn.fullpage.moveSlideLeft(); |
1220 |       |
1221 | } |
moveToMobile |
|
1222 | function MoveTo(){ |
1223 |      |
1224 | } |
pinchToZoom |
|
1225 | var allowScrolling = true; |
1226 | /* |
1227 | $(document).ready(function() {  |
1228 | |
1229 |     var scale = 1.0; // initial-scale |
1230 |     var r = 0.10; |
1231 |     var oldScale = scale; |
1232 | |
1233 |     $(document).bind('gesturechange',function(event){ |
1234 |         allowScrolling = false; |
1235 |         $.fn.fullpage.destroy(); |
1236 |          var height = viewport.height; |
1237 |          var halfHeight = height / 2.0; |
1238 |          var  offsetTop = vewport.offsetTop; |
1239 |           var oldHeight = halfHeight + offsetTop; |
1240 |          |
1241 |         var newScale = event.originalEvent.scale; |
1242 |         if(newScale  > 1) scale = scale <2 ?  newScale : 2 |
1243 |         else scale = scale > 0.5 ? newScale : 0.5 |
1244 | |
1245 |        |
1246 |          var ratio = newScale /oldScale;  |
1247 |          var newHeight = (oldHeight * ratio) -height; |
1248 |          viewport.offsetTop = newHeight;        |
1249 |         $('meta[name=viewport]').attr('content', 'width=device-width, minimum-scale='+ scale.toFixed(2) +', maximum-scale='+ scale.toFixed(2) +', user-scalable=yes'); //  |
1250 |         setTimeout(pleaseAllowScrolling,300); |
1251 |              $.fn.fullpage.reBuild(); |
1252 |               |
1253 |         oldScale = newScale; |
1254 | |
1255 |     }); |
1256 | }); |
1257 | |
1258 | function pleaseAllowScrolling(){ |
1259 |      allowScrolling = true; |
1260 | } |
1261 | */ |
reload |
|
1262 | var fullPage = false; |
1263 | var newSlides; |
1264 | function reload(){ |
1265 |     |
1266 |     setChildIndex(); |
1267 |      //setSlides(homeNode); |
1268 |      setAndReload(); |
1269 | }      |
1270 | |
1271 | function loadOneSlide(){ |
1272 |      |
1273 |     verticalSlides=[homeNode]; |
1274 |     horizontalSlides=[homeNode]; |
1275 |     setAndReload(); |
1276 | } |
1277 | |
1278 | function setAndReload(){  |
1279 |        setSingleSlide(); |
1280 |        reloadCore(); |
1281 |         destroyFullPage(); |
1282 |        } |
1283 |         |
1284 | function reloadCore(){        |
1285 |        replaceFullPage(); |
1286 |        destroyFullPage(); |
1287 |        restartFullPage(); |
1288 | }         |
1289 | |
1290 | |
1291 |      |
1292 | function replaceFullPage(){    |
1293 |          document.title=pageTitle(homeNode); |
1294 |      $('#fullpage div').addClass("old"); |
1295 |      newSlides = renderVerticalSlides(homeNode); |
1296 |      $(".old").remove(); |
1297 |      $('#fullpage').append(newSlides); |
1298 | } |
1299 | |
1300 | function destroyFullPage(){ |
1301 |       if (fullPage){ |
1302 |        $.fn.fullpage.destroy('all');    |
1303 |      } |
1304 | }      |
1305 | |
1306 | function restartFullPage(){ |
1307 |      fullPage = true; |
1308 |      $('#fullpage').fullpage(fullPageArguments); |
1309 | } |
1310 | |
MyFilter |
|
1311 |  //THS FUNCTION IS A HOOK SO THAT EVERYONE CAN GENERATE THE APPROAPRIATE |
1312 | //STRING TO SEARCH IN THEIR APPLICATION |
1313 | function getStringToSearch(node){ |
1314 |          var searchString = node.data.title+' '+node.data.description + ''; |
1315 |          if (node.data.class == 'Video'){ |
1316 |             searchString += tree.getNodeByKey(node.data.conference).title;  |
1317 |          } |
1318 |          return searchString; |
1319 |     } |
1320 |      |
1321 |      |
1322 | // THIS IS THE FUNCTION WHICH RETURNS TRUE IF ALL THE WORDS ARE FOUND IN THE STRING |
1323 | //FALSE OTHERWISE |
1324 | function MyFilter(node,regexpArray){  |
1325 |      |
1326 |     |
1327 |     var j; |
1328 |     var stringToSearch=getStringToSearch(node); |
1329 |     var result=true; |
1330 |     for (j in regexpArray){ |
1331 |          if (!(regexpArray[j].test(stringToSearch))){ |
1332 |              result=false; |
1333 |          } |
1334 |     } |
1335 |   |
1336 |     return result; |
1337 | } |
1338 | |
1339 | function formattedTitle(node,coreTitle){ |
1340 |   return  "• <a title=\""+node.data.description  +  "\"><b>"+ coreTitle +"</b></a>"; |
1341 |      |
1342 | }   |
1343 | |
1344 | |
applyFilter |
|
1345 |  //SETS A SHORT TITLE, NO DESCRIPTION, FOR BREADCRUMB NODES |
1346 | function setShortTitle(node){ |
1347 |                          node.title=node.data.title; |
1348 |                          //"<a><b>"+node.data.title +"</b></a>"+ |
1349 |                   //" ("+getBranchSize(node)+")"; |
1350 |         } |
1351 |          |
1352 |   |
1353 | $.ui.fancytree._FancytreeClass.prototype._applyFilterImpl = function(filter, branchMode, opts){ |
1354 | |
1355 |     //FIRST DEFINE AND SET SOME VARIABLES    |
1356 | var leavesOnly, |
1357 |     match,  |
1358 |     re,  |
1359 |     searchString=filter, |
1360 | filterOpts = this.options.filter, |
1361 | hideMode = filterOpts.mode === "hide", |
1362 | regexpArray=getRegxpArray(filter); |
1363 | re2 = new RegExp(filter, "gi"); |
1364 | tree.enableFilter=true; |
1365 | |
1366 | |
1367 | //SET SOME MORE VARIABLES |
1368 |     count=0; |
1369 | opts = opts || {}; |
1370 | lavesOnly = !!opts.leavesOnly && !branchMode; |
1371 | |
1372 | //NOW CREATE THE FUNCTION TO SEARCH A SINGLE NODE |
1373 | filter = function(node){ |
1374 |         var coreTitle; |
1375 |     var res = MyFilter(node,regexpArray); |
1376 |     if (res){ |
1377 |          node.title=formattedTitle(node,node.data.title); |
1378 |          setTitle(node); |
1379 |         } |
1380 | |
1381 | // DONT DO THIS IF MULTIPLE SEARCH TERMS    (regexpArray.length>1) |
1382 | if( res && filterOpts.highlight && (regexpArray.length<2)) { |
1383 |      coreTitle=node.data.title.replace(re2, function(s){ |
1384 | return "<mark>" + s + "</mark>"; |
1385 | }); |
1386 | node.titleWithHighlight = formattedTitle(node,coreTitle); |
1387 | |
1388 |  } else { |
1389 |   delete node.titleWithHighlight; |
1390 | } |
1391 | |
1392 | return res; |
1393 | }; |
1394 | |
1395 | |
1396 | this.enableFilter = true; |
1397 | this.lastFilterArgs = arguments; |
1398 | |
1399 | this.$div.addClass("fancytree-ext-filter"); |
1400 | if( hideMode ){ |
1401 | this.$div.addClass("fancytree-ext-filter-hide"); |
1402 | } else { |
1403 | this.$div.addClass("fancytree-ext-filter-dimm"); |
1404 | } |
1405 | |
1406 | this.visit(function(node){ |
1407 |     node.title = node.data.title + node.match; |
1408 | delete node.match; |
1409 | delete node.titleWithHighlight; |
1410 | node.subMatchCount = 0; |
1411 | }); |
1412 | |
1413 | // SEACH THE TREE  |
1414 | //Adjust node.hide, .match, and .subMatchCount properties |
1415 |   |
1416 |    callVisit(this,function(node){ |
1417 |       |
1418 | if (filter(node)) { |
1419 | count++; |
1420 | node.match = true; |
1421 | node.visitParents(function(p){ |
1422 |     //MAKE THE UNMATCHED PARENTS LOOK GOOD |
1423 |    if (!(p.match)){ |
1424 |            p.match=true; |
1425 |            p.titleWithHighlight="<span style=\"color:#888;\" >"+p.data.title+"</span>"; |
1426 |     } |
1427 |      |
1428 |      if ('subMatchCount' in p) {   |
1429 |           p.subMatchCount += 1; |
1430 |           } |
1431 |          else {  |
1432 |             p.subMatchCount=1; |
1433 |          } |
1434 |       |
1435 | //if( opts.autoExpand && !p.expanded ) { |
1436 | |
1437 | p.setExpanded(true, {noAnimation: true, noEvents: true, scrollIntoView: false}); |
1438 | p._filterAutoExpanded = true; |
1439 | |
1440 | }); |
1441 | |
1442 | } |
1443 | |
1444 | }); |
1445 | |
1446 | |
1447 | }; |
1448 | |
1449 | |
1450 | |
branchSize |
|
1451 |   var branchSize; |
1452 |  function getBranchSize(node){ |
1453 |     if (node.match || node.unmatchedParent){ |
1454 |         return node.subMatchCount; |
1455 |     } |
1456 |     else { |
1457 |         branchSize=node.data.branchSize; |
1458 |         branchSize = parseInt(branchSize); |
1459 |         branchSize = branchSize.toString(); |
1460 |         return branchSize; |
1461 |          |
1462 |     } |
1463 | } |
1464 | |
collapseChildren |
|
1465 |  function collapseChildren(node){ |
1466 |     var index; |
1467 |     var item; |
1468 |     var children=node.children; |
1469 |     if((node.isFolder())&&node.hasChildren()){ |
1470 |         node.setExpanded(false, {noAnimation: true, noEvents: true, scrollIntoView: false}); |
1471 |         for (index=0;index<children.length;index++){ |
1472 |             item=children[index] |
1473 |             if (item.isExpanded()){ |
1474 |                 collapseChildren(item);  |
1475 |             } |
1476 |         } |
1477 |     } |
1478 | } |
gui-functions |
|
1479 |    |
1480 | |
1481 | |
1482 | |
1483 | var tree = $("#tree").fancytree("getTree"); |
1484 | |
1485 | /* |
1486 |  * Event handlers for search |
1487 |  */ |
1488 | var match; |
1489 | |
1490 | function searchTheTree(match,opts){ |
1491 |             oldSearchString=match; |
1492 |             tree.clearFilter(); |
1493 |   tree.filterNodes(match, opts); |
1494 | } |
1495 | |
1496 |      |
1497 | function myKeyUp(e){     |
1498 |      if(e && e.which === $.ui.keyCode.ESCAPE ){ |
1499 | $("button#btnResetSearch").click(); |
1500 | return; |
1501 | } |
1502 | |
1503 | var match=$("input[name=search]").val(); |
1504 |             myKeyUpCore(match); |
1505 | } |
1506 | |
1507 | $("input[name=search]").keyup(myKeyUp); |
1508 | |
1509 | |
1510 | function myKeyUpCore(match){ |
1511 | var opts={}; |
1512 | var n; |
1513 |     currentSearchString=match; |
1514 |       |
1515 |       |
1516 |     //IF YOU JUST DELETED THE SEARCH STRING |
1517 |     if (currentSearchString.length===0) { |
1518 |        tree.clearFilter();  |
1519 |        collapseChildren(root); |
1520 |        root.render(); |
1521 |        oldSearchString=""; |
1522 |        return; |
1523 |     } |
1524 |      |
1525 |     //IF YOU JUST STARTED SEARCHING |
1526 |     if (oldSearchString===""){ |
1527 |         oldSearchString=currentSearchString.slice(1); |
1528 |          root.render(); |
1529 |          return; |
1530 |         } |
1531 |               |
1532 |             if (callbackCount===0){ |
1533 |                 searchTheTree(match,opts); |
1534 |          |
1535 |             } |
1536 |      |
1537 | |
1538 | |
1539 | }       |
1540 | |
1541 |   function futureSearch(match,opts){ |
1542 |                      searchTheTree(match,opts); |
1543 |                   root.render(); |
1544 |                  } |
1545 | |
1546 | |
1547 | |
1548 | |
1549 |    |
1550 | $("button#btnResetSearch").click(function(e){ |
1551 | $("input[name=search]").val(""); |
1552 | $("span#matches").text(""); |
1553 | tree.clearFilter(); |
1554 | }).attr("disabled", true); |
1555 | |
1556 | |
1557 | |
1558 | |
1559 | |
1560 | |
search.js |
|
1561 |       var callbackCount=0; |
1562 | var count; |
1563 | var currentSearchString=""; |
1564 | var oldSearchString=""; |
1565 | |
1566 | function cleanUp(){ |
1567 |      var rootNode=$("#tree").fancytree("getTree").getRootNode(); |
1568 |         rootNode.render(true); |
1569 |         $("button#btnResetSearch").attr("disabled", false); |
1570 |     $("span#matches").text("(" + count + " matches)"); |
1571 |     $.fn.fullpage.reBuild(); |
1572 | |
1573 | } |
1574 | |
1575 | function reSearch(filterFunction){ |
1576 |     var value=$("input[name=search]").val(); |
1577 |     if (currentSearchString!=value){ |
1578 |           $("input[name=search]").trigger("keyup"); |
1579 | |
1580 |        } |
1581 |     else{ |
1582 | |
1583 |            cleanUp(); |
1584 |        } |
1585 | $.fn.fullpage.reBuild(); |
1586 | |
1587 | } |
1588 |   |
1589 | |
1590 |   |
1591 |   |
setScrolling |
|
1592 |    function setScrolling(){ |
1593 |     if (homeNode.data.class == 'Chat'){ |
1594 |       $.fn.fullpage.setAutoScrolling(false); |
1595 |       $.fn.fullpage.setFitToSection(false); |
1596 |     } |
1597 |     else{ |
1598 |          $.fn.fullpage.setAutoScrolling(true); |
1599 |          $.fn.fullpage.setFitToSection(true);   |
1600 | |
1601 |     } |
1602 | } |
1603 | |
ViewCount |
|
1604 |  function getViewCount(aNode){ |
1605 |     if (isMobile){ |
1606 |         return aNode.data.viewCount; |
1607 |     } |
1608 |     return aNode.viewCount; |
1609 | } |
1610 | |
1611 | function score (aNode){ |
1612 |       var upVotes, downVotes, viewCount, ratio; |
1613 |       upVotes=Number(getUpVotes(aNode)); |
1614 |       downVotes= Number(getDownVotes(aNode)); |
1615 |       viewCount=Number(getViewCount(aNode)); |
1616 |       ratio = (upVotes - (5 * downVotes))/viewCount; |
1617 |       ratio = ratio * 10000; |
1618 |       return ratio; |
1619 | } |
Arrows |
|
1620 | function oneArrow(direction,x,y,visible, onClick){ |
1621 |     var result=''+ |
1622 |     '<i style="position:relative;' + |
1623 |     'top:' + y + 'em;'+ |
1624 |     'left:' + x + 'em;'+ |
1625 |     'opacity:'; |
1626 |     if (visible){ |
1627 |         result +='1.0;'; |
1628 |     } |
1629 |     else{ |
1630 |         result += '0.4;'; |
1631 |     } |
1632 |     if (visible){ |
1633 |        result += 'color:green;'; |
1634 |     } |
1635 |     else{ |
1636 |        result += 'color:red;'; |
1637 |     } |
1638 |     result += '" ' |
1639 |     result += 'class="fa fa-arrow-circle-' + direction + |
1640 |     '"'+ |
1641 |     'onClick="' + onClick + '"' +  |
1642 |     '></i>'; |
1643 |     return result; |
1644 | } |
1645 | |
1646 | function addArrows(slide){ |
1647 |     |
1648 |     if (isMobile){ |
1649 |            return arrowsMobile(slide); |
1650 |     } |
1651 |     else{ |
1652 |         return arrowsDesktop(slide); |
1653 |     } |
1654 |       |
1655 |     |
1656 | } |
1657 | |
1658 |   |
1659 | function arrowsDesktop(slide){ |
1660 |   var result = "" + |
1661 | '<div  class = "my-desktop-arrows" >' + |
1662 | arrows(slide)+ |
1663 | '</div>';   |
1664 | return result; |
1665 | } |
1666 | |
1667 | //THIS IS WHERE THE 3EM FONT SIZE WAS SET |
1668 | function arrowsMobile(slide){ |
1669 | |
1670 |   var result = "" + |
1671 | '<div  class = "my-mobile-arrows" >' + |
1672 | arrows(slide)+ |
1673 | '</div>';   |
1674 | return result; |
1675 | } |
1676 | |
1677 | function arrows(slide){ |
1678 |    |
1679 |      |
1680 | var result = "" + |
1681 | |
1682 | oneArrow('left',1,1,canGoLeft(slide),'goLeft()') + |
1683 | oneArrow('up',1,0,canGoUp(slide),'goUp()') + |
1684 | oneArrow('right',1,1,canGoRight(slide),'goRight()') + |
1685 | oneArrow('down',-1.0,2,canGoDown(slide),'goDown()') |
1686 | |
1687 | return result; |
1688 | } |
arguments |
|
1689 |  var urlParams = new URLSearchParams(window.location.search); |
1690 | var sortBy = 'bestWilsonScore'; |
1691 |   |
1692 | if (urlParams.has('sortBy') ){ |
1693 |     sortBy = urlParams.get('sortBy'); |
1694 | } |
1695 | if (!(['bestWilsonScore','bestMyScore','bestMostRecent'].includes(sortBy))){ |
1696 |     sortBy='bestWIlsonScore'; |
1697 | } |
1698 | |
arrowKeys |
|
1699 | function getChildIndex(aNode){ |
1700 |      var childIndex= 0   |
1701 |      if ( 'previousChildIndex' in aNode){ |
1702 |       childIndex = homeNode.previousChildIndex; |
1703 |       } |
1704 |      return childIndex;  |
1705 | } |
1706 | |
1707 | function canGoUp(node){ |
1708 |     return !isRoot(node); |
1709 | } |
1710 | |
1711 | function goUp (){ |
1712 |     if (canGoUp(homeNode)){ |
1713 |         var offset = homeNode.parent.children.indexOf(homeNode); |
1714 |         homeNode.parent.previousChildIndex = offset; |
1715 |         moveUp(); |
1716 |     } |
1717 | } |
1718 | |
1719 | |
1720 | function canGoDown(node){ |
1721 |  return hasChildren(node);    |
1722 | } |
1723 | |
1724 | function goDown (){ |
1725 |     if(! canGoDown(homeNode)){ |
1726 |         return; |
1727 |     } |
1728 |     var childIndex=getChildIndex(homeNode); |
1729 |     moveDown(childIndex); |
1730 | } |
1731 | |
1732 | function canGoRight(node){ |
1733 |     var siblings= getSiblings(node); |
1734 |     var offset = siblings.indexOf(homeNode); |
1735 |     var numberOfSiblings = siblings.length; |
1736 |     return (offset < numberOfSiblings -1 ) |
1737 | } |
1738 | |
1739 | function goRight (){ |
1740 |    var siblings = getSiblings(homeNode); |
1741 |     var offset = siblings.indexOf(homeNode); |
1742 |     var numberOfSiblings = siblings.length; |
1743 |     if (canGoRight(homeNode)){ |
1744 |        homeNode.parent.previousChildIndex = offset + 1; |
1745 |        moveRight(offset); |
1746 |     } |
1747 |     else { |
1748 |         homeNode.parent.previousChildIndex = 0; |
1749 |          moveToFirst(); |
1750 |     } |
1751 | } |
1752 | |
1753 | |
1754 | function canGoLeft(node){ |
1755 |        |
1756 |     var siblings= getSiblings(homeNode); |
1757 |     var offset = siblings.indexOf(homeNode); |
1758 |     var numberOfSiblings = siblings.length; |
1759 |     return  (offset > 0); |
1760 | |
1761 | } |
1762 | function goLeft (){ |
1763 |    |
1764 |     var siblings= getSiblings(homeNode); |
1765 |     var offset = siblings.indexOf(homeNode); |
1766 |     var numberOfSiblings = siblings.length; |
1767 | |
1768 |     if (canGoLeft(homeNode)){ |
1769 |         homeNode.parent.previousChildIndex = offset -1; |
1770 |         moveLeft(offset); |
1771 |     } |
1772 |      |
1773 |     else{ |
1774 |        homeNode.parent.previousChildIndex = numberOfSiblings -1; |
1775 |        moveToLast(numberOfSiblings);  |
1776 |     } |
1777 |      |
1778 | } |
1779 | |
1780 | |
1781 | |
1782 |    document.onkeydown = function (e) { |
1783 |   if (e.key=="ArrowUp"){ |
1784 |       goUp(); |
1785 |        |
1786 |   } |
1787 |     else if (e.key=="ArrowDown"){ |
1788 |       goDown(); |
1789 |   } |
1790 |     else if (e.key=="ArrowLeft"){ |
1791 |       goLeft(); |
1792 |   } |
1793 |     else if (e.key=="ArrowRight"){ |
1794 |         goRight(); |
1795 |        |
1796 |   } |
1797 |    else if (e.key=="PageUp"){ |
1798 |       goLeft(); |
1799 |   } |
1800 |     else if (e.key=="PageDown"){ |
1801 |         goRight(); |
1802 |        |
1803 |   } |
1804 | }; |
arrows |
|
1805 |  function footer(item,index){ |
1806 |      var result = ""; |
1807 |                       |
1808 |      if (hasChildren(item)){ |
1809 |          result += " ↑ "; |
1810 |      } |
1811 |         if (isRoot(item) !== null){ |
1812 |          result += " ↓ "; |
1813 |      } |
1814 |         if (index > 0){ |
1815 |          result += " → "; |
1816 |      } |
1817 |         if (! isRoot(item)){ |
1818 |          result += " ← "; |
1819 |      } |
1820 |      return result; |
1821 |  } |
loadContent |
|
1822 | function errorF( jqXHR, textStatus, errorThrown ){ |
1823 |     console.log ("AJAX ERROR", jqXHR, textStatus, errorThrown ); |
1824 |         // $.fn.fullpage.reBuild(); |
1825 | |
1826 | } |
1827 | |
1828 | |
1829 | //after slide load |
1830 | function loadContent(){ |
1831 |    |
1832 |     if (homeNode === undefined){ |
1833 |         return; |
1834 |     } |
1835 |     |
1836 |     var url = "/" + getKey(homeNode) + "/content"; |
1837 |     divName = "#" + getKey(homeNode) + "-content"; |
1838 |     console.log("URL", url); |
1839 |     console.log ("sortBy", sortBy); |
1840 |       $.ajax({ |
1841 |           type: 'POST', |
1842 |           url: url,  |
1843 |       data: {'sortBy':sortBy}, |
1844 |       cache: false,  |
1845 |       error: errorF, |
1846 |       success: function(result){ |
1847 |         $(divName).html(result); |
1848 |         resizeVideos(0,0,"body"); |
1849 |      localRebuild(); |
1850 |     } |
1851 |       }); |
1852 |      |
1853 | } |
1854 |   |
1855 | |
1856 |     |
navbar.pug |
|
1857 | nav.navbar.navbar-expand-md.navbar-dark.bg-dark |
1858 |   button.navbar-toggler(type='button', data-toggle='collapse', data-target='#navbarsExample04', aria-controls='navbarsExample04', aria-expanded='false', aria-label='Toggle navigation') |
1859 |     span.navbar-toggler-icon  |
1860 |   #navbarsExample04.collapse.navbar-collapse |
1861 |     ul.navbar-nav.mr-auto |
1862 |       li.nav-item.dropdown |
1863 |         a#dropdown04.nav-link.dropdown-toggle(href='https://example.com', data-toggle='dropdown', aria-haspopup='true', aria-expanded='false') Sites |
1864 |         .dropdown-menu(aria-labelledby='dropdown04') |
1865 |           != renderServerOptions(node)         |
1866 |           a.dropdown-item(href='https://PythonLinks.info') Python Videos |
1867 |           a.dropdown-item(href='https://ClimateVideos.info') Climate Change Videos |
1868 |           a.dropdown-item(href='https://Cloud-Native.pl') Cloud-Native.pl |
1869 |       if getClass(node)!='Video'        |
1870 |         li.nav-item.dropdown |
1871 |           a#dropdown04.nav-link.dropdown-toggle(href='https://example.com', data-toggle='dropdown', aria-haspopup='true', aria-expanded='false') View |
1872 |           .dropdown-menu(aria-labelledby='dropdown05') |
1873 |             a.dropdown-item( |
1874 |               href='#' |
1875 |               onClick='wilsonView()' |
1876 |             ) WIlson Score |
1877 |             a.dropdown-item( |
1878 |               href='#' |
1879 |               onClick ='myScoreView()' |
1880 |             ) Votes/View |
1881 |             a.dropdown-item( |
1882 |               href='#' |
1883 |               onClick ='mostRecentView()' |
1884 |             ) Most Recent |
1885 |              a.dropdown-item(href='https://PythonLinks.info/wilson-score') Explain |
1886 |       // IF VIDEO |
1887 |       if getClass(node)=='Video'          |
1888 |         li.nav-item.dropdown |
1889 |           a#dropdown04.nav-link.dropdown-toggle(href='https://example.com', data-toggle='dropdown', aria-haspopup='true', aria-expanded='false') Vote |
1890 |           .dropdown-menu(aria-labelledby='dropdown05') |
1891 |             a.dropdown-item( |
1892 |               href='#' |
1893 |               onClick = 'upVote()' |
1894 |             ) Up Vote |
1895 |             a.dropdown-item( |
1896 |               href='#' |
1897 |               onClick = 'downVote()' |
1898 |             ) Down Vote |
1899 |             a.dropdown-item(href='https://PythonLinks.info/wilson-score') Explain |
1900 | |
1901 |       // More |
1902 |       li.nav-item.dropdown |
1903 |           a#dropdown04.nav-link.dropdown-toggle(href='https://example.com', data-toggle='dropdown', aria-haspopup='true', aria-expanded='false') More |
1904 |           .dropdown-menu(aria-labelledby='dropdown05') |
1905 |             a.dropdown-item( |
1906 |               href='https://PythonLinks.info/contact' |
1907 |               ) Contact |
1908 |               span.sr-only (Contact) |
1909 |             if  ! isAuthenticated  |
1910 |               a.dropdown-item( |
1911 |                 href='./register/user' |
1912 |               ) Subscribe |
1913 |               span.sr-only (Subscribe) |
1914 |                |
1915 |             if  ! isAuthenticated  |
1916 |               a.dropdown-item( |
1917 |                 href='./register/web' |
1918 |               ) Login |
1919 |               span.sr-only (Login)  |
1920 |              |
1921 |                      |
1922 |     |
1923 |         |
1924 |           |
1925 |              |
1926 |     if isMobile             |
1927 |       form.form-inline.my-2.my-md-0 |
1928 |         input.form-control( |
1929 |           type='text' |
1930 |           placeholder='Search'   |
1931 |           onFocus = 'showSearch()' |
1932 |         )           |
1933 |     ul.navbar-nav.ml-auto |
1934 |       li.nav-item |
1935 |         a.nav-link( |
1936 |           href='https://twitter.com/intent/follow?screen_name=PythonLinks' |
1937 |           target='_blank'  |
1938 |         )    |
1939 |             != twitterLinkFront() |
1940 |             img( |
1941 |               alt='Follow to receive video recommendations'  |
1942 |               style = 'height:  1.5em;' |
1943 |               src='https://pythonlinks.info/static/graphics/twitter-logo.png' |
1944 |             ) |
1945 |             != twitterLinkBack() |
1946 |       li.nav-item |
1947 |         a.nav-link( |
1948 |           href='#'  |
1949 |           onclick='resizeText(-1)'   |
1950 |         ) a |
1951 |           span.sr-only (Make the Font Smaller) |
1952 |       li.nav-item |
1953 |         a.nav-link( |
1954 |           href='#' |
1955 |           onclick='resizeText(+1)' |
1956 |         ) A |
1957 |           span.sr-only (Make the Font larger) |
1958 |       |
1959 |          |
1960 |            |
1961 |           |
1962 | |
1963 | |
breadcrumbs |
|
1964 |  function oneCrumb(item,step,width,showChildren){ |
1965 |         result = '<div style = "margin-left:' + (step).toString() + 'em">' + |
1966 |          getTitle(item).link('/' + getKey(item)) |
1967 |          if (width > 500){ |
1968 |              result +=  '  (' + getBranchSize(item) + ')' |
1969 |          } |
1970 |          result +=  '</div>'; |
1971 |         return result; |
1972 |  } |
1973 |   |
1974 |   |
1975 |  function selectChanged(arg){ |
1976 |      if (arg.value===''){ |
1977 |          return; |
1978 |      } |
1979 |      displaySlideNamed(arg.value); |
1980 |  } |
1981 |   |
1982 |   |
1983 |   |
1984 | function setSelectedIndex(s, valsearch){ |
1985 |   for (i = 0; i< s.options.length; i++){  |
1986 |     if (s.options[i].value == valsearch){ |
1987 |     s.options[i].selected = true; |
1988 |     break; |
1989 |     } |
1990 |   } |
1991 | } |
1992 | |
1993 |   |
1994 |  function onSelectFocus(arg,id){ |
1995 |        |
1996 |      arg.selectedIndex = 0; |
1997 | } |
1998 | |
1999 |  function onSelectBlur(arg, id){   |
2000 |     setSelectedIndex(arg, arg.id.slice(7)); |
2001 |  } |
2002 |   |
2003 |  function selectSiblings (node,step,width,showChildren){ |
2004 |      var siblings = getSiblings(node); |
2005 |      var id = 'select-' + getKey(node); |
2006 |      if (showChildren){ |
2007 |          siblings = node.children; |
2008 |          id = 'select-child-category'; |
2009 |      } |
2010 |      |
2011 |       result = '<div style = "margin-left:' + (step).toString() + 'em">' |
2012 |     result += '<select style="-webkit-appearance: none; -moz-appearance: none;  appearance:none; '; |
2013 |     result +='width:auto; max-width: 50em; padding: 0; height:1.7em" class= "text-primary form-control" id = "' + id  + '"'; |
2014 |     result += ' onchange ="selectChanged(this)" ' |
2015 |     result += " onfocus =\"onSelectFocus(this,'" + id + "')\""; |
2016 |     result += " onblur =\"onSelectBlur  (this,'" + id + "')\""; |
2017 |     result += ' value="" '; |
2018 |     result += ">"; |
2019 |      |
2020 |     if (showChildren){ |
2021 |         result += '<option selected value="">Select Sub-Category or Video▼</option>'; |
2022 |     } |
2023 |      else{ |
2024 |         result += '<option  >Jump To:</option>'; |
2025 |    |
2026 |      } |
2027 |      |
2028 |    // AND NOW GENERAT OPTIONS |
2029 |    for ( let index in siblings){ |
2030 |        |
2031 |        item = siblings [index]; |
2032 |      |
2033 |        result += "<option ";    |
2034 |         |
2035 |        if (item == node){ |
2036 |            result += " selected "; |
2037 |        } |
2038 |      result +=' value="';  |
2039 |      result += getKey(item); |
2040 |      result +='">'; |
2041 |      |
2042 |      result += getTitle(item); |
2043 |       if (item == node){ |
2044 |            result += " ▼"; |
2045 |        } |
2046 |      if (width > 500){ |
2047 |         result +=  '  (' + getBranchSize(item) + ')' |
2048 |      } |
2049 |   |
2050 |       result += "</option>"; |
2051 |    } |
2052 |   result += "</select>"; |
2053 |     result +=  '</div>'; |
2054 | |
2055 |   return result; |
2056 |  } |
2057 |   |
2058 |  function breadcrumbs(node,index){ |
2059 |       var width = $( window ).width(); |
2060 |      var result=""; |
2061 |      var offset; |
2062 |      var items=parents(node); |
2063 |      var length = items.length; |
2064 |      var step; |
2065 |      result+= "<div style = \"text-align:left; \">"; |
2066 |     for (step = 0; step < length-1; step++) { |
2067 |         item=items[step]; |
2068 |         result += selectSiblings(item,step,width,false); |
2069 |         } |
2070 |      result += selectSiblings(node,length -1,width,false);   |
2071 |       |
2072 |      if (hasChildren(node)){ |
2073 |          result += selectSiblings(node,length,width, true);  |
2074 |      } |
2075 |      result += "</div>"; |
2076 |      return result; |
2077 |  } |
2078 |   |
generateTwitter |
|
2079 |  function getHashTag(node){ |
2080 |     if (isMobile) { |
2081 |         return node.data.hashTag; |
2082 |     } |
2083 |     else { |
2084 |         return node.hashTag; |
2085 |     } |
2086 | } |
2087 |  function renderTweetForm(node){ |
2088 |      if (node != homeNode){ |
2089 |          return ""; |
2090 |      } |
2091 |      var url =  'https://PythonLinks.info/'+ getKey(node) |
2092 |     result = ""; |
2093 |     result += '<div class="form-group" style = "padding: 20px;">' |
2094 |      |
2095 |     result += '<form id="messageForm"  action="https://twitter.com/share" method="get">' + |
2096 |      '<label for="comment">Comment on Twitter about:</label><br>' + |
2097 |     '<input type="hidden" name="source" value="tweetbutton"> ' + |
2098 |     '<textarea id="tweet" name= "text"  rows="5"' + |
2099 |     'class="form-control">' + node.title + '\n' + |
2100 |      url  +  |
2101 |     ' via @PythonLinks ' + |
2102 |      getHashTag(node) + ' '  + |
2103 |      '</textarea>' + |
2104 |     '<button type="submit"  formtarget="_blank" class="btn btn-primary">Tweet</button>  ' + |
2105 |      '<span id="charactersRemaining"></span>' + |
2106 |      '</form>' |
2107 |       |
2108 |     result += '</div>' |
2109 |      |
2110 |     return result; |
2111 | } |
2112 | |
2113 | function commentType(node){ |
2114 |     if (getClass(node) == 'Conference'){ |
2115 |         return 'If you are kind enough to say what you thought about this conference,' +  |
2116 |         'your comments will show up here.'; |
2117 |     } |
2118 |         if (getClass(node) == 'Video'){ |
2119 |             return 'If you are kind enough to review this video after you watch it,' + |
2120 |             'your review on twitter will be posted here'; |
2121 |         } |
2122 |     if (getClass(node) == 'Category'){ |
2123 |         return 'If you are kind enough to give me your professional advice on the organization '+ |
2124 |         'of this category, I will either make the changes, or post your ocmment here'; |
2125 |     } |
2126 |     return ''; |
2127 | |
2128 | } |
2129 | |
2130 | function renderTweet(tweetId){ |
2131 |     var result = '<blockquote class="twitter-tweet" data-lang="en"><p lang="en"' + |
2132 |      'dir="ltr">"Data Science Without Borders" is the overall best '+ |
2133 |     '<a href="https://twitter.com/hashtag/Python?src=hash&ref_src=' +tweetId +'">#Python</a> video, beating out "Towards Pandas 1.0" by 181 to 119 Youtube up votes. <a href="https://t.co/EXWwvk3BKG">https://t.co/EXWwvk3BKG</a></p>—' + |
2134 |     ' The Best of 710 Python Conference Videos (@PythonLinks) ' + |
2135 |     '<a href="https://twitter.com/PythonLinks/status/1048163192080404480?ref_src=twsrc%5Etfw">'+ |
2136 |     'October 5, 2018</a></blockquote>' + |
2137 |     '<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>'; |
2138 |      return result; |
2139 | } |
2140 |  /* |
2141 | function notUsed(){ |
2142 |   if ('showHashTag' in node){ |
2143 |       result +='<a href="https://twitter.com/search?q=' +  |
2144 |       node.hashTag + |
2145 |       '">See the comments on twitter.</a>'; |
2146 |   } |
2147 |   else{ |
2148 |       result += "<p>If you would be so kind as to post the "+ |
2149 |       "first comment on this page, I will go ahead and add a link to the unique hashtag "+ |
2150 |       "timeline on Twitter</p>"; |
2151 |   } |
2152 | } |
2153 |   */ |
2154 | |
2155 | var el;                                                     |
2156 | |
2157 | function countCharacters(e) {                                     |
2158 |   var textEntered, countRemaining, counter;           |
2159 |   textEntered = document.getElementById('tweet').value;   |
2160 |   counter = (280 - (textEntered.length)); |
2161 |   countRemaining = document.getElementById('charactersRemaining');  |
2162 |          countRemaining.textContent = "";  |
2163 | |
2164 |     if (counter < 20){ |
2165 |         countRemaining.textContent = counter.toString() +  |
2166 |         ' Characters Remaining'; |
2167 |     } |
2168 | |
2169 | } |
2170 | |
2171 | function postRender(){ |
2172 |     el = document.getElementById('tweet');                    |
2173 | el.addEventListener('keyup', countCharacters, false); |
2174 | countCharacters(); |
2175 | } |
2176 | |
buttonFunctions |
|
2177 |   |
2178 | function editProfile(){ |
2179 |     window.location.href = "/person/" + userId + "/editPrincipal"; |
2180 | } |
2181 | |
2182 | |
2183 | function editProfile(){ |
2184 |     window.location.href = "/person/" + userId + "/editPrincipal"; |
2185 | } |
2186 | |
2187 |  function changeView(){ |
2188 |         showBest = ! showBest; |
2189 | |
2190 |      var label = "Best View"; |
2191 |      if (showBest){ |
2192 |          label = "List View"; |
2193 |      } |
2194 |     |
2195 |     $("#viewButton").html(label); |
2196 |     var result = generateLeadersOrContentCore(homeNode); |
2197 |     $("#bestContent" + '-' + getKey(homeNode)).html(result); |
2198 |          localRebuild();    |
2199 | |
2200 |     } |
renderButtons |
|
2201 | function renderServerOptions(node){ |
2202 |     var url ="https://"; |
2203 |     if (isMobile) { |
2204 |         url += 'desktop.'; |
2205 |         url+=domain; |
2206 |         url += '/'; |
2207 |         url += getKey (node); |
2208 |         return '<a class="dropdown-item" href="' + url + '">Desktop (Beta)</a>'; |
2209 |     } |
2210 |      if (! isMobile) { |
2211 |          url += domain.slice(8); |
2212 |             url += '/'; |
2213 |      url += getKey (node); |
2214 |         return '<a class="dropdown-item"  href="' + url + '">Mobile</a>'; |
2215 |     } |
2216 |      |
2217 | } |
2218 | |
2219 | function lili(arg){ |
2220 |     return '<li>' + arg + '</li>'; |
2221 | } |
2222 | |
2223 |  function renderProfileOption(){ |
2224 |     if (isAuthenticated){ |
2225 |            return lili('<a onclick="editProfile()">Profile</a>'); |
2226 |     } |
2227 |     else  |
2228 |     {return "";} |
2229 | } |
2230 | |
2231 | |
2232 | |
2233 | function renderSubscribeOption(item){ |
2234 |    if ( ! isAuthenticated){ |
2235 |            return lili('<a href="./register/user">Get Updates</a>'); |
2236 |  } |
2237 |  return ''; |
2238 | } |
2239 | |
2240 |    |
2241 | |
2242 |   |
2243 |   |
2244 |   |
2245 |  function renderChatButton(item){ |
2246 |      if (getClass(item)=="Video"){ |
2247 |          return "<button  onclick=\"goToChat('" + |
2248 |       getKey(item)+  |
2249 |        "')\" type=\”submit\” class=\”btn btn-primary\”>Chat</button> " |
2250 |       } |
2251 |       return ""; |
2252 |  } |
2253 |   |
2254 |   |
2255 |   function renderRegisterButton(item){ |
2256 |          return "<button  onclick=goToRegister(\"" + |
2257 |       getKey(item) +  |
2258 |        "\")  type=\”submit\” class=\”btn btn-primary\”>Register</button> " |
2259 |  } |
2260 |   |
2261 |   |
2262 |   function renderLoginOption(item){ |
2263 |          if ( ! isAuthenticated){     |
2264 |              return lili( '<a  href = "./register/web">Login</a> ') |
2265 |          } |
2266 |    else { |
2267 |              return ""; |
2268 |          } |
2269 |  } |
renderSearchButton |
|
2270 |  function renderSearchOption(item){ |
2271 |   return  lili ('<a  class="text-primary" onclick="showSearch()"> Search</a>') |
2272 |  } |
renderthumbs |
|
2273 |   function getVoteDivName(item,divName){ |
2274 |       return  getKey(item) + "-" + divName; |
2275 |   } |
2276 |    |
2277 |    function renderVoteButton(item,thumb,functionName,votes,divName){ |
2278 |      if (getClass(item)!="Video"){ |
2279 |                return ""; |
2280 |      } |
2281 |          return "<button  onclick=" + functionName +"('" + |
2282 |       getKey(item)+  |
2283 |        "')  type=\”submit\” class=\”btn btn-primary\”>" +  |
2284 |         "<span style=\"font-size=3em\"" + |
2285 |        "id =\""+ getVoteDivName(item,divName) + "\">" + |
2286 |        votes + "</span>" + thumb + "</button>" |
2287 |       |
2288 |  } |
2289 | |
2290 |   function renderThumbs(slide){ |
2291 |      if (getClass(slide) != "Video"){ |
2292 |                return ""; |
2293 |   } |
2294 |    |
2295 |   |
2296 |         return   renderVoteButton(slide," 👍 ","upVote", getUpVotes(item),"upVotes") + |
2297 |           renderVoteButton(slide," 👎 ","downVote", getDownVotes (item), "downVotes"); |
2298 |          |
2299 | } |
2300 | |
2301 |           |
2302 |    |
2303 |    |
2304 |   |
threeMenuButtons |
|
2305 |  function visible(){ |
2306 |      if ( (userId == 'lozinski') ||  |
2307 |        (handle == "ChristopherLozinski") ||  |
2308 |        (handle == "JustinMorgan") || |
2309 |        (handle=="WojtekB.") |
2310 |        ){ |
2311 |          return true; |
2312 |      } |
2313 |      else{return false;} |
2314 |  } |
2315 |   |
2316 |   function editMenu(slide){ |
2317 |      if (! visible()) |
2318 |      { |
2319 |          return ''; |
2320 |      } |
2321 |     |
2322 |      var result ="" +    |
2323 |      ' <span class="dropdown">' + |
2324 |       '<button class="btn btn-primary dropdown-toggle"'+ |
2325 |         'type="button"data-toggle="dropdown">Editor'+ |
2326 |        '<span class="caret"></span></button>' |
2327 |      result +=       '<ul class="dropdown-menu dropdown-menu-right">' + |
2328 |     lili("<a href=\"/" + getKey(homeNode) + "/ckedit\">Ck Edit</a> ") + |
2329 |     lili("<a href=\"/" + getKey(homeNode) + "/aceedit\">Ace Edit</a> ") |
2330 |     if (getClass(slide) == 'Category'){ |
2331 |       result +='' +  |
2332 |       lili("<a href=\"/" + getKey(homeNode) + "/addCategory\">Add Category</a> ") + |
2333 |       lili("<a href=\"/" + getKey(homeNode) + "/addConference\">Add Conference</a> ") |
2334 |       } |
2335 |     if (getClass(slide) != 'Vudeo'){ |
2336 |       result +='' +  |
2337 |             lili("<a href=\"/" + getKey(homeNode) + "/addVideo\">Add Video</a> ") |
2338 |     } |
2339 |        if (getClass(slide) == 'Video'){ |
2340 |     result+= lili("<a href=\"/" + getKey(homeNode) + "/starttime\">Edit Start Time</a>") |
2341 |     //lili("<a href=\"/" + getKey(homeNode) + "/addComment\">Add Comment</a> ") |
2342 |     }  |
2343 |            if (getClass(slide) != 'Video'){ |
2344 |     result+= lili("<a href=\"/" + getKey(homeNode) + '/manage">Manage</a>') |
2345 | } |
2346 |     |
2347 |     result += "</ul>  </span> "; |
2348 | return result; |
2349 | } |
2350 | |
2351 | |
2352 |  function manageMenu(slide){ |
2353 |      if (userId != 'lozinski'){ |
2354 |          return ''; |
2355 |      } |
2356 |     |
2357 |      var result ="" +    |
2358 |      ' <span class="dropdown">' + |
2359 |       '<button class="btn btn-primary dropdown-toggle"'+ |
2360 |         'type="button"data-toggle="dropdown">Manage'+ |
2361 |        '<span class="caret"></span></button>' |
2362 |      result +=       '<ul class="dropdown-menu dropdown-menu-right">' |
2363 |     if (getClass(slide) != 'Video'){ |
2364 |       result +='' +  |
2365 |       lili("<a href=\"/" + getKey(homeNode) + '/manage">Manage</a> ') + |
2366 |        lili("<a href=\"/" + getKey(homeNode) + '/manage2">Manage2</a> ') + |
2367 |       lili('<a href=\"' +'/Products/Root/AllJavascript/search">Scripts</a> ') + |
2368 |       lili("<a href=\"/" + getKey(homeNode) + '/addPlayList">Add PlayList</a> ') + |
2369 |       lili("<a href=\"/" + getKey(homeNode) + '/addChannel">Add Channel</a> ') + |
2370 |       lili("<a href=\"/" + getKey(homeNode) + '/addPyVideo">Add PyVideo</a> ') + |
2371 |       lili("<a href=\"/" + getKey(homeNode) + '/editors">Editors</a> ') + |
2372 |       lili("<a href=\"/" + getKey(homeNode) + '/cachedContent">CachedContent</a> ') |
2373 |     } |
2374 |     if (getClass(slide) == 'Video'){  |
2375 |      result+=   lili( " <a href=\"/" + getKey(homeNode) + "/move\">Move</a>") |
2376 |     } |
2377 |     |
2378 |     result += "</ul>  </span> "; |
2379 | return result; |
2380 | } |
2381 | |
2382 | |
2383 |  function userMenu(slide){ |
2384 |      var result ="" +    |
2385 |      ' <span class="dropdown">' + |
2386 |       '<button class="btn btn-primary dropdown-toggle"'+ |
2387 |         'type="button"data-toggle="dropdown">Menu'+ |
2388 |        '<span class="caret"></span></button>' |
2389 |      result +=       '<ul class="dropdown-menu dropdown-menu-right">'; |
2390 |       result +=renderViewOption(slide) |
2391 |      result += renderSearchOption(slide) + |
2392 |      renderSubscribeOption(slide) + |
2393 |      renderServerOptions(slide) + |
2394 |      //renderProfileOption (slide) + |
2395 |      lili ('<a href ="/contact">Contact</a>')+ |
2396 |      renderLoginOption(slide) + |
2397 |      renderSignOutOption(slide) + |
2398 |     "</ul>  </span>" |
2399 | return result; |
2400 | } |
whichview |
|
2401 |   function changeContent(){ |
2402 |     |
2403 |      $('#buttons').html(renderButtons(homeNode)); |
2404 |       loadContent(homeNode); |
2405 |          saveCurrentURL(); |
2406 |  } |
2407 |   |
2408 |  function wilsonView(){ |
2409 |      sortBy='bestWilsonScore'; |
2410 |      changeContent(); |
2411 |  } |
2412 |   |
2413 |  function myScoreView(){ |
2414 |      sortBy = 'bestMyScore'; |
2415 |          changeContent(); |
2416 |  } |
2417 |   |
2418 |  function mostRecentView(){ |
2419 |      sortBy =  'bestMostRecent'; |
2420 |         changeContent(); |
2421 |  } |
2422 |   |
2423 |   function renderViewOption(item){ |
2424 |       if (getClass(item) == "Video"){ |
2425 |           return ""; |
2426 |       } |
2427 | |
2428 |   var showWilson  = ' <a  class="text-primary" onclick="wilsonView()"> Best Score</a>' |
2429 |   var showMyScore = ' <a  class="text-primary" onclick="myScoreView()">Score/Views</a>' |
2430 |   var showRecent  = ' <a  class="text-primary" onclick="recentView()"> Most Recent</a>' |
2431 |    |
2432 |   var result =''; |
2433 |   |
2434 |   if (sortBy != 'bestWilsonScore'){ |
2435 |       result+= lili(showWilson); |
2436 |   } |
2437 |    if (sortBy != 'bestMyScore'){ |
2438 |       result+= lili(showMyScore); |
2439 |   } |
2440 |   if (sortBy != 'bestMostRecent'){ |
2441 |       result+= lili(showRecent); |
2442 |   } |
2443 |   return result; |
2444 |  } |
2445 |   |
news |
|
2446 |  var news = '' //+ |
2447 |  //'<b>Nov 27, 2018</b>  ' + |
2448 |  //'Here are   <a onclick="displaySlideNamed(\'tensorflow-dev-summit-2018\')">' + |
2449 |  //'the best talks from the TensorFlow Dev Summit.</a>' |
2450 |   |
renderContetnDiv |
|
2451 |  function renderContentDiv(slide){ |
2452 |      return "<div id=\"" + |
2453 |      getKey(slide) + "-content" + |
2454 |      '"' + |
2455 |      "></div>"  |
2456 |  } |
2457 |   |
2458 |  function debugIt(){ |
2459 |      var i,j; |
2460 |      var result ="<br>" |
2461 |      for (i=0; i<verticalSlides.length; i++){ |
2462 |          if (verticalIndex == i){ |
2463 |                   for (j=0; j<horizontalSlides.length; j++){ |
2464 |                result += horizontalSlides[j].key; |
2465 |                result += " "; |
2466 |               } |
2467 |          } |
2468 |          else{ |
2469 |              result += verticalSlides[i].key; |
2470 |          } |
2471 |          result += "<br> \n"; |
2472 |      } |
2473 |      return result; |
2474 |  } |
renderMore |
|
2475 |  function renderExtra(){ |
2476 |     return "<br> <br> <br><br><br><br>"; |
2477 | |
2478 | } |
2479 | function renderButtons(slide,index){ |
2480 |          var result = "" + |
2481 |          "<center>" + |
2482 |          editMenu(slide) + |
2483 |          manageMenu(slide); |
2484 |         result +=   "</center> <br> " |
2485 |         return result; |
2486 | } |
2487 | |
2488 | function renderFollowTwitter(){ |
2489 |     return '<a style = " padding: 20px;" target="_blank" ' + |
2490 |     'href="https://twitter.com/intent/follow?screen_name=' + |
2491 |     twitterId+ '">' + |
2492 |     '<img alt="Follow to receive video recommendations"' + |
2493 |     'target= "_blank"' + |
2494 |     'src="https://pythonlinks.info/static/graphics/twitter-logo.png"' +  |
2495 |     '></a> ' |
2496 | } |
2497 | |
2498 |      |
2499 | |
2500 | function renderDescription (slide){ |
2501 |          return  "<p>" + |
2502 |         getDescription(slide) +  |
2503 |            "</p>" |
2504 | } |
2505 | |
renderTitleSubTitle |
|
2506 |   function getSubTitle(slide){ |
2507 |       if (getClass(slide)!='Conference'){ |
2508 |           return ""; |
2509 |       } |
2510 |       var result = ''; |
2511 |       var conferenceName; |
2512 |       var preamble = "Talks at " |
2513 |       if (slide.key == rootName){ |
2514 |           preamble = "at "; |
2515 |       } |
2516 |       if (getClass(slide) == 'Category'){ |
2517 |           return ''; |
2518 |       }    |
2519 |      |
2520 |       conferenceName = getConferenceName(slide);//WASgetSearchedConferenceName(); |
2521 |       if (conferenceName){ |
2522 |          result += '<h3 style ="text-align:center;">' + preamble + conferenceName + '</h3>';   |
2523 |       } |
2524 |       return result; |
2525 |  } |
2526 |   |
2527 |  function renderTitle(slide){ |
2528 |      var children = ''; |
2529 |      var offset = 0; |
2530 |      var siblings =  getSiblings(slide);  |
2531 |      if (siblings.length > 1){ |
2532 |         offset = siblings.indexOf(slide); |
2533 |         children = "  (" + (offset + 1) + "/" +  |
2534 |                siblings.length + ')' |
2535 |       } |
2536 |      var result = ''; |
2537 |      |
2538 |      result +=  '<h1  style ="text-align:center;">' +  |
2539 |                    getTitle(slide) + |
2540 |                    children + |
2541 |                   "</h1>" |
2542 |       return result; |
2543 |  } |
2544 |            |
socialMediaLinks |
|
2545 | // FUNCTION TO GENERATE SOCIAL MEDIA LINKS |
2546 | |
2547 | function socialMediaLinks(slide){ |
2548 | |
2549 | |
2550 | var title = getTitle(slide); |
2551 | var encodedTitle = encodeURI(title); |
2552 | var description = getDescription(slide); |
2553 | var encodedDescription = encodeURI(description); |
2554 | var theURL ="https://PythonLinks.info"+ '/' + getKey(slide); |
2555 | var titlePlusDescription = title + ' ' + description; |
2556 | var encodedTitlePlusDescription = encodeURI(title + ' ' + description); |
2557 | var result =""; |
2558 | |
2559 | result +='<center><div>' + |
2560 | //FIRST THE EMAIL LINK |
2561 |  '<a href="mailto:?subject='+ encodedTitle+ '&body=' +  |
2562 |  encodeURI (description + ' ' + theURL) +'"' +  |
2563 | 'class="share-btn email" title="Email">' + |
2564 | '<i class="fa fa-envelope"></i></a>' |
2565 | |
2566 | |
2567 | |
2568 | //NOW THE FACEOOK LINK |
2569 | result += '<a href="https://www.facebook.com/sharer/sharer.php?u=' + |
2570 | theURL + '&t=' + encodedTitle +'" class="share-btn facebook"' + |
2571 | 'title="Facebook">' + |
2572 | '<i class="fa fa-facebook"></i></a>'; |
2573 | |
2574 | //NOW TWITTER |
2575 | //result += '<a href="https://twitter.com/share?text=' + |
2576 | //encodedDescription + '&url=' + theURL +';via=PythonLinks' +   |
2577 | //'" class="share-btn twitter" title="Twitter">' + |
2578 | //'<i class="fa fa-twitter"></i></a>' |
2579 | |
2580 | |
2581 | //AND REDDIT |
2582 | result += '<a href="http://reddit.com/submit?url=' + |
2583 | theURL + '&title=' + encodedDescription + '&kind=link" class="share-btn reddit" title="reddit">'+ |
2584 | '<i class="fa fa-reddit"></i></a>'; |
2585 | |
2586 | //NOW FOR LINKED IN  |
2587 | result += '<a href="https://www.linkedin.com/shareArticle?url=' + |
2588 | theURL + '&title=' + encodedTitlePlusDescription + |
2589 | encodedTitlePlusDescription +  |
2590 | '" class="share-btn linkedin" title="LinkedIn">' + |
2591 | '<i class="fa fa-linkedin"></i></a>'; |
2592 | |
2593 | |
2594 | result += '</div></center>'; |
2595 | |
2596 | return result; |
2597 | } |
generateLeadersCore |
|
2598 |   |
2599 | function generateLeadersOrContentCore(slide){ |
2600 |     if (showBest){ |
2601 |         return generateLeaders(slide); |
2602 |     } |
2603 |     else{ |
2604 |         return generateContent(slide); |
2605 |     } |
2606 | } |
generateContents |
|
2607 |    |
2608 |      function generateContent(rootNode){ |
2609 |       if ((getClass(rootNode) === 'Video')){ |
2610 |              return ""; |
2611 |          } |
2612 |          result ='<div style="margin:auto; max-width: 100vh;">'; |
2613 |         |
2614 |         result += generateContentCore(rootNode) |
2615 |         result +='</div>'; |
2616 |         return result; |
2617 |      }         |
2618 |       |
2619 |       |
2620 |       |
2621 | function tableHead(subTitle){ |
2622 |         return    "<tr>" + |
2623 |         TD (' <a href = "https://www.evanmiller.org/how-not-to-sort-by-average-rating.html">Score</a>')+ |
2624 |                   |
2625 |                   TD (' Votes ') + |
2626 |                   TD(subTitle ) + |
2627 |                   "</tr>"; |
2628 | }      |
2629 | function videosInThisFolder(node){ |
2630 |     var videos=[]; |
2631 |     var video; |
2632 |     var children = node.children; |
2633 |     if (! hasChildren(node)){ |
2634 |         return videos; |
2635 |     } |
2636 |     var arrayLength = node.children.length; |
2637 |     for (var i = 0; i < arrayLength; i++) { |
2638 |         video=children[i]; |
2639 |         if (getClass(video) =='Video'){ |
2640 |          |
2641 |         video.data.ratio =  score (video);         |
2642 |         videos.push(video); |
2643 |         } |
2644 |     } |
2645 | return videos; |
2646 | } |
2647 | |
2648 | function childCategoriesRow (rootNode){ |
2649 |       var text = '<tr><td colspan="4">'; |
2650 |            text += renderChildCategories(rootNode); |
2651 |            text += "</td></tr>" |
2652 |       return text; |
2653 | } |
2654 |             |
2655 |             |
2656 |          |
2657 |     function generateContentCore(rootNode){ |
2658 | |
2659 |      |
2660 |           var text=''; |
2661 |           var i; |
2662 |           var sortedArray = videosInThisFolder(rootNode); |
2663 |           var sortedArrayLength = sortedArray.length; |
2664 |           if (sortedArrayLength === 0){ |
2665 |               return renderChildCategories(rootNode); |
2666 |           } |
2667 |            |
2668 |           text += renderChildCategories(rootNode); |
2669 |           text += "<h3>Videos in this Folder</h3>"; |
2670 |           text +='<table class="table table-striped" style = "padding:20px;">'; |
2671 |           text += "<thead>";    |
2672 |           |
2673 |           text += tableHead("Talk Title"); |
2674 |           text += "</thead>"; |
2675 |           text += "<tbody>";           |
2676 |           for (i = sortedArrayLength-1; i >= 0; i--) {  |
2677 |                   item=sortedArray[i]; |
2678 |                   text += '<tr>' |
2679 |                   text+= '<td align="left"> ' +  |
2680 |                   item.data.ratio.toFixed(0) + |
2681 |                   '% </td>'; |
2682 |                   |
2683 |                   votes = ''; |
2684 |                   if (getUpVotes(item) >0){ |
2685 |                      votes += getUpVotes(item) + '👍 '; |
2686 |                   } |
2687 |                   if (getDownVotes(item) >0){ |
2688 |                      votes+= '<br>' + getDownVotes(item) + '👎 '; |
2689 |                   } |
2690 |                   text+= TD(' ' + votes + ' '); |
2691 |                    |
2692 |                   text+=TD(' ' + generateLink(item)); |
2693 |                    |
2694 |                |
2695 |                   text +='</tr>'  |
2696 |                   } |
2697 |          |
2698 |             text += "</tbody>";  |
2699 |            text +='</table>'      |
2700 |             //text += '</div>';   //TABLE-RESPONSIVE |
2701 | |
2702 | |
2703 |            return text; |
2704 |            } |
2705 |       |
2706 | |
2707 |      |
generateLeaders |
|
2708 |   |
2709 |      function generateLeaders(rootNode){ |
2710 |       if ((getClass(rootNode) === 'Video')){ |
2711 |              return ""; |
2712 |          } |
2713 |      |
2714 |           |
2715 |          // FOR THE LIST OF CHANNELS DO NOT SHOW THE BEST VIDEOS |
2716 |          if (getKey(rootNode) == 'conferences-and-channels'){ |
2717 |                 return generateContent(rootNode); |
2718 |          } |
2719 |            |
2720 |           if (getKey(rootNode) == 'devops'){ |
2721 |                 return generateContent(rootNode); |
2722 |          } |
2723 |      |
2724 |        if (getKey(rootNode) == 'data-science-software'){ |
2725 |                 return generateContent(rootNode); |
2726 |          } |
2727 |      |
2728 |           |
2729 |          var result =""; |
2730 |          var text2 =  generateLeadersCore(rootNode) |
2731 |          result +=  "<center>" +  text2 + "</center> <br>"; |
2732 |        |
2733 |          return result; |
2734 |      } |
2735 |       |
2736 |       |
2737 |               //FIRST GENERATES A SORTED LIST OF ITEMS IN THIS BRANCH OF THE TREE |
2738 |         //AND THEN PRINTS OUT THE SORTED HISTORY  |
2739 |     function generateLeadersCore(rootNode){ |
2740 |           var text=''; |
2741 |           var i; |
2742 |           var subTitle = " Best Videos Overall "; |
2743 |           var sortedArray = generateTop10(rootNode); |
2744 |         |
2745 |           var sortedArrayLength = sortedArray.length; |
2746 |           if (sortedArrayLength === 0 ){ |
2747 |               return ""; |
2748 |               } |
2749 |           |
2750 |         text +='<table class="table table-striped" style = "padding:20px;">'; |
2751 |                  |
2752 |           text += "<tr>" + |
2753 |                 TD (' <a href = "https://www.evanmiller.org/how-not-to-sort-by-average-rating.html">Score</a>')+ |
2754 | |
2755 |                   TD (' Votes ') |
2756 |                   if (getKey(rootNode) != rootName){ |
2757 |                       subTitle = ' Best Videos on ' + getTitle(rootNode); |
2758 |                   } |
2759 |                    |
2760 |             text+=  TD( sortedArrayLength.toString() + subTitle ) + |
2761 |                |
2762 |                    |
2763 |                   "</tr>"; |
2764 |           for (i = sortedArrayLength-1; i >= 0; i--) {  |
2765 |                   item=sortedArray[i]; |
2766 |                   text += '<tr>' |
2767 |                   text+= '<td align="left"> ' +  |
2768 |                   item.data.ratio.toFixed(0) + |
2769 |                   '% </td>'; |
2770 |                   |
2771 |                   votes = ''; |
2772 |                   if (getUpVotes(item) >0){ |
2773 |                      votes += getUpVotes(item) + '👍 '; |
2774 |                   } |
2775 |                   if (getDownVotes(item) >0){ |
2776 |                      votes+= '<br>' + getDownVotes(item) + '👎 '; |
2777 |                   } |
2778 |                   text+= TD(' ' + votes + ' '); |
2779 |                    |
2780 |                   text+=TD(' ' + generateLink(item)); |
2781 |                    |
2782 |                |
2783 |                   text +='</tr>'  |
2784 |                   } |
2785 |           |
2786 |            text +='</table>'      |
2787 |           |
2788 | |
2789 |            return text; |
2790 |            } |
2791 |       |
2792 | |
2793 |      |
generateTop10Array |
|
2794 |   |
2795 |     function generateTop10(rootNode){ |
2796 |         if ( (getClass(rootNode) == 'Category')  |
2797 |         && |
2798 |             (! hasChildren(rootNode)) |
2799 |         ){ |
2800 |             return ""; |
2801 |         } |
2802 |         if (rootNode.data.hasOwnProperty('best')){ |
2803 |               return rootNode.data.best; |
2804 |           } |
2805 |          var item; |
2806 |           var i; |
2807 |           var rootNodeChildren=rootNode.children; |
2808 |           |
2809 |           //IF IT IS A CONFERENCE, Just show the  |
2810 |           //Conference Videos |
2811 |           if (getClass(rootNode)=='Conference'){ |
2812 |                var allVideos = []; |
2813 |               getConferenceVideos(getKey(rootNode),root,allVideos); |
2814 |             rootNodeChildren =  allVideos; |
2815 |           } |
2816 |           sortedTree=buckets.BSTree(compare); |
2817 |           for (k=0;k<rootNodeChildren.length;k++){ |
2818 |               var aChild = rootNodeChildren[k]; |
2819 |               sortNodes(aChild); |
2820 |           } |
2821 |                |
2822 |           var sortedArray=sortedTree.toArray(); |
2823 |            |
2824 |           //FOR CONFERENCES SHOW ALL THE TALKS, SORTED. |
2825 |           if (getClass (rootNode)== 'Conference'){ |
2826 |               return sortedArray; |
2827 |           } |
2828 |            |
2829 |           //OTHERWISE RETURN THE FIRST 10 ITEMS |
2830 |           var sortedArrayLength=sortedArray.length; |
2831 |           var lowerBound=sortedArrayLength-10; |
2832 |           if (lowerBound<0) lowerBound=0; |
2833 |        |
2834 |            |
2835 |           var shortArray = sortedArray.slice(lowerBound); |
2836 |           rootNode.data.best = shortArray;   |
2837 |           return shortArray; |
2838 |      } |
2839 |   |
2840 |       |
2841 |    |
2842 |     |
getConferenceVideos |
|
2843 |  function getConferenceVideos(conferenceName,aNode,allVideos){ |
2844 |          var i; |
2845 |          var thisNode; |
2846 |          var children; |
2847 |           if ((getClass(aNode) =="Video")&& |
2848 |              (getConferenceKey(aNode)==conferenceName)){ |
2849 |              allVideos.push(aNode); |
2850 |          } |
2851 |          //COULD RETURN IF IT IS A VIDEO. |
2852 |           |
2853 |          if (! hasChildren(aNode)){ |
2854 |              return; |
2855 |          } |
2856 |          children=aNode.children; |
2857 |            |
2858 |           if (children && children.length){ |
2859 |              for (i in children){ |
2860 |                 thisNode=children[i]; |
2861 |                 getConferenceVideos(conferenceName,thisNode,allVideos); |
2862 |              } |
2863 |           } |
2864 |      } |
historyScripts |
|
2865 | function generateLink(item){ |
2866 |     return "<a onClick=\"displaySlideNamed('" +  |
2867 |     getKey(item) +  |
2868 |     "')\">"+  |
2869 |     getTitle(item)+"</a>"; |
2870 | } |
2871 | |
2872 | function openWindow (key){ |
2873 |     window.open("/" + key); |
2874 | } |
2875 | |
2876 |    //TO GENERATE HISTORY HAVE TO SORT ITEMS BY EDIT DATE |
2877 | //THIS COMPARE FUNCTION DOES THAT |
2878 | function compareLOG(a,b){ |
2879 | |
2880 |     var result = compare2(a,b); |
2881 |     var aRatio = a.data.ratio;  |
2882 |     var bRatio = b.data.ratio; |
2883 |     return result; |
2884 | } |
2885 | function compare(a, b) { |
2886 |   var aRatio = a.data.ratio;  |
2887 |   var bRatio = b.data.ratio; |
2888 |      |
2889 |  if (aRatio < bRatio) { |
2890 |     return -1; |
2891 |  } if (aRatio > bRatio) { |
2892 |     return 1; |
2893 |  } |
2894 |   //SAME Ratio, CHECK Totals |
2895 |  if (Number(getUpVotes(a)) < Number(getUpVotes(b))) { |
2896 |     return -1; |
2897 |  } if (Number(getUpVotes(a)) > Number(getUpVotes(b))) { |
2898 |     return 1; |
2899 |  } |
2900 |   |
2901 |  //SAME Ratio, same upVotes, CHECK URLS |
2902 |  if (getKey(a) < getKey(b)) { |
2903 |     return 1; |
2904 |  } if (getKey(a) > getKey(b)) { |
2905 |     return -1; |
2906 |  } |
2907 |   |
2908 |  // a must be equal to b |
2909 |   |
2910 |  return 0;  |
2911 | } |
2912 | |
2913 | var sortedTree; |
2914 | |
2915 | function TD(text){ |
2916 |     return '<td>' + text + '</td>'; |
2917 | } |
2918 | |
2919 | |
2920 | //THIS FUNCTION ACTUALLY CREATES A BINARY TREE OF NODES SORTED BY EDIT DATE |
2921 | //USED TO GENERATE HISTORY |
2922 | function sortNodes(aNode){ |
2923 |       |
2924 |          //IF IT IS A VIDEO |
2925 |          if (getClass(aNode) =="Video" ){ |
2926 |              aNode.data.ratio = score(aNode); |
2927 |              sortedTree.add(aNode); |
2928 |              return; |
2929 |          } |
2930 |          //NOT A VIDEO?  CARRY ON |
2931 |         var i; |
2932 |          //SETS THE RATIO |
2933 |          var children=aNode.children; |
2934 |            |
2935 |           if (children && children.length){ |
2936 |              for (i in children){ |
2937 |                 var thisNode=children[i]; |
2938 |                 sortNodes(thisNode); |
2939 |              } |
2940 |           } |
2941 |                |
2942 |      } |
score |
|
2943 | //THIS IS THE WILSON SCORE |
2944 |  function  aScore (positiveScore, total) { |
2945 | |
2946 |     if (total === 0) { |
2947 |         return { |
2948 |             left: 0, |
2949 |             right: 0 |
2950 |         }; |
2951 |     } |
2952 | |
2953 |     // phat is the proportion of successes |
2954 |     // in a Bernoulli trial process |
2955 |     const phat = positiveScore / total; |
2956 | |
2957 |     // z is 1-alpha/2 percentile of a standard |
2958 |     // normal distribution for error alpha=5% |
2959 |     const z = 1.96; |
2960 | |
2961 |     // implement the algorithm |
2962 |     // (http://goo.gl/kgmV3g) |
2963 |     const a = phat + z * z / (2 * total); |
2964 |     const b = z * Math.sqrt((phat * (1 - phat) + z * z / (4 * total)) / total); |
2965 |     const c = 1 + z * z / total; |
2966 | |
2967 |     return { |
2968 |         left: (a - b) / c, |
2969 |         right: (a + b) / c |
2970 |     }; |
2971 | } |
2972 | |
2973 | |
2974 | function score (aNode){ |
2975 |       var upVotes, downVotes, total,wilsonScore; |
2976 |       upVotes=Number(getUpVotes(aNode)); |
2977 |       downVotes= Number(getDownVotes(aNode)); |
2978 |       totalVotes = upVotes + downVotes; |
2979 |       |
2980 |       wilson =   aScore (upVotes, totalVotes); |
2981 |       return wilson.left* 100; |
2982 |        |
2983 | } |
renderChildCategories |
|
2984 |  function renderChildLink(item){ |
2985 |     return "<a onClick=\"slideDownTo('" +  |
2986 |     getKey(item) +  |
2987 |     "')\">"+  |
2988 |     getTitle(item)+"</a>" + |
2989 |     ' (' + getBranchSize(item) + ')'; |
2990 | } |
2991 | |
2992 | function slideDownTo(key){ |
2993 |     var nextNode=tree.getNodeByKey(key); |
2994 |     var index = homeNode.children.indexOf(nextNode); |
2995 |     homeNode.previousChildIndex=index; |
2996 |     setSlides(homeNode); |
2997 |     reload(); |
2998 |     $.fn.fullpage.moveSectionDown(); |
2999 | |
3000 | }  |
3001 | |
3002 | |
3003 | function displayChildCategories (slide){ |
3004 |     var child; |
3005 |     var  children = slide.children; |
3006 |     if ((! children) || (children.length===0)){ |
3007 |         return ""; |
3008 |     } |
3009 |     var result = "<h3>Child Categories</h3><br>"; |
3010 |     if (getKey(slide) == 'conferences-and-channels'){ |
3011 |         result = "<h3>Conferences Indexed</h3><br>"; |
3012 |     } |
3013 |      |
3014 |     for (var i in slide.children) { |
3015 |         child = slide.children[i]; |
3016 |          if (getClass(child) != "Video"){ |
3017 |             result += renderChildLink(child) + "<br><br>"; |
3018 |        } |
3019 |          |
3020 |     } |
3021 |     //result += "</div>"; |
3022 |     return result; |
3023 |      |
3024 | } |
3025 | |
3026 | |
3027 | //IF ANY CHILD IS A CONFERENCE OR CATEGORY |
3028 | //DISPLAY THE LIST |
3029 | function renderChildCategories(slide){ |
3030 |     var child; |
3031 |     if (slide.children === null){ |
3032 |         return ""; |
3033 |     } |
3034 |         if (slide.children.length === 0){ |
3035 |         return ""; |
3036 |     } |
3037 |     for (var i in slide.children) { |
3038 |          child = slide.children[i]; |
3039 |        if (getClass(child) != "Video"){ |
3040 |            return  displayChildCategories(slide); |
3041 |        } |
3042 |     } |
3043 |      return "";   |
3044 | } |
3045 | |
renderSlide |
|
3046 |   var showBest = true; |
3047 |   |
3048 | |
3049 | |
3050 | function generateLeadersOrContent(slide){ |
3051 |      return '<div  id = "bestContent' +  |
3052 |      '-' + getKey(slide) + '" >'+ |
3053 |           generateLeadersOrContentCore(slide) + |
3054 |       "</div>"; |
3055 | } |
3056 |  var isMobile = true; |
3057 |  function renderSlide(slide,index){  |
3058 |          var result = "" |
3059 |            |
3060 |           result += template( |
3061 |               {'showSearch':showSearch, |
3062 |                'node':slide, |
3063 |                'upVote':upVote, |
3064 |                'downVote': downVote, |
3065 |                'getClass': getClass, |
3066 |                'renderServerOptions': renderServerOptions, |
3067 |                'isAuthenticated': isAuthenticated,  |
3068 |                'twitterLinkFront': twitterLinkFront, |
3069 |                'twitterLinkBack': twitterLinkBack,  |
3070 |                'twitterId': twitterId |
3071 |           }); |
3072 |    |
3073 |         result += addArrows(slide); |
3074 | |
3075 |         result +='<div style = "padding-left: 20px">'; |
3076 | |
3077 |              result +=  breadcrumbs(slide,index) |
3078 |           |
3079 |          result += renderTitle(slide) + |
3080 |          "<br>" //+ |
3081 |         getSubTitle(slide) |
3082 |      |
3083 |        |
3084 |         if ((getClass(slide) == 'Video')){ |
3085 |              |
3086 |             var conference = getConference(slide); |
3087 |             result += '<h5 class="text-primary" style = "margin-left:50%">-'+  |
3088 |             '<a onClick="displaySlideNamed(' + "'" + getConferenceKey(slide) + "')" +'">'+  |
3089 |             getTitle(conference) +'</a></h5>'; |
3090 |         } |
3091 | |
3092 |          |
3093 |          if (isMobile){ |
3094 |            result+= "<center>"; |
3095 |          } |
3096 |            result +=renderDescription (slide); |
3097 |         if (isMobile){ |
3098 | |
3099 |             result+= "</center>"; |
3100 |         } |
3101 |       result += '<div id="buttons">'; |
3102 |             result += renderButtons(slide,index); |
3103 |        result +='</div>'; |
3104 |         result += renderContentDiv(slide) |
3105 |       |
3106 |       |
3107 |     result += socialMediaLinks(slide); |
3108 |     result += renderExtra();   |
3109 |     result += '</div>'; |
3110 |     return result;  |
3111 |     } |
rootname |
|
3112 |  var rootName='';   |
3113 |  var mobileJson =''; |
3114 |  var deskTopJson =''; |
3115 |  var domain= window.location.hostname.toLowerCase(); |
3116 |  var searchURL = "/search"; |
3117 |  var contactURL = "/contact"; |
3118 |  var twitterId ="PythonLinks"; |
3119 |   |
3120 |  if (domain=='pythonlinks.info'){ |
3121 |     mobileJson='https://json.PythonLinks.info/python/json'; |
3122 |     rootName ='python'; |
3123 |     twitterId ="PythonLinks"; |
3124 | } |
3125 | |
3126 | else if (domain=='desktop.pythonlinks.info'){ |
3127 |     deskTopJson= 'https://json.PythonLinks.info/python/tree.json'; |
3128 |     rootName ='python'; |
3129 |     twitterId ="PythonLinks"; |
3130 | } |
3131 | |
3132 | else if (domain=='climatevideos.info'){ |
3133 |     mobileJson='https://json.PythonLinks.info/climate-change/json'; |
3134 |     rootName='climate-change'; |
3135 |     contactURL = "/contact2"; |
3136 |     searchURL = "/search2"; |
3137 |      twitterId ="ChangeClimate"; |
3138 | } |
3139 | |
3140 | |
3141 | else if (domain=='desktop.climatevideos.info'){ |
3142 |     deskTopJson='https://json.PythonLinks.info/climate-change/tree.json'; |
3143 |     rootName='climate-change'; |
3144 |     contactURL = "/contact2"; |
3145 |     searchURL = "/search2"; |
3146 |      twitterId ="ChangeClimate"; |
3147 | } |
3148 | |
3149 | //AND NOW FOR GoLang |
3150 | else if (domain=='cloud-native.pl'){ |
3151 |     mobileJson='https://json.PythonLinks.info/cloud-native/json'; |
3152 |     rootName='cloud-native'; |
3153 |     contactURL = "/golang-contact"; |
3154 |     searchURL = "/golang-search"; |
3155 |     twitterId ="golangwarsaw1"; |
3156 | } |
3157 | |
3158 | |
3159 | else if (domain=='desktop.cloud-native.pl'){ |
3160 |     deskTopJson='https://json.PythonLinks.info/cloud-native/tree.json'; |
3161 |     rootName='cloud-native'; |
3162 |     contactURL = "/golang-contact"; |
3163 |     searchURL = "/golang-search"; |
3164 |     twitterId ="golangwarsaw1 "; |
3165 | } |
3166 | |
3167 | |
3168 | else if (domain=='dev.pythonlinks.info'){ |
3169 |     rootName ='python'; |
3170 |     mobileJson='/python/json'; |
3171 |     deskTopJson='/python/tree.json'; |
3172 |     var twitterId ="PythonLinks";    |
3173 |     //rootName ='climate-change'; |
3174 |     //mobileJson='/climate-change/json'; |
3175 |     //deskTopJson='/climate-change/tree.json'; |
3176 |     //searchURL = "/search2"; |
3177 |     //contactURL = "/contact2"; |
3178 | |
3179 | } |
3180 |   |
3181 | |
callbackVisit |
|
3182 |    |
3183 | /** Call fn(node) for all child nodes.<br> |
3184 |  * Stop iteration, if fn() returns false. Skip current branch, if fn() returns "skip".<br> |
3185 |  * Return false if iteration was stopped. |
3186 |  * |
3187 |  * @param {function} fn the callback function. |
3188 |  *     Return false to stop iteration, return "skip" to skip this node and |
3189 |  *     its children only. |
3190 |  * @param {boolean} [includeSelf=false] |
3191 |  * @returns {boolean} |
3192 |  */ |
3193 |   |
3194 | |
3195 |  function callbackVisit(item,fn, includeSelf) { |
3196 | var i,  |
3197 |     l, |
3198 | res = true, |
3199 | children = item.children; |
3200 | if( includeSelf === true ) { |
3201 | res = fn(item); |
3202 | if( res === false || res === "skip" ){ |
3203 | return res; |
3204 | } |
3205 | } |
3206 | if(children&&(children.length>0)){ |
3207 |     callbackCount++; |
3208 |   |
3209 |     aFunction = function(){ |
3210 |     for(i=0, l=children.length; i<l; i++){ |
3211 |       callbackVisit(children[i],fn, true); |
3212 |     } |
3213 |     callbackCount--; |
3214 |     if (callbackCount===0){ |
3215 |                reSearch(fn); |
3216 |                } |
3217 |     };    |
3218 |     setTimeout(aFunction, 1); |
3219 | } |
3220 | |
3221 | |
3222 |   |
3223 |  } |
3224 | |
3225 | |
3226 |   |
3227 |          |
3228 |          |
3229 | function callVisit(item,fn) { |
3230 | return callbackVisit(item.rootNode,fn, false); |
3231 | } |
childrenFunctions |
|
3232 | |
3233 | function getSiblings (item){ |
3234 |     if (isRoot(item)){ |
3235 |         return [item]; |
3236 |     } |
3237 |     return item.parent.children; |
3238 | } |
3239 |      |
parent-functions |
|
3240 |  function pageTitle(node){ |
3241 |     var nodeParents= parents(node); |
3242 |     var arrayLength = nodeParents.length; |
3243 |     var result =[]; |
3244 |     for (var i = 0; i < arrayLength; i++) { |
3245 |        result.push (getTitle(nodeParents[i])); |
3246 |     } |
3247 |      return result.join(' -> '); |
3248 |      |
3249 | } |
3250 | |
3251 | //Starting with parent |
3252 | function reversedParents(node){ |
3253 |        var result=[]; |
3254 |      while (true){ |
3255 |          result.push(node); |
3256 |          if (isRoot(node)){ |
3257 |              return result; |
3258 |          } |
3259 |          node=node.parent; |
3260 |      } |
3261 | } |
3262 | |
3263 | //Starting with first ancenstor |
3264 | function parents(node){ |
3265 |     return reversedParents(node).reverse(); |
3266 | } |
pushpopstate |
|
3267 | function addSortBy(){ |
3268 |     return '?sortBy=' + sortBy; |
3269 | } |
3270 | function saveCurrentURL(){ |
3271 |     |
3272 |     var domain= window.location.hostname; |
3273 |     var location=getKey(homeNode); |
3274 | |
3275 |     var url="https://" + domain + "/" + location + addSortBy(); |
3276 |      |
3277 | |
3278 |     var title=getTitle(homeNode); |
3279 |     var data={key:getKey(homeNode)}; |
3280 |   |
3281 |   |
3282 | history.pushState(data, title, url); |
3283 |      |
3284 | } |
3285 | |
3286 | function saveCurrentURLAndSearch(){ |
3287 |     |
3288 |     var domain= window.location.hostname; |
3289 |     var location=homeNode.key; |
3290 |     var search=window.location.search; |
3291 | |
3292 |     var url="https://" + domain + "/" + location; |
3293 |     if (search){ |
3294 |         url+= search; |
3295 |     } |
3296 |     var title=homeNode.title; |
3297 |     var data={key:homeNode.key}; |
3298 |   |
3299 |   |
3300 | history.pushState(data, title, url); |
3301 |      |
3302 | } |
regexp |
|
3303 |    |
3304 | |
3305 | //FUNCTION TO SPLIT A SEARCH STRING INTO W LIST OF WORDS,  |
3306 | // AND THEN CREATRE A LIST OF REGEXP |
3307 | // FROM IT.  This is needed to implement "SearchTermm1" and "SearchTerm2" |
3308 | |
3309 | |
3310 |  function _escapeRegex(str){ |
3311 | /*jshint regexdash:true */ |
3312 | return (str + "").replace(/([.?*+\^\$\[\]\\(){}|-])/g, "\\$1"); |
3313 | } |
3314 | |
3315 | |
3316 | //FUNCTION TO SPLIT A SEARCH STRING INTO W LIST OF WORDS,  |
3317 | // AND THEN CREATRE A LIST OF REGEXP |
3318 | // FROM IT.  This is needed to implement "SearchTermm1" and "SearchTerm2" |
3319 | |
3320 | function getRegxpArray(match) { |
3321 |                 if (match=="all"){ |
3322 |                     return [new RegExp(".")]; |
3323 |                 } |
3324 |                 if (match=="All"){ |
3325 |                     return [new RegExp(".")]; |
3326 |                 } |
3327 |         var regexpArray=[];  |
3328 |         var i; |
3329 |         var input; |
3330 |         var k=0; |
3331 |         var subStrings=match.split(/\s+/i); |
3332 |         for (i in subStrings){ |
3333 |             if (subStrings[i]!==""){ |
3334 |                input= _escapeRegex(subStrings[i]); |
3335 |                regexpArray[k]=new RegExp(input, "i"); |
3336 |                k++; |
3337 |             } |
3338 |         } |
3339 |         return regexpArray; |
3340 | } |
3341 | |
resizeText |
|
3342 |  function resizeText(multiplier) { |
3343 |   if (document.body.style.fontSize === "") { |
3344 |     document.body.style.fontSize = "2.0em"; |
3345 |   } |
3346 |   document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (multiplier * 0.2) + "em"; |
3347 |   localRebuild(); |
3348 |       |
3349 |  } |
3350 | |
scaleVideos |
|
3351 | function resizeVideos( arg1, arg2, containerQuery){ |
3352 |   //should be "body" |
3353 | // Find all YouTube videos |
3354 | var $allVideos = $("iframe[src^='https://www.youtube.com']"), |
3355 | |
3356 |     // The element that is fluid width |
3357 |     $fluidEl = $(containerQuery); |
3358 | |
3359 | // Figure out and save aspect ratio for each video |
3360 | $allVideos.each(function() { |
3361 | |
3362 |   $(this) |
3363 |     .data('aspectRatio', this.height / this.width) |
3364 |     .data('width', this.width) |
3365 | |
3366 |     // and remove the hard coded width/height |
3367 |     .removeAttr('height') |
3368 |     .removeAttr('width'); |
3369 | |
3370 | }); |
3371 | |
3372 | function resize () { |
3373 | |
3374 |   var newWidth = $fluidEl.width(); |
3375 |   if (newWidth > 800){ |
3376 |       newWidth = 0.8 * newWidth; |
3377 |   }  |
3378 |   // Resize all videos according to their own aspect ratio |
3379 |   $allVideos.each(function() { |
3380 | |
3381 |     var $el = $(this); |
3382 |     $el |
3383 |       .width(newWidth) |
3384 |       .height(newWidth * $el.data('aspectRatio')); |
3385 | |
3386 |   }); |
3387 |   localRebuild(); |
3388 |   |
3389 | // Kick off one resize to fix all videos on page load |
3390 | } |
3391 | resize(); |
3392 | } |
setChildINdex |
|
3393 |  //onSLideLeave |
3394 | function setChildIndex(){ |
3395 |         if (homeNode.parent!== null) |
3396 |            homeNode.parent.previousChildIndex = getSiblings(homeNode).indexOf(homeNode); |
3397 | } |
setTitle |
|
3398 |  function setTitle(node){ |
3399 |      if (node.data.class == 'Video'){ |
3400 |          node.title =  score(node).toFixed(0) + '% '  |
3401 |          + node.data.upVotes + '👍 ' +  |
3402 |          node.data.downVotes + '👎 '+ |
3403 |          node.title; |
3404 |      } |
3405 |      return true; |
3406 |  } |
showRedirect |
|
3407 |  function showRedirect(node){ |
3408 |      if ((isMobile && (node==landingPage))) { |
3409 |            var url = "https://" + |
3410 |            "desktop." + domain + '/' + getKey(node); |
3411 |            return '<center> <a href="' + url + |
3412 |            '">Desktop Site (Beta)</a></center>'; |
3413 |      } |
3414 |         return ""; |
3415 |  } |
signout |
|
3416 |  function renderSignOutOption(){ |
3417 |     if (isAuthenticated){ |
3418 |            return lili( '<a class="text-primary" onclick="signOut()">Sign Out</a>'); |
3419 |     } |
3420 |     else  |
3421 |     {return "";} |
3422 | } |
3423 | |
3424 | function signOut(){ |
3425 |     window.location.href = "/" + getKey(homeNode) + "/logout2"; |
3426 | } |
vote |
|
3427 | function registerVoter(){ |
3428 |      window.location.href="/" + homeNode.key + "/register/voter"; |
3429 | } |
3430 | |
3431 | |
3432 | function recordVotes(responseText,itemName){ |
3433 |      |
3434 |     var result = responseText.split (" , "); |
3435 |      document.getElementById(itemName + "-" + "upVotes").innerHTML = result [0];  |
3436 |       document.getElementById(itemName + "-" + "downVotes").innerHTML = result [1]; |
3437 | } |
3438 | |
3439 | function upVote(){ |
3440 |     var itemName = getKey(homeNode); |
3441 | |
3442 |     if (isAuthenticated){ |
3443 |        var xhttp = new XMLHttpRequest(); |
3444 |        xhttp.onreadystatechange = function() { |
3445 |            if (this.readyState == 4 && this.status == 200) { |
3446 |                recordVotes(this.responseText,itemName); |
3447 |            } |
3448 |        }; |
3449 |        var url = "/" + homeNode.key + "/upVote"; |
3450 |        xhttp.open("GET", url, true); |
3451 |        xhttp.send(); |
3452 |        return; |
3453 |        } |
3454 |     registerVoter(); |
3455 | } |
3456 | |
3457 | function downVote(){ |
3458 |       var itemName = getKey(homeNode); |
3459 | |
3460 |     if (isAuthenticated){ |
3461 |         var xhttp = new XMLHttpRequest(); |
3462 |         xhttp.onreadystatechange = function() { |
3463 |            if (this.readyState == 4 && this.status == 200) { |
3464 |               recordVotes(this.responseText,itemName); |
3465 |            } |
3466 |         }; |
3467 |         var url = "/" + homeNode.key + "/downVote"; |
3468 |         xhttp.open("GET", url, true); |
3469 |         xhttp.send(); |
3470 |         return; |
3471 |      } |
3472 |          registerVoter(); |
3473 | |
3474 | } |
3475 | |
3476 | |
3477 | |
3478 | |
twitterImage |
|
3479 |    var showBest = true; |
3480 |   |
3481 |  function renderTwitterImage(){ |
3482 |       return '' +  |
3483 |       '<img src="https://pythonlinks.info//static/graphics/Tweet.png" '+  |
3484 |       'alt="I wanted to add users tweets to my website, but Twitter'+ |
3485 |       'would then track every page that you visit.  Not good for privacy. ' + |
3486 |       'So if you are kind enough to tweet comments, I will link to them."'+ |
3487 |        'style = "max-width:100%;" onload="localRebuild">' + |
3488 |         '<br> Privacy Protecting Tweet Image'; |
3489 | |
3490 |       |
3491 |  } |
3492 |           |
3493 | function showIntroductoryVideo(slide){          |
3494 |         if ((slide == landingPage)&&isMobile&& (rootName == 'python'))  |
3495 |              {     |
3496 |         return '<h3 style = "text-align:center;">'+ |
3497 |         '<a onClick="displaySlideNamed('+ |
3498 |         "'introductory-video')"+ '">' +  |
3499 |         'Introductory Video</a></h3>'+ |
3500 |         '<p style="text-align:center">' + news + "</p>";  |
3501 |         } |
3502 |         else { |
3503 |        return ''; |
3504 |         } |
3505 | }  |
3506 | |
3507 | function generateLeadersOrContent(slide){ |
3508 |      return '<div  id = "bestContent' +  |
3509 |      '-' + getKey(slide) + '" >'+ |
3510 |           generateLeadersOrContentCore(slide) + |
3511 |       "</div>"; |
3512 | } |
twitterlink |
|
3513 | |
3514 | function twitterLinkFront(){ |
3515 |     var result =""; |
3516 |     var base = 'https://twitter.com/intent/follow?screen_name='; |
3517 |     result +=  '<a href="' + base + |
3518 |     twitterId + |
3519 |     '">' |
3520 |     return result; |
3521 | } |
3522 | function twitterLinkBack(){ |
3523 |     return + '</a>'; |
3524 | } |
3525 |