پیش نمایش جادوگر
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
جادوگر پیش نمایش به گونه ای طراحی شده است که به شما امکان می دهد پیش نمایش ها را سریع، آسان و قابل اعتماد با سایت خود ادغام کنید. شما می توانید یک نمایشگر کتاب جاسازی کنید، به جستجوی کتاب پیوند دهید، یا حتی یک پنجره "پاپ آپ" پیش نمایش را به سایت خود اضافه کنید — تنها کاری که باید انجام دهید این است که کد را ایجاد کرده و آن را در صفحه خود جایگذاری کنید. همچنین می توانید این کد را با استفاده از برخی از توابع ساده جاوا اسکریپت سفارشی کنید .
جادوگر پیشنمایش یک کتابخانه ساده است که ما بر روی پیوندهای پویا و APIهای نمایشگر جاسازی شده خود ساختهایم. اگر توسعهدهندهای هستید که به دنبال یکپارچهسازی سفارشیشده هستید، مستقیماً از APIهای زیربنایی استفاده کنید.
کد پیش نمایش خود را ایجاد کنید
نمونه هایی از پیش نمایش های تولید شده
نمونههای زیر با استفاده از پیشنمایش ویزارد تولید شدهاند.
کد خود را سفارشی کنید
علاوه بر استفاده از جادوگر بالا، میتوانید مستقیماً برخی از توابع ساده جاوا اسکریپت "Helper" را فراخوانی کنید. برای انجام این کار، ابتدا باید کتابخانه Preview Wizard را بارگذاری کنید. یکی از راه های انجام این کار این است که تگ زیر را به بخش <head>
صفحه خود اضافه کنید:
<script type="text/javascript" src="https://books.google.com/books/previewlib.js"></script>
پس از بارگیری کتابخانه پیشنمایش، میتوانید هر یک از توابع زیر را از درون تگهای <script>
داخل <body>
سند خود فراخوانی کنید. به عنوان مثال، اگر میخواهید دکمه «پیشنمایش Google» را وارد کنید، کد مربوط به این کار را در عنصر <script>
در موقعیت دلخواه دکمه در صفحه قرار دهید.
GBS_setLanguage
GBS_setLanguage(languageCode)
زبان هر دکمه یا متنی را که پس از فراخوانی این تابع اضافه می شود، تغییر می دهد. این شامل زبان دکمه «پیشنمایش Google»، زبان رابط پیشنمایش تعبیهشده و غیره است.
مولفه های: string languageCode
- کد زبان RFC 3066 مورد نظر (پیشفرض برای انگلیسی 'en' است). کدهای زبانی که در حال حاضر پشتیبانی می شوند عبارتند از: hy, bg, ca, zh-CN, zh-TW, hr, cs, da, nl, en, fil, fi, fr, de, el, hi, hu, is, id, in, it , ja, ko, lv, lt, no, pl, pt-BR, pt-PT, ro, ru, sr, sk, sl, es, sv, th, tr, uk, و vi.
GBS_setViewerOptions
GBS_setViewerOptions(optionObj)
مولفه های: Object optionsObj
- مجموعه ای از جفت های کلید-مقدار به سازنده DefaultViewer API Embedded Viewer ارسال می شود. به طور معمول، این برای سفارشی سازی های پیشرفته استفاده می شود.
GBS_setCobrandName
GBS_setCobrandName(cobrandName)
این تابع که برای استفاده توسط ناشران در برنامه شریک در نظر گرفته شده است، سایت جستجوی نام تجاری مشترک را تنظیم می کند تا هنگام درج پیوندهای پیش نمایش به جستجوی کتاب استفاده شود. فراخوانی این عملکرد قبل از قرار دادن دکمه تضمین می کند که کاربران آرم شریک را در بالای پیش نمایش های جستجوی کتاب می بینند.
GBS_insertEmbeddedViewer
GBS_insertEmbeddedViewer(identifier, opt_width, opt_height)
هر جا که این تابع فراخوانی شود، پیشنمایش کتاب تعبیهشده را درج میکند. اگر پیش نمایش در دسترس نباشد، هیچ بیننده ای نشان داده نمی شود.
مولفه های: Number opt_width
- عرض مورد نظر بیننده، بر حسب پیکسل.
Number opt_height
- ارتفاع مورد نظر بیننده، بر حسب پیکسل.
GBS_insertPreviewButtonPopup(identifiers)
اگر پیشنمایش کتاب در دسترس باشد، این عملکرد دکمه «پیشنمایش Google» را مینویسد. با کلیک بر روی این دکمه یک "پنجره پیش نمایش شناور" درست در بالای صفحه شما باز می شود. اگر پیشنمایش در دسترس نباشد، دکمه کشیده نمیشود. ممکن است برنامهنویسان پیچیدهتر به Embedded Viewer API علاقهمند باشند، که این تابع به صورت داخلی از آن استفاده میکند.
مولفه های: string, Array identifier
- URL پیش نمایش یا شناسه کتاب مانند شماره ISBN، OCLC یا LCCN. قالب درخواست پیوندهای پویا را ببینید. اگر چندین شناسه جایگزین برای کتاب میشناسید، میتوانید آرایهای از این شناسهها را ارسال کنید و اگر پیشنمایش برای هر یک از آنها در دسترس باشد، دکمه ظاهر میشود.
GBS_insertPreviewButtonLink(identifiers, opt_options)
اگر پیشنمایش کتاب در دسترس باشد، این عملکرد دکمه «پیشنمایش Google» را مینویسد که به سادگی به صفحه پیشنمایش کتاب پیوند میخورد. بهطور پیشفرض، این به پیشنمایش در Google Books پیوند دارد، اما همچنین میتوانید:- به یک URL در سایت خود پیوند دهید (که باید به نوبه خود حاوی یک نمایشگر تعبیه شده باشد). شما می توانید این کار را با عبور از گزینه optional
alternativeUrl
انجام دهید. - اگر GBS_setCobrandName قبل از این تابع فراخوانی شده باشد، به نسخه Co-Branded صفحه پیش نمایش کتاب پیوند دهید.
اگر هیچ پیش نمایشی در دسترس کاربر نباشد، دکمه ای روی صفحه کشیده نمی شود.
مولفه های: string, Array identifier
- URL پیش نمایش یا شناسه کتاب مانند شماره ISBN، OCLC یا LCCN. قالب درخواست پیوندهای پویا را ببینید. اگر چندین شناسه جایگزین برای کتاب میشناسید، میتوانید آرایهای از این شناسهها را ارسال کنید و اگر پیشنمایش برای هر یک از آنها در دسترس باشد، دکمه ظاهر میشود.
Object opt_options
- اختیاری - نقشه نام-مقدار مورد استفاده برای پیکربندی رفتار دکمه. در حال حاضر یک گزینه پشتیبانی می شود: alternativeUrl
. برای مثال، برای اینکه دکمه پیشنمایش Google به یک صفحه پیشنمایش سفارشی در سایت خود پیوند داشته باشد، کافی است موارد زیر را به عنوان آرگومان دوم به GBS_insertPreviewButtonLink
ارسال کنید:
{ 'alternativeUrl' : 'http://yoursite.com/your-preview-page' }
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2024-06-28 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2024-06-28 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Preview Wizard\n\nThe Preview Wizard is designed to let you quickly, easily, and reliably integrate previews with your site. You can embed a book viewer, link to Book Search, or even add a preview \"popup\" window to your site---all you need to do is [generate the code](#generateCode) and paste it onto your page. You can also [customize this code](#customizeYourCode) using some simple JavaScript functions.\n\nThe Preview Wizard is a simple convenience library we built on top of our [Dynamic Links](/books/docs/dynamic-links) and [Embedded Viewer](/books/docs/viewer/developers_guide) APIs. If you're an advanced developer looking for customized integration, consider\nusing the underlying APIs directly.\n\nGenerate your preview code\n--------------------------\n\n#### Enter book identifiers\n\nTell us all the ISBNs or other identifiers you know of for this book. If we can find a preview associated with any of these numbers, we can make it available to your site's users:\n\n|--------------------------------------|---|\n| ISBN OCLC number LCCN Book Search ID | |\n| ISBN OCLC number LCCN Book Search ID | |\n| ISBN OCLC number LCCN Book Search ID | |\n\n[Enter more identifiers...](about:invalid#zGoSafez)\n\n#### Choose how to show the book preview\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| If a preview is available for this book, what should the user see on your page? |---|------------------------------------------------------------------------| | | An embedded book viewer. Viewer size: pixels wide, pixels high | | | A button that opens a floating book viewer. | | | A button that links to the book's preview page on Book Search. | | | A button that goes to a custom preview page on your site. Preview URL: | If no preview can be found for the specified book(s), the preview or button will be automatically disabled and nothing will appear. | |\n\n#### Select your language\n\nChinese (Simplified) Chinese (Traditional) Dutch English French German Italian Japanese Portuguese (Brazilian) Russian Spanish\n\n#### Generate code for your web page\n\nExamples of generated previews\n------------------------------\n\nThe following examples were generated using the Preview Wizard.\n\n- [previewwizard-embed](/books/examples/previewwizard-embed): Embeds a book viewer on the page.\n- [previewwizard-popup](/books/examples/previewwizard-popup): Adds a button that can be clicked to open a floating preview over the page.\n- [previewwizard-linktogbs](/books/examples/previewwizard-linktogbs): Inserts a button that links to the preview on the Book Search site.\n- [previewwizard-customurl](/books/examples/previewwizard-customurl): Shows a button that goes to a specific URL.\n\nCustomize your code\n-------------------\n\nIn addition to using the wizard above, you can call some simple JavaScript \"helper\" functions directly. To do this, you should first load the Preview Wizard library. One way to do this is by adding the following tag to the `\u003chead\u003e` section of your page: \n\n```\n\u003cscript type=\"text/javascript\" src=\"https://books.google.com/books/previewlib.js\"\u003e\u003c/script\u003e\n```\n\nHaving loaded the preview library, you can then call any of the following functions from within `\u003cscript\u003e` tags inside your document's `\u003cbody\u003e`. For example, if you'd like to insert the \"Google Preview\" button, you'd put the code to do so in a `<script\u003e` element at the button's desired position within the page.\n\n### GBS_setLanguage\n\n```\nGBS_setLanguage(languageCode)\n```\n\nChanges the language of any buttons or text added after this function is called. This includes the language of the \"Google Preview\" button, the interface language of the embedded preview, and so on.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string*` languageCode ` - The desired RFC 3066 language code (default is 'en' for English). Currently supported language codes include hy, bg, ca, zh-CN, zh-TW, hr, cs, da, nl, en, fil, fi, fr, de, el, hi, hu, is, id, in, it, ja, ko, lv, lt, no, pl, pt-BR, pt-PT, ro, ru, sr, sk, sl, es, sv, th, tr, uk, and vi.\n\n### GBS_setViewerOptions\n\n```\nGBS_setViewerOptions(optionObj)\n```\n\n**Parameters:** *Object*` optionsObj ` - A set of key-value pairs passed to the Embedded Viewer API's [DefaultViewer constructor](/books/docs/viewer/reference#google.books.DefaultViewer). Typically, this is used for advanced customizations.\n\n### GBS_setCobrandName\n\n```\nGBS_setCobrandName(cobrandName)\n```\n\nIntended for use by publishers in the [Partner Program](https://books.google.com/partner), this function sets the [Co-Branded Search](https://books.google.com/support/partner/bin/answer.py?hl=en&answer=65113) site to be used when inserting any preview links to Book Search. Calling this function before inserting a button ensures that users see the partner's logo above the Book Search previews.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string*` cobrandName ` - The cobrand name to be added to any Book Search URLs. This is typically what comes after `/p/` in existing Co-Branded Search preview URLs.\n- For example, setting the value to `sup` will send the user to links like \n `https://books.google.com/books/p/sup?id=Q8ysL64pM54C&printsec=frontcover` \n rather than the default \n `https://books.google.com/books?id=Q8ysL64pM54C&printsec=frontcover`\n\n### GBS_insertEmbeddedViewer\n\n```\nGBS_insertEmbeddedViewer(identifier, opt_width, opt_height)\n```\n\nInserts an embedded book preview wherever this function is called. If the preview is unavailable, no viewer is shown.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string*` identifier ` - A preview URL or book identifier such as an ISBN, OCLC, or LCCN number. See [Dynamic Links request format](/books/docs/dynamic-links#requestFormat).\n\u003c!-- --\u003e\n\n*Number*` opt_width ` - The desired width of the viewer, in pixels.\n\u003c!-- --\u003e\n\n*Number*` opt_height ` - The desired height of the viewer, in pixels.\n\n### GBS_insertPreviewButtonPopup\n\n```\nGBS_insertPreviewButtonPopup(identifiers)\n```\n\nIf the book preview is available, this function writes out a \"Google Preview\" button. Clicking this button opens a \"floating preview window\" right on top of your page. If no preview is available, the button is not drawn.\n- More sophisticated developers may be interested in the [Embedded Viewer API](/books/docs/viewer/developers_guide), which this function uses internally.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string, Array*` identifier ` - A preview URL or book identifier such as an ISBN, OCLC, or LCCN number. See [Dynamic Links request format](/books/docs/dynamic-links#requestFormat). If you know of several alternative identifiers for the book, you can pass an array of these identifiers, and the button will appear if a preview is available for any one of them.\n\n### GBS_insertPreviewButtonLink\n\n```\nGBS_insertPreviewButtonLink(identifiers, opt_options)\n```\n\nIf the book preview is available, this function writes out a \"Google Preview\" button that simply links off to a preview page for the book. By default, this links to the preview on Google Books, but you can also:\n- link to a URL on your site (which should, in turn contain an embedded viewer). You can do this by passing an optional `alternativeUrl` option.\n- link to a Co-Branded version of the book preview page, if [GBS_setCobrandName](#GBS_setCobrandName) is called before this function.\nIf no preview is available to the user, no button is drawn onto the page.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string, Array*` identifier ` - A preview URL or book identifier such as an ISBN, OCLC, or LCCN number. See [Dynamic Links request format](/books/docs/dynamic-links#requestFormat). If you know of several alternative identifiers for the book, you can pass an array of these identifiers, and the button will appear if a preview is available for any one of them.\n\u003c!-- --\u003e\n\n*Object*` opt_options ` - *optional* - A name-value map used to configure the behavior of the button. Currently one option is supported: `alternativeUrl`. For example, to have the Google Preview button link to a custom preview page on your site, simply pass the following as a second argument to `GBS_insertPreviewButtonLink`: \n` { 'alternativeUrl' : 'http://yoursite.com/your-preview-page' } `"]]