SHARE
TWEET

Untitled

a guest May 4th, 2014 13 Never
  1. /*
  2.  * On-Hover-Menu (OHM)
  3.  */
  4.  
  5. Ohm = {
  6.         init: function(){
  7.                 Ohm.preload([  // Preload images for non-lag during hover
  8.                         'https://dl.dropboxusercontent.com/u/931983/chan/heart.png',
  9.                         'https://dl.dropboxusercontent.com/u/931983/chan/0.png',
  10.                         'https://dl.dropboxusercontent.com/u/931983/chan/menu.png'
  11.                 ]);
  12.                 OhmThumbs.add(); // Add all thumbs on page
  13.                 OhmThumbFooter.init();
  14.                 OhmThumbToolbar.init();
  15.                 OhmThumbContextMenu.init();
  16.                 OhmEditBox.init();
  17.                 OhmTagsBox.init();
  18.                 OhmThumbsListener.apply();
  19.         },
  20.         preload: function(arrayOfImages) {
  21.                 jQuery(arrayOfImages).each(function(){
  22.                         jQuery('<img/>')[0].src = this;
  23.                 });
  24.         },
  25. };
  26.  
  27. OhmOptions = { // Default options
  28.         toolbar: {
  29.                 display: true, // Display toolbar?
  30.                 mode: undefined, // Current mode
  31.                 parenting: false // Display parenting icons
  32.         },
  33.         footer: true,
  34.        
  35.         translations: {
  36.                 language: "e",
  37.                 "Add to favorites": "Add to favorites desu",
  38.         },
  39.        
  40.         trans: function(english){ // return japanese or english translation
  41.                 return english;
  42.         },
  43.        
  44.         init: function(){ // overwrite default options with options from the cookies
  45.        
  46.         },
  47. };
  48.  
  49. OhmThumbs = {
  50.         current: undefined, // Currently hovered thumb
  51.         chosen: undefined, // Currently chosen thumb
  52.         all: {}, // All thumbs
  53.         last: {}, // Last added thumbs
  54.        
  55.         add: function(thumbs){
  56.                
  57.                 OhmThumbs.last = {}; //  Empty last added thumbs
  58.        
  59.                 if(!thumbs) { // Get all thumbs from page if no thumbs provided
  60.                         thumbs = jQuery('.thumb');
  61.                 }
  62.                
  63.                 thumbs.each(function(){ // Create div, set ids and push them in the database
  64.                
  65.                         var obj = jQuery(this);
  66.                         if(!obj.data("hasOhm")){ // If thumb doesnt have Ohm
  67.                                 obj.data("hasOhm", true)
  68.                                
  69.                                 var thumb = {};
  70.                                
  71.                                 // Get post-id and generate ohmid
  72.                                 thumb.ohmid = obj.attr('id').substr(1); // Id of the ohm containers
  73.                                 thumb.id = thumb.ohmid; // Post id
  74.                                 while(OhmThumbs.all[thumb.ohmid]){ // While defined
  75.                                         thumb.ohmid = thumb.ohmid + "n";
  76.                                 }
  77.                                 obj.data("ohmid", thumb.ohmid);
  78.                                 obj.find("img").data("ohmid", thumb.ohmid);
  79.                                
  80.                                 var src = {};
  81.                                 src.link = obj.find("img").attr("src");
  82.                                 src.width = obj.find("img").attr("width");
  83.                                 src.height = obj.find("img").attr("height");
  84.                                 thumb.src = src;
  85.                                
  86.                                 thumb.favorited = false;
  87.                                 if(obj.find("img").hasClass("favorited")){
  88.                                         thumb.favorited = true;
  89.                                 }
  90.                                
  91.                                 // Get thumb-info out of the title
  92.                                 var title = obj.find("img").attr("title");
  93.                                 var parts = /(.*) Rating:(\w)\w+ Score:(\S+) Size:(\d+)x(\d+) User:(.*)/.exec(title);
  94.                                 thumb.tags = parts[1];
  95.                                 thumb.rating = parts[2].toLowerCase();
  96.                                 thumb.score = parts[3];
  97.                                 thumb.width = parseInt(parts[4]);
  98.                                 thumb.height = parseInt(parts[5]);
  99.                                 thumb.user = parts[6];
  100.                                 obj.find("img").attr("title", ""); // suppress the current tooltip
  101.                                
  102.                                 // Set css of thumb
  103.                                 obj.css({
  104.                                         position: "relative",
  105.                                 });
  106.                                
  107.                                 // Create div-containers
  108.                                 obj.prepend('<div id="abovethumb-'+thumb.ohmid+'" class="ohmAboveThumb"></div>');
  109.                                 obj.append('<div id="belowthumb-'+thumb.ohmid+'" class="ohmBelowThumb"></div>');
  110.                                
  111.                                 thumb.obj = obj;
  112.                                
  113.                                 // Add thumb
  114.                                 OhmThumbs.last[thumb.ohmid] = thumb;
  115.                                 OhmThumbs.all[thumb.ohmid] = thumb;
  116.                         }
  117.                        
  118.                         OhmThumbs.compare(OhmThumbs.last);
  119.                 });
  120.                
  121.         },
  122.        
  123.         getById: function(id){ // return all thumbs by given id (hint: multiple ids because thumbs can appear more than once on page)
  124.                 var thumbs = {};
  125.                 for(var ohmid in OhmThumbs.all){
  126.                         var thumb = OhmThumbs.all[ohmid];
  127.                         if(thumb.id === id){
  128.                                 thumbs[thumb.ohmid] = thumb;
  129.                         }
  130.                 }
  131.                 return thumbs;
  132.         },
  133.        
  134.         compare: function(thumbs){ // compare all thumbs with the chosen post and set them as good or bad
  135.                 var chosen = OhmThumbs.chosen;
  136.                 if(OhmThumbs.chosen){ // if chosen post is defined
  137.                         if(!thumbs){ // if thumbs are undefined
  138.                                 thumbs = OhmThumbs.all;
  139.                                
  140.                                 // remove last comparison
  141.                                 for(var ohmid in thumbs){
  142.                                         var thumb = thumbs[ohmid];
  143.                                         thumb.obj.removeClass("better worse chosen");
  144.                                 }
  145.                         }
  146.                        
  147.                         for(var ohmid in thumbs){ // for all thumbs
  148.                                 var thumb = thumbs[ohmid];
  149.                                
  150.                                 if(thumb.id !== chosen.id){ // if thumb is not chosen thumb
  151.                                         var ratioThumb = Math.round(thumb.width * 100 / thumb.height);
  152.                                         var ratioChosen = Math.round(chosen.width * 100 / chosen.height);
  153.                                        
  154.                                         if(ratioThumb === ratioChosen){ // if thumb is same ratio, compare
  155.                                                 if(thumb.width > chosen.width && thumb.height > chosen.height) { // if thumb is bigger than chosen one, it's better
  156.                                                         thumb.obj.addClass("better");
  157.                                                 }
  158.                                                 else if(thumb.width < chosen.width && thumb.height < chosen.height){ // if thumb is smaller than chosen one, it's worse
  159.                                                         thumb.obj.addClass("worse");
  160.                                                 }
  161.                                                 else { // else compare age of post, this works almost ever
  162.                                                         if(parseInt(thumb.id) < parseInt(chosen.id)){ // if thumb is older
  163.                                                                 thumb.obj.addClass("better");
  164.                                                         }
  165.                                                         else{
  166.                                                                 thumb.obj.addClass("worse");
  167.                                                         }
  168.                                                 }
  169.                                         }
  170.                                 }
  171.                                 else{ // if thumb is chosen thumb
  172.                                         thumb.obj.addClass("chosen");
  173.                                 }
  174.                         }
  175.                 }
  176.                 else{ // if chosen post is undefined
  177.                         // remove last comparison
  178.                         for(var ohmid in OhmThumbs.all){
  179.                                 var thumb = OhmThumbs.all[ohmid];
  180.                                 thumb.obj.removeClass("better worse chosen");
  181.                         }
  182.                 }
  183.         }
  184. };
  185.  
  186. OhmThumbsListener = {
  187.         apply: function(last){ // Apply listener to all thumbs
  188.                
  189.                 var thumbs = {};
  190.                 if(!last) {
  191.                         thumbs = OhmThumbs.all;
  192.                 }
  193.                 else{
  194.                         thumbs = OhmThumbs.last;
  195.                 }
  196.                
  197.                 for(var ohmid in thumbs){
  198.                         var thumb = thumbs[ohmid];
  199.                         var obj = thumb.obj;
  200.                         if(obj) { // if defined
  201.                                 obj.mouseenter(function(event){
  202.                                         var ohmid = jQuery(this).data("ohmid");
  203.                                         OhmThumbs.current = OhmThumbs.all[ohmid];
  204.                                        
  205.                                         OhmThumbFooter.placeToCurrent();
  206.                                         OhmThumbFooter.show();
  207.                                        
  208.                                         OhmThumbToolbar.placeToCurrent();
  209.                                         OhmThumbToolbar.show();
  210.                                 });
  211.                                
  212.                                 obj.mouseleave(function(event){
  213.                                         var ohmid = jQuery(this).data("ohmid");
  214.                                         OhmThumbFooter.hide();
  215.                                         OhmThumbToolbar.hide();
  216.                                         OhmThumbContextMenu.hide();
  217.                                 });
  218.                                
  219.                                 // Different Listener for the image
  220.                                 obj.find("img").mouseenter(function(event){
  221.                                         var ohmid = obj.find("img").data("ohmid");
  222.                                        
  223.                                         OhmThumbs.all[ohmid].hover = true;
  224.                                         OhmThumbs.all[ohmid].timer = setTimeout(function(){ // display tags after some time
  225.                                                 if(OhmThumbs.all[ohmid].hover){ // if still hovering
  226.                                                         OhmTagsBox.placeToCurrent();
  227.                                                         OhmTagsBox.show();
  228.                                                 }
  229.                                         }, 1500);
  230.                                 });
  231.                                
  232.                                 obj.find("img").mouseleave(function(event){
  233.                                         var ohmid = obj.find("img").data("ohmid");
  234.                                        
  235.                                         //clearTimeout(OhmThumbs.all[ohmid].timer); // reset timer for displaying tags if thumb is left
  236.                                         OhmThumbs.all[ohmid].hover = false;
  237.                                         OhmTagsBox.hide();
  238.                                 });
  239.                         }
  240.                 }
  241.         },
  242. };
  243.  
  244. OhmThumbFooter = {
  245.         init: function() { // Create footer and append it to body
  246.                 jQuery(document.body).append('<div id="ohmThumbFooter"></div>');
  247.         },
  248.        
  249.         show: function() {
  250.                 jQuery("#ohmThumbFooter").show();
  251.         },
  252.        
  253.         hide: function() {
  254.                 jQuery("#ohmThumbFooter").hide();
  255.         },
  256.        
  257.         placeToCurrent: function() { // Place the footer to currently hovered thumb
  258.                 var footer = jQuery("#ohmThumbFooter");
  259.                 var thumb = OhmThumbs.current;
  260.                
  261.                 footer.html(thumb.width + 'x' + thumb.height + ' / ' + thumb.rating + ' / ' + thumb.user);
  262.                 thumb.obj.append(footer);
  263.         },
  264.        
  265. };
  266.  
  267. OhmThumbToolbar = {
  268.         init: function() { // Create toolbar and append it to body
  269.                 jQuery(document.body).append('<div id="ohmThumbToolbar"><a onclick="javascript:OhmThumbActions.favoriteCurrent();" id="ohmThumbToolbarFavoriteIcon" class="ohmIcon" title="Add to favorites"></a><a onclick="javascript:OhmThumbActions.executeMode();" id="ohmThumbToolbarModeIcon" class="ohmIcon" title="No mode selected" ></a><a onclick="javascript:OhmThumbActions.displayContextMenu();" id="ohmThumbToolbarContextMenuIcon" class="ohmIcon" title="Open context menu"></a></div>');
  270.         },
  271.        
  272.         show: function() {
  273.                 jQuery("#ohmThumbToolbar").show();
  274.         },
  275.        
  276.         hide: function() {
  277.                 jQuery("#ohmThumbToolbar").hide();
  278.         },
  279.        
  280.         placeToCurrent: function() {
  281.                 var toolbar = jQuery("#ohmThumbToolbar");
  282.                 var thumb = OhmThumbs.current;
  283.                 if(thumb.favorited){
  284.                         jQuery("#ohmThumbToolbarFavoriteIcon").addClass("clicked");
  285.                 }
  286.                 else{
  287.                         jQuery("#ohmThumbToolbarFavoriteIcon").removeClass("clicked");
  288.                 }
  289.                 thumb.obj.append(toolbar);
  290.         },
  291. };
  292.  
  293. OhmThumbContextMenu = {
  294.         left: false, // If contextmenu is placed left
  295.        
  296.         init: function(){ // Create contextmenu and append it to body
  297.                 jQuery(document.body).append('<div id="ohmThumbContextMenu"> Mode Options: <br><div style="display:block;vertical-aling:center"><a href="javascript:OhmThumbActions.setMode(\'preview\');" id="ohmThumbContextMenuPreviewIcon" class="ohmIcon" title="Set this as mode"></a><a href="javascript:OhmThumbActions.openPreview();"> Open preview </a></div><div style="display:block;vertical-aling:center"><a href="javascript:OhmThumbActions.setMode(\'quickedit\');" id="ohmThumbContextMenuQuickEditIcon" class="ohmIcon" title="Set this as mode"></a><a href="javascript:OhmThumbActions.quickEdit();"> Quick edit </a></div><div style="display:block;vertical-aling:center"><a href="javascript:OhmThumbActions.setMode(\'flag\');" id="ohmThumbContextMenuFlagIcon" class="ohmIcon" title="Set this as mode"></a><a href="javascript:OhmThumbActions.flagPost();"> Flag post </a></div><div style="display:block;vertical-aling:center"><a href="javascript:OhmThumbActions.setMode(\'similar\');" id="ohmThumbContextMenuFindSimilarIcon" class="ohmIcon" title="Set this as mode"></a><a href="javascript:OhmThumbActions.findSimilar();"> Find similar posts </a></div><br>Advanced operations: <div style="display:block;vertical-aling:center"><a href="javascript:OhmThumbActions.setMode(\'choose\');" id="ohmThumbContextMenuChooseIcon" class="ohmIcon" title="Set this as mode"><a href="javascript:OhmThumbActions.choose();"> Choose post </a></div><div style="display:block;vertical-aling:center"><a href="javascript:OhmThumbActions.setMode(\'child\');" id="ohmThumbContextMenuChildIcon" class="ohmIcon" title="Set this as mode"><a href="javascript:OhmThumbActions.setAsChild();"> Set as child </a></div><div style="display:block;vertical-aling:center"><a href="javascript:OhmThumbActions.setMode(\'parent\');" id="ohmThumbContextMenuParentIcon" class="ohmIcon" title="Set this as mode"><a href="javascript:OhmThumbActions.setAsParent();"> Set as parent </a></div><div style="display:block;vertical-aling:center"><a href="javascript:OhmThumbActions.removeParent();"> Remove parent </a></div><div style="display:block;vertical-aling:center"><a href="javascript:OhmThumbActions.toggleParentingIcons();"> Toggle parenting icons </a></div></div>');
  298.         },
  299.        
  300.         show: function() {
  301.                 jQuery("#ohmThumbContextMenu").show();
  302.                 jQuery("#ohmThumbToolbarContextMenuIcon").addClass("clicked");
  303.         },
  304.        
  305.         hide: function() {
  306.                 jQuery("#ohmThumbContextMenu").hide().removeClass("left");
  307.                 jQuery("#ohmThumbToolbarContextMenuIcon").removeClass("clicked");
  308.                 OhmThumbContextMenu.left = false;
  309.         },
  310.        
  311.         isVisible: function() {
  312.                 return jQuery("#ohmThumbContextMenu").is(":visible");
  313.         },
  314.        
  315.         placeToCurrent: function() {
  316.                 var contextmenu = jQuery("#ohmThumbContextMenu");
  317.                 var thumb = OhmThumbs.current;
  318.                 thumb.obj.append(contextmenu);
  319.         },
  320.        
  321.         placeLeft: function() {
  322.                 jQuery("#ohmThumbContextMenu").addClass("left");
  323.                 OhmThumbContextMenu.left = true;
  324.         },
  325. };
  326.  
  327. OhmTagsBox = { // display a box below
  328.         init: function(){ // create box and append it to body
  329.                 jQuery(document.body).append('<div id="ohmTagsBox"></div>');
  330.         },
  331.        
  332.         placeToCurrent: function(){ // place box to current thumb
  333.                 var thumb = OhmThumbs.current;
  334.                 var box = jQuery("#ohmTagsBox");
  335.                
  336.                 box.html(thumb.tags);
  337.                 thumb.obj.append(box);
  338.         },
  339.        
  340.         show: function(){
  341.                 jQuery("#ohmTagsBox").show();
  342.         },
  343.        
  344.         hide: function(){
  345.                 jQuery("#ohmTagsBox").hide();
  346.         },
  347. },
  348.  
  349. OhmInfoBox = {
  350.  
  351. };
  352.  
  353. OhmEditBox = {
  354.         thumb: undefined, // thumb which is currently loaded into the editbox
  355.  
  356.         init: function(){ // Create edit box with Listener for drag and drop and append it to body
  357.                 jQuery(document.body).append('<div id="ohmEditBox" onmousedown="javascript:OhmEditBox.startMoving(event);" onmouseup="javascript:OhmEditBox.stopMoving();" ></div>');
  358.         },
  359.        
  360.         placeToCurrent: function(){
  361.                 var box = jQuery("#ohmEditBox");
  362.                 var thumb = OhmThumbs.current;
  363.                
  364.                 // thumb position in relation to window
  365.                 var thumbTop = thumb.obj.offset().top - jQuery(window).scrollTop();
  366.                 var thumbLeft = thumb.obj.offset().left - jQuery(window).scrollLeft();
  367.                
  368.                 var boxTop;
  369.                 var boxLeft;
  370.                
  371.                 // calculate box position in relation to contextmenu and thumb
  372.                 if(OhmThumbContextMenu.left) { // if cm is left to thumb, put box left to contextmenu
  373.                         boxTop = thumbTop;
  374.                         boxLeft = thumbLeft  - box.width() - jQuery("#ohmThumbContextMenu").width();
  375.                 }
  376.                 else{ // put it left to thumb
  377.                         boxTop = thumbTop;
  378.                         boxLeft = thumbLeft  - box.width();
  379.                 }
  380.                 if(boxTop < 0) {
  381.                         boxTop = 0;
  382.                 }
  383.                 if(boxLeft < 0) {
  384.                         boxLeft = 0;
  385.                 }
  386.                
  387.                 box.css({
  388.                         left:boxLeft,
  389.                         top:boxTop,
  390.                 });
  391.         },
  392.        
  393.         show: function() {
  394.                 jQuery("#ohmEditBox").show();
  395.         },
  396.        
  397.         hide: function() {
  398.                 jQuery("#ohmEditBox").hide();
  399.         },
  400.        
  401.         move : function(divid,xpos,ypos){
  402.                 var a = document.getElementById(divid);
  403.                 $(divid).style.left = xpos + 'px';
  404.                 $(divid).style.top = ypos + 'px';
  405.     },
  406.         startMoving : function(evt){
  407.                 if(!(document.activeElement.nodeName === "INPUT" || document.activeElement.nodeName === "TEXTAREA")){
  408.                         evt = evt || window.event;
  409.                         var posX = evt.clientX,
  410.                                 posY = evt.clientY,
  411.                                 a = document.getElementById('ohmEditBox'),
  412.                         divTop = a.style.top,
  413.                         divLeft = a.style.left;
  414.                         divTop = divTop.replace('px','');
  415.                         divLeft = divLeft.replace('px','');
  416.                         var diffX = posX - divLeft,
  417.                                 diffY = posY - divTop;
  418.                         document.onmousemove = function(evt){
  419.                                 evt = evt || window.event;
  420.                                 var posX = evt.clientX,
  421.                                         posY = evt.clientY,
  422.                                         aX = posX - diffX,
  423.                                         aY = posY - diffY;
  424.                                 OhmEditBox.move('ohmEditBox',aX,aY);
  425.                         }
  426.                 }
  427.     },
  428.         stopMoving : function(){
  429.                 var a = document.createElement('script');
  430.                 document.onmousemove = function(){}
  431.     },
  432. };
  433.  
  434. OhmThumbActions = {
  435.         displayContextMenu: function(){
  436.                 if(OhmThumbContextMenu.isVisible()) {
  437.                         OhmThumbContextMenu.hide();
  438.                 }
  439.                 else {
  440.                         OhmThumbContextMenu.placeToCurrent();
  441.                         var w = jQuery(document).width();
  442.                         OhmThumbContextMenu.show();
  443.                         var ocm = jQuery("#ohmThumbContextMenu").offset().left;
  444.                         var wcm = jQuery("#ohmThumbContextMenu").width();
  445.                        
  446.                         if(w < ocm+wcm) { // If context menu is outside of document to the right
  447.                                 OhmThumbContextMenu.placeLeft();
  448.                         }
  449.                 }
  450.         },
  451.         quickEdit: function(){
  452.                 // Place content in Editbox and show it
  453.                 var box = jQuery("#ohmEditBox");
  454.                 var thumb = OhmThumbs.current;
  455.                 OhmEditBox.thumb = thumb;
  456.                
  457.                
  458.                 var rating;
  459.                 switch(thumb.rating){
  460.                         case 's':
  461.                                 rating = 'safe';
  462.                                 break;
  463.                         case 'q':
  464.                                 rating = 'questionable';
  465.                                 break;
  466.                         case 'e':
  467.                                 rating = 'explicit';
  468.                                 break;
  469.                 }
  470.                
  471.                 // Bug fix: Get source width and height again in case it's 0
  472.                 if((thumb.src.width === 0) || (thumb.src.height === 0)){
  473.                         thumb.src.width = thumb.obj.find("img").width();
  474.                         thumb.src.height = thumb.obj.find("img").height();
  475.                         OhmThumbs.all[thumb.ohmid].src.width = thumb.src.width;
  476.                         OhmThumbs.all[thumb.ohmid].src.height = thumb.src.height;
  477.                 }
  478.                
  479.                 box.html('<div id="ohmEditBoxTitle"> Edit Post:</div><a onclick="javascript:OhmEditBox.hide();" id="ohmEditBoxCloseIcon" class="ohmIcon"></a><hr color="white" size="1"><div style="display:table"><div id="ohmEditBoxTagDiv" style="display:table-cell;vertical-align:top;text-align:center;height:100%;text-align:left;overflow-y:auto;background-color:white"></div><div style="display:inline-block;vertical-align:top;text-align:center" class="thumb"><div class="ohmAboveThumb"> Id: ' + thumb.id + ' </div><a href="javascript:OhmThumbActions.toggleZoomDuringEdit();"><div id="ohmEditBoxThumbImageDiv"><img class="preview" src="' + thumb.src.link + '" title="" alt="Toggle Zoom" width="' + thumb.src.width + '" height="' + thumb.src.height + '"></div></a><div class="ohmBelowThumb"> ' + thumb.width + 'x' + thumb.height + ' <br>User: ' + thumb.user + ' <br>Rating: ' + rating + ' </div></div><div style="display:inline-block;vertical-align:top"><table style="border-width:1px;"><tbody style="border:none;"><tr style="color:white;background-color: rgba(125,125,125,0.8);"><th><label class="block" for="post_rating_questionable"> Rating </label></th><td style="border:none;"><input id="ohm_post_rating_explicit" name="post[rating]" tabindex="1" type="radio" value="explicit"><label for="ohm_post_rating_explicit"> Explicit </label><input id="ohm_post_rating_questionable" name="post[rating]" tabindex="2" type="radio" value="questionable"><label for="ohm_post_rating_questionable"> Questionable </label><input checked="" id="ohm_post_rating_safe" name="post[rating]" tabindex="3" type="radio" value="safe"><label for="ohm_post_rating_safe"> Safe </label></td></tr><tr style="color:white;background-color: rgba(125,125,125,0.8);"><th><label class="block" for="post_tags"> Tags </label></th><td style="border:none;"><textarea cols="50" id="ohm_post_tags" name="post[tags]" rows="4" tabindex="10"> ' + thumb.tags + ' </textarea></td></tr></tbody></table><div style="text-align:right"><input type="button" value="Save" onclick="javascript:OhmThumbActions.quickEditSave();"><input type="button" value="Save and close" onclick="javascript:OhmThumbActions.quickEditSaveAndClose();"><input type="button" value="Cancel" onclick="javascript:OhmEditBox.hide();"></div></div></div>');
  480.                 box.show();
  481.                 jQuery("#ohmEditBoxThumbImageDiv").data("zoom", false);
  482.                
  483.                 // Place Editbox next to thumb
  484.                 OhmEditBox.placeToCurrent();
  485.         },
  486.        
  487.         quickEditSave: function(){
  488.                 var thumb = OhmEditBox.thumb;
  489.                 var params = {};
  490.                 params["id"] = thumb.id;
  491.                 params["post[tags]"] = jQuery("#ohm_post_tags").val();
  492.                 // Post.update(thumb.id, params);
  493.                
  494.                 var rating = '';
  495.                 if(jQuery("#ohm_post_rating_explicit").is(":checked")){
  496.                         rating = jQuery("#ohm_post_rating_explicit").attr("value");
  497.                 }
  498.                 else if(jQuery("#ohm_post_rating_questionable").is(":checked")){
  499.                         rating = jQuery("#ohm_post_rating_questionable").attr("value");
  500.                 }
  501.                 else if(jQuery("#ohm_post_rating_safe").is(":checked")){
  502.                         rating = jQuery("#ohm_post_rating_safe").attr("value");
  503.                 }
  504.                 params["post[rating]"] = rating;
  505.                
  506.                 Post.notice_update("inc")
  507.         new Ajax.Request('/post/update.json', {
  508.             parameters: params,
  509.             onComplete: function(resp) {
  510.                 Post.notice_update("dec")
  511.                 var resp = resp.responseJSON
  512.                 if (resp.success) {
  513.                     Post.register(resp.post)
  514.                 } else {
  515.                     notice('Error: ' + resp.reason)
  516.                 }
  517.                                
  518.                                 OhmThumbs.all[thumb.ohmid].tags = params["post[tags]"];
  519.                                 OhmEditBox.thumb = OhmThumbs.all[thumb.ohmid];
  520.                                
  521.                                 // Update Tag field
  522.                                 var tagDiv = jQuery("#ohmEditBoxTagDiv");
  523.                                 jQuery(document.body).append('<div id="ohmHiddenPost" style="display:none"></div>');
  524.                                 var hiddenPostDiv = jQuery("#ohmHiddenPost");
  525.                                 var link = "http://chan.sankakucomplex.com/post/show/" + thumb.id;
  526.                                
  527.                                 hiddenPostDiv.load(link+" #post-view", function(){
  528.                                         tagDiv.html(hiddenPostDiv.find("#tag-sidebar").clone().wrap('<p>').parent().html());
  529.                                         tagDiv.css("width", "212px");
  530.                                         tagDiv.find("ul").css({
  531.                                                 "height": "5px",
  532.                                                 "overflow": "initial",
  533.                                         });
  534.                                        
  535.                                         // Remove hidden post
  536.                                         hiddenPostDiv.remove();
  537.                                 });
  538.             }
  539.         })
  540.         },
  541.        
  542.         quickEditSaveAndClose: function(){
  543.                 var thumb = OhmEditBox.thumb;
  544.                 var params = {};
  545.                 params["id"] = thumb.id;
  546.                 params["post[tags]"] = jQuery("#ohm_post_tags").val();
  547.                
  548.                 var rating = '';
  549.                 if(jQuery("#ohm_post_rating_explicit").is(":checked")){
  550.                         rating = jQuery("#ohm_post_rating_explicit").attr("value");
  551.                 }
  552.                 else if(jQuery("#ohm_post_rating_questionable").is(":checked")){
  553.                         rating = jQuery("#ohm_post_rating_questionable").attr("value");
  554.                 }
  555.                 else if(jQuery("#ohm_post_rating_safe").is(":checked")){
  556.                         rating = jQuery("#ohm_post_rating_safe").attr("value");
  557.                 }
  558.                 params["post[rating]"] = rating;
  559.                
  560.                 // Post.update(thumb.id, params);
  561.                
  562.                 Post.notice_update("inc")
  563.         new Ajax.Request('/post/update.json', {
  564.             parameters: params,
  565.             onComplete: function(resp) {
  566.                 Post.notice_update("dec")
  567.                 var resp = resp.responseJSON
  568.                 if (resp.success) {
  569.                     Post.register(resp.post)
  570.                 } else {
  571.                     notice('Error: ' + resp.reason)
  572.                 }
  573.                                
  574.                                 OhmThumbs.all[thumb.ohmid].tags = params["post[tags]"];
  575.                                 OhmEditBox.thumb = OhmThumbs.all[thumb.ohmid];
  576.                                 OhmEditBox.hide();
  577.             }
  578.         })
  579.         },
  580.        
  581.         toggleZoomDuringEdit: function(){
  582.                 var thumb = OhmEditBox.thumb;
  583.                 var imgDiv = jQuery("#ohmEditBoxThumbImageDiv");
  584.                 var tagDiv = jQuery("#ohmEditBoxTagDiv");
  585.                
  586.                 if(!imgDiv.data("zoom")){ // If not zoomed in, load image
  587.                         var link = "http://chan.sankakucomplex.com/post/show/" + thumb.id;
  588.                         if(!jQuery("#ohmHiddenPost").get(0)){ // if hidden post container doesnt exist create one
  589.                                 jQuery(document.body).append('<div id="ohmHiddenPost" style="display:none"></div>');
  590.                         }
  591.                         var hiddenPostDiv = jQuery("#ohmHiddenPost");
  592.                        
  593.                         hiddenPostDiv.load(link+" #post-view", function(){
  594.                                 tagDiv.html(hiddenPostDiv.find("#tag-sidebar").clone().wrap('<p>').parent().html());
  595.                                 tagDiv.css("width", "212px");
  596.                                 tagDiv.find("ul").css({
  597.                                         "height": "5px",
  598.                                         "overflow": "initial",
  599.                                 });
  600.                                 imgDiv.html(hiddenPostDiv.find("#image").clone().wrap('<p>').parent().html());
  601.                                 var width = imgDiv.find("img").attr("width");
  602.                                 var height = imgDiv.find("img").attr("height");
  603.                                 var newWidth = width;
  604.                                 var newHeight = height;
  605.                                 var maxLength = 500;
  606.                                 if(width > height){ // If wide image, maximize width and set height
  607.                                         if(width>maxLength){
  608.                                                 newWidth = maxLength;
  609.                                                 newHeight = maxLength*height/width;
  610.                                         }
  611.                                 }
  612.                                 else{
  613.                                         if(height>maxLength){
  614.                                                 newHeight = maxLength;
  615.                                                 newWidth = maxLength*width/height;
  616.                                         }
  617.                                 }
  618.                                 imgDiv.find("img").attr("width", newWidth);
  619.                                 imgDiv.find("img").attr("height", newHeight);
  620.                                
  621.                                 // Remove hidden post
  622.                                 //hiddenPostDiv.remove();
  623.                                 imgDiv.data("zoom", true);
  624.                         });
  625.                 }
  626.                 else{
  627.                         imgDiv.html('<img class="preview" src="' + thumb.src.link + '" title="" alt="Toggle Zoom" width="' + thumb.src.width + '" height="' + thumb.src.height + '">');
  628.                         imgDiv.data("zoom", false);
  629.                 }
  630.         },
  631.        
  632.         favoriteCurrent: function(){
  633.                 var thumb = OhmThumbs.current;
  634.                 var post_id = thumb.id;
  635.                
  636.                 if(!thumb.favorited){ // if not favorited, add to favorites
  637.                         notice('Adding post #' + post_id)
  638.                         new Ajax.Request('/favorite/create.json', {
  639.                                 parameters: {
  640.                                         id: post_id
  641.                                 },
  642.                                 onComplete: function(resp) {
  643.                                         var resp = resp.responseJSON
  644.                                         if (resp.success) {
  645.                                                 notice("Post #" + post_id + " added to favorites")
  646.                                                
  647.                                                 // Set all thumbs to favorited
  648.                                                 var thumbs = OhmThumbs.getById(post_id);
  649.                                                 console.log(thumbs);
  650.                                                 for(var ohmid in thumbs){
  651.                                                         var t = thumbs[ohmid];
  652.                                                         t.obj.find("img").addClass("favorited");
  653.                                                         OhmThumbs.all[t.ohmid].favorited = true;
  654.                                                 }
  655.                                                 if(OhmThumbs.current.id === post_id){ // if still hovering image, update heart icon
  656.                                                         jQuery("#ohmThumbToolbarFavoriteIcon").addClass("clicked");
  657.                                                         jQuery("#ohmThumbToolbarFavoriteIcon").attr("title", "Remove from favorites");
  658.                                                 }
  659.                                                
  660.                                         } else {
  661.                                                 notice("Error: " + resp.reason)
  662.                                         }
  663.                                 }
  664.                         });
  665.                 }
  666.                 else{ // remove from favorites
  667.                         notice('Removing post #' + post_id)
  668.                         new Ajax.Request('/favorite/destroy.json', {
  669.                                 parameters: {
  670.                                         id: post_id
  671.                                 },
  672.                                 onComplete: function(resp) {
  673.                                         var resp = resp.responseJSON
  674.                                         notice("Post #" + post_id + " removed from your favorites")
  675.                                        
  676.                                         // Set all thumbs to not favorited
  677.                                         var thumbs = OhmThumbs.getById(post_id);
  678.                                         console.log(thumbs);
  679.                                         for(var ohmid in thumbs){
  680.                                                 var t = thumbs[ohmid];
  681.                                                 t.obj.find("img").removeClass("favorited");
  682.                                                 OhmThumbs.all[ohmid].favorited = false;
  683.                                         }
  684.                                        
  685.                                         if(OhmThumbs.current.id === post_id){ // if still hovering image, update heart icon
  686.                                                 jQuery("#ohmThumbToolbarFavoriteIcon").removeClass("clicked");
  687.                                                 jQuery("#ohmThumbToolbarFavoriteIcon").attr("title", "Add to favorites");
  688.                                         }
  689.                                 }
  690.                         });
  691.                 }
  692.         },
  693.        
  694.         setMode: function(mode){
  695.                 if(mode){ // if mode is defined
  696.                
  697.                         // Remove clicked status from every class
  698.                         jQuery("#ohmThumbContextMenuPreviewIcon").removeClass("clicked");
  699.                         jQuery("#ohmThumbContextMenuQuickEditIcon").removeClass("clicked");
  700.                         jQuery("#ohmThumbContextMenuFlagIcon").removeClass("clicked");
  701.                         jQuery("#ohmThumbContextMenuFindSimilarIcon").removeClass("clicked");
  702.                         jQuery("#ohmThumbContextMenuChooseIcon").removeClass("clicked");
  703.                         jQuery("#ohmThumbContextMenuChildIcon").removeClass("clicked");
  704.                         jQuery("#ohmThumbContextMenuParentIcon").removeClass("clicked");
  705.                
  706.                         // Set mode Icon in toolbar
  707.                         var icon;
  708.                         var title;
  709.                         switch(mode){
  710.                                 case 'preview':
  711.                                         icon = jQuery("#ohmThumbContextMenuPreviewIcon");
  712.                                         title = "Preview";
  713.                                         break;
  714.                                 case 'quickedit':
  715.                                         icon = jQuery("#ohmThumbContextMenuQuickEditIcon");
  716.                                         title = "Quick Edit";
  717.                                         break;
  718.                                 case 'flag':
  719.                                         icon = jQuery("#ohmThumbContextMenuFlagIcon");
  720.                                         title = "Flag";
  721.                                         break;
  722.                                 case 'similar':
  723.                                         icon = jQuery("#ohmThumbContextMenuFindSimilarIcon");
  724.                                         title = "Find similar posts";
  725.                                         break;
  726.                                 case 'choose':
  727.                                         icon = jQuery("#ohmThumbContextMenuChooseIcon");
  728.                                         title = "Choose Post";
  729.                                         break;
  730.                                 case 'child':
  731.                                         icon = jQuery("#ohmThumbContextMenuChildIcon");
  732.                                         title = "Set this post as child of the chosen post";
  733.                                         break;
  734.                                 case 'parent':
  735.                                         icon = jQuery("#ohmThumbContextMenuParentIcon");
  736.                                         title = "Set this post as parent of the chosen post";
  737.                                         break;
  738.                         }
  739.                         var bgx = icon.css("background-image");
  740.                         icon.addClass("clicked");
  741.                         jQuery("#ohmThumbToolbarModeIcon").css("background-image", bgx).attr("title", title);
  742.                        
  743.                         // Set mode in options
  744.                         OhmOptions.toolbar.mode = mode;
  745.                        
  746.                 }
  747.         },
  748.        
  749.         executeMode: function(){
  750.                 switch(OhmOptions.toolbar.mode){
  751.                         case 'preview':
  752.                                 OhmThumbActions.openPreview();
  753.                                 break;
  754.                         case 'quickedit':
  755.                                 OhmThumbActions.quickEdit();
  756.                                 break;
  757.                         case 'flag':
  758.                                 OhmThumbActions.flagPost();
  759.                                 break;
  760.                         case 'similar':
  761.                                 OhmThumbActions.findSimilar();
  762.                                 break;
  763.                         case 'choose':
  764.                                 OhmThumbActions.choose();
  765.                                 break;
  766.                         case 'child':
  767.                                 OhmThumbActions.setAsChild();
  768.                                 break;
  769.                         case 'parent':
  770.                                 OhmThumbActions.setAsParent();
  771.                                 break;
  772.                 }
  773.         },
  774.        
  775.         openPreview: function(){
  776.                 var thumb = OhmThumbs.current;
  777.                 var link = "http://chan.sankakucomplex.com/post/show/" + thumb.id;
  778.                 if(!jQuery("#ohmHiddenPost").get(0)){ // if hidden post container doesnt exist, create one
  779.                         jQuery(document.body).append('<div id="ohmHiddenPost" style="display:none"></div>');
  780.                 }
  781.                 var hiddenPostDiv = jQuery("#ohmHiddenPost");
  782.                
  783.                 hiddenPostDiv.load(link+" #post-view", function(){
  784.                         jQuery(document.body).append('<a href="javascript:OhmThumbActions.closePreview();" id="ohmThumbPreview" class="ohmThumbPreview"></a>');
  785.                         var preview = jQuery("#ohmThumbPreview");
  786.                        
  787.                         // Load image into preview-container
  788.                         preview.html(hiddenPostDiv.find("#image").clone().wrap('<p>').parent().html());
  789.                        
  790.                         // Put image in center
  791.                         var imgWidth = preview.find("#image").attr("width");
  792.                         var imgHeight = preview.find("#image").attr("height");
  793.                         var winWidth = jQuery(window).width();
  794.                         var winHeight = jQuery(window).height();
  795.                         var prevWidth = imgWidth;
  796.                         var prevHeight = imgHeight;
  797.                        
  798.                         if(winWidth < imgWidth){ // Fit to width
  799.                                 prevWidth = winWidth;
  800.                                 prevHeight = winWidth*imgHeight/imgWidth;
  801.                         }
  802.                         imgWidth = prevWidth;
  803.                         imgHeight = prevHeight;
  804.                        
  805.                         if(winHeight < imgHeight){ // Fit image to height
  806.                                 prevWidth = winHeight*imgWidth/imgHeight;
  807.                                 prevHeight = winHeight;
  808.                         }
  809.                        
  810.                         preview.find("#image").attr("width", prevWidth);
  811.                         preview.find("#image").attr("height", prevHeight);
  812.                        
  813.                         preview.css({
  814.                                 "width": prevWidth,
  815.                                 "height": prevHeight,
  816.                                 "left": (winWidth - prevWidth) * 0.5,
  817.                                 "top": (winHeight - prevHeight) * 0.5,
  818.                                 "position": "fixed",
  819.                         });
  820.                        
  821.                         // Remove hiddenPost
  822.                         //setTimeout(function(){hiddenPostDiv.remove();}, 2000);
  823.                 });
  824.         },
  825.        
  826.         closePreview: function(){
  827.                 jQuery("#ohmThumbPreview").remove();
  828.         },
  829.        
  830.         flagPost: function(){
  831.                 Post.flag(OhmThumbs.current.id);
  832.         },
  833.        
  834.         findSimilar: function(){
  835.                 var thumb = OhmThumbs.current;
  836.                 var link = "http://chan.sankakucomplex.com/post/similar?id="+thumb.id;
  837.                 var fmid = thumb.ohmid;
  838.                 while(jQuery("#ohmFindSimilar-"+fmid).get(0)){ // While defined
  839.                         fmid = fmid + "n";
  840.                 }
  841.                 thumb.obj.after('<div id="ohmFindSimilar-' + fmid + '" class="status-notice ohm"></div>');
  842.                 var findsim = jQuery('#ohmFindSimilar-' + fmid);
  843.                 findsim.load(link+' #similar-form', function(){
  844.                         findsim.find("#similar-image-form").remove();
  845.                         findsim.find(".thumb").removeClass("blacklisted");
  846.                         OhmThumbs.add(findsim.find(".thumb"));
  847.                         OhmThumbsListener.apply();
  848.                        
  849.                         // append close button
  850.                         findsim.append('<a onclick="javascript:jQuery(\'#ohmFindSimilar-' + fmid + '\').hide();" id="ohmFindSimilarCloseIcon" class="ohmIcon"></a>');
  851.                 });
  852.         },
  853.        
  854.         toggleParentingIcons: function(){
  855.                 if(OhmOptions.toolbar.parenting){ // if parenting icons are already displayed, remove them
  856.                         jQuery("#ohmThumbToolbar").html('<a onclick="javascript:OhmThumbActions.favoriteCurrent();" id="ohmThumbToolbarFavoriteIcon" class="ohmIcon" title="Add to favorites"></a><a onclick="javascript:OhmThumbActions.executeMode();" id="ohmThumbToolbarModeIcon" class="ohmIcon" title="No mode selected" ></a><a onclick="javascript:OhmThumbActions.displayContextMenu();" id="ohmThumbToolbarContextMenuIcon" class="ohmIcon" title="Open context menu"></a>');
  857.                        
  858.                         jQuery("#ohmThumbToolbarFavoriteIcon").css('left', '30px');
  859.                         jQuery("#ohmThumbToolbarModeIcon").css('left', '77px');
  860.                         jQuery("#ohmThumbToolbarContextMenuIcon").css('left', '124px');
  861.                        
  862.                         if(OhmThumbs.current.favorited){
  863.                                 jQuery("#ohmThumbToolbarFavoriteIcon").addClass("clicked");
  864.                         }
  865.                        
  866.                         OhmOptions.toolbar.parenting = false;
  867.                        
  868.                         OhmThumbActions.setMode(OhmOptions.toolbar.mode);
  869.                 }
  870.                 else{ // parenting icons are not visible, create them
  871.                         jQuery("#ohmThumbToolbar").html('<a onclick="javascript:OhmThumbActions.favoriteCurrent();" id="ohmThumbToolbarFavoriteIcon" class="ohmIcon" title="Add to favorites"></a><a onclick="javascript:OhmThumbActions.choose();" id="ohmThumbToolbarChooseIcon" class="ohmIcon" title="Choose Post" ><a onclick="javascript:OhmThumbActions.setAsChild();" id="ohmThumbToolbarChildIcon" class="ohmIcon" title="Set this post as child of the chosen post" ><a onclick="javascript:OhmThumbActions.setAsParent();" id="ohmThumbToolbarParentIcon" class="ohmIcon" title="Set this post as parent of the chosen post" ><a onclick="javascript:OhmThumbActions.executeMode();" id="ohmThumbToolbarModeIcon" class="ohmIcon" title="No mode selected" ></a><a onclick="javascript:OhmThumbActions.displayContextMenu();" id="ohmThumbToolbarContextMenuIcon" class="ohmIcon" title="Open context menu"></a>');
  872.                        
  873.                         jQuery("#ohmThumbToolbarFavoriteIcon").css('left', '12px');
  874.                         jQuery("#ohmThumbToolbarChooseIcon").css('left', '38px');
  875.                         jQuery("#ohmThumbToolbarChildIcon").css('left', '64px');
  876.                         jQuery("#ohmThumbToolbarParentIcon").css('left', '90px');
  877.                         jQuery("#ohmThumbToolbarModeIcon").css('left', '116px');
  878.                         jQuery("#ohmThumbToolbarContextMenuIcon").css('left', '142px');
  879.                        
  880.                         if(OhmThumbs.current.favorited){
  881.                                 jQuery("#ohmThumbToolbarFavoriteIcon").addClass("clicked");
  882.                         }
  883.                        
  884.                         OhmOptions.toolbar.parenting = true;
  885.                        
  886.                         OhmThumbActions.setMode(OhmOptions.toolbar.mode);
  887.                 }
  888.         },
  889.        
  890.         choose: function(){ // choose a post and also save in cookies
  891.                 var thumb = OhmThumbs.current;
  892.                
  893.                 if(OhmThumbs.chosen){ // if chosen thumb is defined
  894.                         if(OhmThumbs.chosen.id !== thumb.id){ // if the chosen thumb is not the currently chosen thumb
  895.                                 OhmThumbs.chosen = thumb;
  896.                                 OhmThumbs.compare(); // compare all thumbs with the chosen post
  897.                         }
  898.                         else{ // else reject it
  899.                                 OhmThumbs.chosen = undefined;
  900.                                 OhmThumbs.compare();
  901.                         }
  902.                 }
  903.                 else{ // if chosen thumb is undefined, choose it
  904.                         OhmThumbs.chosen = thumb;
  905.                         OhmThumbs.compare(); // compare all thumbs with the chosen post
  906.                 }
  907.         },
  908.        
  909.         setAsParent: function(){ // set current post as parent of the chosen post
  910.                 var current = OhmThumbs.current;
  911.                 var chosen = OhmThumbs.chosen;
  912.                 var params = {};
  913.                 params["id"] = chosen.id;
  914.                 params["post[parent_id]"] = current.id;
  915.                
  916.                 Post.notice_update("inc")
  917.         new Ajax.Request('/post/update.json', {
  918.             parameters: params,
  919.             onComplete: function(resp) {
  920.                 Post.notice_update("dec")
  921.                 var resp = resp.responseJSON
  922.                 if (resp.success) {
  923.                     Post.register(resp.post)
  924.                 } else {
  925.                     notice('Error: ' + resp.reason)
  926.                 }
  927.                                
  928.                                 // Set all thumbs with the same id as chosen_id to has-parent
  929.                                 var thumbs = OhmThumbs.getById(chosen.id);
  930.                                 for(var ohmid in thumbs){
  931.                                         thumbs[ohmid].obj.find("img").addClass("has-parent");
  932.                                 }
  933.                                
  934.                                 // Set all thumbs with the same id as current_id to has-children
  935.                                 thumbs = OhmThumbs.getById(current.id);
  936.                                 for(var ohmid in thumbs){
  937.                                         thumbs[ohmid].obj.find("img").addClass("has-children");
  938.                                 }
  939.             }
  940.         });
  941.         },
  942.        
  943.         setAsChild: function(){ // set current post as child of the chosen post
  944.                 var current = OhmThumbs.current;
  945.                 var chosen = OhmThumbs.chosen;
  946.                 var params = {};
  947.                 params["id"] = current.id;
  948.                 params["post[parent_id]"] = chosen.id;
  949.                
  950.                 Post.notice_update("inc")
  951.         new Ajax.Request('/post/update.json', {
  952.             parameters: params,
  953.             onComplete: function(resp) {
  954.                 Post.notice_update("dec")
  955.                 var resp = resp.responseJSON
  956.                 if (resp.success) {
  957.                     Post.register(resp.post)
  958.                 } else {
  959.                     notice('Error: ' + resp.reason)
  960.                 }
  961.                                
  962.                                 // Set all thumbs with the same id as chosen_id to has-children
  963.                                 var thumbs = OhmThumbs.getById(chosen.id);
  964.                                 for(var ohmid in thumbs){
  965.                                         thumbs[ohmid].obj.find("img").addClass("has-children");
  966.                                 }
  967.                                
  968.                                 // Set all thumbs with the same id as current_id to has-parent
  969.                                 thumbs = OhmThumbs.getById(current.id);
  970.                                 for(var ohmid in thumbs){
  971.                                         thumbs[ohmid].obj.find("img").addClass("has-parent");
  972.                                 }
  973.             }
  974.         });
  975.         },
  976.        
  977.         removeParent: function(){ // remove parent of the current post
  978.                 var current = OhmThumbs.current;
  979.                 var params = {};
  980.                 params["id"] = current.id;
  981.                 params["post[parent_id]"] = "";
  982.                
  983.                 Post.notice_update("inc")
  984.         new Ajax.Request('/post/update.json', {
  985.             parameters: params,
  986.             onComplete: function(resp) {
  987.                 Post.notice_update("dec")
  988.                 var resp = resp.responseJSON
  989.                 if (resp.success) {
  990.                     Post.register(resp.post)
  991.                 } else {
  992.                     notice('Error: ' + resp.reason)
  993.                 }
  994.                                
  995.                                 // Remove has-parent from all thumbs with the current id
  996.                                 var thumbs = OhmThumbs.getById(current.id);
  997.                                 for(var ohmid in thumbs){
  998.                                         thumbs[ohmid].obj.find("img").removeClass("has-parent");
  999.                                 }
  1000.             }
  1001.         });
  1002.         },
  1003. };
  1004.  
  1005. // OhmTags = {
  1006.         // all: {},
  1007.         // last: {},
  1008.         // current: undefined,
  1009.        
  1010.         // add: function(){ // get tags from sidebar
  1011.                 // var sidebar = jQuery("#tag-sidebar");
  1012.                 // if(!sidebar.get(0)){ // if undefined
  1013.                         // sidebar = jQuery("#tag-subs-sidebar");
  1014.                 // }
  1015.                 // if(sidebar.get(0)){ // if defined
  1016.                         // sidebar.find("li").each(function(i){
  1017.                                 // var li = $(this);
  1018.                                 // var ohmid = "ohmtag"+i;
  1019.                                 // var tag = {};
  1020.                                 // var tag.obj = li.first(); // get the first link
  1021.                                
  1022.                         // });
  1023.                 // }
  1024.         // },
  1025. // };
  1026.  
  1027. OhmTagsListener = {
  1028.         apply: function(){
  1029.                
  1030.         },
  1031. }
  1032.  
  1033. OhmTagContextMenu = { // contextmenu for tags in sidebar
  1034.         init: function(){
  1035.        
  1036.         },
  1037. };
  1038.  
  1039. OhmTagActions = { // Actions for the contextmenu in the tag sidebar
  1040.  
  1041. }
  1042.  
  1043. OhmFix = { // Fix stuff which is already implemented on the site
  1044.         noticeBox: function(){
  1045.                 var notice = jQuery("#notice");
  1046.                
  1047.                 notice.css({
  1048.                                 "font-size": "1.2em",
  1049.                                 "color": "red",
  1050.                                 "font-weight": "bold",
  1051.                                 "margin-bottom": "1em",
  1052.                                 "padding-left": "20px",
  1053.                                 "padding-right": "20px",
  1054.                                 "position": "fixed",
  1055.                                 "left": "0px",
  1056.                                 "top": "0px",
  1057.                                 "background-color": "white",
  1058.                                 "z-index": "99999999",
  1059.                                 "border": "2px solid #DDD;",
  1060.                         });
  1061.                
  1062.                 notice.bind('DOMNodeInserted DOMSubtreeModified DOMNodeRemoved', function(){
  1063.                         notice.stop().css({"opacity":"1"});
  1064.                         setTimeout(function(){
  1065.                                 notice.fadeOut();
  1066.                         }, 3000);
  1067.                 });
  1068.         },
  1069. };
  1070.  
  1071. jQuery(document).ready(function(){
  1072.  
  1073.         console.log('ok');
  1074.        
  1075.         Ohm.init();
  1076.         OhmFix.noticeBox();
  1077.        
  1078.         console.log('end');
  1079. });
RAW Paste Data
Top