Yuav tau qhia kom meej rau cov neeg ua tus nrhiav tau li cas / Cov qhov uas siv cov SharePoint 2013 SO API

Kuv twb tias koj tsis mus ua hauj lwm nrog cov SharePoint 2013 Nrhiav API ntawm so li thawj zaug. Kuv xav mus nrhiav neeg, tsis tau muaj ntaub ntawv. Lub ntsiab kev kawm ntawm no yog tias koj thov qhia cov kev pab ntawm nws cov GUID (los yog tsawg kawg yog qhov no). Cov nram qab no jQuery snippet qhia li cas:

    loadExpertsAsync: muaj nuj nqi() {

        jQuery.support.cors = tseeb;

        $.ajax({
            url: qhov no.CreateFullApiUrl() +
                "?querytext = 'portals'&sourceid = 'b09a7990-05ea-4af9-81ef-edfab16c4e31'" +
                "&selectproperties ='LinkedInProfileUrl,GoogleCirclesProfileUrl,BALargeProfilePictureUrls,BAGridPictures,WorkEmail,Kev txawj ntse,AboutMe,Nyiam,JobTitle,PastProjects,PictureURL,PreferredName,TwitterHandle,LinkedInProfileUrl,PreferredName,GoogleCirclesProfileUrl'" +
                "&rowlimit = 99",
            txujci: "TXAIS",
            headers: { "Txais": "daim ntawv thov/json; odata = verbose" },
            cache: tsis tseeb,
            zoo: muaj nuj nqi (ntog) {

Hauv kuv tsev neeg, Kuv tab tom khiav API tiv thaiv SharePoint hauv internet. Tau lub GUID, Kuv raws li cov kauj ruam:

  1. Mus saib hauv qhov chaw SharePoint admin
  2. Xaiv "nrhiav" los ntawm lub sab laug tes navigation
  3. Xaiv "Hwj tshwm sim los"
  4. Xaiv "Cov neeg hauv zos tau"
  5. Saib qhov URL.

Kuv qhov URL ntsia ib yam dab tsi zoo li:

https://xyzzy-admin.sharepoint.com/_layouts/15/searchadmin/EditResultSource.aspx?level=tenant&sourceid=b09a7990%2D05ea%2D4af9%2D81ef%2Dedfab16c4e31&view=1

Lub sourceid parameter yog dab tsi ua haujlwm rau kuv.

(Kuv to taub hais tias cov sourceid tej zaum yeej yuav ib tug tsi tshaj plaws lawm nrog SP, but I’ll always check anyway 🙂 ).

</kawg>

undefinedSubscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Piv txwv li SharePoint so hu

Hauv qab no yog qauv so hu uas ua hauj lwm rau kuv thiab tej zaum yuav pab tau koj thiab txheej. Li ntawm 02/2014, yog piv txwv 2 🙂

  1. Reference ib sab nrog rau tej qhov chaw hauv nws lub npe
  2. Siv ib tug ncej tag ntau qho
  3. Ua ib tug neeg mus nrhiav ntawm so

 

Kuv mam ntxiv rau qhov no raws li lub sij hawm dhau mus.

Nov yog ib co pab inks kuv twb pom zoo li:

Reference ib sab nrog rau tej qhov chaw hauv nws lub npe

Kuv tsim ib daim ntawv teev kev cai nrog rau ib sab hu ua "Blog sau" (qhov chaw ntawm cov Blog thiab sau).

Yog tus $select mus reference ntawd qhia kiag:

image

Ib tsab no yuav hloov tau qhov chaw uas "_x0020_". Peb pom cov _x0020_ nyob rau cov qauv no nyob rau internets thiab so kom txaus yog tsis txawv.

Yog hais tias tsis txhob ua li, koj nyob nraum nyog yuav tau txais ib qho lus yuam kev li no:

Cov qhia “Blog sau” yog tsis siv tau.

Yooj yim txaus.

Siv ib qho ntau Lookup sab

Teeb:

  1. Tsim ib daim ntawv teev kev cai hu ua pawg.
  2. Ntxiv rau tej pawg. Kuv ntxiv tus kab thusly:image
  3. Tsim dua sau kev cai hu ua MockBlog thiab ntxiv cov pawg raws li ib qho ntau teev kem (los yog qhov chaw qhia kiag tias yog li cas koj ntog).

Ntxiv ib co khoom rau koj daim ntawv teev hauv Mockblog thiab koj.

Tus Ajax style hu siv jQuery yuav nrhiav tej yam zoo li no:

serverUrl  = "/_api/web/npe/GetByTitle('MockBlog')/khoom" +
             "?$xaiv = Title,Pawg/Title,Blog_x0020_Author/Title" + 
             "&$nthuav = Blog_x0020_Author,Pawg";

Peb nyob nraum qhia SharePoint "muab kuv lub npe rau txhua pawg (Pawg/Title). Tau qhov tseeb qhov tseem ceeb rau Npe by $nthuaving pawg daim ntawv." (Kuv RESTful paraphrasing yog xoob ntshe zoo nkauj, tab sis qhov no li cas kuv tabtom txhais tau tias).

Yog koj nyob nraum ua no ntawm JavaScript thiab siv cov Fiddler nyob hauv cov zis, koj mus muab tau tej yam zoo li no koom:

 

image

(Cov saum no yog ib yam twj paj nruas JSON)

Ua ib tug neeg mus nrhiav ntawm so

Kuv blogged txog no nyias. Lub ntsiab yog hais kom meej ib sourceid parameter cov nqi uas nws yog tus GUID uas yog lub zos neeg qha qhov. (Qha qhov chaw siv yog hu ua scopes thiab yog kuv-huag-kuv nyuaj ua luaj tsis txhob hu rau txhua tsav txhua tus uas duav txhua yam rau kuv!).

Read ntxiv hais txog nws ntawm no: http://www.mstechblogs.com/paul/?p=10385

 

</kawg>

undefinedSubscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Txoj kev sai thiab yooj yim: Ua kom muaj ib qhov chaw SharePoint siv so

Muaj ntau ntau pab ib ncig uas qhia tau tias yuav ua li cas, tab sis kuv nrhiav tsis tau ib tug muab mus-mus txuas, yog li no peb cov.

Koj muaj peev xwm tsim ib qhov chaw SharePoint siv API so.  Ntawm no yog ib tug piv txwv ci siab:

<!--
    SiteRequestForm.html: Sau xov xwm thiab tsim tau ib qhov chaw rau cov neeg siv.
-->

<chaw>
<cov lus>
    <tr>
        <Td>Rau npe:</Td>
        <Td><tswv yim hom= "ntawv nyeem" lub npe= "SiteName" tus ID= "SiteName" /></Td>
    </tr>
    <tr>
        <Td colspan= "2">
            <tswv yim hom= "xa ntawv" tus ID= "CreateSiteButton" tus nqi= "Tsim lub Site" />
        </Td>
    </tr>
</cov lus>
</chaw>

<tsab ntawv src="../Plugins/jquery-1.11.0.min.js"></tsab ntawv>

<tsab ntawv>
Var CreateSiteLogicContainer = {

    createSiteData: {
            "tsis": {
                __metadata: { "hom": "SP.WebInfoCreationInformation" },
                Url: "Paultest1",
                Npe: "Paultest1",
                Hauj lwm lawm: "tsim so web los ntawm Paul!",
                Hais lus: 1033,
                WebTemplate: "sts",
                UseUniquePermissions: tsis tseeb
            }
    },

    createSite: muaj nuj nqi () {

        jQuery.support.cors = tseeb;

        CreateSiteLogicContainer.createSiteData.parameters.Url = $("#SiteName").val();
        
        $.ajax({
            url: "https://bigapplesharepoint.sharepoint.com/NBAIADev/_api/web/webinfos/add",
            txujci: "NCEJ",

            headers: {
                "Txais": "daim ntawv thov/json; odata = verbose",
                "cov ntawv hom": "daim ntawv thov/json;odata = verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val()
            },

            cov ntaub ntawv: JSON.stringify(CreateSiteLogicContainer.createSiteData),

            zoo: muaj nuj nqi () { alert("zoo"); },
            yuam kev: muaj nuj nqi () { alert("kev ua yuam kev"); }

        });
    },

    wireUpForm: muaj nuj nqi () {
        $("#CreateSiteButton").nyem(muaj nuj nqi () {
            alert("Li mus sim thiab tsim tau lub site.");
            CreateSiteLogicContainer.createSite();
        });
    }


}

CreateSiteLogicContainer.wireUpForm();

</tsab ntawv>

Thaum zoo, koj tau ib tug JSON tuaj rau lawv teb li no:

image

Kuv xav tseem ceeb thiab learnings ntawm no muaj xws li:

  • Kauj siv jQuery.  Hauv kuv tsev neeg, Kuv lub tsev qiv ntawv jQuery nyob rau hauv "../ plugins. "  Koj mam li xav hais tias yuav kis tau mus rau qhov chaw koj nyiam JQ nyob.
  • Luam thiab paste ntawd cov snippet tag nrho rau hauv ib cov ntawv Editor Web feem ntawm ib sab thiab nws yuav tsum ua hauj lwm xwb fine.  Koj mam xav hloov tag kis API hu thiab xyuas kom tseeb tias koj siv JQ kom raug.
  • Qhov URL yog ntu koj API endpoint.  Hauv kuv tsev neeg, Nws yog ib txoj kev kom ncua chaw kom https://bigapplesharepoint.com
  • Koj tsis tas yuav muab cov ntsiab lus-ntev. Ib co posts uas nyuam thiab MSDN daim ntawv implies tias koj tsis, tab sis tshwm sim rau kuv tau, uas kuv xav tias yog raug leej twg rau $.ajax hu rau nws tus kheej.
  • Cov kab no yuav tsum tau kom tsis txhob muaj qhov lus teb "forbidden": "X-RequestDigest": $("#__REQUESTDIGEST").val().  Muaj ntau hom kev ua, tab sis qhov no yog qhov zoo zoo nkauj.  Kuv tau poob qhov link rau blog muab no shortcut.  H/T rau koj, mysterious blogger!

Hmoov zoo thiab vam cia qhov no yuav pab lwm tus neeg paub.

</kawg>

undefinedSubscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Overcome Annoying teeb meem nrog tus kwv tij Urls hauv SharePoint ceev Launch

Kuv xav mus ntxiv ib qhov txuas rau tus ceev community launch navigation lwm hnub thiab SharePoint hais rau kuv:

image

Ntawv ntshiab version ntawd yog:

Xyuas kom qhov URL no siv tau pib nrog tog twg los ib tug cim uas koj siv tau (ib daim ntawv tooj (#) los luaj pem (/)) los yog ib tug siv tau txaus siab raws tu qauv (Piv txwv, ' http://’, ' https://’, ' ntaub ntawv://’, ' ftp://’, ' mailto:’, ' xov xwm:’).

"Blech thiab qoob!"Kuv hais.

Ib lub workaround rau qhov no yog siv cov JavaScript nrhiav ib qhov txuas paub tias nyob rau lub lub community launch ceev thiab override cov cwj pwm.

Sim no, ntxiv ib qhov txuas tshiab ntawd rau koj lub chaw kuaj thusly:

image

Kuv siv jQuery. Yuav kom daws tau nws, tau ib co JavaScript thiab jQuery mus rau ntawm nplooj ntawv uas siv cov txheej txheem yuav nyiam koj thiab nrog rau ib txoj kab kev cai zoo li no:

 

$(daim ntawv).npaj txhij( muaj nuj nqi () {

    $("ib tug:muaj('Kuaj URL hloov')").nyem(muaj nuj nqi () { alert("nias hloov tus cwj pwm!"); rov qab los tsis tseeb;});

});

Thiab Bob ntawv koj tus txiv ntxawm.

Cov jQuery selector pom txhua txhua <ib tug> lossis tau "Tshuaj ntsuam URL hloov" nws lub npe. Koj yuav tau xyuas-qhib uas nyob ntawm seb koj txuas thiab xws li.

Lub .click(muaj nuj nqi() xijpeem SharePoint yuav tau ua li cas thaum tus neeg siv clicked overrides. Xyuas kom tseeb tias koj "rov qab mus cuav" los yog mus yos nws yuav ua koj cov khoom thiab ces txhob href qhov dhau, Nws yog ib qho yuav luag yeej tsis koj lub hom phiaj no.

Qhov no yog ua li cas thiab kuaj hauv ib SharePoint hauv Internet chaw, tab sis yuav tsum ua hauj lwm zoo ua 2010 thiab dhau hwv.

</kawg>

undefinedSubscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Yooj yim thiab ceev thaum: SharePoint so hu xwb rov qab los 100 Cov ntaub ntawv

Kuv twb ua haujlwm rau ib tug pej xeem facing qhov web site rau kuv SharePoint xyaum no nyob rau hauv New York thiab nws siv ntau hu JavaScript thiab so kom txaus los qhia tias cov.

Thaum lub caij kev khiav, Kuv tsim tau ib dataset me me uas nyuam qhuav 10 los thiaj natwm nyob rau hauv ib daim ntawv teev kev cai thiab kuv tus so txhua txhua rho tawm ntawd.  Thaum kuv tsoo tau daim ntawv los tau ob peb puas natwm cov ntaub ntawv kuaj kev muab hlob, Kuv pom tias kuv tau txais raws nraim 100 xa rov qab rau kuv tus so hu natwm.

Qhov no nws yog ib tug yooj yim heev tshaj plaws rau qhov chaw nyob.  Hauv kuv tsev neeg (thiab kuv ntseeg tias feem ntau), lub neej ntawd so hu rau SharePoint (thiab tejzaum nws ua ib qho kev lag luam txheem?) rov qab los 100 natwm.  Rov qab mus tshaj lub neej ntawd, siv cov $top parameter rau koj, raws li nyob rau hauv:

TAU /Insights Dev/_api/web/lists/GetByTitle('MockBlog')/khoom?$xaiv = ID,Npe,Pawg/Title,Blog_x0020_Author/Title,DatePublished,BlogSummary&$nthuav = Blog_x0020_Author,Pawg&$lim =&$saum = 9999

Kuv yuav khaws 9999 qhov no lawm kuv paub hais tias growth-wise, yuav tsis muaj ntau tshaj 200 los luaj natwm ntxiv rau daim ntawv nyob hauv ib lub xyoos.  Yog hais tias nws yuav ungainly, peb yuav tau siv ib co paging sibtsoo.

</kawg>

undefinedSubscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Yooj yim thiab ceev thaum: Daws "Invalid URL Parameter” qhov teeb meem uas muaj UpdateListItems hauv lists.asmx

Thaum ua hauj lwm nrog cov UpdateListItems ntawm lists.asmx, Nws yog ib qho yooj yim uas ua kom muaj qhov yuam kev:

Invalid URL Parameter.

Qhov URL muaj muaj tus hais kom ua lossis tus nqi uas invalid. Thov khij qhov URL dua.

Koj yuav tau txais qhov yuam kev no thaum uas koj hnov qab xws li daim ID hauv cov daim ntawv uas teb yuav hloov.  Qhov no, zoo li ntau qhov kev pab no SP Web site, yog ib ntsis counterintuitive txij thaum koj yuav tau mus nrog tus ID tus ID attribute ntawm tus <Txujci> caij.  Thiab koj nyob nraum tsis tshiab ID thiab tej zaum koj yeej tsis xav ua tus thawj place.

No lub hnab ntawv uas tsis yog tshuaj ntxuav tes xwb:

<soapenv:Hnab ntawv xmlns:soapenv =' http://schemas.xmlsoap.org/soap/envelope/'>
  <soapenv:Lub cev>                      
    <UpdateListItems xmlns =' http://schemas.Microsoft.com/sharepoint/soap/'>                     
      <listName>{C712E2EA-54E1-47AD-9D99-1848C7773E2F}</listName>                     
        <tshiab>                     
         <Batch OnError ="Mus ntxiv">
          <Txujci ID ="1" Cmd ="Hloov tshiab">
            <Teb Name ="CooperativeLock">muab tub!</Teb>
            <Teb Name ="TUS ID">1</Teb>
          </Txujci>
        </Batch>                     
        </tshiab>                
      </UpdateListItems>             
  </soapenv:Lub cev>         
</soapenv:Hnab ntawv>

Yog hais tias koj tawm tus ID teb siv strip ces koj mam tau txais annoying "Invalid URL parameter" hais.

</kawg>

undefinedSubscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

 

Tus txiv neej tsis tus Caching hauv JavaScript

[TL;DR version: siv cov ncuav qab zib kom cia ntsuam async hu; kav soj ntsuam lawm hais lus async tam sim ntawd thiab ces validate lawv tom qab nplooj load.]

Kuv twb tau ua rau ntawm qhov chaw intranet SharePoint rau ib tug neeg ntawd nta, cov lwm yam, ib stylized lwm yam navigation uas los ntawm kev xaiv zaub mov muaj tswj ntawm ib txwm qub kev cai sau.  Tsab cai idea yog tias tus neeg twg thiaj tau tus tswj "lawv" rau cov zaub mov uas tsis rau los muab cuam tshuam los ntawm lub ntiaj teb no navigation muab tso los ntawm nws.

(muaj dab tsi subversive incredibly txog ntxiv ib CEWP uas cov ntsiab lus rau ib tug HTML uas loads ib co CSS thiab JS fundamentally tshwm sim yuav luag txhua yam hais txog tus kawm li cwjpwm... tiam sis yog rau lwm tus ncej)

Qhov chaws kom yooj yim yuav zoo nkauj no:

  • Tos li cov nplooj ntawv kom tag rau nraum chaw thau khoom thiab muab ib tug async hu mus thauj tuaj tshuab raj ua ib yam khoom ntawm ib daim ntawv teev tas los yog lists.asmx los yog los xijpeem
  • Siv jQuery, dynamically populate ib Rev yog <lis>tus hauv ib tug niam txiv <ul> (saib cov Christian Pinder tsab xov xwm no rau lub vaj no tecnnique simplistic)
  • Kev siv CSS yuav ua txhua yam rau formatting
  • Nyiaj!

Tej teev hauv no mob ntawd yog txhua zaus thaum leej twg hits yog ib cov chaw nplooj, tus neeg ntawd lub web browser yog caw kom tau yam khoom los ntawm daim ntawv.  Thaum dev no tiav thiab kuaj tau proven yam yuav ruaj thiab teb, no hu no hu ruaj dua 99% lub sij hawm thaum cov zaub mov tsis tshua hloov.  Nws kuj muaj ib tug weird UI muaj uas muaj nyob rau qhov brave new world ntawm cus-ajaxy web sites – cov phab renders thiab xwb ces yog cov ntawv qhia zaub mov kav.  Nws yog jittery thiab distracting rau kuv saib.  Thiab jittery. Li ntawd, caching. 

Kuv raug kho qhov logic thusly:

  • Nrhiav ib cov kua nplaum uas nyob rau hauv qhov browser uas muaj daim ntawv qhia zaub mov li kuv kawg nyeem nws
    • Yog nrhiav tau, kav nws tam sim ntawd.  Tsis txhob tos txog rau sab mus tag rau nraum chaw thau khoom.  (Koj yuav tau xyuas kom tseeb tias koj cov HTML leeg muab tso ntawm no, tab sis nws yuav tsis ua zog).
  • Tos li cov nplooj ntawv kom tag rau nraum chaw thau khoom thiab muab ib tug async hu mus thauj tuaj tshuab raj ua ib yam khoom ntawm ib daim ntawv teev tas los yog lists.asmx los yog los xijpeem
  • Piv li kuv tau tiv cov kua nplaum uas
    • Yog hais tias nws qhov khoom, TSO TSEG
    • Txwv tsis pub, siv jQuery, dynamically populate ib Rev yog <lis>cov nyob hauv lub <ul>
  • Kev siv CSS yuav ua txhua yam rau formatting
  • Nyiaj!

Qee yam uas koj yuav hais, "hav! yog tsis muaj real caching mus rau hauv no vim muaj koj nyob nraum nyeem cov ntawv qhia zaub mov rau nkawv noj txhua txhua zaug uas koj nkaus xwb.”  Thiab koj nyob nraum txoj kev-kuv tsis muab rau tus neeg rau zaub mov ntais txhua yam.  Tab sis vim hu yog async thiab tshwm sim tom qab uas pib ntawm nplooj ntawv HTML payload siab renders, nws "yim" noog kom tus neeg siv.  Daim ntawv qhia zaub mov renders zoo nkauj ntau li cov nplooj draws.  Yog hais tias cov zaub mov zoo li yuav hloov, cov neeg siv yog nyuam ib jittery rov kos ntawm cov ntawv qhia zaub mov, tab sis lub caij ntawd xwb.

Yog cov kev ua no caching zoo tshaj thiab pab kom paub cov neeg rau zaub mov txhij:

  • Muab tso rau hauv ib txoj cai tias tus tus "kua nplaum uas cache" yog muaj tsawg kawg yog 24 teev los yog ib txhia timeframe. Tsuav yog tsis DRA cov kua nplaum uas, siv cov kua nplaum uas tshuab raj snapshot thiab tsis txhob ntaus cov neeg rau zaub mov.

Qhov tshij... uas txhua yam uas tuaj siab tamsim no :). 

Yog leej twg muaj tus muaj cov tswv yim ntse nov kuv yuav hlub kom paub tias lawv.

Thiab ntsig – cov txheej txheem no yuav raug siv rau lwm yam khoom.  No neeg sab muaj ntau yam ntaub ntawv-uas tau tsav ntawv teev rau phab ntau, muaj coob leej kuj tsis tshua hloov (zoo li ib zaug ib lub lim tiam los sis ib hlis ib zaug).  Yog tias koj phiaj txog tej chaw functionality, koj muab tau ib daim UI feem ntau yog rub cov ntsiab lus los ntawm cov kua nplaum uas nyob tom khw thiab rendering tam sim ntawd.  Nws yim sai rau cov neeg siv txawm hais tias koj nyob nraum tsis txuag cov neeg rau zaub mov twg Pest.  Koj tau txuag cov neeg rau zaub mov mus los ntawm kev txiav txim siab rau tej mob uas muaj tej yam rau invalidate no qhov chaw cov kua nplaum uas cache.  Li no tag situational thiab artsy khoom thiab tiag tiag mas kev lom zem :). 

</kawg>

undefinedSubscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Yuav ua li cas: Configure tsev kuaj thiab tshuaj ntsuam cov kev pab uas muaj QUnit.js thiab Blanket.js rau ib qho chaw ua hauj lwm 365 SharePoint App

Intro

Twb tau kawm chav tsev kuaj thiab ntsuam xyuas cov kev pab tsis rau JavaScript nrog kuv ua hauj lwm hauv SharePoint app rau SharePoint hauv internet nyob rau hauv qhov chaw ua hauj lwm 365 Suite.  Cov cuab kev tshawb fawb paths coj kuv mus Qunit.js thiab txoj cai tom qab uas, mus Blanket.js.

QUnit cia kuv teeb tsev kuaj thiab koom rau hauv modules.  Ib tug module nws cia li yooj yim rau Teacher lwm yam kev kuaj. (Kuv tsis paub hais tias kuv yuav siv nws los siv yuav tsum, tab sis nws puas ua haujlwm rau kuv nyob deb thiaj nrog lub me me teeb ntawm kev ntsuam xyuas uas kuv tau deb deb li no txhais).

Blanket.js integrates nrog Qunit thiab nws yuav qhia kuv qhov tseeb kab ntawm JavaScript tau – thiab ntau ceeb tshaj – twb tsis tau tseg thaum khiav cov kev ntsuam xyuas.  Qhov no yog "los" – cov kab mob tseg yog them los ntawm txoj kev kuaj no thaum lwm tus uas tsis.

Teem mus kuaj mob zoo thiab saib cov kev pab them nqi, peb yuav txo tau qhov uas yuav ua kom cov code peb tau muab zais tsis xws luag.  Zoo sij hawm.

Qunit

Piv txwv tias yog koj muaj koj Studio uas koj siv qhov muag saib ib qhov teeb, pib los daus JavaScript pob ntawm http://qunitjs.com.  Ntxiv cov JavaScript thiab coj CSS koj cov tshuaj.  Mine looks li no:

image

Daim duab 1

Raws li koj tau pom, Kuv twb siv 1.13.0 thaum lub sij hawm uas kuv sau tau no blog tswg. Tsis txhob hnov qab ntxiv rau CSS daim download tau thiab kev pab.

Uas tawm hauv txoj kev, cov kauj ruam tom ntej yog los tsim tej yam xeem sam xauv nees thiab reference lub Qunit khoom.  Kuv yuav kuaj ib Rev muaj zog hauv ib tsab ntawv thov hu ua "QuizUtil.js" es kuv tsim ib nplooj hu ua "QuizUtil_test.html" thaum pom tias cov HTML:

image Daim duab 2

Ntawm no yog cov chaws:

<!DOCTYPE html>
<html xmlns= "http://xyoo 1999/xhtml www.w3.org/">
<lub taub hau>
    <npe>QuizUtil xeem nrog Qunit</npe>
    <txuas rel= "stylesheet" href="../CSS/qunit-1.13.0.CSS" />
    <tsab ntawv hom= "ntawv nyeem/javascript" src="QuizUtil.js" cov ntaub ntawv npog></tsab ntawv>
    <Script yam ="ntawv nyeem/javascript" src ="qunit-1.13.0.js"></tsab ntawv>
    <Script yam ="ntawv nyeem/javascript" src ="blanket.min.js"></tsab ntawv>

    <tsab ntawv>
        Module("getIDFromLookup");
        ntsuam xyuas("QuizUtil getIDFromLookupField", muaj nuj nqi () {
            Var goodValue = "1;#Paul Galvin";

            sib npaug(getIDFromLookupField(goodValue) + 1, 2), "Tus ID rau [" + goodValue + "] + 1 yuav tsum muaj rau 2";
            sib npaug(getIDFromLookupField(undefined), undefined, "Undefined input cav yuav rov raug undefined.");
            sib npaug(getIDFromLookupField(""), undefined, "Khoob input cav yuav tsum tau xa ib tus nqi uas undefined.");
            sib npaug(getIDFromLookupField("gobbledigood3-thq;dkvn ada;skfja sdjfbvubvqrubqer0873407t534piutheqw;vn"), undefined,"Yuav tsum nco ntsoov rov ib lub convertible no rau ib Integer");
            sib npaug(getIDFromLookupField("2;#ib txhia neeg"), "2", "Xyuas [2;#ib txhia neeg].");
            sib npaug(getIDFromLookupField("9834524;#tus nqi uas ntev"), "9834524", "Coob tus nqi kuaj.");
            notEqual(getIDFromLookupField("5;#leej twg los", 6), 6, "Kuaj ib notEqual (5 yog tsis sib npaug 6 rau cov qauv no: [5;#leej twg los]");

        });

        Module("htmlEscape");
        ntsuam xyuas("QuizUtil htmlEscape()", muaj nuj nqi () {
            sib npaug(htmlEscape("<"), "&LT;", "Escaping ib tug tsawg dua li tus neeg teb xov tooj ('<')");
            sib npaug(htmlEscape("<div hoob = yog muaj "someclass">Tej ntawv nyeem</div>"), "&LT;chav kawm ntawv div =&quot;someclass&quot;&gt;Tej ntawv nyeem&LT;/div&gt;", "Ntau xeem txoj hlua.");
        });

        Module("getDateAsCaml");
        ntsuam xyuas("QuizUtil getDateAsCaml()", muaj nuj nqi () {
            sib npaug(getDateAsCaml(tshiab Hnub tim("12/31/2013")), "2013-12-31T:00:00:00", "Kuaj coded ib hnub: [12/31/2013]");
            sib npaug(getDateAsCaml(tshiab Hnub tim("01/05/2014")), "2014-01-05T:00:00:00", "Kuaj coded ib hnub: [01/05/2014]");
            sib npaug(getDateAsCaml(tshiab Hnub tim("01/31/2014")), "2014-01-31T:00:00:00", "Kuaj coded ib hnub: [01/31/2014]");
            sib npaug(getTodayAsCaml(), getDateAsCaml(tshiab Hnub tim()), "getTodayAsCaml() yuav tsum siab sib npaug getDateAsCaml(Hnub tshiab())");
            sib npaug(getDateAsCaml("dev paus tus nqi"), undefined, "Sim tau hnub ntawm ib cov nqi dev paus.");
            sib npaug(getDateAsCaml(undefined), undefined, "Sim tau lub hnub lub [undefined] hnub.");
        });

        Module("getParameterByName");
        ntsuam xyuas("QuizUtil getParameterByName (los ntawm cov lus nug hlua)", muaj nuj nqi () {
            sib npaug(getParameterByName(undefined), undefined, "Sim nrhiav undefined parameter yuav tsum tau rov undefined.");
            sib npaug(getParameterByName(muaj "tsis nyob"), undefined, "Sim nrhiav parameter nqi thaum uas peb paub tias muaj tus parameter tsis nyob.");

        });

        Module("Ncuav qab zib");
        ntsuam xyuas("QuizUtil kua nplaum uas ntau zog.", muaj nuj nqi () {
            sib npaug(setCookie("sim", "1", -1), getCookieValue("sim"), "Tau ib cov kua nplaum uas kuv teem caij yuav tsum tau ua.");
            sib npaug(setCookie("anycookie", "1", -1), tseeb, "Qhov chaw kawm ib tug siv tau noj yuav tsum tau xa 'nws muaj tseeb'.");
            sib npaug(setCookie("npab kua nplaum uas lub npe !@#$%"%\^&*(()?/><.,", "1", -1), tseeb, "Qhov chaw kawm ib lub npe phem cov kua nplaum uas yuav tsum tau rov 'cuav'.");
            sib npaug(setCookie(undefined, "1", -1), undefined, "Raws li cov kua nplaum uas npe undefined.");
            sib npaug(getCookieValue(muaj "tsis nyob"), "", Muaj "kua nplaum uas tsis nyob ntawd.");
        });

    </tsab ntawv>
</lub taub hau>
<lub cev>
    <div tus ID= "qunit"></div>
    <div tus ID= "qunit-fixture"></div>

</lub cev>
</html>

Muaj ntau ntau yam zoj zis no:

  1. Referencing kuv code (QuizUtil.js)
  2. Referencing Qunity.js
  3. Defining tej modules (getIDFromLookup, Ncuav qab zib, thiab lwm tus)
  4. Muab ib <div> nws daim ID yog "qunit".

Ces, Kuv cia li rub tau cov nplooj ntawv no thiab koj mus muab tau tej yam zoo li no:

image

Daim duab 3

Yog qhov koj saib hla saum, koj tau xaiv ob peb, yog ob tug uas nthuav:

  • Hide dhau kev ntsuam xyuas: Cuab kev zoo nkauj.  Yuav pab tau koj qhov muag pom xwb lub teeb meem chaw thiab tsis muaj coob plaus.
  • Module: (hlauv): Qhov no yuav lim tau cov kev ntsuam xyuas pawg xwb cov kev ntsuam xyuas uas koj xav mus ua.

Ntawm kev tshuaj ntsuam lawv tus kheej – ob peb lus:

  • Nws yuav mus tsis tau hais tias koj tau sau koj cov cai xws tias nws yog testable ua tus xub place.  Siv cov cuab tam yuav pab tswj qhov kev qhuab qhia. Piv txwv, Kuv muaj ib tug ua haujlwm hu ua "getTodayAsCaml()”.  Qhov no tsis testable heev vim nws yuav siv sij hawm tsis sib cav uas input thiab kuaj kev koob pheej ntawm lawv, peb yuav tau lossi kho qhov chaws kuaj kom muaj kev cuam tshuam rau hnub tam sim no.  Kuv refactored ntawd los ntawm kev muab ib cov ntaub ntawv input parameter ces dua sau hnub thaum kuv xav hnub no CAML hom.
  • Qhov lub moj khaum Qunit ntaub ntawv rau qhov kev ntsuam xyuas nws tus kheej thiab no mas, robust zoo nkauj.  Nws yuav ua tau tej yam yooj yim xws li kuaj kev koob pheej ntawm lawv thiab tseem muaj nyiaj yug rau ajax style hu (ob leeg "tiag tiag" los mocked siv koj txoj kev mocker).
  • Yuav ua raws cov txheej txheem kuj forces koj xav mus txog ntug no – yuav ua cas nrog "undefined" lossis null dhau mus ua ib tug muaj nuj nqi.  Nws ua nws tuag yooj yim mus kuaj cov scenarios tawm.  Khoom zoo.

Cov kev pab uas muaj Blanket.js

Blanket.js complements Qunit los nrhiav lub txoos kab kev cai txim tuag thaum khiav koj kev ntsuam xyuas.  Nws integrates txoj cai rau hauv Qunit no, txawm ho yog ib tus tseem cais app, nws nicely plays – nws yeej zoo li nws yog ib tug seamless app.

Qhov no nws yog blanket.js rau hauv ntawv:

image Daim duab 4

image

Daim duab 5

(Koj yeej tau mus nias rau ntawm "Pab kom cov kev pab" checkbox rau saum [pom daim duab 3] kom niam no.)

Tus kab highlighted nyob hauv daim duab 5 tau tsis tau tseg los ntawm ib yam ntawm kuv qhov kev ntsuam xyuas, li ntawd, kuv yuav npaj ib txoj kev kuaj uas ua rau lawv rau txim tuag yog kuv xav tau kev pab tas nrho.

Tau ua hauj lwm los yog ua raws li cov kauj ruam nram blanket.js:

  1. Download tau nws tawm http://blanketjs.org/.
  2. Ntxiv rau koj qhov project
  3. Hloov koj nplooj ntawv kuaj sam xauv nees (QuizUtil_test.html hauv kuv tsev neeg) raws li nram no:
    1. Siv tus cai
    2. Kho koj <tsab ntawv> siv nyiam qhov no:
    <tsab ntawv hom= "ntawv nyeem/javascript" src="QuizUtil.js" cov ntaub ntawv npog></tsab ntawv>

Blanket.js picks los ntawm "cov ntaub ntawv npog" attribute thiab puas tau nws cov khawv koob.  Nws mus ua Qunit hooks, siab tus UI ntxiv qhov "Pab kom cov kev pab" option thiab voila!

Txoj kev (TL; DR)

Siv Qunit los mus sau koj cov raug kuaj.

  • Download tau nws
  • Ntxiv rau koj qhov project
  • Sau tau ib nplooj ntawv kuaj sam xauv nees
  • Ua kom muaj qhov kev ntsuam xyuas koj
    • Ib txhia ntawm koj cov cai ua testable refactor
    • Yuav muaj tswv yim!  Xav txog crazy, scenarios yeej ua thiab kuaj lawv lawm.

Siv cov blanket.js kom muaj kev pab them nqi

  • Xyuas kom tseeb tias Qunit ua hauj lwm
  • Download tau blanket.js thiab ntxiv mus rau koj qhov project
  • Ntxiv rau mus kuaj sam xauv nees phab:
    • Ntxiv ib siv mus blanket.js
    • Ntxiv "cov ntaub ntawv npog" attribute rau koj <tsab ntawv> lossis
  • Khiav koj cov kev kuaj Qunit.

Kuv yeej tsis ua yam no ua ntej thiab muaj ib co rudimentary khoom ua hauj lwm ib handful teev. 

Kev soj ntsuam zoo siab!

</kawg>

undefinedSubscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Qhov kawg ce koj mam li tau hnav?

[Quick ceeb – qhov no yog ib tug ncej rau ib txoj haujlwm qhib kuv pawg no hauv New York zoo nkauj ntev ntev koj yuav tau mus nyob hauv cheeb tsam lub xeev tri yog hais tias koj xav.]

Kuv koom pab los ntaw Slalom dua 18 lub hlis dhau los thiab cov uas ua rau qhov no kuv txoj hauj lwm longest lasting txij thaum 2007. Kuv ho tsis npaj nws ua li ntawd mas. Ua ntej ib txoj hlua ntawm hopping txoj hauj lwm uas pib nrog kuv tus leap mus rau hauv lub ntiaj teb no SharePoint, Kuv nyob hauv ib qho chaw kaum ib lub xyoo. Kuv twb thaum kawg pom ib tug tshiab, nyiaj ib puas tsav cov chaw ua hauj lwm rau lub log no los ntev li ntawm no hauv Slalom.

Cov chaw no loj hlob thiab kuv xav tau ib co kev pab uas tswj. Kuv yuav tsum tau pab yog feem ntau hu kws kes duab ib "SharePoint dlaws vajtse" txawm tias kuv twb nrhiav tau kws kes duab vajtse lo lus tshaj thiab incorrectly siv nyob rau hauv qhov chaw SharePoint heev ib pliag tam sim no. Kuv twb tau tau chav blog hais txog qhov no thiaj li. Kuv tsis xav kom tsuas sau tawm ib Rev cov mos txwv yog cov ntsiab lus hauv cov style tsuav/dab. Kuv zoo phooj ywg recruiting muaj tau ua uas twb :). Li ntawd, Kuv txiav txim siab coj ib tug mus kom ze "hnub nyob rau lub neej". Nyeem thiab tsis xav txog:

1) Yog hais tias nws appeals thiab

2) Seb koj paub hauv koj cov pob txha uas koj yuav ua nws.

Yog muaj, hu rau kuv (Paul.galvin@slalom.com) wb sib tham.

Cov no yog dab tsi koj yuav cia siab tias yuav ua rau raug lim piam/hli raws li ib tug kws kes duab vajtse dlaws nyob hauv pab neeg kuv:

  • Khiav txug tej yaam, ntau tshaj ib tug zuj zus. Muaj qee tej yaam num loj thiab ces koj yuav nyias muaj nyias ib qhov project uas. "Khiav" ib qhov project txhais tau tias koj tau ua muaj rau kev ntsuam xyuas cov hauj lwm zoo zuag qhia tag nrho cov tub. Nyob rau hauv txhua rooj plaub no koj yuav muaj ib tug PM thiab ib pab yeej muaj zog devs, BAs, Cov neeg UX, thiab lwm yam., txhawb koj. Tiam sis koj yuav tau lub ntsiab muag pom tus neeg, trusts, yam. Yog tsis muaj qho hauv ntxoov ntxoo hauv no lub luag hauj lwm :). Koj mam li nqi lub sij hawm no thiab lub hom phiaj yog mus kom tibneeg hu tauj coob txaus ua li no koj 80 feem pua ntawm qhov sij hawm.
  • Pab nrog cov ntaub ntawv – SOWs, RFPs, decks – cov khoom zoo tag li. Kuv xav tias peb muaj peb txheej txheem maum npua los zoo nkauj kaw ntom nti thiab khoom ces nws tseem haum formulaic. Yog koj nyob nraum siv sau ntawv SOWs no, peb txoj kev tsis yuav tau muaj kev sib tw rau koj. RFPs – cov no kuj nce mentsis nyuab. Lawv yuav tsum bespoke tsuag rau begin with thiab RFPs rub feem ntau nyob rau hauv cov zajlus ntau. Nws yog cov zoo thiab phem, tiam sis mas zoo. Qhov no yuav tau scrambly thaum peb yuav tau juggle qhov kev nplua tus neeg muab kev pab thaum nws tseem ua kom yeej tshiab ua hauj lwm. Koj ntshe yuav tsis muaj ib tug RFP, tiam sis yuav kom koj pab txhawb khej.
  • Yog hais lus muag, tab sis tsis muaj closer. Thaum lub hli, koj yeej yuav tau txais mus rau ob peb muag hu rau peb pab neeg uas muag. Koj mam muab cov SME nyob rau hauv lub chav, muab ntawv thiab pab shape yuav muab. Txawm li cas los, koj yuav tsis tau nug los yuav tau ko lub voj voog muag los pib los suaj kaum. Koj tsis tas yuav mus rau "muag,"koj cia li xav twj ywm lub suab cuag vim nyob rau hauv chav tsev. Qhov no thaum lub trust thiab cog qoob loo thiab yog vim li cas koj nyob nraum muaj. tau mas, Yog koj xav muag, ces yog chav rau koj tuaj ntawm no heev.
  • Pab nrog recruiting. Peb puas muaj tej yam kev xa mus cuag kev pab, li ntawd, yog hais tias koj yeej paub muaj zog folks hauv lub zej zos uas koj xav hais tias yuav tsum ntawm Slalom, koj yuav pab tau li ntawd mas. Peb muaj nplooj siab keeb (yog leej twg yav tom ntej) yuav tsis qhia tawm cov tsov ntxhuav ntawd cov hauj lwm no qhia. Cov kev pab tiag interviewing txheeb – yog lawv ib tus zoo haum kawm? Lawv tsis paub lawv cov khoom? Lawv yuav ua * kuv * lub neej yooj yim? 🙂 This comes in spurts, ob peb zaug ib lub hlis, Txawm hais tias nyob rau hauv tej lub hlis koj yuav tsis tau nws cov.
  • Pab txhais tej kev coj zoo tshaj, txoos ua peb tus IP thiab ua rau peb sis tw ntau nyob rau hauv txoj kev ua lag luam. Koj nyob nraum ib txog tej txiv leej tub/gal. Koj mus ncig lub thaiv – tsis yog nyob SharePoint, tab sis koj muaj kev kawm txawj lwm yam yees thiab nyob zoo thiab phem (Txawm phem heev) tej yaam num dus. Yog li ntawd, koj paub dab tsi thiab dab tsi tsis ua. Peb mam li xav kom koj muab qhov kev kawm txawj nrog peb ib hnub rau ib hnub puav nyob rau hauv ib qhov txiav txim zoo tactical (i.e. khiav koj tej yaam num zoo tiag tiag) tab sis kuj leeg. "Kev zoo" yog lub overused yog ib lub sij hawm thiab kuv tsis kam siv nws. Cov tswv yim yooj yim yog tias koj nyob nraum los ua ib txog tej tus neeg uas sib sib zog nqus thiab ntau yam kev thiab peb xav kom integrate raws li koj cov learnings ua li cas peb koom nrog rau cov neeg muas zaub ib hnub rau ib hnub puav.
  • thov kom koj muaj kev lom zem – peb muaj ib cov Rev integrated heev. Kuv xav yuav zam tau lwm platitude, tiam sis nws tseem tshua apt qhov no – peb ua hauj lwm ib (tsawm tsawv thiab) thiab peb kuj nyuab dua si :). Yog ib tug Aaron Sorkin dab banter no, lub chav lawm yeej yuav yog tag nrho cov neeg ntse, peb nyiam peb haus thiab ncaj ncees ntau lom zem Teacher peb txheej xwm – yeeb yam tsaus ntuj, mus ua si kev baseball (Txawm tias lawv yog phev heev, paab suab siab phem).

Yog hais tias kuv yuav sum nws ua ib lo lus, Kuv yuav siv tau cov lo lus "coj." Ua tej yaam num, coj lub luag hauj lwm ua nyob hauv lub tuam tsev seb qhov (IP, lub tuam tsev pem lub pab (team)), yam.

Tab sis tos! Yog xav paub ntxiv! Vim lwm ua hauj lwm hauv Slalom?

  • Kev sib sau cia tib si – zoo kawg li sawv daws xav kom hlob no tshaj tawm. "No uas" yog qhov chaw ua hauj lwm New York. Sawv daws tseem nyob board txog qhov nov.
  • Poob rau koj sails – tus muam chaw ua hauj lwm, tus muam ntawd – Slalom yog "daim ntawv qhia txog qhov" noj yug haus rau lub koom haum. Kuv ua tau mus pab SharePoint (ib "xyaum cheeb tsam ua" nyob rau hauv Slalom lingo). Kuv tus muam muaj xyaum kom nyob 11 lwm yam chaw ua hauj lwm Slalom. Yog li txawm tias kuv yog huab tais li far li SharePoint yog concerned nov hauv Slalom New York, Kuv muaj tug phooj ywg txoj kev nyob Chicago, Seattle, Dallas, Atlanta, Boston, yam. uas kuv yuav dlua yug. Nws yog qhov zoo tshaj plaws ntawm ob worlds – qhov autonomy ntawm no hauv New York, tiam sis tau tons cov txuj ci thoob hauv lub koom haum.
  • Poob rau koj muag khoom (2) – Peb ua ntau tshaj SharePoint – ntau npaum li cas. Peb ua lis, CRM, UX, lag luam noj kev haus, Txawb, kev cai kev loj hlob thiab lwm tus. Peb yeej zoo rau cross muag nrad peb tus kheej thiab tag lawm zoo ntawm painting – thiab ceeb ntau tshaj, delivering li – ib daim duab "puv service" rau peb cov neeg. Qhov no yog qhov tshwj xeeb tshaj yog ua txaus rau kuv. Kuv mus nyob ntau orgs me me thiab ua hauj lwm hauv SharePoint gigs thiab tag kev cia siab tsiv vim peb twb nquab holed li cov "SharePoint neeg." Uas tsis ua li cov Slalom thiab peb tau mus ua cov hauj lwm nthuav ntau vim li ntawd.
  • Lub zos qauv – tsis muaj tebchaws.
  • Hlob long-term – Slalom twb tau mus gangbusters. Ntau cov kev loj hlob thiab stability. Kev loj hlob txhais tau tias peb xav ntiav cov thawj coj niaj hnub rau taub hau tuaj paab tshiab li peb ntxiv dua neeg thiab ua hauj lwm pab txhawb cov neeg.

Kuv yuav mus nyob rau, tab sis kuv twb ntshe twb leej tuaj mus ntev ntev. Kuv xav tias kuv twb yog tej lub essence ntawm no. Yog koj nyob nraum xav txog kev hloov ua hauj lwm thiab qhov no zoo zoo rau koj, wb tham.

Yog hais tias koj zoo siab rau koj txoj hauj lwm – wb tham lawm :). Twb tau mus ntau qhov chaw thiab zoo siab heev "" thaum lub sij hawm. Slalom no txawv thiab kuv yuav txais tos lub sij hawm rau convince uas koj.

</kawg>

undefinedSubscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Txoj kev sai thiab yooj yim: Teev tus me me ntawm ib yam khoom nyob rau hauv ib lub thawv sau nyob rau hauv lub qhov rais tom khw App

Nyob rau hauv lub qhov rais tom khw App kuv yuav tsim, Kuv xav kom koj qhia cov neeg siv ntau yam lus xwm txheej.  Kuv nqa ib ListBox li lub cuab tam los qhia nws kom lawv scroll los ntawm cov khoom lawv thiab zoo tag li. 

Lus muaj xwm txheej xwb, li ntawd, yuav tsis muaj muab ntxiv tag li whitespace ncig vim tus neeg siv yuav yeej tsis xaiv lawv rau txhua yam.  Default cwj pwm ntawm cov ListBox muab ib tug nqi ntau yam pauv loj padding thiab kuv xav rhuav tshem ntawm nws.  Zoo.... koj tsis tau ua tshaj plaws nyob rau hauv ListBox ntawd tsi ncaj qha.  TXAWM LI CAS LOS, koj yuav ua rau cov khoom uas koj ntxiv:

        lwm yam khoob lug AddGameStateLogMessage(hlua theMessage)
        {
            TextBox t = tshiab TextBox();
            t.Text = GameStateCounter    + ": " + theMessage;
            t.TextWrapping = TextWrapping.Wrap;
            t.MinWidth = 400;
            Thickness thisPadding = tshiab Thickness(5, 0, 5, 0);
            t.Padding = thisPadding;
            t.FontSize = 12;

            ListBoxItem lis = tshiab ListBoxItem();
            lis.Txheej = t;
            lis.MaxHeight = 25;
            thisPadding = tshiab Thickness(5, 0, 5, 0);
            lis.Padding = thisPadding;

            GameStateLog.Items.Insert(0,lis);
        }

nyob rau saum no, Kuv tabtom npaj ib cov TextBox thiab teem nws font, nws cov padding, yam.

Tom ntej, Tsim tau ib lub ListBoxItem thiab muab nws cov ntaub ntawv kawm kom tau cov formatted TextBox.

Thaum kawg, Kuv ntxig rau ListBoxItem mus rau lub ListBox.  (Kuv xav qhia tias tsis ntev los no tshaj lus rau saum daim ntawv, li no tso nrog rau cov(0,lis) tsis muaj ib tug sib ntxiv tej yam yooj yim() invocation.).

Kuv yuav ua tweaking no ua lub ntej kuv yeej zoo siab nrog lub ListBox zoo tab sis cov qauv qhia saum toj no lawm ncw.  Hopefully lwm tus pom tias yuav pab tau.

</kawg>

undefinedSubscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin