Geeks With Blogs

News
About Me:
I am a Female SharePoint Developer (a platinum unicorn). I have been working with SharePoint since I attended the Portal University in 2005. I hold a BA in Computer Science from the University of Missouri - Kansas City. I love playing Rockband, organizing user group meetings, working with code, attending events as a speaker or organizer, and having bizarre conversations about geek things with cool people. If you have any comments or questions fill out the contact form and I will try my best to help.



The Guide of a MOSSLover Becky Isserman's Blog

I must admit that I know only the most basic things about javascript (how to create a slideshow, how to redirect items, and how to write basic functions).  I am debugging someone else's code and I still have no idea what I am doing.  Basically on every one of these sites we have one default master page with a script inside to check every list and document library to see if a yes/no "Flag" field is checked and also checks the "Flag Expiration" to see if it is expired.  If the field is checked and it is not expired, then a Flag Picture shows up (rather than yes or no) and the  Flag Expiration Field is hidden.  Well there is a problem with wiki articles, because the ListIteratorView Webpart only shows columns in text without a picture.  I understand that to get these to push out on all the sites that were created the template would need to be overrode or someway to override the ListFieldIterator part on just the wiki pages would need to be implemented (possibly a custom template).  If anyone has a great idea for me I'm all ears and maybe some awesome linking.  Here is the code for the convert to flag function:

function convertFlagColumn(listName, columnName, pictureURL){
    //alert('test2');
    var error;
    try{
        //alert('test3');
        var permList;
        //alert('test4');
        var tables = document.getElementsByTagName('table');
        //alert('test5');
        for(var i = 0; i < tables.length; i++){
            //alert('test6');
            if(tables[i].summary.indexOf(listName) != -1){
                //alert('test7');
                webpartZone = tables
              [i].parentNode.parentNode.parentNode.parentNode.
              parentNode.parentNode.parentNode.parentNode; 

                var error; 
                try{
                   //If regular list without full toolbar
                    permList = webpartZone.children[0].children[0].children[0].children
                   [0].children[1].children[0].children[0].children[0].children[0].children;
                }
                catch(error){
                    var error2;
                    try{
                        //If regular list with full toolbar
                        permList = webpartZone.children[0].children[0].children[0].children
                        [1].children[1].children[0].children[0].children[0].children
                       [0].children;
                    }
                    catch(error2){
                        var error3;
                        try{
                           //If document library with full toobar
                            permList = webpartZone.children[0].children[0].children
                           [0].children[1].children[2].children[0].children[0].children
                          [0].children[0].children;
                        }
                        catch(error3){
                            //If document library without full toolbar
                            var error4;
                            try{
                                permList = webpartZone.children[0].children[0].children
                               [0].children[0].children[2].children[0].children[0].children
                              [0].children[0].children;
                            }
                            catch(error4){
                                //If no Items
                                var error5;
                                try{
                                    permList = webpartZone.children[0].children[0].children
                                    [0].children[2].children[0].children;
                                }
                                catch(error5){ 
                                          break;
                                }
                            }
                        }   
                    }
                } 
                var colNum = -1;
                var columns = permList[0].getElementsByTagName('th'); 
                for(var o = 0; o < columns.length; o++){
                    if(columns[o].innerText == columnName){
                        colNum = o;
                        //alert(columns[o+1].innerText);
                        columns[o+1].style.display = "none";
                        break;
                    }
                }
                //alert('test20');
                if(colNum > -1){
                    for(var q = 1; q < permList.length; q++){
                        var Flag = permList[q].children[colNum];
                        var FlagExpiration = permList[q].children[(colNum+1)]
                        if(FlagExpiration){
                            var expired = checkExpiration(FlagExpiration.innerText);
                            FlagExpiration.style.display = "none";
                            if(Flag.innerText == "Yes" && !expired)
                                Flag.innerHTML = "<img src='"+pictureURL+"'>";
                            else
                                Flag.innerHTML = "";
                        }
                    }
                } 
                break;
            }
        }
    }
    catch(error){
        alert(error.message);
    }
}
function grabTitle(){
    return document.getElementsByTagName('title')[0].innerText;
}
function runUIMods(){
    var error;
    try{
        var EditMode = false;
        var hyperlinks = document.getElementsByTagName("a");
        for(var t = 0; t < hyperlinks.length; t++){
            if(hyperlinks[t].innerHTML == "Exit Edit Mode"){
                EditMode = true;
                break;
            }
        }
        //if edit mode clear all titles
        if(EditMode == false){
            //hideNC_Number(grabTitle());
            //alert('test1');
            convertFlagColumn(grabTitle(), 'Flag', 'redflag2_jpg.jpg')
        }
       
    }
    catch(error){
        alert(error.message);
    }
}
runUIMods();


Thanks for the help in advance to anyone out there that is willing to help out.

Re-Posted from Old Blog

Technorati Tags: ,,
Posted on Wednesday, February 27, 2008 6:12 PM MOSS , Javascript | Back to top


Comments on this post: Custom Flag Issue in Wikis

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © MOSSLover | Powered by: GeeksWithBlogs.net