User:Robert W King/Sandbox: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Robert W King
imported>Robert W King
Line 3: Line 3:
{{tl|Timeline}} with {{tl|TLevent}}
{{tl|Timeline}} with {{tl|TLevent}}
{{Timeline
{{Timeline
|height=20}}
|height=25}}
{{TLevent|event=Something happened 1. Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.
{{TLevent|event=Something happened 1. Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.
|width=80%
|width=80%

Revision as of 16:33, 9 March 2008

Timeline test

{{Timeline}} with {{TLevent}}

Something happened 1. Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.Something happened 1.
Something happened 2.
Something happened 13.


VB Module for Extracting Contributions

Module Module1

    Dim url
    Dim CZ
    Dim wikipath
    Dim totalcdata
    Dim title
    Dim currentid
    Dim articleid
    Dim oldid
    Dim latestid
    Dim diffclass

    Sub Main()
        Dim T

        T = 0
        initCZ()
        title = "fire"
        url = wikipath + "/" + title
        CZ.navigate(url)
        Do Until CZ.readyState = 4

        Loop
        getcdata()

        articleid = Right(Mid(totalcdata, InStr(totalcdata, "wgArticleId"), 24), 9)
        currentid = Right(Mid(totalcdata, InStr(totalcdata, "CurRevisionId"), 26), 9)

        navtorecentdiff()

        Do
            getoldid()
            If latestid <> oldid Then

                getinsdiffchange()
                getdeldiffchange()
                navolddiff()
            End If

        Loop While latestid <> oldid

    End Sub
    Function initCZ()
        wikipath = "http://en.citizendium.org/wiki"
        CZ = CreateObject("InternetExplorer.Application")
        CZ.Toolbar = 0
        CZ.Visible = 1
        CZ.navigate(wikipath)
        Do Until CZ.readyState = 4
        Loop
        Return CZ
    End Function

    Function getcdata()
        Dim tags
        Dim thing
        Dim x
        Dim test

        x = 0
        tags = CZ.document.getElementsbyTagName("script")

        For Each Items In tags
            thing = tags.Item(x).innerHtml
            test = InStr(thing, "CDATA")
            If test <> 0 Then
                totalcdata = thing
                Exit For
            End If
            x = x + 1
        Next
        Return totalcdata
    End Function

    Function navtorecentdiff()
        url = wikipath + "?title=" + title + "&diff=prev&oldid=" + (Right(currentid, 9))
        CZ.navigate(url)
        Do Until CZ.readystate = 4

        Loop
        Return url
    End Function

    Function getoldid()
        Dim tags
        Dim thing
        Dim x
        Dim test

        x = 0
        tags = CZ.document.getElementsbyTagName("a")

        For Each Items In tags
            thing = tags.Item(x).outerHtml
            test = InStr(thing, "oldid")
            If test <> 0 Then
                latestid = oldid
                oldid = Mid(thing, test + 6, 9)
                Exit For
            End If
            x = x + 1
        Next

        Return oldid
    End Function

    Function navolddiff()
        url = wikipath + "?title=" + title + "&diff=prev&oldid=" + oldid
        CZ.navigate(url)
        Do Until CZ.readystate = 4

        Loop
        Return url

    End Function

    Function getinsdiffchange()
        Dim tags
        Dim thing
        Dim x
        Dim test
        Dim totalwrite

        x = 0
        tags = CZ.document.getElementsbyTagName("ins")

        For Each Items In tags
            thing = tags.Item(x).innerHtml
            test = InStr(thing, "class=diffchange")
            If thing <> Nothing Then
                diffclass = diffclass + "+" + "'" + thing + "'" + "; "
            End If
            x = x + 1
        Next
        totalwrite = title + " | " + articleid + " | " + latestid + " | " + diffclass + vbCrLf
        IO.File.AppendAllText(("c:\" + title + "_insdiffchange.txt"), totalwrite)
        diffclass = Nothing
        Return diffclass
    End Function

    Function getdeldiffchange()
        Dim tags
        Dim thing
        Dim x
        Dim test
        Dim totalwrite

        x = 0
        tags = CZ.document.getElementsbyTagName("del")

        For Each Items In tags
            thing = tags.Item(x).innerHtml
            test = InStr(thing, "class=diffchange")
            If thing <> Nothing Then
                diffclass = diffclass + "-" + "'" + thing + "'" + "; "
            End If
            x = x + 1
        Next
        totalwrite = title + " | " + articleid + " | " + latestid + " | " + diffclass + vbCrLf
        IO.File.AppendAllText(("c:\" + title + "_deldiffchange.txt"), totalwrite)
        diffclass = Nothing
        Return diffclass
    End Function

End Module

Excel VB Script version

Function grabdiffdata()
    Dim url
    Dim CZ
    Dim wikipath
    Dim totalcdata
    Dim title
    Dim currentid
    Dim articleid
    Dim oldid
    Dim latestid
    Dim diffclass
    Dim T
    Dim tags
    Dim thing
    Dim x
    Dim test
    Dim totalwrite

    T = 0

    wikipath = "http://en.citizendium.org/wiki"
    Set CZ = CreateObject("InternetExplorer.Application")
    CZ.Toolbar = 0
    CZ.Visible = 1
    CZ.navigate (wikipath)
        Do Until CZ.readyState = 4
        Loop

    title = "fire"
    url = wikipath + "/" + title
    CZ.navigate (url)
        Do Until CZ.readyState = 4
        Loop

    x = 0
    Set tags = CZ.document.getElementsByTagName("script")
        For Each Items In tags
            thing = tags.Item(x).innerHTML
            test = InStr(thing, "CDATA")
            If test <> 0 Then
                totalcdata = thing
                Exit For
            End If
            x = x + 1
        Next

    articleid = Right(Mid(totalcdata, InStr(totalcdata, "wgArticleId"), 24), 9)
    currentid = Right(Mid(totalcdata, InStr(totalcdata, "CurRevisionId"), 26), 9)

    url = wikipath + "?title=" + title + "&diff=prev&oldid=" + (Right(currentid, 9))
    CZ.navigate (url)
        Do Until CZ.readyState = 4
        Loop

        Do
            x = 0
            Set tags = CZ.document.getElementsByTagName("a")
                For Each Items In tags
                    thing = tags.Item(x).outerHTML
                    test = InStr(thing, "oldid")
                    If test <> 0 Then
                        latestid = oldid
                        oldid = Mid(thing, test + 6, 9)
                        Exit For
                    End If
                x = x + 1
                Next

            If latestid <> oldid Then
                x = 0
                Set tags = CZ.document.getElementsByTagName("ins")
                    For Each Items In tags
                        thing = tags.Item(x).innerHTML
                        test = InStr(thing, "class=diffchange")
                        If thing <> Empty Then
                            diffclass = diffclass + "+" + "'" + thing + "'" + "; "
                        End If
                    x = x + 1
                    Next
                totalwrite = title + " | " + articleid + " | " + latestid + " | " + diffclass + vbCrLf
                'IO.File.AppendAllText(("c:\" + title + "_insdiffchange.txt"), totalwrite)
                diffclass = Empty
        
                x = 0
                Set tags = CZ.document.getElementsByTagName("del")
                For Each Items In tags
                    thing = tags.Item(x).innerHTML
                    test = InStr(thing, "class=diffchange")
                    If thing <> Empty Then
                        diffclass = diffclass + "-" + "'" + thing + "'" + "; "
                    End If
                    x = x + 1
                Next
                totalwrite = title + " | " + articleid + " | " + latestid + " | " + diffclass + vbCrLf
                'IO.File.AppendAllText(("c:\" + title + "_deldiffchange.txt"), totalwrite)
                diffclass = Empty
             
                url = wikipath + "?title=" + title + "&diff=prev&oldid=" + oldid
                CZ.navigate (url)
                    Do Until CZ.readyState = 4
                    Loop
        End If
        Loop While latestid <> oldid
   
End Function